akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Pi = pair < int , int >;

int main()
{
	int n;

	while ( cin >> n, n ) {
		int times[55][2][255];
		Pi dat[55];
		int t[55], c[55];

		for ( int i = 0; i < n; i++ ) {
			cin >> dat[i].first >> dat[i].second; dat[i].second++;
		}
		sort(dat, dat + n);
		for ( int i = 0; i < n; i++ ) {
			t[i] = dat[i].first;
			c[i] = dat[i].second;
		}

		for ( int i = n - 1; i >= 0; i-- ) {
			int sum = 0;
			times[i][0][0] = 0;
			times[i][1][0] = 0;
			for ( int j = 1; j < c[i]; j++ ) {
				for ( int k = 0; k < 2; k++ ) {
					int save = sum;
					sum += t[i];
					for ( int l = i + 1; l < n; l++ ) {
						int pos = upper_bound(times[l][k], times[l][k]+c[l], sum) - times[l][k];
						int prevpos = pos;
						if ( pos == c[l] ) continue;
						if ( k == 0 ) prevpos--;
						if ( times[l][1-k][prevpos] < save ) sum = max(sum, times[l][k][pos] );
					}
					times[i][k][j] = sum;
				}
			}
		}
		int maxv = 0;
		for ( int i = 0; i < n; i++ ) {
			maxv = max(maxv, times[i][1][c[i] - 1]);
		}

		cout << maxv << endl;
	}

	return ( 0 );
}




Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args) {
		try {
			//Input
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int N = Integer.parseInt(br.readLine());
			for (int i = 0; i < N; i++) {
				String A = br.readLine();
				String B = br.readLine();
				if ((A.length() > 80)|| (B.length() > 80)) {
					System.out.println("overflow");
				} else {
					BigInteger P = new BigInteger(A);
					BigInteger Q = new BigInteger(B);
					BigInteger R = new BigInteger("0");

					R = R.add(P); R = R.add(Q);
					String total = R.toString();

					if (total.length() > 80) {
						System.out.println("overflow");
					} else {
						System.out.println(total);
					}

				}

			}
		} catch (Exception e) {
			System.out.println("error");
		}
	}

}

Measured memory_bytes: 24356
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        vector<pii> p;
        map<pii, int> s;
        int mx = 0;
        REP(i, n) {
            int x, y;
            cin >> x >> y;
            p.emplace_back(x, y);
        }
        REP(i, n) {
            REP(j, n) {
                if (i != j) {
                    chmax(mx, ++ s[p[i] - p[j]]);
                }
            }
        }
        int ans;
        cout << (n == 1 ? 1 : n - mx) << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100000

struct Queue{
	char s[15];
	int time;
};

int head=0,tail=0;
Queue name[100000];

int FULL(){
	return head == (tail+1)%MAX;
}

int EMPTY(){
	return head == tail;
}

void enqueue(Queue x){
	name[tail] = x;
	tail=(tail + 1)%MAX;
}

Queue dequeue(){
	Queue x =name[head];
	head = (head + 1)%MAX;
	return x;
}

int main(){
	int i,n,j,k,q;
	scanf("%d",&n);
	scanf("%d",&q);
	getchar();
	int cur=0;
	for(i=0;i<n;i++){
		scanf("%s",name[i].s);
		scanf("%d",&name[i].time);
		tail++;
		getchar();
	}
	while(head != tail){
		Queue u=dequeue();
		if(u.time>q){
			u.time-=q;
			cur+=q;
			enqueue(u);
		}
		else{
			cur+=u.time;
			printf("%s %d\n",u.s,cur);
		}
	}
} 


Measured memory_bytes: 4568
#include<bits/stdc++.h>
using namespace std;
int n, a[101];
long long sum;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			sum += a[i] * a[j];
		} 
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
	int N;
	//cin >> N;

	string s;
	cin >> s;

	//int A[5]
	//sort(A, A + 5);

	if ("ABC"==s)
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n);
int main(){
    int x; cin >> x;
    int i = x;
    while(1){
        if(isPrime(i)){
            cout << i << endl;
            break;
        }else{
            i++;
        }
    }
}

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


Measured memory_bytes: 256
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	LL k, x, ans;
	cin >> k;
	for (x = 7 % k, ans = 1; x != 0 && ans < 10000000; ++ans) {
		x = (x * 10 + 7) % k;
	}
	cout << (ans >= 10000000 ? -1 : ans) << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int b,f,r,v,N;
    long long fa[4][3][10]={};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>b>>f>>r>>v;
        fa[b-1][f-1][r-1] =fa[b-1][f-1][r-1] + v;
    }
    for(int u =0;u<4;u++){
        for(int o=0;o<3;o++){
            for(int w=0;w<10;w++){
                cout<<" "<<fa[u][o][w];
            }
            cout<<endl;
        }
        if(u==3)break;
        for(int q = 0;q<20;q++){
            cout<<"#";
        }
        cout<<endl;
    }
}




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

const int N = 4e6 + 10;
int n, x, sum;
bitset < N > q;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    q[0] = 1;
    for(int i = 1; i <= n; i++){
        cin >> x;
        sum += x;
        q |= q << x;
    }
    int i;
    for(i = sum / 2 + (sum % 2); !q[i]; i++){

    }
    cout << i;
}


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

int gcd(int a, int b)
{
  if(a==0)return b;
  return gcd(b%a, a);
}
int main() {
	// your code goes here
	int n;
	long long int res=0;
	cin>>n; 
	for(int i=1;i<=n;i++)
      for(int j=1;j<=n;j++)
      	for(int k=1;k<=n;k++)
        {
              	int x=0;
              	if(i>j) x = gcd(j, i);
              	else x = gcd(i, j);
              	if(x>k) res=res+ gcd(k, x); 
              	else res=res+ gcd(x, k);
        
        }
        
	cout<<res;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


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

vector<int> a;
vector<int> b;
vector<int> c;

void CountingSort(int n, int k){
  b.resize(n+5);
  c.resize(k+5);
  for(int i = 0; i <= k; i++) c[i] = 0;
  
  for(int i = 1; i <= n; i++) c[a[i]]++;

  for(int i = 1; i <= k; i++) c[i] = c[i] + c[i-1];

  for(int i = n; i >= 1; i--){
    b[c[a[i]]] = a[i];
    c[a[i]]--;
  } 
}

int main()
{
  int n;
  cin >> n;

  a.resize(n+5);
  int k = 0;

  for(int i = 0; i < n; i++){
    cin >> a[i+1];
    if(a[i+1] > k) k = a[i+1];
  }

  CountingSort(n, k);

  for(int i = 1; i <= n; i++){
    if(i != 1) cout << " ";
    cout << b[i];
  }

  cout << endl;

  return 0;

}



Measured memory_bytes: 18336
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

int main()
{
    int a, b;
    cin >> a >> b;
    if((a+b)%2) cout << "IMPOSSIBLE\n";
    else
    {
        cout << ((a+b)/2) << "\n";
    }
}




Measured memory_bytes: 6016
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<=0 && b>=0) puts("Zero");
    else if(a>0&&b>0) puts("Positive");
    else if((b-a)%2) puts("Positive");
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

lans = 1
rans = n
for i in range(m):
  l,r = map(int,input().split())
  lans = max(lans,l)
  rans = min(rans,r)
if lans <= rans:
  print(len(list(range(lans,rans+1))))
else:
  print(0)

Measured memory_bytes: 44504
// problem: "https://atcoder.jp/contests/abc161/tasks/abc161_c"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ll a,b;
    cin>>a>>b;

    cout<<min(a%b,abs(a%b - b));

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a[] = new long[n];

		long sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			sum += a[i];
		}

		long result = 0;
		for (int i = 0; i < n; i++) {
			sum -= a[i];
			result = (result + a[i] * (sum % 1000000007)) % 1000000007;
//			sum = sum % 1000000007;
		}

		System.out.println(result);

		sc.close();

	}

}

Measured memory_bytes: 62176
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string S, T;
  int N, Sho, Amr, hnti = 0;
  
  cin >> N >> S;
  
  Amr = N % 2;
  Sho = N / 2;
  
  if(N == 1||Amr == 1) cout << "No" << endl;
  else if(N > 1){
    for(int i = Sho; i < N; i++){
      T += S[i];
    }
    //cout << T << endl; //デバック用
    for(int i = 0; i < Sho; i++){
      if(S[i] == T[i]) hnti++;
    }
    //cout << hnti << endl; //判定確認用
    if(hnti == Sho) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}

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

#define MAX 32768
int main(){
  int b[MAX]={0},i,j,c[MAX]={0};
  b[0]=b[1]=1;
  for(i=4;i<MAX;i+=2)b[i]=1;
  for(i=3;i*i<MAX;i+=2)
    if(!b[i])for(j=i+i;j<MAX;j+=i)b[j]=1;

  for(i=2;i<MAX;i++){
    for(j=i;!b[i] && j<MAX;j++){
      if(b[j])continue;
      c[i+j]++;
    }
  }

  while(cin>>i,i){
    cout<<c[i]<<endl;
  }
}

Measured memory_bytes: 1008
d = [0] * 200000
d[100] = 1
d[101] = 1
d[102] = 1
d[103] = 1
d[104] = 1
d[105] = 1
for i in range(110, 100000 + 1):
    d[i] += d[i-100]
    d[i] += d[i-101]
    d[i] += d[i-102]
    d[i] += d[i-103]
    d[i] += d[i-104]
    d[i] += d[i-105]
n = int(input())
print("1" if d[n] != 0 else "0")

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

using namespace std; 

const int MAX_N = 100005; 
const int MAX_D = 15; 

int dp[MAX_N][MAX_D]; 
int c[MAX_N]; 
vector <int> adj[MAX_N]; 
int n, m, query; 

int main () {
//	freopen("input.txt", "r", stdin); 
	//freopen("output.txt", "w", stdout); 
	scanf("%d %d", &n, &m); 
	for (int i = 1; i <= m; i++) {
		int u, v; 
		scanf("%d %d", &u, &v); 
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	scanf("%d", &query); 
	for (int i = 1; i <= query; i++) {
		int u, d; 
		scanf("%d %d %d", &u, &d, &c[i]); 
		dp[u][d] = i; 
	}

	for (int i = 1; i <= n; i++) {
		adj[i].push_back(i); 
	}

	for (int d = 9; d >= 0; d--) {
		for (int u = 1; u <= n; u++) {
			for (int i = 0; i < (int) adj[u].size(); i++) {
				int v = adj[u][i]; 
				dp[v][d] = max(dp[v][d], dp[u][d + 1]); 
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		int ans = 0; 
		for (int d = 0; d <= 9; d++) {
			ans = max(ans, dp[i][d]); 
		}

		printf("%d\n", c[ans]); 
	}
	return 0; 
}

Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,c=0;
    cin >> N;
    vector<int> L(N);
    for(int i=0;i<N;i++)
        cin >> L.at(i);
    for(int i=0;i<N-2;i++){
        for(int j=i+1;j<N-1;j++){
            for(int k=j+1;k<N;k++){
                if((L.at(i) != L.at(j))&&(L.at(i) != L.at(k))){
                    if(L.at(j)!=L.at(k)){
                        if((L.at(i)+L.at(j)>L.at(k))&&(L.at(j)+L.at(k)>L.at(i))){
                            if(L.at(k)+L.at(i)>L.at(j)){
                                c++;
                            }
                        }
                    }     
                }
            }
        }
    }
    
    cout << c << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i = 0; i <= a; i++)
    {
        for (int j = 0; j <= b; j++)
        {
            for (int k = 0; k <= c; k++)
            {
                if (i * 500 + j * 100 + k * 50 == x)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int BinarySearch(int key,int n,int S[]){
  int l=0,r=n;
  while(r-l>1){
    int mid=(l+r)/2;
    if(S[mid]>key)r=mid;
    else l=mid;
  }
  return S[l]==(key?1:0);
}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8


int main(){
    ll N,C=0;cin >> N;
    while(N/2>0){
        N/=2;
        C++;
    }
    cout << pow(2,C) <<endl;
}

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

/* Memo
* turu a. kame b
* X = a + b
* Y = 2 * a + 4 * b
*
* (X, Y) =  [[1,1],[2,4]] (a,b)
* a = - (Y - 4 * X) / 2
* b = (Y - 2 * X) / 2
*/

int main(void)
{
    int X, Y;
    std::cin >> X >> Y;

    int a,b;
    a = (4 * X - Y);
    b = (Y - 2 * X);

    if((a >= 0) && (b >= 0)) {
        if ((a % 2 == 0) && (b % 2 == 0)) {
            std::cout << "Yes" << std::endl;
        }
        else {
            std::cout << "No" << std::endl;
        }
    }
    else {
         std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        int Array[] = new int[20000];
        Scanner InData = new Scanner(System.in);
        for(int n = 1;n<20000; n++){
            Array[n] = InData.nextInt();
            if(Array[n]==0)
                break;
        }
        for(int n = 1; n<20000; n++){
            if(Array[n]!=0)
                System.out.println("Case "+n+": "+Array[n]);
            else
                break;

        }

    }


}

Measured memory_bytes: 43648
#include <bits/stdc++.h>
using namespace std;
const int maxn=200010;
const int INF=(1<<30);
int n,m,T[maxn*4],b[maxn],s[maxn],dp[maxn],ans;
vector<int> g[maxn];
void build(int l,int r,int root) {
	T[root]=-(1<<30);
	if (l==r) return;
	int mid=(l+r)/2;
	build(l,mid,root*2);
	build(mid+1,r,root*2+1);
}
int query(int L,int R,int l,int r,int root) {
	if (L<=l&&r<=R) return T[root];
	int mid=(l+r)/2,res=-INF;
	if (L<=mid) res=max(res,query(L,R,l,mid,root*2));
	if (mid<R) res=max(res,query(L,R,mid+1,r,root*2+1));
	return res;
}
void update(int pos,int l,int r,int root,int val) {
	if (l==r) {
		T[root]=max(T[root],val); return;
	}
	int mid=(l+r)/2;
	if (pos<=mid) update(pos,l,mid,root*2,val);
	else update(pos,mid+1,r,root*2+1,val);
	T[root]=max(T[root*2],T[root*2+1]);
}
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&b[i]);
		s[i]=s[i-1]+b[i];
	}
	scanf("%d",&m);
	for (int i=1;i<=m;i++) {
		int l,r; scanf("%d %d",&l,&r);
		g[l].push_back(r);
	}
	build(0,n,1);
	update(0,0,n,1,0);
	for (int i=1;i<=n;i++) {
		int tmp=query(i-1,i-1,0,n,1)+s[i-1]+(b[i]==0);
		for (int j=0;j<g[i].size();j++)
			dp[j]=s[g[i][j]]+query(i-1,g[i][j],0,n,1);
		update(i,0,n,1,tmp-s[i]);
		for (int j=0;j<g[i].size();j++)
			update(g[i][j],0,n,1,dp[j]-s[g[i][j]]);
	}
	ans=query(n,n,0,n,1)+s[n];
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 14976
class dice:
    def __init__(self, f):
        assert(len(f) == 6)
        self.face = f
        self.N = [1, 5, 2, 3, 0, 4]
        self.S = [4, 0, 2, 3, 5, 1]
        self.E = [3, 1, 0, 5, 4, 2]
        self.W = [2, 1, 5, 0, 4, 3]
        self.R = [0, 2, 4, 1, 3, 5]

    def rotate(self, dir):
        rot = self.__getattribute__(dir)
        old = self.face
        new = [-1 for _ in range(6)]
        for i in range(6):
            new[i] = old[rot[i]]
        self.face = new


F = list(map(int, input().split()))
D = dice(F)
m = int(input())
for _ in range(m):
    a, b = map(int, input().split())
    for _ in range(4):
        if a == D.face[0]:
            break
        else:
            D.rotate('N')
    if a != D.face[0]:
        for _ in range(4):
            if a == D.face[0]:
                break
            else:
                D.rotate('E')
    assert(a == D.face[0])
    for _ in range(4):
        if b == D.face[1]:
            break
        else:
            D.rotate('R')
    assert(b == D.face[1])
    print(D.face[2])


Measured memory_bytes: 5612
eval"N,K,*A="+`dd`.split*?,
s,*l=A.reduce:+
1.upto(3e4){|i|s% i<1&&l<<i<<s/i}
p l.select{|d|a=A.map{|a|a%d}.sort
a[0..-a.reduce(:+)/d-1].reduce(:+)<=K}.max

Measured memory_bytes: 5252
# -*- coding: utf-8 -*-
import sys 
sys.setrecursionlimit(10**6)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
road = [[] for _ in range(N+1)]
visit = [0]*(N+1)

for i in range(M):
    x,y = map(int,readline().split())
    road[x].append(y)
    road[y].append(x)
  
def dfs(v,prev):
    for x in road[v]:
        if x == prev:
            continue
        if visit[x] != 0:
            continue
        visit[x] = 1
        dfs(x,v)
    return 

count = 0     
for i in range(1,N+1):
    if visit[i] == 0:
        dfs(i,-1)
        count += 1

print(count-1)

Measured memory_bytes: 966480
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    a, b, c = LI()
    d = max(0, c - (a - b))
    print(d)


main()



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  map<ll, vector<ll>> ans;
  std::vector<long long> P(M);
  std::vector<long long> Y(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> Y[i];
    ans[P[i]].pb(Y[i]);
  }

  for (auto& p : ans) {
    sort(all(p.second));
  }

  ostringstream sout;
  rep(i, 0, M) {
    ll city = P[i];
    ll year = Y[i];

    int index = lower_bound(all(ans[city]), year) - begin(ans[city]);
    sout << setfill('0') << setw(6) << city << setw(6) << (index + 1) << endl;
  }

  put(sout.str());
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 16644
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
var student = (0..<N).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}}
var checkpoint = (0..<M).map{_ in readLine()!.characters.split(" ").map{Int(String($0))!}}
for i in 0..<N {
    var ans = 0
    var minDist = 400000001
    for j in 0..<M {
        let dist = abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1])
        if dist < minDist {
            minDist = dist
            ans = j + 1
        }
    }
    print(ans)
}

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

using namespace std;

int main(){
   	int n, sum = 0, count = 0;
   	cin >> n;
   	int h[n];

   	for (int i = 0; i < n; i++)
   	{
   		cin >> h[i];
   	}

   	for (int i = 0; i < n - 1; i++)
   	{
   		if (h[i] >= h[i+1])
   		{
   			sum++;
   		}
   		else{
   			if (sum > count)
   			{
   				count = sum;
   			}
   			sum = 0;
   		}
   	}
   	// cout << sum << endl;
   	if (sum > count)
   	{
   		count = sum;
   	}
 	cout << count;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
Sums = set()
for i in range(2**n):
    Sum = 0
    for j in range(n):
        if (i >> j) & 1:
            Sum += a[j]
    Sums.add(Sum)

for i in range(q):
    if m[i] in Sums:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5644
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>

#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f
#define met(a,x) memset(a,x,sizeof(a))
#define mp make_pair

using namespace std;
const int N=1e6+10;
const int mod=1e9+7;
char s[1010];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    int cnt2=0,cnt4=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>m;
        if(m%4==0)
        {
            cnt4++;
        }
        else if(m%2==0)
        {
            cnt2++;
        }
    }
    if(cnt2!=0)
        n-=(cnt2-1);
    if(cnt4>=ceil(1.0*(n-1)/2))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

void solve(long long X)
{
    long ans = ((X / 500) * 1000) + ((X % 500) / 5) * 5;
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


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

int main() {
    string s;
    cin>>s;
    int q;
    cin>>q;
    int bit=0;
    string a,b;
    while(q--)
    {
        int ch; cin>>ch;
        if(ch==1) bit=1-bit;
        else
        {
            int x; char y;
            cin>>x>>y;
            if(x==1) 
            {
                if(bit) b+=y;
                else a+=y;
            }
            else
            {
                if(bit) a+=y;
                else b+=y;
            }
        }
    }
    if(bit) 
    {
        reverse(b.begin(),b.end()); reverse(s.begin(),s.end());
        cout<<b+s+a<<endl;
    }
    else
    {
        reverse(a.begin(),a.end());
        cout<<a+s+b<<endl;
    }
	return 0;
}


Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
typedef double D;
const D INF = 1e18;
struct P {
  D x, y;
  P() { }
  P(D x_, D y_) : x(x_), y(y_) { }
};
struct C {
  P p; D r;
  C() { }
  C(P p_, D r_) : p(p_), r(r_) { }
};
P operator -(P a, P b) { return P(a.x - b.x, a.y - b.y); }
D inp(P a, P b) { return a.x*b.x + a.y*b.y; }
D abs(P p) { return sqrt(inp(p,p)); }
struct Edge {
  int to;
  double cost;
  Edge(int to_, double cost_) : to(to_), cost(cost_) { }
};
struct State {
  int pos;
  double cost;
  State(int pos_, double cost_) : pos(pos_), cost(cost_) { }
  bool operator <(const State &s) const {
    return cost > s.cost;
  }
};
vector<double> shortest_path(const vector<vector<Edge>> &G, const int src) {
  const int n = G.size();
  vector<double> d(n, INF);
  priority_queue<State> Q;
  Q.emplace(src, 0);
  d[src] = 0;
  while(!Q.empty()) {
    State s = Q.top(); Q.pop();
    if(s.cost > d[s.pos]) continue;
    for(Edge e : G[s.pos]) {
      if(d[e.to] > s.cost + e.cost) {
        d[e.to] = s.cost + e.cost;
        Q.emplace(e.to, d[e.to]);
      }
    }
  }
  return d;
}
signed main() {
  ios::sync_with_stdio(false);
  P s, t;
  cin >> s.x >> s.y >> t.x >> t.y;
  int N; cin >> N;
  vector<C> V(N);
  REP(i,N) {
    cin >> V[i].p.x >> V[i].p.y >> V[i].r;
  }
  vector<vector<Edge>> G(N+2);
  REP(i,N) {
    REP(j,N) {
      double d = max(0.0, abs(V[i].p - V[j].p) - V[i].r - V[j].r);
      G[i].emplace_back(j, d);
    }
  }
  REP(i,N) {
    double d;
    d = max(0.0, abs(s - V[i].p) - V[i].r);
    G[N].emplace_back(i, d);
    G[i].emplace_back(N, d);
    d = max(0.0, abs(t - V[i].p) - V[i].r);
    G[N + 1].emplace_back(i, d);
    G[i].emplace_back(N + 1, d);
  }
  auto d = shortest_path(G, N);
  double ans = d[N + 1];
  ans = min(ans, abs(s - t));
  cout.setf(ios::fixed);
  cout.precision(10);
  cout << ans << endl;
}


Measured memory_bytes: 20592
import java.util.Scanner;
class Main {
public static void main(String[] args) {

try (Scanner sc = new Scanner(System.in)) {
while (true) {
int n = sc.nextInt();
double sum=0.0;
double ssum=0.0;
if (n == 0) { break; }
int[] scores = new int[n];
for (int i = 0; i < scores.length; i++) {
scores[i] = sc.nextInt();
}
double average = 0, variance = 0;
for(int j=0;j<scores.length;j++){
    sum +=scores[j];
}
average=sum/scores.length;
for(int k=0;k<scores.length;k++){
    ssum+=(scores[k]-average)*(scores[k]-average);
}
variance =ssum/scores.length;
System.out.println(Math.sqrt(variance));
}
}
}
}


Measured memory_bytes: 31376
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl '\n'
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
//int rnd(int x) { return mrand() % x;}
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int n;
ll a[maxn];

int main()
{
	fastIO;
	cin >> n;
	ll mx = 1e18;
	ll v = 1;
	rep(i,0,n) cin >> a[i];
	sort(a, a + n);
	rep(i,0,n) {
		if(a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
		if(a[i] > mx || v > mx / a[i] || v > mx) {
			cout << -1 << endl;
			return 0;
		}
		v *= a[i];
	}
	cout << v << endl;
	return 0;
}

Measured memory_bytes: 4440
#include <iostream>
#include <vector>

void Print(int size, std::vector<int> ls) {
	for (int i = 0; i < size; i++)
		i != size - 1 ? std::cout << ls[i] << " " :
		std::cout << ls[i] << "\n";
}

void SelectionSort(int size, std::vector<int> ls) {
	int swap = 0, mini;
	for (int i = 0; i < size; i++) {
		mini = i;
		for (int j = i; j < size; j++)
			if (ls[j] < ls[mini]) {
				mini = j;
			}
		if (i != mini) {
			int _ = ls[i];
			ls[i] = ls[mini];
			ls[mini] = _;
			swap++;
		}
	}
	Print(size, ls);
	std::cout << swap << "\n";
}

std::vector<int> scan(int size) {
	std::vector<int> ls(size);
	for (int i = 0; i < size; i++) {
		std::cin >> ls[i];
	}
	return ls;
}

int main() {
	int size;
	std::cin >> size;
	SelectionSort(size, scan(size));
	return 0;
}



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

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

int main() {
  int N;
  ll A[100000]={0};
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  ll ans(gcd(A[0],A[1]));
  for (int i(2);i<N;i++){
     ans=gcd(ans,A[i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int h[20];
  int count = 0;
  int max = 0;
  for(int i=0; i<n; i++){
    cin >> h[i];
    if(max<=h[i]){
      count++;
      max = h[i];
    }
  }
  cout << count;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	int vote[26],n;
	char a,tmp;
	while (S(d, n), n) {
		getchar();
		int max, sec,i;
		max = sec = i = 0;
		tmp = 'A';
		memset(vote, 0, sizeof(vote));
		while (n--) {
			fscanf(stdin, "%c%*c", &a);
			if (max > sec + n+1)continue;
			i++;
			vote[a - 'A']++;
			if (vote[a - 'A'] >= max) {
				if(vote[tmp-'A']-1!=max) sec = max;
				max = vote[a - 'A'], tmp = a;
			}
			else if (vote[a - 'A'] > sec) sec = vote[a - 'A'];
		}
		if (max == sec) puts("TIE");
		else fprintf(stdout, "%c %d\n", tmp, i);
	}
	return 0;
}

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

#define int long long
#define MOD 1000000007

int n;
map<int, int> mp;
int a[100010];
int pt[100010];

signed main(){
    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    mp[-1] = 3;
    int ans = 1;
    for(int i = 0;i < n;i++){
        pt[i] = mp[a[i]-1] - mp[a[i]];
        mp[a[i]]++;
        ans *= pt[i];
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		String S = in.next();
		String T = in.next();
		long lcm = lcm(M, N);
		Pair[] n = new Pair[N];
		Pair[] m = new Pair[M];
		for (int i = 0; i < N; i++) {
			long num = i * (lcm / N) + 1;
			char c = S.charAt(i);
			n[i] = new Pair(num, c);
		}
		for (int i = 0; i < M; i++) {
			long num = i * (lcm / M) + 1;
			char c = T.charAt(i);
			m[i] = new Pair(num, c);
		}
		int index = 0;
		boolean isOk = true;
		for (int i = 0; i < N; i++) {
			while (index < M) {
				if (n[i].num < m[index].num) {
					break;
				} else if (n[i].num == m[index].num && n[i].c != m[index].c) {
					isOk = false;
					break;
				}
				index++;
			}
		}
		System.out.println(isOk ? lcm : -1);
		in.close();
	}

	//最大公約数を求める関数。ｍ＞ｎの必要がある。
	static long gcd(long x, long y) {
		if (x < y) {
			long tmp = y;
			y = x;
			x = tmp;
		}
		if (y == 0) {
			return x;
		}
		return gcd(x % y, y);
	}

	//最小公倍数を求める関数。ｍ＞ｎの必要がある。
	static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}
}

class Pair {

	long num;
	char c;

	public Pair(long num, char c) {
		this.num = num;
		this.c = c;
	}
}

Measured memory_bytes: 30712
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#なお、任意の整数 M に対して M の −2 進数表現が一意に定まることが証明できます。
#2桁ごとに見るとよかった（もう実験したよ）
def resolve():
    N,M,C=pin()
    B=lispin()
    cnt=0
    for n in range(N):
        
        A=tupin()
        temp=0
        for i in range(M):
            temp+=B[i]*A[i]
        
        if temp+C>0:cnt+=1
    print(cnt)

#%%submit!
resolve()


Measured memory_bytes: 38256
number = [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]
N = int(input())
print(number[N-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust\n";
	else cout << "win\n";

	return 0;
}



Measured memory_bytes: 888
s = input()

def func(ac,s,op):
  next = int(s[0])
  if len(s) ==1:
    if ac + next == 7:
      print(op+'+'+s[0]+'=7')
      exit(0)
    if ac - next == 7:
      print(op+'-'+s[0]+'=7')
      exit(0)
  else:
    func(ac+next,s[1:],op+'+'+str(next))
    func(ac-next,s[1:],op+'-'+str(next))
  
func(int(s[0]),s[1:],s[0])



Measured memory_bytes: 3060
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    L = [int(x) for x in input().split()]

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                tmp = []
                tmp.append(L[i])
                tmp.append(L[j])
                tmp.append(L[k])
                x = set(tmp)
                if len(x) != 3:
                    continue
                tmp.sort()
                if tmp[2] < tmp[1] + tmp[0]:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68272
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;
 
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}
 
map<ll,ll> prime_factorize(const ll N) {
    map<ll,ll> fac;
    ll n = N;
    for(ll p = 2; p*p <= n; p++) {
        if (n%p != 0) continue; // p is not n's devisor
        else {
            while (n%p == 0) {
              fac[p]++;
              n /= p;
            }
        }
    }
    if (n > 1) fac[n]++;
    return fac;
}
 

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  ll A,B; cin >> A >> B;
 
  ll C = gcd(A, B);
  
  map<ll,ll> mp = prime_factorize(C);
 
  int ans = mp.size() + 1;
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+10;
int a[8005];
int dp[8005][8005];
int sum[8005];
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        swap(a,b);
    }
    if(a>c){
        swap(a,c);
    }
    if(b>c){
        swap(b,c);
    }
    int x=(c-b);
    int y=(c-(a+x));
    if(y%2){
        printf("%d\n",x+y/2+2);
    }
    else{
        printf("%d\n",x+y/2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int cnta = 0, cntb = 0, cntc = 0;
    rep(i, 3) {
        if(s[i] == 'a') {
            cnta++;
        }
        if(s[i] == 'b') {
            cntb++;
        }
        if(s[i] == 'c') {
            cntc++;
        }
    }

    if(cnta > 0 && cntb > 0 && cntc > 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    
    cout << endl;
    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() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  
  if (b<=c || a>=d){
    cout << 0 << endl;
    return 0;
  }
  int start = max(a,c),finish = min(b,d);
  cout << finish - start << endl;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let S: String = sc.read();
    if S == "ABC" {
        println!("{}", "ARC");
    } else {
        println!("{}", "ABC");
    }
}

Measured memory_bytes: 2160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    int stayTimeAll = Integer.parseInt(bf.readLine());
    int firstStayTime = Integer.parseInt(bf.readLine());
    int firstMoney = Integer.parseInt(bf.readLine());
    int lastMoney = Integer.parseInt(bf.readLine());

    int lastStayTime = 0;
    if (stayTimeAll > firstStayTime) {
      lastStayTime = stayTimeAll - firstStayTime;
    } else {
      firstStayTime = stayTimeAll;
    }

    System.out.println((firstStayTime * firstMoney) + (lastStayTime * lastMoney));
  }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=998244353;
const int MAX=300000;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

signed main(){
    COMinit();
  	int N,M,K;cin>>N>>M>>K;
    int ans=0;
    for(int i=0;i<=K;i++){
        int d=M*powMOD(M-1,N-1-i)%MOD*COM(N-1,i)%MOD;
        ans+=d;
      	ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10672
S = str(input())
K = int(input())
tmp = 1
cnt1 = 0
cnt2 = 0
for i in range(1, len(S)):
    if S[i-1] == S[i]:
        tmp += 1
    else:
        cnt1 += tmp // 2
        tmp = 1
if tmp == len(S):
        print(len(S) * K // 2)
        exit()
if tmp > 1:
    cnt1 += tmp//2
S2 = S + S
tmp = 1
for i in range(1, len(S2)):
    if S2[i-1] == S2[i]:
        tmp += 1
    else:
        cnt2 += tmp // 2
        tmp = 1
if tmp > 1:
    cnt2 += tmp//2
if K == 1:
    print(cnt1)
else:
    print((cnt2 - cnt1) * (K-2) + cnt2)



Measured memory_bytes: 3192
N = int(input())
results = [input() for _ in range(N)]
cntAC = 0
cntWA = 0
cntTLE = 0
cntRE = 0

for i in results:
    if i == "AC":
        cntAC += 1
    elif i == "WA":
        cntWA += 1
    elif i == "TLE":
        cntTLE += 1
    elif i == "RE":
        cntRE += 1

print("AC x {}".format(cntAC))
print("WA x {}".format(cntWA))
print("TLE x {}".format(cntTLE))
print("RE x {}".format(cntRE))

Measured memory_bytes: 16244