akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n;
		String str;
		boolean[] ch = new boolean[4];
		int count, out;
		
		n = scan.nextInt();
		
		for(int i = 0; i < n; i++){
			count = 0;
			out = 0;
			for(int j = 0; j < 4; j++){
			ch[j] = false;	
			}
			
			while(out != 3){
				str = scan.next();
				if(str.equals("HIT")){
					for(int j = 0; j < 4; j++){
						if(ch[j] == false){
							ch[j] = true;
							if(j == 3){
								count++;
								ch[j] = false;
							}
							break;
						}
					}
				}else if(str.equals("HOMERUN")){
					for(int j = 0; j < 4; j++){
						if(ch[j] == true){
							count++;
							ch[j] = false;
						}
					}
					count++;
				}else if(str.equals("OUT")){
					out++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 26372
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class BSumOfThreeIntegers {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int k, s;
	    in >> k >>s;
	    ll ans = 0;
	    bool f = 0;
	    for (int i = 0; i <= k; ++i) {
	        for (int j = 0; j <= k; ++j) {
	            int l = s-j-i;
	                if (l >= 0 && l <= k) {
	                    ans++;       // out << i << ' ' << j << ' ' << l << el;
	                }
	        }
	    }
	    out << ans << el;
	}
};


int main() {
	BSumOfThreeIntegers solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n, &k);
    vector<int> a(n);
    for(int& x: a)
        scanf("%d", &x);
    vector<bool> dp(k+1);
    for(int stones = 0; stones<=k; stones++)
    {
        for(int x : a)
            if(stones>=x &&!dp[stones -x])
                dp[stones] = true;
    }
    if(dp[k])
        printf("First\n");
    else 
        printf("Second\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>


using namespace std;

int main(){
    int n;
    cin >>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)ans+=i;
    }
    //printf("%lld\n",ans);
    cout<<ans;
}






Measured memory_bytes: 3580
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N, M = mi()

print((N*(N-1)+M*(M-1))//2)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N, K;

	cin >> N >> K;
	
	ll ans = 0;
	for(ll b = 1; b <= N; b++){
		ans += (N / b) * max(0LL, (b - K));
		ans += max(0LL, N % b - K + 1);
	}

	if(K == 0) ans = N*N;

	cout << ans << endl;

	Never To return 0;
}


Measured memory_bytes: 256
<?php
                            //4 9 2 3
    fscanf(STDIN,"%d%d%d%d",$A,$B,$C,$D);
    
    $ansx=0;
    $ansy=0;
    //$B以下の整数で$c,$d,lcm($c,$d)で割り切れるものの個数を求める
    $ansx += intdiv($B,$C);
    $ansx += intdiv($B,$D);
    $ansx -= intdiv($B,lcm($C,$D));
    $ansy += intdiv(($A-1),$C);
    $ansy += intdiv(($A-1),$D);
    $ansy -= intdiv(($A-1),lcm($C,$D));

    echo ($B-($A-1))-($ansx-$ansy);
    
    function lcm($m, $n){
        return $m * $n / gcd($m, $n);
    }
    function gcd($m,$n){
        //$mが大きい値にしておきたい
        if($n>$m)list($m,$n)=array($n,$m);
        
        //余りが0になるまで割り続けるような
        //計算をする。
        while($n != 0){
            $tmp_n = $n;
            $n = $m % $n;
            $m = $tmp_n;
        }
        return $m;
    }
    
?>

Measured memory_bytes: 16252
#include<iostream>
#include<algorithm>
using namespace std ;

int N , D ;
int T[210] ;
int W[210][3] ;

int dp[210][210] ;

int a( int x , int y ){
	int z = x - y ;
	if( z < 0 ) z *= -1 ;
	return z ;
}

int f( int day , int p ){
	if( day == D-1 ) return 0 ;
	if( dp[day][p] != -1 ) return dp[day][p] ;
	
	int ans = 0 ;
	for( int i=0 ; i<N ; i++ ){
		if( W[i][0] <= T[day+1] && W[i][1] >= T[day+1] ){
			ans = max( ans , a( W[p][2] , W[i][2] ) + f( day+1 , i ) ) ;
		}
	}
	
	return dp[day][p] = ans ;
}

int main(){
	
	cin >> D >> N ;
	for( int i=0 ; i<D ; i++ ) cin >> T[i] ;
	for( int i=0 ; i<N ; i++ ){
		cin >> W[i][0] ; // 下限
		cin >> W[i][1] ; // 上限
		cin >> W[i][2] ; // コスト
	}
	
	for( int i=0 ; i<210 ; i++ ){
		for( int j=0 ; j<210 ; j++ ){
			dp[i][j] = -1 ;
		}
	}
	
	int best = 0 ;
	for( int i=0 ; i<N ; i++ ){
		if( W[i][0] <= T[0] && W[i][1] >= T[0] ){
			best = max( best , f(0,i) ) ;
		}
	}
	
	cout << best << endl ;
	
return 0;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin >> n;
	long long ans = 1;
	for (int i = 0; i < n; i++){
		long long x; cin >> x; 
		ans = (ans/__gcd(ans,x))*x;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int k;
set<string>ss;
int main(){
	cin>>s>>k;
	for(int i=0;i<s.size();i++){
		string st;
		for(int j=i;j<s.size()&&j<i+k;j++){
			st+=s[j];
			ss.insert(st);
		}
	}
	set<string>::iterator it=ss.begin();
	for(int i=0;i<k-1;i++)it++;
	cout<<*it;
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#define MOD 1000000007

typedef long long ll;
using namespace std;

int main(void) {
    int i,j;
    cin >> i >> j;
    cout << i-j+1 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
def divisor_all(n): # 約数全列挙
    l = [1,n]
    for i in range(2,int(pow(n,1/2))+1):
        if n % i == 0:
            if i == n//i:
                l.append(i)
            else:
                l.append(i)
                l.append(n//i)
    l.sort()
    return l # list
L = divisor_all(N)
flag = False
for i in range(len(L)):
    if 1<=L[i]<=9 and 1<=N//L[i]<=9:
        flag = True
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n;
    cin>>n;
    vector<ll> p(n);
    for (ll i = 0; i<n; i++){
        cin>>p[i];
    }
    ll MAX = 0;
    ll sum = 0;
    for (ll i = 0; i<n; i++){
        MAX = max(MAX,p[i]);
        sum += p[i];
    }
    cout << sum - MAX/2 <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (U == S) A--;
    else B--;
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
k = int(input())
target = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(target[k-1])

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  ll h, w;
  cin >> h >> w;
  vector<string> s(h);
  string white = string(w, '.');
  vector<string> ans1;
  rep(i, h) {
    cin >> s.at(i);
    if (s.at(i) != white) ans1.push_back(s.at(i));
  }

  vector<string> ans2(ans1.size());
  rep(j, w) {
    bool is_white = true;
    rep(i, ans1.size()) {
      if (ans1.at(i).at(j) == '#') is_white = false;
    }
    if (!is_white) {
      rep(i, ans1.size()) {
        ans2.at(i).push_back(ans1.at(i).at(j));
      }
    }
  }

  rep(i, ans1.size()) {
    cout << ans2.at(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

x,y = ip()
if 2*x <= y <= 4*x and y%2 == 0:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 61848
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val s = scanner.next()

    val ret = when (s) {
        "Sunny" -> "Cloudy"
        "Cloudy" -> "Rainy"
        "Rainy" -> "Sunny"
        else -> null
    }

    println(ret)
}

Measured memory_bytes: 31136
#include <iostream>
using namespace std;
int main()
{
    int n, m, a, b, ans = 0;
    int h[100001] = {}, ab[100001] = {};
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        scanf("%d", &h[i]);
    }
    for(int i = 0; i < m; i++) {
        scanf("%d%d", &a, &b);
        if(ab[a] < h[b]) {
            ab[a] = h[b];
        }
        if(ab[b] < h[a]) {
            ab[b] = h[a];
        }
    }
    for(int i = 1; i <= n; i++) {
        if(h[i] > ab[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  int r = 0;
  int l = 0;
  int flag = 0;
  int pr = 0;
  int pl = 0;
  vector<int> ans(s.size(), 0);
  for (int i = 0; i < s.size() - 1; i++) {
    if (flag == 1 && s.at(i) == 'R') {
      ans.at(pr) = (r + 1) / 2 + l / 2;
      ans.at(pl) = r / 2 + (l + 1) / 2;
      r = 0;
      l = 0;
      pr = 0;
      pl = 0;
      flag = 0;
    }
    if (s.at(i) == 'R' && s.at(i + 1) == 'L') {
      pr = i;
      pl = i + 1;
      flag = 1;
      r++;
    }

    if (s.at(i) == 'R' && flag == 0) {
      r++;
    }
    if (s.at(i) == 'L' && flag == 1) {
      l++;
    }
  };
  l++;
  ans.at(pr) = (r + 1) / 2 + l / 2;
  ans.at(pl) = r / 2 + (l + 1) / 2;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans.at(i);
    if (i != ans.size() - 1) cout << " ";
  }
}


Measured memory_bytes: 1024
use std::io::*;

fn f(x: i64) -> i64 {
    let y = x % 4;
    match y {
        0 => x,
        1 => 1,
        2 => x ^ 1,
        _ => 0,
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: i64 = itr.next().unwrap().parse().unwrap();
    let b: i64 = itr.next().unwrap().parse().unwrap();

    println!("{}", f(a - 1) ^ f(b));
}


Measured memory_bytes: 4352
/*
	Roll no : 18EC10057
	PC No.:   70
*/


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define size 100000
#define ll long long int
int arr[size];
ll arr1[size];


int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	arr1[0]=0;
	arr1[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
	{

		ll min=INT_MAX;
		for(int j=1;(j<=k && i-j>=0);j++)
		{
			if(min>arr1[i-j]+abs(arr[i]-arr[i-j]))
				min=arr1[i-j]+abs(arr[i]-arr[i-j]);
		}
		arr1[i]=min;
	}
	cout<<arr1[n-1]<<endl;
}


Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author aps
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ICoins solver = new ICoins();
        solver.solve(1, in, out);
        out.close();
    }

    static class ICoins {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            double[] a = new double[n + 1];
            double[][] dp = new double[n + 1][n + 1];

            for (int i = 1; i <= n; i++) a[i] = in.nextDouble();

            dp[0][0] = 1.0;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    if (j > i) continue;
                    if (j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - a[i]);
                    if (j > 0) dp[i][j] = dp[i - 1][j - 1] * a[i] + dp[i - 1][j] * (1.0 - a[i]);
                }
            }

            double ans = 0.0;
            for (int j = n / 2 + 1; j <= n; j++) {
                ans += dp[n][j];
            }

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }
}



Measured memory_bytes: 129236
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b){
			System.out.println("a < b");
		} else if(a > b){
			System.out.println("a > b");
		} else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 17304
// abc111_b
// #include <bits/stdc++.h>
#include <iostream>
using namespace std;

int main(void) {
	int N;
	cin >> N;
	for (;N <= 999; N++) {
		int a = N / 100;
		int b = (N - (a * 100)) / 10;
		int c = (N - (a * 100) - (b * 10));
		if (a == b && b == c && a == c) {
			break;
		}
	}
	cout << N << endl;
	/*
	string n;
	cin >> n;
	int max = n[0] - '0';
	for (int i = 1; i < n.length(); i++) {
		if (max < (n[i] - '0')) {
			max = n[i] - '0';
		}
	}
	for (int i = 0; i < n.length(); i++) {
		n[i] = '0' + max;
	}
	cout << n << endl;
	*/
	return 0;
}

Measured memory_bytes: 256
//Abhigyan's Code:
             
    //YOU DON'T DARE TO COPY :) 

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    typedef unsigned long long int ull;
    #define checker cout<<"CHECKED" 
    #define modulo 1000000007
    ll dp[10000][10000] ;

    void lcs(string x , string y)
    {
      ll s1 = x.size();
      ll s2 = y.size();

      for(ll i = 0 ; i<= s1 ;i++)
      {
        for(ll j = 0; j<=s2; j++)
        {
          if(i ==0 || j ==0)
            dp[i][j] = 0;
          else if(x[i-1] == y[j-1])
          {
            dp[i][j] = dp[i-1][j-1] +1;
          }
          else
          {
            dp[i][j] = max( dp[i-1][j] , dp[i][j-1] ) ;
          }  

        }
      }

    }
    
    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      string x , y;

      cin >> x >> y;

      ll i =x.size();
      ll j = y.size();

      lcs(x , y );


      vector<char> st(dp[x.size()][y.size()]) ;

      ll curr ;

      curr = dp[x.size()][y.size()] -1;

      //cout<<curr<<endl;
      while(i > 0 && j > 0 && curr >= 0)
      {
        if(x[i-1] == y[j-1])
        {
          st[curr] =x[i-1] ;
          i--;
          j--;
          curr--;
        }
        else if(dp[i-1][j] > dp[i][j-1])
        {
          i--;
        }
        else
        {
          j--;
        }
      }   

      for(auto z : st)
        cout<<z;
      

      
      return 0 ;

    } 

Measured memory_bytes: 86168
#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)

int main(){
  int n, m;
  cin >> n >> m;
  if(n & 1){
    REP(i, m){
      cout << i + 1 << " " << n - i << endl;
    }
  }else{
    REP(i, m){
      cout << (i < n / 4 ? i + 1 : i + 2) << " " << n - i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    /**/
    int ans = 0;
    int nxt = 1;

    for(int i = 0;i < n;i++){
        if(nxt == a[i]) nxt++;
        else ans++;
    }
    if(ans != n){
        cout << ans << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)
#define Fo(i,k,n) for(i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define endl '\n'
#define MOD 1000000007//998244353
#define pbb push_back
#define mpp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
ll dp[100005][2];
ll answer(ll u,ll par,ll col,vi* graph){
    if(dp[u][col]>=0) return dp[u][col];
	ll ans=1;
	for(auto v:graph[u]){
        if(v==par) continue;
		if(col==0){
            ans*=answer(v,u,1,graph);
        }else{
            ans*=answer(v,u,0,graph)+answer(v,u,1,graph);
        }
        ans%=MOD;
	}
	return dp[u][col]=ans;
}
void solve(ll caseno){
	ll i,n,x,y,ans;
	cin>>n;
	vi* graph = new vi[n];
	fo(i,0,n-1){
		cin>>x>>y;
		x--;y--;
		graph[x].pbb(y);
		graph[y].pbb(x);
	}
    mset(dp,-1);
	ans = answer(0,-1,0,graph) + answer(0,-1,1,graph);
    ans%=MOD;
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		solve(i);
	}
	return 0;
}


Measured memory_bytes: 19000
from itertools import combinations_with_replacement as c
n,m,q=map(int,input().split())
Q=[list(map(int,input().split())) for _ in range(q)]
a=0
for i in c(range(1,m+1),n):
    s=0
    for j in Q:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            s+=j[3]
    a=max(a,s)
print(a)

Measured memory_bytes: 9164
#include<stdio.h>
#include<string.h>

int main(void)
{
   int a=0,b=0,c=0;
   char A[11],B[11],C[11];

   scanf("%s%s%s",A,B,C);
   a=strlen(A);
   b=strlen(B);
   c=strlen(C);

   if ((A[a-1]==B[0])&&(B[b-1]==C[0]))
      printf("YES\n");
   else 
      printf("NO\n");
   return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

char get_next(char prev, char curr, char resp) {
  bool same = (resp == 'o');
  if (curr == 'W') same = !same;
  if (same) return prev;
  return (prev == 'W' ? 'S' : 'W');
}

void make(const string &s, string &res) {
  const int n = s.size();
  for (int i = 1; i < n - 1; ++i) {
    res[i+1] = get_next(res[i-1], res[i], s[i]);
  }
}

void solve(ll N, string s) {
  s += s[0];
  s += s[1];
  string res(N + 2, '.');
  REP(i,2) REP(j,2) {
    res[0] = (i ? 'W' : 'S');
    res[1] = (j ? 'W' : 'S');
    make(s, res);
    if (res[0] == res[N] && res[1] == res[N + 1]) {
      cout << res.substr(0, N) << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	string s;
	scanf("%lld", &N);
	cin >> s;
	solve(N, s);
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int N, x; cin >> N >> x;
	vector<int>a(N); for (auto&& tmp : a)cin >> tmp;
	sort(a.begin(), a.end());
	
	int ans = 0;
	for (auto& tmp : a) {
		x -= tmp;
		if (x >= 0)ans++;
		else break;
	}
	if (x > 0)ans--;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
using ll = long long;
const int N = 2e3 + 7;
pair<ll, int> a[N];
ll dp[N][N];
int n;
ll solve(int l, int r) {
    auto m = n - (r - l);
    if (m > n || r - l < 0) return 0;
    if (dp[l][r] != -1) return dp[l][r];
    ll& ans = dp[l][r] = 0LL;
    auto to = a[m].first;
    return ans = max(solve(l + 1, r) + to * abs(l - a[m].second), 
        solve(l, r - 1) + to * abs(r - a[m].second));
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
    int tt = clock();
    cin >> n;
    for (int i = 1; i <= n; ++i) { 
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a + 1, a + 1 + n, [](const auto& lhs, const auto& rhs) {
        return lhs.first > rhs.first;
    });
    memset(dp, -1, sizeof dp);
    cout << solve(1, n) << '\n';
    


    cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
	return 0;
}


Measured memory_bytes: 35460
#include<bits/stdc++.h>
using namespace std;

int h,w;

long long calc(int H,int W){
    long long res=1e18;
    for(long long  i=1;i<H;i++){
        long long a,b,c;
        a=i*W;
        b=W/2*(H-i);
        c=(H-i)*(W-W/2);
        res=min(res,max(a,c)-min(a,b));

    }
    for(long long i=1;i<H;i++){
        long long a,b,c;
        a=i*W;
        b=(H-i)/2*W;
        c=((H-i)-(H-i)/2)*W;
        res=min(res,max(a,c)-min(a,b));
    }
    return res;
}
 
int main(){
    cin>>h>>w;
    if(w%3==0 || h%3==0){
        cout<<0<<endl;
        return 0;
    }
    long long ans=1e18;
    ans=min(calc(h,w),calc(w,h));
    cout<<ans;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char const* argv[])
{
	int target[5];

	cin >> target[0] >> target[1] >> target[2] >> target[3] >> target[4];

	sort( target, target + 5, greater<int>() );

	for( int i = 0;i < 5;i++ ){
		cout << ( i == 0 ? "" : " " ) << target[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    ans = a+b+c;
    if(ans <=21)cout<<"win"<<endl;
    else cout<<"bust"<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long long h,w,res;
  cin >> h >> w;
  res=h*w;
  if(res%2==1) res++;
  res/=2;
  if(h==1 || w==1) res=1;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let s = Array.init n (fun _ -> Scanf.scanf " %d" (fun s -> s)) in
    Array.sort compare s;
    let sum = Array.fold_left (+) 0 s in
    Printf.printf "%d\n" @@
        if sum mod 10 > 0 then sum else
            let rec loop i =
                if i = n then 0 else
                    if s.(i) mod 10 = 0 then loop (i + 1)
                    else sum - s.(i)
            in
            loop 0
)

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

void print(int a) {
  printf("%02d:%02d:%02d", a/60/60, a/60%60, a%60%60);
}

int main() {
  int n;
  while(cin >> n, n) {
    int ts[12*60*60];
    memset(ts, 0, sizeof(ts));
    REP(i, n) {
      int ang[3];
      REP(j, 3) cin >> ang[j];
      sort(ang, ang+3);
      do {
        REP(j, 60) {
          if (ang[0] % 5 == ang[1] / 12) {
            int h = ang[0] / 5;
            int m = ang[1];
            int s = ang[2];
            ts[(h*60+m)*60+s] |= 1<<i;
            //print((h*60+m)*60+s); cout << endl;
          }
          REP(k, 3) ang[k] = (ang[k]+1)%60;
        }
      } while(next_permutation(ang, ang+3));
      //cout << endl;
    }

    vector<int> num(n);
    int s=0, t=0;
    int cnt = 0;
    int ans1, ans2;
    int mi = INF;
    
    while(s<12*60*60 && t<12*60*60) {
      while(cnt != n && t<12*60*60) {
        REP(i, n) {
          if (ts[t] >> i & 1) {
            if (num[i]==0) cnt++;
            num[i]++;
          }
        }
        t++;
      }
      // REP(i, n) cout << num[i] << " ";
      // cout << endl;
      // print(s); cout << " ";
      // print(t-1); cout << endl;

      if (cnt == n) {
        if (mi > t-s) {
          mi = t-s;
          ans1 = s;
          ans2 = t-1;
        }
      }
      if (t==12*60*60) break;
      while(cnt == n && s<12*60*60) {
        REP(i, n) {
          if (ts[s] >> i & 1) {
            if (num[i]==1) cnt--;
            num[i]--;
          }
        }
        s++;
        if (cnt == n) {
          if (mi > t-s) {
            mi = t-s;
            ans1 = s;
            ans2 = t-1;
          }
        }
      }
    }
    print(ans1); cout << " ";
    print(ans2); cout << endl;
  }
}

Measured memory_bytes: 1108
// E.cpp
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int MAX_N = 13, MAX_M = 1e3 + 200;
const ll INF = 0x3f3f3f3f3f3f3f3f;

ll dp[MAX_M][(1 << MAX_N)], n, m, ai[MAX_M], keymp[MAX_M];

int main()
{
    scanf("%lld%lld", &n, &m);
    for (int i = 1; i <= m; i++)
    {
        int tmp, tmpx;
        scanf("%lld%d", &ai[i], &tmp);
        while (tmp--)
            scanf("%d", &tmpx), keymp[i] |= (1 << (tmpx - 1));
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 1; i <= m; i++)
    {
        dp[i][0] = 0;
        for (int stat = 0; stat < (1 << n); stat++)
            dp[i][stat] = dp[i - 1][stat];
        for (int stat = 0; stat < (1 << n); stat++)
            dp[i][stat | keymp[i]] = min(dp[i][stat | keymp[i]], dp[i - 1][stat] + ai[i]);
    }
    if (dp[m][(1 << n) - 1] == INF)
        puts("-1");
    else
        printf("%lld", dp[m][(1 << n) - 1]);
    return 0;
}

Measured memory_bytes: 77056
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string K; cin >> K;
  int N = K.length();
  int a[N]; rep(i,N) a[i] = K[i] - '0';
  int D; cin >> D;

  ll dp[2][N+1][D];
  rep(i,2) rep(j,N+1) fill_n(dp[i][j],D,0); dp[0][0][0] = 1;
  rep(i,N) rep(j,D) {
    rep(k,a[i]) dp[1][i+1][(j+k)%D] = (dp[1][i+1][(j+k)%D]+dp[0][i][j]) % MOD;
    dp[0][i+1][(j+a[i])%D] = (dp[0][i+1][(j+a[i])%D]+dp[0][i][j]) % MOD;
    rep(k,10) dp[1][i+1][(j+k)%D] = (dp[1][i+1][(j+k)%D]+dp[1][i][j]) % MOD;
  }

  ll result = (dp[0][N][0]+dp[1][N][0]-1+MOD) % MOD;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

map<char,ll> piche[100005],aage[100005],tmpmap;
    string s,t;
    ll n,m;

bool check(){
    set<char> ss;
    for(auto it:s) ss.insert(it);
    for(auto it:t) if(ss.find(it)==ss.end()) return 0;
    return 1;
}


int main()
{
    io
    ll i,j;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    tmpmap.clear();
    for(i=0;i<n;i++){
        if(!tmpmap[s[i]] and s[0]!=s[i]) tmpmap[s[i]]=i;
        piche[i]=tmpmap;
    }
    tmpmap.clear();
    for(i=n-1;i>=0;i--){
        aage[i]=tmpmap;
        tmpmap[s[i]]=i;
    }
    ll ans=0;
    ll cur=-1;
    for(i=0;i<n;i++){
        if(s[i]==t[0]){ 
            cur=i; break;
        }
    }
    if(cur==-1 || !check()){
        cout<<-1; return 0;
    }
    ans+=(cur+1);
    for(i=1;i<m;i++){
        char aglachar=t[i];
        if(aage[cur][aglachar]){
            ans+=(aage[cur][aglachar]-cur);
            cur=aage[cur][aglachar];
        }
        else{
            ans+=(n-cur-1);
            ans+=(piche[cur][aglachar]+1);
            cur=piche[cur][aglachar];
        }
    }
    cout<<ans;



    return 0;
}

Measured memory_bytes: 334800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

using int128 = __int128_t;
using uint128 = __uint128_t;
ostream &operator<<(ostream &os, int128 value) {
    ostream::sentry s(os);
    if (s) {
        uint128 tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) --d, *d = '-';
        int len = end(buffer) - d;
        if (os.rdbuf()->sputn(d, len) != len) {
            os.setstate(ios_base::badbit);
        }
    }
    return os;
}
istream &operator>>(istream &is, int128 &val) {
    string s; is >> s;
    val = 0;
    REP(i, s.size()) if ('0' <= s[i] && s[i] <= '9') {
        val = 10 * val + s[i] - '0';
    }
    return is;
}

int main(void) {
    int128 t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    auto naive = [&] {
        int128 p = (a1-b1)*t1, q = (a2-b2)*t2;
        if(p > 0) p *= -1, q *= -1;

        if(p + q < 0) return (int128)0;
        if(p + q == 0) return (int128)-1;

        int128 x = (-p) / (p+q);
        int128 r = (-p) % (p+q);
        return x*2 + !!r;
    };

    auto solve = [&] {
        bool flag;
        auto check = [&](int128 mid) {
            int128 nowx = (mid+1)/2*t1*a1 + mid/2*t2*a2;
            int128 nowy = (mid+1)/2*t1*b1 + mid/2*t2*b2;
            int128 prex = mid/2*t1*a1 + (mid-1)/2*t2*a2;
            int128 prey = mid/2*t1*b1 + (mid-1)/2*t2*b2;

            bool iscross = false;
            iscross |= prex <= prey && prey <= nowx && prex <= nowy && nowy <= nowx;
            iscross |= prey <= prex && prex <= nowy && prey <= nowx && nowx <= nowy;
            flag = prex == prey;
            return iscross;
        };

        if((a1-b1)*t1 + (a2-b2)*t2 == 0) return (int128)-1;

        int128 lb = 1, ub = 1e22;
        if(check(ub)) return (int128)-1;
        while(ub-lb > 1) {
            int128 mid = (lb+ub)/2;
            if(check(mid)) lb = mid;
            else ub = mid;
        }
        check(lb);
        if(lb > 1 && flag) lb--;
        return lb-1;
    };

    ll ret = solve();
    if(ret == -1) cout << "infinity" << endl;
    else cout << ret << endl;

    // REP(loop, 100000) {
    //     t1 = rand() % 100 + 1, t2 = rand() % 100 + 1;
    //     a1 = rand() % 100 + 1, a2 = rand() % 100 + 1;
    //     b1 = rand() % 100 + 1, b2 = rand() % 100 + 1;

    //     ll nans = naive();
    //     ll ans = solve();

    //     if(ans != nans) {
    //         dump(ans, nans);
    //         dump(t1, t2, a1, a2, b1, b2);
    //     }
    // }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  string s;cin>>s;
  bool f=0;
  if(s.at(0)!=s.at(1)) f=1;
  if(s.at(1)!=s.at(2)) f=1;  

  cout<<(f?"Yes":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> t(n);
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> t[i] >> a[i];
  ll nowt = 0;
  ll nowa = 0;
  nowt = 1;
  nowa = 1;
  for(int i = 0;i < n;i++){
    ll now = 0;
    ll memot = nowt / t[i];
    if(nowt % t[i] != 0)memot++;
    ll memoa = nowa / a[i];
    if(nowa % a[i] != 0)memoa++;
    now = max(memot,memoa);
    //cout << "ceil"<< ceil(nowt / t[i]) << " " << nowa / a[i] << endl;
    //cout << now << endl;
    nowt = t[i] * now;
    nowa = a[i] * now;
    //cout << nowt << " " << nowa << endl;
  }
  //cout << nowt << " " << nowa << endl;
  cout << nowt + nowa << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ph push
#define ptc putchar
#define enter putchar('\n')
using namespace std;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long lnt;
inline int read(){
	   int x = 0;char c = getchar();
	   while (!isdigit(c)) c = getchar();
	   while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0' , c = getchar();
	   return x;
}
inline void write(int x){
	   if (!x){
          ptc('0');
          return;
	   }
	   int dg[20] , len = 0;
	   while (x) dg[len++] = x % 10 , x /= 10;
	   while (len--) ptc(dg[len]+'0');
}
inline void writeln(int x){
	   write(x);
	   ptc('\n');
}
const int N = 1e5 + 10;

struct Edge{
	int to , nex;
}e[N << 1];int head[N] , ecnt; 

void adde(int fr,int to){
	e[++ecnt] = (Edge){to , head[fr]};
	head[fr] = ecnt;
}

void addedge(int fr,int to){
	adde(fr,to);
	adde(to,fr);
}

int f[N];
void dfs(int x,int par){
	for (int j = head[x];j;j=e[j].nex)
	if (e[j].to != par){
		dfs(e[j].to , x);
		f[x] ^= f[e[j].to] + 1;
	}
}
int n;


int main(){
	scanf("%d",&n);
	for (int i = 1;i < n;i++){
		int u , v;scanf("%d%d",&u,&v);
		addedge(u , v);
	}
	dfs(1 , 0);
	cout<< (f[1] ? "Alice" : "Bob"); 
	return 0;
}


Measured memory_bytes: 7296
n=int(input(''))
l=list(map(int,input('').split(' ')))
p=0
for a in range(0,n):
    for b in range(a,n):
        s0=l[a]+l[b]
        for c in range(b,n):
            s1=l[a]+l[c]
            s2=l[b]+l[c]

            if l[a]!=l[b] and l[b]!=l[c] and l[c]!=l[a]:
                if s1>l[b] and s2>l[a] and s0>l[c]:
                    p+=1

print(p)

Measured memory_bytes: 9232
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;


int count(ll v){
    int cnt = 0;
    while(v % 100 == 0){
        cnt ++;
        v = v / 100;
    }
    return cnt;
}

int main(){

    ll D;
    ll n;
    cin >> D >> n;

    ll val = 1;
    ll cnt = 0;
    ll div = 0;
    if(D == 0) div = 1;
    if(D == 1) div = 100;
    if(D == 2) div = 10000;
    while(true){
        int d = count(val);
        if(d == D) cnt++;
        if(cnt == n){
            cout << val << endl;
            return 0;
        }
        val ++;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>

int main (void){

  std::array<int, 3> S;
  std::cin >> S[0] >> S[1] >> S[2];

  if ( S[0] <= S[2] && S[1] >= S[2] ) {
    std::cout << "Yes" << std::endl;
    return 0;
  }
  if ( S[0] >= S[2] && S[1] <= S[2] ) {
    std::cout << "Yes" << std::endl;
    return 0;
  }
  std::cout << "No" << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n,m,c;
    int b[21];
    int a[21][21];
    int sum[21];
    int cou=0;
    
    scanf("%d %d %d",&n,&m,&c);
    for(int i=0;i<m;i++){
        scanf("%d",&b[i]);
        
    }
    for(int j=0;j<n;j++){
        sum[j]=0;
        for(int i=0;i<m;i++){
            scanf("%d",&a[j][i]);
            sum[j]+=a[j][i]*b[i];
        }
        if(sum[j]+c>0)cou++;
        
    }
    
    printf("%d\n",cou);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);

//---------------------------------------------------------------------------------------------//
int n, m;
int a[50], b[50], c[50], d[50];
int ans[50];
int aans[50];
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
	for (int i = 0; i < m; i++)cin >> c[i] >> d[i];
	for (int i = 0; i < n; i++)ans[i] = inf;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int mm = ans[i];
			ans[i] = min(ans[i], abs(a[i] - c[j]) + abs(b[i] - d[j]));
			if (ans[i] != mm) {
				aans[i] = j+1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << aans[i] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return a; } return a; }

int main() {
    ll n, d; cin >> n >> d;
    ll ans = 0;
    rep(i, n) {
        ll x, y; cin >> x >> y;
        if (x*x + y*y <= d*d) ans++;
        // cout << d*d << " " << x*x + y*y << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3524
data = $stdin.gets
a,b,c,d = data.split(" ").map{|x| x.to_i }
ab = b - a + 1
n_c = b/c - (a+c-1)/c + 1
n_d = b/d - (a+d-1)/d + 1
lcm_cd = c.lcm(d)
n_cd = b/lcm_cd - (a+lcm_cd-1)/lcm_cd + 1
result = (ab - n_c - n_d + n_cd)
puts result

Measured memory_bytes: 14404
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int w, q;
		int a[];
		int sleepAt;

		w = sc.nextInt();
		q = sc.nextInt();
		while (w + q != 0) {
			a = new int[w];
			for (int i = 0; i < w; i++) {
				a[i] = -1;
			}
			for (int i = 0; i < q; i++) {
				int name, size;
				char c = sc.next().charAt(0);
				if (c == 's') {
					name = sc.nextInt();
					size = sc.nextInt();
					sleepAt = sleep(a, w, name, size);
					if (sleepAt != -1) {
						System.out.println(sleepAt);
					} else {
						System.out.println("impossible");
					}
				} else if (c == 'w') {
					name = sc.nextInt();
					wakeup(a, w, name);
				}
			}
			System.out.println("END");
			w = sc.nextInt();
			q = sc.nextInt();
		}
	}

	public static int sleep(int a[], int w, int name, int size) {
		boolean flag = true;;
		for (int i = 0; i < w - size + 1; i++) {
			flag = true;
			for (int j = i; j < i + size; j++) {
				if (a[j] != -1) {
					flag = false;
					break;
				}
			}
			if (flag) {
				for (int j = i; j < i + size; j++) {
					a[j] = name;
				}
				return i;
			}
		}
		return -1;
	}
	
	public static void wakeup(int a[], int w, int name) {
		for (int i = 0; i < w; i++) {
			if (a[i] == name) {
				a[i] = -1;
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 1; i < (int)S.size(); i++) {
        if (S[i] != S[i-1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    
    
    ll ans=0;
    ll idx = 0;
    ll cnt=1;
    for(int i=0; i<n-1; i++){
      ans+=a[idx];
      cnt++;
      if(cnt==2){
        cnt=0;
        idx++;
      }

    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
#define TYPE(x) typeid(x).name()
int main(){
	string a;
	cin>>a;
	if(a=="ABC")
	cout<<"ARC";
	else
	cout<<"ABC"; 
}


Measured memory_bytes: 3596
#include <iostream>
#define ll long long
int main() {
	ll N, X, p = 0;
	std::cin >> N >> X;
	for (ll i = (ll)(1 << N / 2) * (1 << (N + 3 >> 1));i;i >>= 1, --X) {
      	if (X + 1 >= i) {
			p |= i >> 1;
			X -= i - 2;
		}
	}
	std::cout << p;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)1e9+7
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < n; i++)
#define Rep(i,n) for (int i = n; i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout<<endl;
#define P pair<int, int>
#define prique priority_queue<P, vector<P>, greater<P>>
struct edge { int to, cost; };
using namespace std;
template<typename T> void unsort(vector<T>& vec) {
	sort(all(vec), greater<T>());
	return;
}

signed main() {
	int a, b;
	cin >> a >> b;
	if (13 <= a) cout << b << endl;
	else if (6 <= a) cout << b / 2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256