akhauriyash/Code-Regression huggingface dataset:
from fractions import gcd

n = int(input().strip())
a = list(map(int, input().split()))

lcm = 1
for i in range(n):
    lcm = (lcm * a[i]) // gcd(lcm, a[i])
arg = lcm - 1
ans = 0
for i in range(n):
    ans += (arg % a[i])
print(ans)


Measured memory_bytes: 66792
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int ans,n,a[100100];
int Calc(int x)
{
	if(x==n)return x;
	int c=a[x]<=a[x+1];x+=1;
	while(x<=n&&c==(a[x]<=a[x+1]))++x;
	return x;
}
int main()
{
	n=read();if(n==1){puts("1");return 0;}
	for(int i=1;i<=n;++i)a[i]=read();
	int tmp=1;for(int i=2;i<=n;++i)if(a[i]!=a[i-1])a[++tmp]=a[i];n=tmp;
	for(int i=1;i<=n;i=Calc(i)+1)++ans;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	long long int  n;
	scanf("%lld",&n);
	long long int i;
	long long int ans=1;
	for(i=1;i<=n;i++)
	{
		ans*=i;
		ans%=1000000007;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) 
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,t,a[100005],suf[100005],prf,cnt;
int main(){
    scanf("%d%d",&n,&t);
    rep(i,1,n) scanf("%d",a+i);
    for(int i=n;i>=1;i--) suf[i]=max(a[i],suf[i+1]);
    rep(i,1,n) {
        if(suf[i]-a[i]>prf) prf=suf[i]-a[i],cnt=1;
        else if(suf[i]-a[i]==prf) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define Max 1000005
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define pi acos(-1.0)
#define pb push_back
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define endl '\n'

#define sc(n) scanf("%d",&n)
#define scan(n) scanf("%lld",&n)
/*        speed up       */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF    1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() _fastio;int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;

//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
template <typename T> T gcd(T a,T b){if(a < 0)return gcd(-a,b);if(b < 0)return gcd(a,-b);return (b == 0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a < 0)return lcm(-a,b);if(b < 0)return lcm(a,-b);return a*(b/gcd(a,b));}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;
typedef tuple<ll,ll,ll>tpl;

int main()
{
    ll n,m,k;
    cin >> n >> m >> k;
    ll ans=m/k - n/k;
    if(n%k==0)ans++;
    cout<<ans<<endl;
}
/*
     remember:
     ll vs int
     array size
     case for 1 2 3 
*/



Measured memory_bytes: 3632
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int last_point = scanner.nextInt();
  	int x = scanner.nextInt();
    int y = scanner.nextInt();
    int[] routes = new int[last_point-1];
    
    for(int start_point = 1;start_point <= last_point;start_point++){
      for(int end_point = start_point + 1;end_point <= last_point;end_point++){
        routes[distance(start_point,end_point,x,y)-1]++;
      }
    }
    
    for(int i = 0;i < routes.length;i++){
      System.out.println(routes[i]);
    }
  }
  static int distance(int start,int end,int x,int y){
    int x_to_y = Math.abs(x-start)+1+Math.abs(y-end);
    int y_to_x = Math.abs(y-start)+1+Math.abs(x-end);
    return Math.min(Math.min(end-start,x_to_y),y_to_x);
  }
}

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

using namespace std;

long a[444], d[444][444];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i + 1], a[i + 1] += a[i];
	for (int i = 2; i < n + 1; i++) {
		for (int j = 0; j < n - i + 1; j++) {
			d[i][j] = 1e18;
			for (int k = 1; k < i; k++)
				d[i][j] = min(d[i][j], d[k][j] + d[i - k][j + k] + a[i + j] - a[j]);
		}
	}
	cout << d[n][0] << endl;
	return 0;
}


Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;
template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

main(){
    int n=in<int>(),a,b,i=0;
    vector<int> p(n),q(n),l(n);
    for (int i=0;i<n;i++)p[i]=in<int>();
  for (int i=0;i<n;i++)q[i]=in<int>();
    for (int i=0;i<n;i++)l[i]=i+1;
    do {
        if (l==p) a=i;
        if (l==q) b=i;
        i++;
    } while( next_permutation(l.begin(), l.end()) );
    out(abs(a-b));
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll n, h, d, dp[1111111], sum[1111111], p = 1,k=0, i,ans=0;
	cin >> n >> h >> d;
	for (i = 1; i <= n; i++) {
		p = p * i%M;
		k = (k + p) % M;
	}
	dp[0] = p;
	sum[0] = p;
	for (i = 1; i < h; i++) {
		if (i - d <= 0)
			dp[i] = sum[i - 1] * k%M;
		else
			dp[i] = (M + sum[i - 1] - sum[i - d - 1])%M*k%M;
		sum[i] = (sum[i - 1] + dp[i]) % M;
	}
	if (h == d)
		ans = sum[h - 1];
	else
		ans = (M + sum[h - 1] - sum[h - d - 1]) % M;
	cout << ans << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int cnt = 0;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                string pin = "";
                char a = '0' + i, b = '0' + j, c = '0' + k;
                pin = pin + a;
                pin = pin + b;
                pin = pin + c;
                int cp1 = 0, cp2 = 0, cp3 = 0;
                for (int l = 0; l < n; l++)
                {
                    if (cp1 != 0 && cp2 != 0 && s[l] == pin[2] && cp3 == 0)
                    {
                        cp3++;
                    }
                    if (cp1 != 0 && s[l] == pin[1] && cp2 == 0)
                    {
                        cp2++;
                    }
                    if (s[l] == pin[0] && cp1 == 0)
                    {
                        cp1++;
                    }
                }
                if (cp1 && cp2 && cp3)
                    cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
typedef long long int ll;
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll a,b;
    vector<pair<ll,ll>> v;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back(mp(b,a));
    }
    sort(v.begin(),v.end());
    ll ans=0;
    for(int i=0;i<v.size();i++){
        ans+=v[i].second;
        // cout<<v[i].first<<" "<<v[i].second<<endl;
        if(ans>v[i].first) {cout<<"No"<<endl; return 0; }
        
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int niz[205];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int ans = 0;
    int n;
    cin >> n;
    ff(i,1,n)cin >> niz[i];
    ff(i,1,n){
        ff(j,i+1,n){
            ff(k,j+1,n){
                if(niz[i] == niz[j] || niz[i] == niz[k] || niz[j] == niz[k])continue;
                if(niz[i] + niz[j] > niz[k] && niz[i] + niz[k] > niz[j] && niz[j] + niz[k] > niz[i])ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int N, D;

int main() {
	cin >> N >> D;
	vector<vector<double> > X(N, vector<double>(D));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < D; j++) {
			cin >> X[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			double d = 0;
			for (int k = 0; k < D; k++) {
				d += pow((X[i][k] - X[j][k]), 2);
			}
			d = sqrt(d);
			int x = (int)d;
			if ((double)x == d) { ans++; }
		}
	}
	cout << ans << endl;
}

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


int main(){
  ll n; cin >> n;
  vector<string> v(n);
  for(ll i = 0; i < n; i++){
    string s; cin >> s;
    sort(s.begin(), s.end());
    v[i] = s;
  }
  sort(v.begin(), v.end());
  ll cnt = 1;
  ll ans = 0;
  for(ll i = 0; i < n-1; i++){
    if(v[i] == v[i+1]){ans += cnt; cnt++;}
    else{cnt = 1;}
  }

  cout << ans << endl;

}

Measured memory_bytes: 5760
import math
import sys
import collections
import bisect


def main():
    n, m = map(int, input().split())
    x = sorted(list(map(int, input().split())))
    print(0 if m <= n else sum(
        sorted([x[i + 1] - x[i] for i in range(m - 1)])[0:(m-n)]))


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;


int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> a(n), b(m);
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 0; i < m; i++)cin >> b[i];
    a.push_back(x), b.push_back(y);

    int nax = *max_element(a.begin(), a.end());
    int niy = *min_element(b.begin(), b.end());

    cout << (niy > nax ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
L.sort(key=lambda x:x[1])
cr=0
chk=1
ll=0
for i in range(N):
  a,b=L[i]
  cr+=b-ll-a
  if cr<0:
    chk=0
    break
  ll=b
  
print("Yes" if chk else "No")

Measured memory_bytes: 90456
#include<iostream>
using namespace std;
int main() {
	int R;
	cin >> R;
	if (R < 1200) {
		cout << "ABC" << endl;
	}
	else if (R < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, K;
    cin >> N >> K;

    map<int, int> ct;

    for (int i = 0, v; i < N; i++) {
        cin >> v;
        ct[v]++;
    }

    vi cts;
    for (auto p : ct) cts.push_back(p.second);
    sort(all(cts), greater<int>());

    int keep = 0;
    for (int i = 0; i < min(sz(cts), K); i++) {
        keep += cts[i];
    }

    cout << N - keep << endl;

    return 0;
}



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


int main(void) {
    using namespace std;

    long n;
    cin >> n;

    vector<vector<long>> G(n);
    for(int i=0; i<n-1; i++) {
        long a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<short> mark(n);

    {
        auto dfs = [&] (auto dfs, int cur, int prev, int idx) -> int {
            if(cur == n-1) return idx;

            for(auto v: G[cur]) {
                if(v == prev) continue;
                int r = dfs(dfs, v, cur, idx+1);
                if(r > 0) {
                    mark[cur] = (idx <= r / 2) ? 1 : 2;
                    return r;
                }
            }
            return 0;
        };

        dfs(dfs, 0, -1, 0);
    }
    mark[0] = 1;
    mark[n-1] = 2;

    {
        auto dfs = [&] (auto dfs, int cur, int prev, int col) {
            if(mark[cur] & ~col) return;
            mark[cur] = col;

            for(auto v: G[cur]) {
                if(v == prev) continue;
                dfs(dfs, v, cur, col);
            }
        };

        dfs(dfs, 0, -1, 1);
        dfs(dfs, n-1, -1, 2);
    }

    long a = 0, b = 0;
    for(int i=0; i<n; i++)
        (mark[i] == 1 ? a : b)++;

    cout << (a <= b ? "Snuke" : "Fennec") << endl;
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
#define FAST_IO   ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Relocate freopen("./in.txt","r",stdin),freopen("./out.txt","w",stdout)
#define up(mi,a,b) for(mi=a;mi<=b;++mi)
#define down(mi,b,a) for(mi=b;mi>=a;--mi)
#define mfill(a,v) memset(a,v,sizeof(a))
#define INF 0x3f3f3f3f
#define MAX 5000010
#define v_n 5005
#define LL long long
#define ULL unsigned long long 
#define e_n 50005
#define eps 0.000000001
#define Blen 31 
const LL MOD = 998244353;
using namespace std;
LL st[MAX][Blen];
LL A[MAX];
LL GCD(LL a, LL b)
{
	return b == 0 ? a : GCD(b, a%b);
}
LL Get(int a, int b)
{
	int len = log2(b - a + 1);
	LL pa = st[a][len];
	LL pb = st[b-(1<<len)+1][len];
	return GCD(max(pa, pb), min(pa, pb));
}
int main(void)
{
	int i, j, k;
	//Relocate;
	FAST_IO;
	int N;
	cin >> N;
	up(i, 1, N)
	{
		cin >> A[i];
		st[i][0] = A[i];
	}
	for (int L = 1; (1 << L) <= N; L++)
	{
		for (int b = 1; b + (1 << L) - 1 <= N; b++)
		{
			LL pa = st[b][L - 1];
			LL pb = st[b + (1 << (L - 1))][L - 1];
			st[b][L] = GCD(max(pa, pb), min(pa, pb));
		}
	}
	LL ans = max(Get(2,N),Get(1,N-1));
	up(i, 2, N-1)
	{
		LL pa = Get(1, i - 1);
		LL pb = Get(i + 1, N);
		ans = max(ans, GCD(max(pa, pb), min(pa, pb)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25600
n,u,v=map(int,input().split())
anss=0
u-=1
v-=1
d=[[]for _ in range(n)]
inf=float('inf')
aoki=[inf]*n
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  d[a].append(b)
  d[b].append(a)
Q=d[v]
aoki[v]=0
dis=1
visited={v}
while Q:
  P=[]
  for i in Q:
    visited.add(i)
    for j in d[i]:
      if j not in visited:P.append(j)
    aoki[i]=dis
  dis+=1
  Q=P
Q=d[u]
chokudai=[-1]*n
chokudai[u]=0
dis=1
visited={u}
point=-1
while Q:
  P=[]
  for i in Q:
    visited.add(i)
    for j in d[i]:
      if aoki[j]<=dis+1:
        if aoki[j]==dis+1:anss=1
        if point<0:point=i
        continue
      if j not in visited:P.append(j)
    chokudai[i]=dis
  dis+=1
  Q=P
Q=d[point]
dis=chokudai[point]+1
visited={point}
while Q:
  P=[]
  for i in Q:
    visited.add(i)
    if chokudai[i]==-1:continue
    chokudai[i]=max(dis,chokudai[i])
    for j in d[i]:
      if j not in visited:P.append(j)
  dis+=1
  Q=P
ans=0
for i in range(n):
  if aoki[i]>chokudai[i]:ans=max(ans,chokudai[i])
print(ans+anss)
#print(aoki)
#print(chokudai)

Measured memory_bytes: 84508
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int a, b;

int main() {
	cin >> a >> b;
	int mmax = max((int)ceil(12.5 * a), 10 * b);
	int mmin = min((int)ceil(12.5 * (a + 1)), 10 * (b + 1));

	if (mmin > mmax)
		cout << mmax << endl;
	else
		puts("-1");

	return 0;
}

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

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key)
        i++;
    return i != n;
}

int binary(int A[], int n, int key) {
    int left = 0, right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (key > A[mid]) {
            left = mid + 1;
        }
        else if (key < A[mid]) {
            right = mid;
        }
        else {
            return mid;
        }
    }
    return 0;
}

int main() {
    int i, n, q, key, sum = 0, S[100001];

    cin >> n;
    for (i = 0; i < n; i++)
        cin >> S[i];

    cin >> q;
    for (int t = 0; t < q; ++t) {
        cin >> key;
        if (binary(S, n, key))
            sum++;
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3480
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    sc.Split(bufio.ScanWords)
    k := nextInt()

    total := 0
    for i := 1; i <= k; i++ {
        for j := 1; j <= k; j++ {
            for c := 1; c <= k; c++ {
                total += gcd(gcd(i,j),c)
            }
        }
    }
    fmt.Println(total)
}

// Library

func gcd(x, y int) int {
    if y == 0 {
        return x
    }

    return gcd(y, x%y)
}

//====================
//  var q Queue
//  q.Enqueue(n)
//  n := q.Dequeue()
//====================
type Queue struct {
    data []int
}

func (q *Queue) Enqueue(n int) {
    q.data = append(q.data, n)
}

func (q *Queue) Dequeue() int {
    tmp := q.data[0]
    q.data = q.data[1:]
    return tmp
}

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func nextInt() int {
    sc.Scan()
    i, _ := strconv.Atoi(sc.Text())
    return i
}

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}



Measured memory_bytes: 1776
N = int(input())

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

B = []

B_val = 0

ans = 0

for i in A[::-1]:
    B.append(B_val)
    B_val += i

for i in range(N):
    ans += ( A[i] * B[-i-1] ) % (1000000000 + 7 )

print(ans % (1000000000 + 7 ) )


Measured memory_bytes: 31756
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int a[510][510];
int b[250010][2],c[250010][2];
int main()
{
    int i,j,k,h,w,n=0;
    cin >> h >> w;
    for(i=1;i<=h;i++)
    	for(j=1;j<=w;j++)
    		cin >> a[i][j];

	for(i=1;i<=h;i++) {
		for(j=1;j<w;j++) {
			if(a[i][j]%2!=0)
			{
				a[i][j]--;
				a[i][j+1]++;
				b[n][0]=i;
				b[n][1]=j;
				c[n][0]=i;
				c[n][1]=j+1;
				n++;
			}
		}
		if(a[i][w]%2!=0 && i!=h) {
			a[i][w]--;
			a[i+1][w]++;
			b[n][0]=i;
			b[n][1]=w;
			c[n][0]=i+1;
			c[n][1]=w;
			n++;
		}
	}

    cout << n << endl;
	for(i=0;i<n;i++) {
		cout << b[i][0] << " " << b[i][1] << " "<< c[i][0] << " " << c[i][1] << endl;
	}

    return 0;
}


Measured memory_bytes: 6016
// --------------
// Tejas Pandey  |
// 24 - 11 - 19  |
// ABC #146      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		string s[7] = {"SUN","SAT","FRI","THU","WED","TUE","MON"};
		string k;
		cin >> k;
		int i = 0;
		for(;i < 7;i++)
		if(s[i] == k)
			break;
		cout << (i?i:7) << "\n";
	}
	return 0;
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

lld dp[2001];

lld solve(lld n) {
	if (n == 0) return dp[n] = 1;
	if (n == 1 || n == 2) return dp[n] = 0;
	if (dp[n] != -1) return dp[n];
	lld c = 0;
	c += solve(n-1) + solve(n-3);
	c %= MOD;
	//~ for (lld i = 3; i <= n; i++) {
		//~ if (n - i >= 0) c += solve(n - i);
		//~ c %= MOD;
	//~ }
	return dp[n] = c;

}

int main() {
	fast;
	cin.tie(0);
	lld n;
	cin >> n;
	if (n == 1 || n == 2) cout << "0" << endl;
	else {
		memset(dp, -1, sizeof(dp));
		cout << solve(n) << endl;
	}
}


Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

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

	ll N;
	cin >> N;

	for (ll h = 1; 3501 > h; h++) {
		for (ll n = 1; 3501 > n; n++) {
			ll a = 4 * h * n, b = N*n, c = N*h;
			if ((a - b - c) > 0) {
				if ((h*n*N) % (a - b - c) == 0) {
					printf("%lld %lld %lld\n", h, n, (h*n*N) / (a - b - c));
					return 0;
				}
			}
		}
	}


	return 0;
}

Measured memory_bytes: 384
#include<iostream>
//#include<bits/stdc++.h>
#include<map>
using namespace std;
int main(){
    long long a;
    int ans=0;
	map<long long,long long>s;
	cin>>a;
	for(long long i=2;i*i<=a;i++){
		if(a%i==0){
		while(a%i==0){
			s[i]++;
			a=a/i;
		}}
		
	}
	if(a>1)
	s[a]++;
	map<long long , long long >::iterator it;
	for(it=s.begin();it!=s.end();it++){
		int i=1 ;
		for(int j=1;j<=it->second;i++,j=j+i){
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

#define M 1000000
#define NIL (-1)
#define L 12

char H[M][L];

int getChar(char ch){
  if(ch == 'A')return 1;
  else if(ch == 'C')return 2;
   else if(ch == 'G')return 3;
   else if(ch == 'T')return 4;
   else return 0;
}

long long getKey(char str[]){
  long long sum = 0,p = 1,i;
  for(i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0)return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

    
int main(){
  int i,n,h;
  char str[L],com[9];
  for(i = 0; i < M; i++)H[i][0] = '\0';
  scanf("%d",&n);
  for(i = 0; i< n; i++){
    scanf("%s %s",com,str);

    if(com[0] == 'i'){
      insert(str);
    }
    else{
      if(find(str)){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }
  return 0;
}

    



Measured memory_bytes: 13480
#include<bits/stdc++.h>
using namespace std;
int main(void){
    while(1){
        int money,change,num=0;
        cin>>money;
        if(money==0){
            break;
        }
        change=1000-money;
        num+=(change/500);
        change%=500;
        num+=(change/100);
        change%=100;
        num+=(change/50);
        change%=50;
        num+=(change/10);
        change%=10;
        num+=(change/5);
        change%=5;
        num+=change;
        cout<<num<<endl;
    }
    return 0;
}


Measured memory_bytes: 2988
import numpy as np

N, M = list(map(int, input().split()))
S = list(map(int, input().split()))
T = np.array(list(map(int, input().split())))

dp = np.ones(M+1, dtype='int64')

for s in S:
    dp[1:] = ((dp[:-1] * (s == T)).cumsum() + dp[1:]) % (10**9+7)
print(dp[-1])

Measured memory_bytes: 12496
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 1 << 18;
int n, Par[N][2], Sz[N][2], R[2], vis[N], ans[N], M[N];
vector<int> G[N][2], F[N];
void input();
void invalid();
void get_size();
void ok_0();
int dfs();
void build();
void bip();
void solve();
void output();
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    input();
    invalid();
    ok_0();
    build();
    solve();
    output();
}
void input() {
	cin >> n;
	for (int t = 0; t < 2; t ++) 
		for (int i = 1; i <= n; i ++) {
			cin >> Par[i][t];
			if (!(~Par[i][t])) 
				R[t] = i;
			else {
				G[Par[i][t]][t].pb(i);
			}
 		}
	
}
void get_size(int v, int t) {
	Sz[v][t] = G[v][t].size();
	for (auto u : G[v][t])
			get_size(u, t);
}
void invalid() {
	get_size(R[0], 0);
	get_size(R[1], 1);
	for (int i = 1; i <= n; i ++) 
		if ((Sz[i][0] ^ Sz[i][1]) & 1) {
			cout << "IMPOSSIBLE";
			exit(0);
		}
}
void ok_0() {
	for (int i = 1; i <= n; i ++) {
		if (Sz[i][0] & 1) {
			vis[i] = 1;
			ans[i] = 0;
		}
	}
}
int dfs(int v, int t) { // Empty : -1
	vector<int> vec;
	if (Sz[v][0] % 2 == 0)vec.pb(v);
	for (auto u : G[v][t]) {
		int rem = dfs(u, t);
		if (~rem) 
			vec.pb(rem);
	}
	while (vec.size() >= 2) {
		int x = vec.back();
		vec.pop_back();
		int y = vec.back();
		vec.pop_back();
		F[x].pb(y);
		F[y].pb(x);
		//cout << x << ' ' << y << endl;
	}
	if (vec.size()) 
		return vec.back();
	return -1;
}
void build() {
	dfs(R[0], 0);
	dfs(R[1], 1);
}
void bip(int v, int c = 1) {
	ans[v] = c;
	vis[v] = 1;
	for (auto u : F[v]) {
		if (vis[u]) continue;
		bip(u, (-1) * c);
	}
}
void solve() {
	for (int i = 1; i <= n; i ++)
		if (!vis[i])
			bip(i, 1);
}
void output() {
	cout << "POSSIBLE\n";
	for (int i = 1; i <= n; i ++)
		cout << ans[i] << ' ';
}

Measured memory_bytes: 34304
a, b = [input() for i in range(2)]

count = 0
out = 0
if a == b:
  print("0")
else:
  c = list(a)
  d = list(b)
  for i in c:
    if i == d[count]:
      pass
    else:
      out = out + 1
    count = count + 1
  print(str(out))

Measured memory_bytes: 12444
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC
{
    class QuestionB
	{
		public static void Main(string[] args)
		{
			var scanner = new Scanner();

			var s = scanner.NextLine();
			var t = scanner.NextLine();

			var max = int.MaxValue;

			for(int i = 0; i <= s.Length - t.Length; i++) {
				var tmp = 0;
				for(int j = 0; j < t.Length; j++) {
					var sIndex = i + j;

					if(s[sIndex] != t[j]) {
						tmp++;
					}
				}

				max = Math.Min(max, tmp);
			}

			Console.WriteLine(max);
		}

		public class Scanner
		{
			private readonly char[] delimiter_ = new char[] { ' ' };
			private readonly string filePath_;
			private readonly Func<string> reader_;
			private string[] buf_;
			private int index_;

			public Scanner(string file = "")
			{
				if (string.IsNullOrWhiteSpace(file)) {
					reader_ = Console.ReadLine;
				} else {
					filePath_ = file;
					var fs = new StreamReader(file);
					reader_ = fs.ReadLine;
				}
				buf_ = new string[0];
				index_ = 0;
			}

			public string NextLine() => reader_();
			public string Next()
			{
				if (index_ < buf_.Length) {
					return buf_[index_++];
				}

				string st = reader_();
				while (st == "") {
					st = reader_();
				}

				buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
				if (buf_.Length == 0) {
					return Next();
				}

				index_ = 0;
				return buf_[index_++];
			}

			public int Int() => int.Parse(Next());
			public long Long() => long.Parse(Next());
			public double Double() => double.Parse(Next());

			public int[] ArrayInt(int N, int add = 0)
			{
				int[] Array = new int[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Int() + add;
				}
				return Array;
			}

			public long[] ArrayLong(int N, long add = 0)
			{
				long[] Array = new long[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Long() + add;
				}
				return Array;
			}

			public double[] ArrayDouble(int N, double add = 0)
			{
				double[] Array = new double[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Double() + add;
				}
				return Array;
			}

			public (int, int) Int2(int add = 0)
			{
				var array = ArrayInt(2, add);
				return (array[0], array[1]);
			}

			public (int, int, int) Int3(int add = 0)
			{
				var array = ArrayInt(3, add);
				return (array[0], array[1], array[2]);
			}

			public (long, long) Long2(int add = 0)
			{
				var array = ArrayLong(2, add);
				return (array[0], array[1]);
			}

			public (long, long, long) Long3(int add = 0)
			{
				var array = ArrayLong(3, add);
				return (array[0], array[1], array[2]);
			}

			public (double, double) Double2(int add = 0)
			{
				var array = ArrayDouble(2, add);
				return (array[0], array[1]);
			}

			public (double, double, double) Double3(int add = 0)
			{
				var array = ArrayDouble(3, add);
				return (array[0], array[1], array[2]);
			}

			public void Save(string text)
			{
				if (string.IsNullOrWhiteSpace(filePath_)) {
					return;
				}

				File.WriteAllText(filePath_ + "_output.txt", text);
			}
		}
	}
}


Measured memory_bytes: 25876
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("0 5");
            //5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("1 11");
            //1100
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2 85");
            //850000
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int D = wkArr[0];
        int N = wkArr[1];

        for (int I = 1; I < int.MaxValue; I++) {
            if (D == 0) {
                if (I % 100 > 0) {
                    N--;
                }
            }
            if (D == 1) {
                if (I % 100 == 0 && I % 10000 > 0) {
                    N--;
                }
            }
            if (D == 2) {
                if (I % 10000 == 0 && I % 1000000 > 0) {
                    N--;
                }
            }
            if (N == 0) {
                Console.WriteLine(I);
                break;
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#define int long long
using namespace std;

signed main() {
    int n, a;
    cin >> n >> a;
    int x[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }

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

    int dp[n + 1][n + 1][n * maxi + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int s = 0; s <= n * maxi; s++) {
                dp[i][j][s] = 0;
            }
        }
    }

    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            for (int s = 0; s <= n * maxi; s++) {
                if (j > i) continue;

                if (i > 0 && s < x[i]) {
                    dp[i][j][s] = dp[i - 1][j][s];
                } else if (i > 0 && j > 0 && s >= x[i]) {
                    dp[i][j][s] = dp[i - 1][j][s] + dp[i - 1][j - 1][s - x[i]];
                }
            }
        }
    }

    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += dp[n][i][i * a];
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
int dist(string &a,string &b)
{
    int n=a.length();
    int res=0;
    for(int i=0;i<n;i++) if(a[i]!=b[i]) res++;
    return res;
}
int main()
{
    string s,t;
    cin>>s>>t;
    int ans = INT_MAX;
    int n=s.length(),m=t.length();
    for(int i=0;i+m-1<n;i++)
    {
        string temp = s.substr(i,m);
        ans = min(ans,dist(t,temp));
    }
    cout<<ans<<endl;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int input = Integer.parseInt(br.readLine());
            System.out.println(input * input);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main(){
  int n; cin >> n;
  vector<int>d(n);
  for(int i=0;i<n;i++)
    cin>>d.at(i);
  int ans=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans += d.at(i)*d.at(j);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		
		Scanner input = new Scanner(System.in);
		
		while (true){
			int year1, month1, date1;
			
			year1 = input.nextInt();
			if (year1 < 0)return;
			
			month1 = input.nextInt();
			if (month1 < 0)return;
			
			date1 = input.nextInt();
			if (date1 < 0)return;
			
			Day d1 = new Day(year1, month1, date1);
			
			int year2, month2, date2;
			
			year2 = input.nextInt();
			if (year2 < 0)return;
			
			month2 = input.nextInt();
			if (month2 < 0)return;
			
			date2 = input.nextInt();
			if (date2 < 0)return;
			
			Day d2 = new Day(year2, month2, date2);
			
			
			int[] md = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
			int[] ml = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
			
			int sumday = 0;
			
			
			for (int i = year1; i < year2; i++){
				if ( i % 400 == 0 || (i % 4 == 0 && i % 100 != 0))sumday += 366;
				else sumday += 365;
			}
			
			
			for (int i = 1; i < month1; i++){
				if ( year1 % 400 == 0 || (year1 % 4 == 0 && year1 % 100 != 0))sumday -= ml[i];
				else sumday -= md[i];
			}
			
			for (int i = 1; i < month2; i++){
				if ( year2 % 400 == 0 || (year2 % 4 == 0 && year2 % 100 != 0))sumday += ml[i];
				else sumday += md[i];
			}
			
			sumday -= date1;
			sumday += date2;
			
			
			System.out.println(sumday);
		}
	}
}

class Day {
	private int year;
	private int month;
	private int date;
	
	public Day(int year, int month, int date) {
		this.year = year;
		this.month = month;
		this.date = date;
	}
	
	public Day() {}
	
	public void printDay(){
		System.out.println("year = " + this.year);
		System.out.println("month = " + this.month);
		System.out.println("date = " + this.date);
	}
	
	public void setYear(int year){
		this.year = year;
	}
	
	public void setMonth(int month){
		this.month = month;
	}
	
	public void setDate(int date){
		this.date = date;
	}
	
	public int getYear(){
		return year;
	}
	
	public int getMonth(){
		return month;
	}
	
	public int getDate(){
		return date;
	}
}

Measured memory_bytes: 19672
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a, b, c;
	char op;
	while (true)
	{
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?')
			break;
		if (op == '+')
			c = a + b;
		else if (op == '-')
			c = a - b;
		else if (op == '*')
			c = a * b;
		else if (op == '/')
			c = a / b;
		cout << c << endl;
	}
}


Measured memory_bytes: 3120
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int [n];
    long ans=0;
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      if(i!=0){
      if(a[i]<a[i-1]){
        ans+=(long)a[i-1]-a[i];
        a[i]=a[i-1];
      }
    }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    printf("%d %d %d\n", C, A, B);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class UnionFind:

    def __init__(self, N):
        self.parents = list(range(N))
        self.depth = [0] * N

    def find(self, x):
        while True:
            if self.parents[x] == x:
                return x
            else:
                x = self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.depth[x] == self.depth[y]:
            self.depth[x] += 1
            self.parents[y] = x
        elif self.depth[x] > self.depth[y]:
            self.parents[y] = x
        else:
            self.parents[x] = y


def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for i in range(M):
        a, b = map(int, input().split())
        uf.union(a - 1, b - 1)
    num = [0] * N
    for i in range(N):
        p = uf.find(i)
        num[p] += 1
    ans = max(num)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 79660
#!python3.4.3

x_str = input()
x = int(x_str)

if x < 100:
    print(0)
else:
    a = int(x_str[:-2])
    b = int(x_str[-2:])

    if a > b:
        print(1)
    else:
        count = 0
        d = b
        for i in range(5, 0, -1):
            c = d // i
            count += c
            if a < count:
                print(0)
                break
            if d % i == 0:
                print(1)
                break
            d = d - c*i


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
main(){
    int n,ans;
    cin>>n;
    string a,b,c;
    cin>>a>>b>>c;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]&&c[i]==b[i]&&a[i]==c[i]){
            ans+=0;
        }else{
            if(a[i]!=b[i]&&c[i]!=b[i]&&a[i]!=c[i])ans+=2;
            if(a[i]==b[i]&&c[i]!=b[i]&&a[i]!=c[i])ans+=1;
            if(a[i]!=b[i]&&c[i]==b[i]&&a[i]!=c[i])ans+=1;
            if(a[i]!=b[i]&&c[i]!=b[i]&&a[i]==c[i])ans+=1;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#define N 2100
#define pb push_back
using namespace std;
struct node{int y,nex;}a[N*N];
int fir[N],len,n,d[N],A[N],B[N],num;
bool b[N];
vector<int> v[N];
void ins(int x,int y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
void merge(int x,int y)
{
	int siz=v[x].size(),al=0,bl=0;
	for(int i=0;i<siz;i++) A[++al]=v[x][i];
	siz=v[y].size();
	for(int i=0;i<siz;i++) B[++bl]=v[y][i];
	v[x].clear();
	int i=1,j=1;
	while(i<=al || j<=bl)
	{
		if(j<=bl && (i>al || A[i]<B[j])) v[x].pb(B[j++]);
		else v[x].pb(A[i++]);
	}
}
void dfs(int x)
{
	b[x]=1;
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		if(b[y]) continue;
		dfs(y);
		merge(x,y);
	}
	int siz=v[x].size();
	num=0;
	A[0]=d[x];
	for(int i=0;i<siz;i++) A[++num]=v[x][i];
	v[x].clear();
	for(int i=0;i<=num;i++) v[x].pb(A[i]);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&d[i]);
	sort(d+1,d+n+1);
	for(int i=1;i<=n;i++)
		for(int j=n;j>=1;j--)
		{
			if(i==j) continue;
			if(gcd(d[i],d[j])>1) ins(i,j);
		}
	for(int i=1;i<=n;i++)
	{
		if(b[i]) continue;
		dfs(i);
		merge(0,i);
	}
	for(int i=0;i<n;i++) printf("%d ",v[0][i]);
	return 0;
}

Measured memory_bytes: 31360
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)

int main() {
  int h, w, d;
  cin >> h >> w >> d;
  vector<pair<int, int>> vp(h * w);
  rep(i, h) {
    rep(j, w) {
      int x;
      cin >> x;
      x--;
      vp[x] = make_pair(i, j);
    }
  }

  vector<vector<int>> s(d, vector<int>{0});
  rep(x, h * w - d) {
    int i, j;
    tie(i, j) = vp[x];
    int y = x + d;
    int ii, jj;
    tie(ii, jj) = vp[y];
    s[x % d].push_back(abs(i - ii) + abs(j - jj));
  }

  rep(k, d) {
    rep2(l, 1, s[k].size()) {
      s[k][l] += s[k][l - 1];
    }
  }

  int q;
  cin >> q;
  rep(t, q) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int k = a % d;
    int l1 = a / d;
    int l2 = b / d;
    cout << s[k][l2] - s[k][l1] << endl;
  }

}


Measured memory_bytes: 6016
#include<stdio.h>
#include<math.h>

int main(){
  int n;
  int i,count1=0,count2=0; //count1:入力したnの個数 count2:合成数の個数

  while(scanf("%d",&n)!=EOF){
    count1++;
    if(n!=2 && n%2==0){
      count2++;//2以外の偶数を除く
      continue;
    }
    for(i=3;i<=sqrt(n);i+=2){
      if(n%i==0){
	count2++;
	break;
      }
    }
  }
  printf("%d\n",count1-count2);

  return 0;
}

// xが合成数ならば、√x以下の約数を持つことを利用した



Measured memory_bytes: 2036
import sys

N = int(sys.stdin.readline().strip())

A = []
t = 0
i = 1
while t <= N:
    t += i
    A.append(i)
    i += 1
# print(A) 
for i in A:
    if t - N == i:
        # print("continue", i)
        continue
    else:
        print(i)

Measured memory_bytes: 42840
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A));

        sc.close();
    }

    static int solve(int[] A) {
        Map<Integer, Integer> valueToCount = new HashMap<>();
        for (int value : A) {
            valueToCount.put(value, valueToCount.getOrDefault(value, 0) + 1);
        }

        return A.length - (valueToCount.values().stream().mapToInt(x -> x - 1).sum() + 1) / 2 * 2;
    }
}

Measured memory_bytes: 52788
import math

A, B, H, M = map(int, input().split())

B_ang = 6*M
A_ang = 30*H + (0.5*M)
AB_cos = math.cos(math.radians(min(360 - abs(A_ang - B_ang), abs(B_ang - A_ang))))
ans = math.sqrt(A**2 + B**2 - (2*A*B*AB_cos))

print(ans)

Measured memory_bytes: 9516
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main(){
    int n; cin >> n;
    vector<vector<int>> ss(n, vector<int>(26));
    for(int i=0; i<n; ++i){
        string s; cin >> s;
        for(auto c : s){
            ++ss[i][c-'a'];
        }
    }
    for(int i=0; i<26; ++i){
        int num=INT_MAX;
        for(int j=0; j<n; ++j){
            num=min(num, ss[j][i]);
        }
        for(int j=0; j<num; ++j){
            cout << (char)(i+'a');
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,c=0,n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==1)
      c++;
  }
  cout<<(c%2==0?"YES":"NO")<<endl;
}

Measured memory_bytes: 256