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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, a, b, c[114514];

int main() {
	cin >> n >> m;
	// クエリ(a,b)は根を適当にrとすると(r,a),(r,b)に分解できる
	// ∵ a,bのLCAをpとすると前者はa-p,b-pに+1、後者はa-p,b-pに+1とr-pに+2なのでmod2で考えると一緒なため
	rep(i,m) {
		cin >> a >> b;
		c[a]++, c[b]++;
	}
	repst(i,1,n) {
		if (c[i]%2!=0) {
			cout << "NO" << ln;
			return 0;
		}
	}
	cout << "YES" << ln;
}

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

#define fastIO                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
	fastIO;
	int n;
  	cin >> n;
  	cout << !n;
}

Measured memory_bytes: 3612
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <cstring>
#include <utility>

#define dprintf(s,...) printf("%s:%d" s,__func__,__LINE__,__VA_ARGS__)
using namespace std;

typedef pair<int,int> P;
typedef long long int ll;

class Edge{
public:
  int to,cost;
  Edge(int t,int c){
    to = t;
    cost = c;
  }
};

int n,k;
int d[10][10];
vector<Edge> G[10];

void dijekstra(int s){

  priority_queue<P, vector<P>, greater<P> > qu;

  qu.push(P(0,s));
  d[s][s]=0;
  
  while(!qu.empty()){

    P p = qu.top();
    int v = p.second; 
    qu.pop();

    if(d[s][v] < p.first) continue;

    for(int i=0; i<G[v].size(); i++){
      Edge e = G[v][i];
      
      if(d[s][v]+e.cost < d[s][e.to]){
	d[s][e.to] = d[s][v]+e.cost;
	qu.push(P(d[s][e.to], e.to));
      }
    }
    
  }

}

void solve(){

  for(int i=0;i<k;i++)
    for(int j=0;j<k;j++){
      d[i][j]=INT_MAX/3;
    }

  for(int i=0;i<k;i++){
    dijekstra(i);
  }
}


int main(){

  ios_base::sync_with_stdio(false);
  
  while(1){

    k=0;
    
    cin>>n;
    if(n==0) break;
    
    
    for(int i=0;i<n;i++){
      int a,b,c;
      cin>>a>>b>>c;
      Edge e1(a,c),e2(b,c);
      G[a].push_back(e2);
      G[b].push_back(e1);
      k = max(k,max(a,b));
    }
    k++;
    //cout<<"k="<<k<<endl;
    solve();
    
    int sum[10];
    int ans, min_cost=INT_MAX/3;
    fill(sum,sum+10,0);

    for(int i=k-1;i>=0;i--){
      //cout<<i<<":";
      for(int j=0; j<k; j++){
	//cout<<d[i][j]<<" ";
	sum[i] += d[i][j];
      }
      //cout<<endl;
      if(sum[i] <= min_cost){
	ans = i;
	min_cost = sum[i];
      }
    }
    cout<<ans<<" "<<min_cost<<endl;
    for(int i=0;i<10;i++){
      G[i].erase(G[i].begin(), G[i].end());
    }    
  }


  
  
  return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s[3];
	rep(i, 3) cin >> s[i];
	int t[3] = {0};
	int count = 0;
	while(t[count] < (int)s[count].size()){
		t[count]++;
		if(s[count][t[count]-1] == 'a'){
			count = 0;
			continue;
		}
		if(s[count][t[count]-1] == 'b'){
			count = 1;
			continue;
		}
		if(s[count][t[count]-1] == 'c'){
			count = 2;
			continue;
		}
		
	}
	cout << "ABC"[count] << endl;
	
}

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

int main(){
	while(1){
		int a,b;
		char op;
		cin >> a >> op >> b;
		if(op =='?')break;
		if(op =='+')cout << a+b<<endl;
		if(op =='-')cout << a-b<<endl;
		if(op =='/')cout << a/b<<endl;
		if(op =='*')cout << a*b<<endl;
	}
	return 0;
}

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

#define gc getchar()
inline ll read(){
	ll x=0,f=1;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=-1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x*f;
}
#define io read()

inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline int check(ll a,ll b,ll c,ll d){
	if(a<b||d<b)return 0;
	if(c>=b-1)return 1;
	a%=b;d%=b;
	ll t=b-(c+1);
	if(a>c)return 0;
	ll g=gcd(b,d);
	ll x=c+1-a,y=b-1-a;
	if(x%g==0||x/g*g+g<=y)return 0;
	return 1;
}

int main(){
//	freopen("b.out","w",stdout);
	int t=io;
	while(t--){
		ll a=io,b=io,c=io,d=io;
		puts(check(a,b,c,d)?"Yes":"No");
	}
	return 0;
}

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

using namespace std;

#define LL long long

int flag, x, d;

void check(int d)
{
	if (flag) return;
	LL A, B;
	for (A=-50000; A<=50000; A++) {
		B=A-d;
		if (A*A*A*A+A*A*A*B+A*A*B*B+A*B*B*B+B*B*B*B==x/d) {
			printf("%d %d\n",A,B);
			flag=1;
			return;
		}
	}
}

int main (void)
{
	scanf("%d",&x);
	for (d=1; d*d<=x; d++) {
		if (x%d==0) {
			check(d);
			if (d*d!=x) check(x/d);
		}
	}
	return 0;
}

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


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		while((line = br.readLine()) != null) {
			line = line.trim();
			String answer = "";

			int value = Integer.parseInt(line);
			for(int i = 0; i < 10; i++){
	    		if((value & (1 << i)) != 0) {
	    			answer += (1 << i) + " ";
	    		}
	    	}
			
			answer = answer.trim();
			System.out.println(answer);
	    }
	}
}

Measured memory_bytes: 16888
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=2e5+4;
int n,a[N],mod,sum[N];
map<int,int> mp;
ll ans;
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
struct Node {
	int pos,val;
	friend bool operator <(const Node &a,const Node &b) {
		return a.pos>b.pos;
	}
};
priority_queue<Node> q;
int main() {
	n=read(),mod=read();
	if (mod==1) {
		puts("0");
		return 0;
	}
	for (register int i=1;i<=n;++i) {
		a[i]=read()-1;
		sum[i]=(sum[i-1]+a[i])%mod;
	}
	mp[0]=1;
	q.push((Node){0,0});
	for (register int i=1;i<=n;++i) {
		while (i-q.top().pos>=mod) {
			Node cur=q.top();
			--mp[cur.val];
			q.pop();
		}
		ans+=mp[sum[i]];
		++mp[sum[i]];
		q.push((Node){i,sum[i]});
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12784
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s,t;
cin>>s>>t;
int n=s.size();
rep(i,n+1){
    if(s==t){
        cout<<"Yes"<<endl;
        return 0;
    }
    
    string c = "";
    c+=+s[n-1];
    s.erase(n-1,1);
    s.insert(0,c);
}
cout<<"No"<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int boo[4]={0,0,0,0};
	int a,b;
	scanf("%d%d",&a,&b);
	boo[a]=1;boo[b]=1;
	int i;
	for (i=1;i<=3;i++)
		if (boo[i]==0)
			printf("%d",i);
	
	return 0; 
}

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

int main(){

int a, b, t;
cin >> a >> b >> t;
bool c = true;
int i = 1, j = 0;
int res = 0;
while(c){
j = i*a;
if(j <= t+0.5){
    res += b;
}else{
    c = false;
}
++i;
}
cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    char c;
    char s = 'a';
    cin >> c;
    if (c >= s) cout << 'a' << '\n';
    else cout << 'A' << '\n';
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b < c){
		cout << "dangerous" << endl;
	}
	else if (b >= c){
		cout << "delicious" << endl;
	}
	else{
		cout << "safe" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';

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

    auto q = [&](long i) {
        cout << i << endl;
        cout << flush;
        string s;
        cin >> s;
        if(s == "Vacant") {
            exit(0);
        }
        if(s == "Male")   return 0;
        if(s == "Female") return 1;
        assert(false);
    };

    long lb = 0, ub = n;
    long sl = q(lb);
    while(1) {
        long m = (lb+ub)/2;

        long sm = q(m);
        if(((m-lb)&1) ^ (sl == sm))
            lb = m, sl = sm;
        else
            ub = m;
    }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>                                                                     
                                                                                             
using namespace std;                                                                         
                                                                                             
#define all(x) x.begin(), x.end()                                                            
#define rep(i, n) for (int i = 0; i < n; ++i)                                                
#define reps(i, m, n) for (int i = m; i <= n; ++i)                                           
                                                                                             
using i64 = long long;                                                                       
using pii = pair<i64, i64>;                                                                  
                                                                                             
template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}   
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}   
                                                                                             
constexpr int INF = 0x3f3f3f3f;                                                              
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;                                                   
constexpr int MOD = int(1e9) + 7;                                                            
                                                                                             
signed main()                                                                                
{                                                                                            
  ios::sync_with_stdio(false);                                                               
  cin.tie(nullptr);                                                                          
                                                                                             
  i64 n, x;                                                                                  
  cin >> n >> x;                                                                             
                                                                                             
  i64 G = __gcd(n, x);                                                                       
  n /= G;                                                                                    
  --n;                                                                                       
  cout << n * G * 3 << "\n";                                                                 
                                                                                             
  return 0;                                                                                  
}                                                                                            

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    s = input().strip("\n")
    N = len(s)
    rev = ""
    for i in reversed(range(N)): rev += s[i]
    if s == rev:
        revl = ""
        revr = ""
        for i in reversed(range((N - 1) // 2)): 
            revl += s[i]
        for i in reversed(range((N + 3) // 2 - 1, N)):
            revr += s[i]
        if s[:(N-1)//2] == revl and s[(N+3)//2 - 1: N] == revr: print("Yes")
        else: print("No")
        #print(s, revl, revr, s[:(N-1)//2], s[(N+3)//2 - 1: N])
    else: 
        print("No")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int x; cin >> x;
  	if(x==0)cout << 1;
  	else cout << 0;
  	cout << endl;
}


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

int main(){
  int N, max=0;
  string S;
  cin >> N >> S;
  for(int i=0; i<N-1; i++){
    int count =0;
    for(char c='a'; c<='z'; c++){
      pair<bool, bool> flag=make_pair(false,false);
      for(int j=0; j<=i; j++){
        if(S[j]==c){
          flag.first=true; break;
        }
      }
      for(int j=i+1; j<N; j++){
        if(S[j]==c){
          flag.second=true; break;
        }
      }
      if(flag.first && flag.second) count++;
    }
    if(max<count) max=count;
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int main() {
    int N, p, m = INFINT, c = 0;
    cin >> N;
    rep(i, N) {
        cin >> p;
        if(chmin(m, p)) c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 3628
def InsertionSort(A, N):
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        for j in range(N):
            if j == N-1:
                print(A[j])
            else:
                print(A[j], end=' ')
    return(A)

N = int(input())
A = list(map(int,input().split()))

InsertionSort(A,N)


Measured memory_bytes: 5980
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;
ll dp[100001][2];//dp[i+1][j]...i番目で反転させたときのi+1番目までの最大値
ll a[100000];
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	fill(dp[0],dp[100001],0);
	
	dp[0][0]=0;
	dp[0][1]=-1e14+1;
	for(int i=0;i<n;i++)
	{
		//i+1番目ではひっくり返さない
		dp[i+1][0]=max(dp[i][1]-a[i],dp[i][0]+a[i]);
		//i+1番目でひっくり返す
		dp[i+1][1]=max(dp[i][0]-a[i],dp[i][1]+a[i]);
	}
	ans=dp[n][0];//n番目はひっくり返せない
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#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()
#define DBL(x) ((x)*(x))
using namespace std;

typedef unsigned int uint;
typedef long long ll;

double dp[1<<12][12];
int r[12];
int n;
int len;

double length(int flag, int last){
  if(last != -1 && dp[flag][last] != 0) return dp[flag][last];
  if(flag == 0) return r[last];

  double ret = 1e10;
  for(int i=0; i<n; i++){
    if(flag & (1 << i)){
      int r2 = r[i];
      double r3;
      if(last == -1)
        r3 = r2;
      else{
        int r1 = r[last];
        r3 = sqrt(DBL(r1+r2) - DBL(r1-r2));
      }
      double tmp = r3 + length(flag ^ (1<<i), i);
      ret = min(ret, tmp);
    }
  }
  if(last != -1) dp[flag][last] = ret;
  return ret;
}

int main(){
  string str;
  while(getline(cin, str)){
    stringstream ss(str);
    int i;
    ss>>len;
    for(i=0; ss>>r[i]; n=++i);
    memset(dp, 0, sizeof(dp));
    double l = length((1<<n)-1,-1);
    //printf("n=%d %f\n",n,l);
    puts(l <= len + 1e-10 ? "OK" : "NA");
  }
  return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
 
using namespace std ;
 
const int MAX = 2e7 , MAXN = 5e5 + 10 ;
 
int L[MAX] , R[MAX] , tree[MAX] , arr[MAXN] , version[MAXN] ;
int nodes = 0 , n , q;
 
int leaf(int value)
{
	int p = ++nodes ;
	L[p] = R[p] = 0 ; //null
	tree[p] = value ;
	return p;
}
 
int parent(int lef , int rig)
{
	int p = ++nodes ;
	L[p] = lef , R[p] = rig ;
	tree[p] = tree[lef] + tree[rig] ;
	return p ;
}
 
int build(int l , int r)
{
	if(l == r)
		return leaf(0) ;
	int mid = (l + r) >> 1 ;
	return parent(build(l , mid) , build(mid + 1 , r)) ;
}
 
int update(int node , int l , int r , int idx , int val)
{
	if(l == r)
		return leaf(tree[node] + val) ;
	int mid = (l + r) >> 1 ;
	if(idx <= mid)
		return parent(update(L[node] , l , mid , idx , val) , R[node]) ;
	else
		return parent(L[node] , update(R[node] , mid + 1 , r , idx , val)) ;
}
 
int query(int node , int l , int r , int from , int to)
{
	if(from > r || to < l)
		return 0 ;
	if(l >= from && r <= to)
		return tree[node] ;
	int mid = (l + r) >> 1 ;
	int a = query(L[node] , l , mid , from , to) ;
	int b = query(R[node] , mid+1 , r , from , to) ;
	return (a + b) ;
}
 
vector<int>v[MAXN] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>q ;
	for(int i = 1 ; i <= n ; ++i)
		cin>>arr[i] ;
	version[0] = build(0 , n) ;
	for(int i = 1 ; i <= n ; ++i)
	{
		int idx ;
		if(v[arr[i]].size())
			idx = v[arr[i]].back() ;
		else
			idx = 0 ;
		version[i] = update(version[i-1] , 0 , n , idx , 1) ;
		v[arr[i]].push_back(i) ;
	}
	int l , r ;
	while(q--)
	{
		cin>>l>>r ;
		cout<<query(version[r] , 0 , n , 0 , l-1) - query(version[l-1] , 0 , n , 0 , l-1)<<"\n" ;
	}
	return 0 ;
} 

Measured memory_bytes: 164204
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++)
		cin >> a[i];
	int ans=0;
	for(int i=0; i<n; i++){
		int num=0, tmp=a[i];
		while(!(tmp%2)){
			tmp/=2;
			num++;
		}
		ans+=num;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Copyright: lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn = 55;
int n, ans = 1e9;
pii p[maxn];
bool flag[maxn];

inline void solve(int dx, int dy) {
	int cnt = 0;
	rep(i, 1, n) flag[i] = 0;
	rep(i, 1, n) {
		if (!flag[i]) flag[i] = 1, cnt++;
		rep(j, i + 1, n) if (p[j].fi == p[i].fi + dx && p[j].se == p[i].se + dy) flag[j] = 1;
	}
	ans = min(ans, cnt);
}

void work() {
	n = read();
	rep(i, 1, n) p[i].fi = read(), p[i].se = read();
	sort(p + 1, p + n + 1);
	rep(i, 1, n) rep(j, i + 1, n) solve(p[j].fi - p[i].fi, p[j].se - p[i].se);
	if (n == 1) ans = 1;
	printf("%d\n", ans);
}

int main(){
	#ifdef LZT
		freopen("in","r",stdin);
	#endif

	work();

	#ifdef LZT
		Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
	#endif
}


Measured memory_bytes: 256
k = int(input())

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a


s = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            s += gcd(gcd(a, b), c)

print(s)


Measured memory_bytes: 68776
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0ll, a + b - n) << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

typedef long long i64;
typedef vector<i64> vl;

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

    int i;
    vl a(n);
    for (i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }

    i64 res=0;
    for (i=0; i<n-1; i++) {
        if (a[i] & 1 && a[i+1]) {
            res++;
            a[i] -= 1;
            a[i+1] -= 1;
        }
        res += a[i]>>1;
    }
    res += a[n-1]>>1;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"os"
)

func main() {
	var (
		n int
		count int
	)

	//fmt.Println("n:", n)
	//fmt.Println(count)

	fmt.Scan(&n)
	nums := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	//flag := true
	for  {
		//fmt.Println(nums)
		for i := 0; i < n; i++ {
			if nums[i] % 2 != 0 {
				//flag = false
				//break

				fmt.Println(count)
				os.Exit(0)
				//break
			} else {
				nums[i] = nums[i] / 2
			}
		}
		count++
	}

	fmt.Println(count)
}

Measured memory_bytes: 512
//============================================================================
// Name        : ProjG.cpp
// Author      : Yong Kiat
// Version     :
// Copyright   : By Algotae.
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

string s, t;
int dp[3001][3001];

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

    cin >> s >> t;
    for (int i = 1; i <= s.size(); i++) {
    	for (int j = 1; j <= t.size(); j++) {
    		if (s[i - 1] == t[j - 1]) {
    			dp[i][j] = dp[i - 1][j - 1] + 1;
    		} else {
    			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    		}
    	}
    }

    string res;
    int i = s.size(), j = t.size();
    while (i && j) {
    	if (s[i - 1] == t[j - 1]) {
    		res = s[i - 1] + res;
    		i--;
    		j--;
    		continue;
    	}

    	if (dp[i - 1][j] > dp[i][j - 1]) {
    		i--;
    	} else {
    		j--;
    	}
    }

    cout << res;
}


Measured memory_bytes: 35456
use std::io;
use std::cmp;
use std::collections::VecDeque;
use std::collections::HashMap;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let n:usize = buf.trim().parse().unwrap();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let mut a: Vec<i64> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    let mut edges = HashMap::new();

    for x in a.iter() {
        let val = edges.get(x).unwrap_or(&0) + 1;
        edges.insert(x, val);
    }

    let mut e1 = 0i64;
    let mut e2 = 0i64;
    for (&x,&y) in edges.iter() {
        if y >=4 {
            e1 = cmp::max(e1, *x);
            e2 = cmp::max(e2, *x);
        } else if y>=2 {
            if e1 < *x {
                e2 = e1;
                e1 = *x;
            } else if e2 < *x {
                e2 = *x;
            }
        }
    }
    println!("{}", e1*e2);

}


Measured memory_bytes: 14588
S = input()
if S[0] == "R":
    if S[1] == "S":
        print("1")
    else:
        if S[2] == "R":
            print(3)
        else:
            print(2)
else:
    if S[1] == "R":
        if S[2] == "S":
            print(1)
        else:
            print(2)
    else:
        if S[2] == "R":
            print(1)
        else:
            print(0)


Measured memory_bytes: 8984
#include <cstdio>
#include <algorithm>
#define maxn 200005
using namespace std;

typedef long long LL;

int n, rpos, a[maxn]; LL k;

inline LL C(const LL& n) { return n * (n - 1) / 2; }

LL fl(LL a, LL b)
{
    bool f = (a < 0) ^ (b < 0);
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    return f ? - ( a / b + 1 ) : a / b;
}

LL cl(LL a, LL b)
{
    bool f = (a < 0) ^ (b < 0);
    if(a < 0) a = -a;
    if(b < 0) b = -b;
    return f ? - ( a / b ) : (a + b - 1) / b;
}

int main()
{
    scanf("%d%lld", &n, &k);
    for(int i=1; i<=n; i++) scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    LL l = 0, r = 0, z = 0, L = 0, R = 0, Z = 0;
    for(int i=1; i<=n; i++) z += a[i] == 0;
    for(int i=1; i<=n; i++) l += a[i] < 0;
    for(int i=1; i<=n; i++) r += a[i] > 0;
    L = l * r; R = C(l) + C(r); Z = C(n) - L - R;
    rpos = n + 1;
    for(int i=1; i<=n; i++)
		if(a[i] > 0)
		{
	        rpos = i;
			break;
    	}
    if(k <= L)
	{
		LL ql = -1e18, qr = -1, mid, ans = -233;
		while(ql <= qr)
		{
			mid = (ql + qr) >> 1;
			LL sum = 0, now = r, cur = rpos;
			for(int i = 1; i <= n && a[i] < 0; i ++)
			{
				LL up = mid % a[i] == 0 ? mid / a[i] + 1 : cl(mid, a[i]);
				while(now && a[cur] < up) cur ++, now --;
				sum += now;
            }
            if(sum < k) ql = (ans = mid) + 1;
            else qr = mid - 1;
        }
        printf("%lld\n", ans);
    }
	else if(k <= L + Z)
        puts("0");
    else
	{
        k -= L + Z;
        LL ql = 1, qr = 1e18, mid, ans = -233;
        while(ql <= qr) {
            mid = (ql + qr) >> 1;
            LL sum = 0, now = r, cur = n;
            for(int i = rpos; i <= n; i ++) {
                LL up = mid % a[i] == 0 ? mid / a[i] - 1 : fl(mid, a[i]);
                while(now && a[cur] > up) cur --, now --;
                sum += cur >= i ? now - 1 : now;
            }
            now = l; cur = 1;
            for(int i = n; i >= 1; i --) if(a[i] < 0) {
                LL up = mid % a[i] == 0 ? mid / a[i] + 1 : cl(mid, a[i]);
                while(now && a[cur] < up) cur ++, now --;
                sum += cur <= i ? now - 1 : now;
            }
            sum >>= 1;
            if(sum < k) ql = (ans = mid) + 1;
            else qr = mid - 1;
        }
        printf("%lld\n", ans);
    }
    return 0;
} 

Measured memory_bytes: 896
#include <stdio.h>
#define MAX 25
int parent[MAX],left[MAX],right[MAX];
int depth(int);
int height(int);
int main(void){
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)  parent[i] = -1;
    for(int i=0; i<n; i++){
        int id, l, r;
        scanf("%d%d%d",&id,&l,&r);
        left[id] = l;
        if(l != -1) parent[l] = id;
        right[id] = r;
        if(r != -1) parent[r] = id;
    }
    for(int i=0; i<n; i++){
        int sibling,degree=0;
        sibling =(left[parent[i]] == i ? right[parent[i]] : left[parent[i]]);
        if(parent[i] == -1) sibling = -1;
        if(left[i] != -1) degree++;
        if(right[i] != -1) degree++;
        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i, parent[i], sibling, degree, depth(i), height(i));
        if(parent[i] == -1) printf("root\n");
        else if(degree == 0) printf("leaf\n");
        else printf("internal node\n");
    }
}
int depth(int node){
    return (parent[node] == -1 ?  0 : depth(parent[node]) + 1);
} 
int height(int n){
    return ((left[n] == -1 ? -1 : height(left[n]) )< (right[n] == -1 ? -1 : height(right[n]) )?(right[n] == -1 ? -1 : height(right[n]) ): (left[n] == -1 ? -1 : height(left[n]) )) + 1;
}


Measured memory_bytes: 2100
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := NewScanner()
	N, A := sc.NextInt(), sc.Next()
	B, _ := strconv.Atoi(strings.ReplaceAll(A, ".", ""))
	fmt.Println(N * B / 100)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

typedef long long ll;

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    ll X;
    cin >> X;
    ll f = X/500;
    ll sf = (X%500)/5;
    cout << f * 1000 + sf * 5;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

char a[10];

signed main(){
    cin >> a;
    if(a[0] == a[1] || a[1] == a[2] || a[2] == a[3]){
        printf("Bad\n");
    }
    else printf("Good\n");

    return 0;
}
/*


*/

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

int main(){
	set<string> s;
	int n;
	string in_c, in_t;
	cin >> n;
	rep(i, n){
		cin >> in_c >> in_t;
		if(in_c == "insert"){
			s.insert(in_t);
		}else if(in_c == "find"){
			if(s.count(in_t) == 0){
				cout << "no" << endl;
			}else{
				cout << "yes" << endl;
			}
		}
	}
	
	return 0;
}


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

vector<int>ans;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; long long ans=1;
    cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++) cin>>a[i];
    int h[100001]={0};

    for(int i=0;i<n;i++){
        if(a[i]==0){
            ans=ans*(3-h[0])%1000000007;
            h[0]++;
        }
        else{
            ans=(ans*(h[a[i]-1]-h[a[i]]))%1000000007;
            h[a[i]]++;
        }
        
    }
    cout<<ans;
    return 0;
}
 

Measured memory_bytes: 1024
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<int> count(n);
	rep(i,n) count[a[i]-1]++;
	std::sort(all(count));
	int sum = 0;
	{
		int i=0;
		while(count[i]==0) i++;
		int unique = n-i;
		rep(j,unique-k) sum+=count[i+j];
	}
	print(sum);
}


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

int main() {
  string S;
  cin >> S;
  string ans = "Yes";
  for (int i=0; i<(int)S.size(); i+=2) {
    if (S.at(i)=='L') {
      ans = "No";
      break;
    }
  }
  for (int i=1; i<(int)S.size(); i+=2) {
    if (S.at(i)=='R') {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, m, cur = 1, mark[N], nm[N], ans;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		nm[i] = 1;
	mark[1] = 1;
	ans = 1;
	for(int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		nm[a]--;
		nm[b]++;
		if(nm[a] == 0 && mark[a] == 1) {
			mark[a] = 0;
			ans--;
			if(mark[b] == 0)
				mark[b] = 1, ans++;
		}
		else if(mark[a] == 1) {
			if(mark[b] == 0)
				ans++;
			mark[b] = 1;
		}
	}
	cout << ans;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<vector>
#include<iostream>
#include<map>
typedef long long ll;
using namespace std;
ll mod = 1000000007;
ll ModeExpression(ll x, ll y) {
    if(y == 0) { return 1; }
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) {
            res = (res * x) % mod;
        }
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

ll ModInverse(ll n) {
    return ModeExpression(n, mod - 2);
}

ll ModMul(ll a, ll b) {
    return (a * b) % mod;
}

ll Combination(ll n, ll r) {
    if(n < r || n < 0 || r < 0) {
        return 0;
    }
    vector<ll> facs(n + 1, 1);
    vector<ll> facInvs(n + 1, 1);
    for (ll i = 1 ; i <= n; i++) {
        facs[i] = (facs[i - 1] * i) % mod;
        facInvs[i] = ModInverse(facs[i]);
    }
    
    ll cur = facs[n];
    cur = ModMul(cur, facInvs[r]);
    cur = ModMul(cur, facInvs[n - r]);
    
    return cur;
}

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

    ll x = 3, y = 3;
    cin >> x >> y;
    if((x + y) % 3 != 0 || max(x, y) > 2 * min(x, y)) {
        cout << 0 << endl;
        return 0;
    }
    ll k1 = (2 * x - y) / 3;
    ll k2 = (2 * y - x) / 3;
    ll answer = Combination(k1 + k2, k1);
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 10624
# AtCoder Beginner Contest 096
# C - Grid Repainting 2

def f (i,j):
    if any ([area[i-1][j]=='#',
            area[i+1][j]=='#',
            area[i][j-1]=='#',
            area[i][j+1]=='#']):
        return True



H,W=map(int,input().split())

area=['.'*(W+2)]

for i in range (H):
    A='.'+ input() +'.'
    area.append(A)

area.append('.'*(W+2))

ans='Yes'

for i in range (1,H+1):
    for j in range (1,W+1):
        if area[i][j]=='#':
            if f(i,j)==True:
                pass
            else:
                ans='No'
                break
        else:
            pass

print(ans)

Measured memory_bytes: 9088
# -*- coding utf-8 -*-

N, M = map(int, input().split())
sm = [list(map(int, input().split()))[1:] for _ in range(M)]
pm = list(map(int, input().split()))


tmp = [[0] * N for _ in range(M)]
for i in range(len(sm)):
    for si in sm[i]:
        tmp[i][si - 1] = 1
sm = tmp


def check(state):
    ret = 0
    for i, k in enumerate(sm):
        c = 0
        for j, s in enumerate(state):
            c += k[j] if s == '1' else 0
        if (c % 2) != pm[i]:
            break
    else:
        ret = 1

    return ret


def count(state):
    ret = 0
    if len(state) == N:
        ret += check(state)
    else:
        for s in '01':
            ret += count(state + s)
    return ret


print(count(''))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    if(a*b%2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    
}

Measured memory_bytes: 256
#include<stdio.h>
//累乗(power)a^n(mod10^9+7)
long long power(long long a,long long n){
  long long count=a,sum=1;
  while(n>0){
    if(n%2==1)
      sum*=count;
    count*=count;
    count%=1000000007;
    sum%=1000000007;
    n/=2;
  }
  return sum;
}

int main(){
  int n;
  scanf("%d",&n);
  long long ans = 0;
  ans = power( 10, n );
  ans -= power( 9 , n );
  ans -= power( 9 , n );
  ans += power( 8 , n );
  while(ans < 0)
    ans += 1000000007;
  printf("%lld\n",ans);
  return 0;
}


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

int main(){
    long long N, M;
    long long A[1001];
    long long i;
    long long sum = 0;
    cin >> N >> M;
    for(i = 1; i <= N; i++){
        cin >> A[i];
        sum += A[i];
    }
    long long counta = 0;
    for(i = 1; i <= N; i++){
        if(A[i]*4*M >= sum){
            counta++;
        }
    }
    if(counta >= M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define ep emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int h, w, m; cin >> h >> w >> m;
  vi cnt_x(w+1), cnt_y(h+1);
  set<pi> bom;

  rep(i, m) {
    int x, y; cin >> y >> x;
    bom.em(x, y);
    ++cnt_x[x], ++cnt_y[y];
  }

  int mx = *max_element(all(cnt_x));
  int my = *max_element(all(cnt_y));

  vi max_x, max_y;

  rep(i, w+1) if (cnt_x[i] == mx) max_x.ep(i);
  rep(i, h+1) if (cnt_y[i] == my) max_y.ep(i);

  for (auto x : max_x) for (auto y : max_y) {
    int score = mx + my;

    if (!bom.count(mp(x, y))) {
      cout << mx + my << endl;
      return (0);
    }
  }

  cout << mx + my - 1 << endl;

  return (0);
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

bool Is_Prime(ll n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0) return 0;
	}
	return n!=1;
}

int n;

int main(){
	cin>>n;
	while(!Is_Prime(n)) n++;
	cout<<n<<endl;
}

Measured memory_bytes: 256
import scala.math.min
import java.util.Arrays.binarySearch
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val lines = Array.fill(n)(sc.nextInt).sorted
    var sum = 0
    for(i <- 0 to lines.size-3) {
      for(j <- i+1 to lines.size-2) {
        // var pos = binarySearch(lines, j+1, lines.size, lines(i)+lines(j))
        var pos = lowerBound(lines, j, lines.size, lines(i)+lines(j))
        val legals = pos - (j+1)
        // printf("%d:%d -> %d, %d\n", lines(i), lines(j), /*lines.deep,*/ pos, legals)
        sum += legals
      }
    }
    println(sum)
  }
  def lowerBound(ar: Array[Int], start:Int, end:Int, v:Int) :Int = {
    var ub = end
    var lb = start
    while(ub - lb > 1) {
      val mid = (ub + lb) / 2
      // printf("ub:%d, lb:%d, mid:%d\n", ub, lb, mid)
      if(ar(mid) >= v){
        //midが条件を満たせば、解の存在範囲は(lb,mid]
        ub = mid;
      } else {
        //midが条件を満たさなければ、解の存在範囲は(mid,ub]
        lb = mid;
      }
    }
    ub
  }
}



Measured memory_bytes: 28648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
bool my_compare(pair<double, string> a, pair<double, string> b)
{
    if (a.first != b.first)
    {
        return a.first > b.first;
    }
    if (a.second != b.second)
    {
        return a.second < b.second;
    }
    else
    {
        return true;
    }
}
int main(int argc, char const *argv[])
{
    int n;
    while (cin >> n, n)
    {
        vector<string> l(n);
        int a, b, c, d, e, f, s, m, p, time, money;

        vector<double> eff(n);
        vector<pair<double, string>> t(n);
        rep(i, n)
        {
            cin >> t[i].second >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            rep(j, m)
            {
                if (j == 0)
                {
                    time = a + b + c + d + e;
                }
                else
                {
                    time += d + e;
                }
            }
            money = f * s * m - p;
            t[i].first = (double)money / (double)time;
        }
        sort(t.begin(), t.end(), my_compare);

        rep(i, n)
        {
            cout << t[i].second << endl;
        }
        cout << "#" << endl;
    }
    return 0;
}



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

int main() {
	ios_base::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	if (n > m) swap(n, m);
	if (n == 1) {
		if (m == 1) cout << 1 << '\n';
		else cout << m - 2 << '\n';
	}
	else cout << 1ll * (m - 2) * (n - 2) << '\n';
}

Measured memory_bytes: 256
use proconio::{fastout, input};

use proconio::marker::Bytes;

#[fastout]
fn main() {
    input! {
        s: Bytes
    }
    let mut a = vec![0; 2019];
    a[0] = 1;
    let mut o = 0;
    let mut e = 1;
    let mut ans = 0 as i64;
    for b in s.iter() {
        let d = (b - 48) as i64;
        o = ((o - d * e) % 2019 + 2019) % 2019;
        ans += a[o as usize];
        a[o as usize] += 1;
        e = e * 202 % 2019;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2408