akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int maxi(int a, int b) {
  if(a > b) return a;
  return b;
}
int main() {
  int n;
  int a[100010] = {};
  int ans = 0;
  scanf("%d",&n);
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  else if (n == 2) {
    int a, b;
    scanf("%d %d",&a,&b);
    printf("%d\n",(abs(a-b)>2)?1:2);
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d",&tmp);
    a[tmp]++;
  }
  for (int i = 1; i < 100000; i++) {
    ans = maxi(ans, a[i-1]+a[i]+a[i+1]);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	vvl abc(3, vl(n));
	REP(i, n) REP(j, 3) cin >> abc[j][i];
	vvl dp(3, vl(n + 1, 0));

	REP(i, n) REP(j, 3) REP(k, 3) if (j != k) MAXC(dp[j][i + 1], dp[k][i] + abc[j][i]);

	ll ans = 0;
	REP(i, 3) MAXC(ans, dp[i][n]);
	cout << ans << endl;
}


Measured memory_bytes: 5752
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
vector<pair<ll,ll>> p; 
void prime(ll n) 
{ 

    ll count = 0; 

  

    // count the number of times 2 divides  

    while (!(n % 2)) { 

        n >>= 1; // equivalent to n=n/2; 

        count++; 

    } 

  

    // if 2 divides it 

    if(count){
      auto pop=mp(2,count);
      p.pb(pop);
    }

  

    // check for all the possible numbers that can  

    // divide it 

    for (ll i = 3; i <= sqrt(n); i += 2) { 

        count = 0; 

        while (n % i == 0) { 

            count++; 

            n = n / i; 

        } 

        if (count){
          auto pop=mp(i,count);
          p.pb(pop);
        }

    } 

  

    // if n at the end is a prime number. 

    if (n > 2){
      auto pop=mp(n,1);
      p.pb(pop);
    }    
} 
signed main(){
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n; 
    cin>>n; 
    prime(n);
    sort(p.begin(),p.end());
    ll ans=0;
    if(n==1){
      cout<<ans<<endl; 
    }
    else{
     ll ans=0;
     for(ll i=0;i<p.size();i++){
       ll k=p[i].ff; 
       if(n==1){
         break; 
       }
       while(n%k==0){
         n/=k;
         ans++; 
         k*=p[i].ff; 
       }
     }
     cout<<ans<<endl; 
    }
    //printclock;
    return 0;
}
    

Measured memory_bytes: 3696
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}



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

ll getSum(ll arr[], int l, int r){
  if(l > r) return 0;
  return arr[r] - arr[l-1];
}

int main(){
  int n, k;
  ll sum[100005], positiveSum[100005];
  sum[0] = positiveSum[0] = 0;

  cin >> n >> k;
  for(int i=1; i<=n; i++){
    int x; cin >> x;
    sum[i] = sum[i-1] + x;
    positiveSum[i] = positiveSum[i-1] + max(x, 0);
  }

  ll ans = 0;
  for(int i=1; i+k-1 <= n; i++){
    int left = i;
    int right = i+k-1;
    ans = max(ans, 
        getSum(positiveSum, 1, left-1) + 
        max(0ll, getSum(sum, left, right)) + 
        getSum(positiveSum, right+1, n)
    );
  }

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

Measured memory_bytes: 5180
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
 
    int N;
    int ans = 100;
    int A;
    
    cin >> N;
    for(int i = 0; i < N; i++){
        int crack_Coount = 0;
        cin >> A;
        while(A%2 == 0){
            crack_Coount++;
            A /= 2;
        }
        ans = min(ans, crack_Coount);
    }
    
    
    cout << ans << endl;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi               vector<int>
#define pii              pair<int,int>
#define si               set<int>
#define mii              map<int,int>
#define umii              unordered_map<int,int>
#define p_b              push_back
#define loop(i,a,b)      for(int i=a;i<b;i++)
#define setbits(x)       __builtint_popcountll(x) //return no. of set bits in x
#define zerobits(x)      __buitlin_ctzll(x)       // return no. of zeroes after first set bit
#define int              long long
#define io          	 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define multipletest     int t;cin>>t;while(t--) 
bool isPrime(int n){if(n==1){return false;}if(n==2){return true;}if(n%2==0){return false;}for(int i = 3; i <= sqrt(n); i+=2){if(n % i == 0){return false;}}return true;}
string make_beautiful(string x , int k){for(int i = k; i<x.size();i++){ x[i]=x[i-k];}return x;
}
 


long long binpow(long long a, long long b) {long long res = 1; while (b > 0) { if (b & 1) res = res * a;a = a * a;b >>= 1;}return res;}
 
// for GCD -> __gcd(a,b);
 
int LCM(int x , int y) { return (x * y)/__gcd(x,y); }
 
const int mod = 100000;
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////f//////////////////////////////////////////////////////////////////////////////


void solve()
{
	string s;
	cin>>s;
	bool south=false , north = false , east = false , west = false;

	for(int i=0;i<s.size() ; i++)
	{
		if(s[i] == 'S') south = true;
		if(s[i] == 'W') west = true;
		if(s[i] == 'N') north = true;
		if(s[i] == 'E') east = true;
	}

	if( (south && !north) || (east && !west) || (!south && north) || (!east && west))
		cout<<"No\n";
    else cout<<"Yes\n";

}

 
int32_t main()
{
	
	io
 	// multipletest
	solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

//aのb乗
int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}



int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	int gyaku = 1;
	for(int i=1;i<=N;i++){
		gyaku = mod(gyaku * i);
	}
	
	int ans = 0;
	
	int now = 0;
	
	for(int i=0;i<N;i++){
		now = mod(gyakugen(i+1)+now);
		int k = mod(A[i] * gyaku);
		k = mod(k*now);
		
		ans = mod(ans + k);
	}
	reverse(A.begin(),A.end());
	
	now=0;
	for(int i=0;i<N;i++){
		now = mod(gyakugen(i+1)+now);
		int k = mod(A[i] * gyaku);
		k = mod(k*now);
		
		ans = mod(ans + k);
	}
	
	for(int i=0;i<N;i++){
		ans = mod(ans - mod(gyaku * A[i]));
	}
	
	cout<<ans<<endl;
	
	
	
	
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
    int n; cin >> n;
    int p[n];
    REP(i,n){
        cin >> p[i];p[i]--;
    }
    int ans=0;
    REP(i,n){
        if(p[i] == i){
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
def f(n):
    result = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            result.add(i)

    if temp != 1:
        result.add(temp)

    return result


a, b = list(map(int, input().split()))

fa = f(a)
fb = f(b)

print(len(fa & fb)+1)


Measured memory_bytes: 38512
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d,q;

int b[maxn],a[maxn];

int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
    char last;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            last=s[i];
            sum++;
        }
        else{
            if(s[i]!=last)
                last=s[i],sum++;
        }

    }
    cout<<sum<<endl;
    return 0;
}


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

int main()
{
	int N, L, min = 101, answer = 0;

	cin >> N >> L;
	for(int i = L; i < L + N; i++)
	{
		answer += i;
		if(abs(min) > abs(i))
		{
			min = i;
		}
	}

	answer += -(min);

	cout << answer << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 44;

int N;
ll _F[MAX_N][MAX_N][MAX_N];
char A[MAX_N][MAX_N];

ll F(int l, int i, int r) {
    ll &res = _F[l][i][r];
    if (res != -1) return res;
    if (l == r) return res = 1;
    if (r - l & 1) return res = 0;
    res = 0;
    for (int j = l; j < i; j++) {
        for (int k = i + 1; k <= r; k++) {
            if (A[j][k] != '1') continue;
            for (int p = j; p < i; p++) {
                for (int q = i + 1; q <= k; q++) {
                    res += F(l, j, p) * F(q, k, r) * F(p + 1, i, q - 1);
                }
            }
        }
    }
    return res;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= 2 * N; i++) scanf("%s", A[i] + 1);
    memset(_F, -1, sizeof(_F));
    ll ans = 0;
    for (int i = 2; i <= 2 * N; i++) {
        if (A[1][i] != '1') continue;
        ans += F(2, i, 2 * N);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n;
ll a[100000];
int om;
pl out[100000];

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    sort(a, a+n);
    if (a[0] < 0 && a[n-1] > 0) {
        for (int i = 1; i < n-1; i++) {
            if (a[i] < 0) {
                out[om++] = pi(a[n-1], a[i]);
                a[n-1] -= a[i];
            } else {
                out[om++] = pi(a[0], a[i]);
                a[0] -= a[i];
            }
        }
        out[om++] = pi(a[n-1], a[0]);
        a[n-1] -= a[0];
    } else if (a[0] >= 0) {
        for (int i = 1; i < n-1; i++) {
            out[om++] = pi(a[0], a[i]);
            a[0] -= a[i];
        }
        out[om++] = pi(a[n-1], a[0]);
        a[n-1] -= a[0];
    } else {
        for (int i = n-2; i > 0; i--) {
            out[om++] = pi(a[n-1], a[i]);
            a[n-1] -= a[i];
        }
        out[om++] = pi(a[n-1], a[0]);
        a[n-1] -= a[0];
    }
    cout << a[n-1] << endl;
    rep(i,om) cout << out[i].first << " " << out[i].second << endl;
}


Measured memory_bytes: 4224
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

ll a,b;

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y, x%y);
}

ll lcm(ll x, ll y){
	return (ll)(x*y/gcd(x,y));
}

int main(){
	while(scanf("%lld %lld", &a, &b)!=EOF){
		cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3148
N,M = map(int,input().split())
PS = []
AC_counter = [0 for i in range(N)]
WA_counter = [0 for i in range(N)]
for i in range(M):
    p,s = input().split()
    p = int(p)-1
    if s == 'AC':
        AC_counter[p] = 1
    else:
        if AC_counter[p] == 0:
            WA_counter[p] += 1
WA_ans = 0
for a,b in zip(AC_counter,WA_counter):
    if a > 0:
        WA_ans += b
print(sum(AC_counter),WA_ans)

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

int main(){
  int M,D;
  cin>>M>>D;
  int i = 0;//一の位
  double j = 0;
  int k = 0;//合計
  int l = 0;//10の位
  for(int m = 0;m <= M;m++){
    for(int d = 0;d <= D;d++){
      i = d % 10;
      j = d / 10;
      l = j;
      if(i >= 2 && l >= 2 && i * l == m){
        k++;
      }
      i = 0;
      j = 0;
      l = 0;
    }
  }
  cout<<k<<endl;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#pragma optimize("", off)
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	n=n%10;
	switch (n){
		case 0:
			cout<<"pon\n";
			break;
		case 1:
			cout<<"pon\n";
			break;
		case 2:
			cout<<"hon\n";
			break;
		case 3:
			cout<<"bon\n";
			break;
		case 4:
			cout<<"hon\n";
			break;
		case 5:
			cout<<"hon\n";
			break;
		case 6:
			cout<<"pon\n";
			break;
		case 7:
			cout<<"hon\n";
			break;
		case 8:
			cout<<"pon\n";
			break;
		case 9:
			cout<<"hon\n";
	}
	return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	string s;
	cin>>s;
	for(int i=a;i<c;i++){
		if(s[i]=='#'&&s[i-1]=='#'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=b;i<d;i++){
		if(s[i]=='#'&&s[i-1]=='#'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	s+="##";
	if(c<d){
		cout<<"Yes"<<endl;
		return 0;
	}
	else{
		for(int i=max(0,b-2);i<d-1;i++){
			if(s.substr(i,3)=="..."){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main(void) {
  long long int a, b, x;
  int i;
  scanf("%lld %lld %lld", &a, &b, &x);
  long long int ad, bd, ans;
  ad = a/x;
  bd = b/x;
  ans = bd - ad;
  if(a%x==0){
    ans++;
  }
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LL long long
#define il inline
#define rg register
using namespace std;
LL s, t, n, m;
const int maxn = 2e6  +5;
il void chkmax(int &a, int b) {a = a > b ? a : b;}
il void chkmin(int &a, int b) {a = a < b ? a : b;}
il int read() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) {
		if(c == '-') f = -f;
		c = getchar();
	}
	while(isdigit(c)) {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * f;
}
il void write(int x) {
	char c[33] = {0}, tot = 0;
	if(x == 0) {puts("0"); return;}
	while(x) {c[++ tot] = x % 10 + '0'; x /= 10;}
	while(tot) {putchar(c[tot --]);}
	return ;
}
LL a[maxn], b[maxn], dp[maxn]; 
int main() {
	n = read(), m = read(), t = read();
	for(int i = 1;i <= n;i ++) a[i] = read() + a[i - 1];
	for(int i = 1;i <= m;i ++) b[i] = read() + b[i - 1]; 
	LL j = m;
	s = 0;
	for(int i = 0;i <= n;i ++) {
		while(a[i] + b[j] > t && j) j --;
		if(i + j > s && a[i] <= t) s = i + j;
	}
	cout << s;
	return 0;
}

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

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, Q;
  cin >> N >> Q;

  fenwick_tree<ll> ft(N);

  for(ll i = 0; i < N; ++i) {
    ll ai;
    cin >> ai;
    ft.add(i, ai);
  }

  for(;Q-->0;) {
    ll op;
    cin >> op;
    if (op) {
      ll l, r;
      cin >> l >> r;
      cout << ft.sum(l, r) << endl;
    } else {
      ll p, x;
      cin >> p >> x;
      ft.add(p, x);
    }
  }
  return 0;
}


Measured memory_bytes: 8240
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int sLen = S.length();
        int oneLen = S.replaceAll("0", "").length();
        int zeroLen = sLen - oneLen;
        int r = Math.min(zeroLen, oneLen) * 2;
        System.out.println(r);
    }
}

Measured memory_bytes: 32296
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30


//------------------------------------------------------

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

    int r = n % 500;

    cout << (a >= r ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
N, A = [int(_) for _ in input().split()]
X = [int(_) - A for _ in input().split()]
X_plus = [_ for _ in X if _ > 0]
X_minus = [-_ for _ in X if _ < 0]
l_zero = len(X) - len(X_plus) - len(X_minus)
s_plus = sum(X_plus)
s_minus = sum(X_minus)
dp_plus = {0: 1}
dp_minus = {0: 1}
for p in X_plus:
    dp_plus_old = dp_plus.copy()
    for k, v in dp_plus_old.items():
        dp_plus[k + p] = dp_plus_old.get(k, 0) + dp_plus_old.get(k + p, 0)
for m in X_minus:
    dp_minus_old = dp_minus.copy()
    for k, v in dp_minus_old.items():
        dp_minus[k + m] = dp_minus_old.get(k, 0) + dp_minus_old.get(k + m, 0)
c_zero = 2 ** l_zero
ans = c_zero - 1
for j in range(1, min(s_plus, s_minus) + 1):
    ans += c_zero * dp_plus.get(j, 0) * dp_minus.get(j, 0)
print(ans)


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

int main() {
	int a, b;
	while(cin >> a >> b){
		int n = a + b;
		int count = 0;
		while(n > 0){
			n /= 10;
			count++;
		}
		cout << count << endl;
	}
	
	return 0;
}

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

using namespace std;
int n, k;
int a[200000];
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int zero = n + 1;
    for (int i = 1; i <= n; i++)
        if (a[i] >= 0) {
            zero = i;
            break;
        }
    int ans = 1e9;
    for (int j = 0; j <= k; j++) {
        if (zero + j - 1 > n) break;
        int l = k - j;
        if (zero - l <= 0) continue;
        int d = 0, c1 = 0, c2 = 0;
        if (j > 0) {
            d += abs(a[zero + j - 1]);
            c1 = abs(a[zero + j - 1]);
        }
        if (j != k) {
            d += abs(a[zero - l]);
            c2 = abs(a[zero - l]);
        }
        ans = min(ans, d + min(c1, c2));
    }
    cout << ans << "\n";

    return 0;
}


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

int main(){
  int n,c=0,i,j;
  int a[10000];

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&a[i]);

  for(i=0;i<n;i++)
    if(isprime(a[i])==1)c++;
  printf("%d\n",c);

  return 0;
}

int isprime(int x){
  int i;
  
  if(x==2)return 1;
  else if(x<2||x%2==0)return 0;
  else{
    i=3;
    while(i<=sqrt(x)){
      if(x%i==0)return 0;
      i=i+2;
    }
    return 1;
  }
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
set<int> a;
set<int> b;
int main()
{
	int n, m;
	scanf("%d",&n);
	int i;
	for(i=0; i<n; i++)
	{
		int x;
		scanf("%d",&x);
		a.insert(x);
	}
	scanf("%d",&m);
	for(i=0; i<m; i++)
	{
		int x;
		scanf("%d",&x);
		b.insert(x);
	}
	vector<int> v;
	set_union(a.begin(), a.end(), b.begin(), b.end(), back_inserter(v));
	for(i=0; i<v.size(); i++) printf("%d\n",v[i]);
	return 0;
}


Measured memory_bytes: 23720
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
int binstring_to_int(string s) {
	int x = 1;
	int res = 0;
	rrep(i, 0, s.size()) {
		if (s[i] == '1')res |= x;
		x <<= 1;
	}

	return res;
}
char crypt(string s) {
	int x = binstring_to_int(s);
	if (x == 26)return ' ';
	else if (x == 27)return '.';
	else if (x == 28)return ',';
	else if (x == 29)return '-';
	else if (x == 30)return '\'';
	else if (x == 31)return '?';
	else {
		return 'A' + (char)x;
	}
}
signed main() {
	map<char, string>m;
	m[' '] = "101";
	m['\''] = "000000";
	m[','] = "000011";
	m['-'] = "10010001";
	m['.'] = "010001";
	m['?'] = "000001";
	m['A'] = "100101";
	m['B'] = "10011010";
	m['C'] = "0101";
	m['D'] = "0001";
	m['E'] = "110";
	m['F'] = "01001";
	m['G'] = "10011011";
	m['H'] = "010000";
	m['I'] = "0111";
	m['J'] = "10011000";
	m['K'] = "0110";
	m['L'] = "00100";
	m['M'] = "10011001";
	m['N'] = "10011110";
	m['O'] = "00101";
	m['P'] = "111";
	m['Q'] = "10011111";
	m['R'] = "1000";
	m['S'] = "00110";
	m['T'] = "00111";
	m['U'] = "10011100";
	m['V'] = "10011101";
	m['W'] = "000010";
	m['X'] = "10010010";
	m['Y'] = "10010011";
	m['Z'] = "10010000";

	string s;
	while (getline(cin, s)) {
		string ans;

		rep(i, 0, s.size()) {
			ans += m[s[i]];
		}
		string cry;
		string t;
		rep(i, 0, ans.size()) {
			t.push_back(ans[i]);
			if (t.size() == 5) {
				cry += crypt(t);
				t.clear();
			}
		}
		if (t.size()) {
			while (t.size() < 5)t = t + "0";
			cry += crypt(t);
		}

		cout << cry << endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<ll,ll> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main(){
    ll n,ans=1;cin>>n;
    vector<ll> v(n,0);
    for(ll i=0;i < n;i++)
    {
        cin>>v[i];
    }

    sort(v.begin(),v.end());

    for(ll i=1;i<siz(v)-2;i++)
    {
        if(v[i-1] != v[i] && v[i]!=v[i+1]){
            v.erase(v.begin()+i);
            i--;
        }
    }

    while(siz(v)>1 && v.back()!=v[siz(v)-2])v.pop_back();
    while(siz(v)>1 && v[0]!=v[1])v.erase(v.begin()+0);

    if(siz(v)>3){
        cout<<v[siz(v)-1]*v[siz(v)-4]<<endl;
    }else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 1024
from itertools import accumulate
n, k = map(int, input().split())
p = list(map(int, input().split()))

pp = [0] + list(accumulate(p))

m = 0
for i in range(n - k + 1):
  m = max(m,pp[i + k] - pp[i])
print((m+k)/2)

Measured memory_bytes: 25148
import java.util.*;
public class Main {

	static int N;
	static int[] color;
	static List<Integer>[] e;
	
	static boolean dfs(int v, int c) {
		color[v] = c;
		for(int i : e[v]) {
			if(color[i] == c)
				return false;
			if(color[i] == 0 && !dfs(i, -c))
				return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int INF  = Integer.MAX_VALUE / 2;
		N = sc.nextInt();
		color = new int[N];
		e = new ArrayList[N];
		int[][] d = new int[N][N];
		for(int i = 0; i < N; i++) {
			e[i] = new ArrayList<>();
			String S = sc.next();
			for(int j = 0; j < N; j++) {
				if(i == j)
					continue;
				if(S.charAt(j) == '1') {
					e[i].add(j);
					d[i][j] = 1;
				}
				else
					d[i][j] = INF;
			}
		}
		if(!dfs(0, 1)) {
			System.out.println(-1);
			return;
		}
		int dmax = 0;
		for(int k = 0; k < N; k++)
			for(int i = 0; i < N; i++)
				for(int j = 0; j < N; j++)
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				if(d[i][j] != INF)
					dmax = Math.max(dmax, d[i][j]);
		System.out.println(dmax + 1);
	}

}

Measured memory_bytes: 25344
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(void){
    
    string  N(200100, 'a');
    string ans="No";
    long long sum_of_digit=0;

    cin >> N;  

    for(int i =0;i<200000;i++){
        if(N[i]=='\0') break;
        sum_of_digit=sum_of_digit+N[i]-'0';
    }
    if(sum_of_digit%9==0) ans ="Yes";

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

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  998244353 
#define ll long long
#define int long long
# define INF 9999999
#define ar array
#define MAX 1000004
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;
const int N=6e5+6;
void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}



int32_t main()
{
    c_p_c();
    
       int x,y;
       cin>>x>>y;
       for(int i=0;i<=x;i++){
        int b=x-i;
        int l=2*i+4*b;
        if(l==y){
            cout<<"Yes\n";
            return 0;
        }
       }
       cout<<"No\n";

        

        
}

Measured memory_bytes: 3596
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[])throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int arr[]=new int[n];
		for(int k=0;k<n;k++)
			arr[k] = Integer.parseInt(st.nextToken());
		int res[] = new int[n];
		int s=arr[0]^arr[1];
		for(int i=2;i<n;i++)
			s= (s^arr[i]);
		for(int i=0;i<n;i++)
			res[i] = (s^arr[i]);
		for(int i=0;i<n;i++)
			System.out.print(res[i]+" ");
		System.out.println();

		

	}
}

Measured memory_bytes: 61264
#include <bits/stdc++.h>
 
using namespace std;
  
#define EPS 1e-3
#define equals(a,b) (abs(a-b) < EPS)
typedef vector<double> vec;
typedef vector<vec> mat;
 
vec gauss_jordan(const mat &A,const vec &b){
    int n = A.size();
    mat B(n,vec(n+1));
    for(int i = 0 ; i < n ; i++){
	for(int j = 0 ; j < n ; j++){
	    B[i][j] = A[i][j];
	}
    }
    for(int i = 0 ; i < n ; i++){
	B[i][n] = b[i];
    }
    for(int i = 0 ; i < n ; i++){
	int pivot = i;
	for(int j = i ; j < n ; j++){
	    if(abs(B[j][i]) > abs(B[pivot][i])){
		pivot = j;
	    }
	}
	swap(B[i],B[pivot]);
	if(abs(B[i][i]) < EPS) return vec();
	for(int j = i+1 ; j <= n ; j++){
	    B[i][j] /= B[i][i];
	}
	for(int j = 0 ; j < n ; j++){
	    if(i != j){
		for(int k = i+1 ; k <= n ; k++){
		    B[j][k] -= B[j][i]*B[i][k];
		}
	    }
	}
    }
    vec x(n);
    for(int i = 0 ; i < n ; i++){
	x[i] = B[i][n];
    }
    return x;
}
 
int main(){
    int d;
    while(cin >> d,d){
	int N = d+3;
	mat A(N,vec(d+1));
	vec b(N);
	for(int i = 0 ; i < N ; i++){
	    cin >> b[i];
	    for(int j = 0 ; j <= d ; j++){
		A[i][j] = pow((double)i,j);
	    }
	}
	for(int i = 0 ; i < N ; i++){
	    int idx = 0;
	    mat A2(N-2,vec(d+1));
	    vec b2(N-2);
	    for(int j = 0 ; idx < N-2 ; j++){
		if(i == j) continue;
		A2[idx] = A[j];
		b2[idx++] = b[j];
	    }
	    vec res = gauss_jordan(A2,b2);
	    if(res.size() > 0){
		int x = (i == N-1 ? N-2 : N-1);
		double sum = 0;
		for(int j = 0 ; j < (int)res.size() ; j++){
		    sum += res[j]*pow((double)x,j);
		}
		if(equals(sum,b[x])){
		    cout << i << endl;
		    break;
		}
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)

int main(){
	int n;
	cin >> n;
	int tri[1000][3];
	REP(i,n){
		REP(j,3){
			cin >> tri[i][j];
		}
		sort(tri[i],tri[i]+3);
	}
	REP(i,n){
		if(tri[i][2]*tri[i][2] == tri[i][1]*tri[i][1] + tri[i][0]*tri[i][0]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3080
class Point
  attr_accessor :x, :y

  def initialize(x, y)
    @x = x
    @y = y
  end
end

class Line
  attr_accessor :a, :b

  def initialize(a, b)
    @a = a
    @b = b
  end

  def side(p)
    n = p.x * (a.y - b.y) + a.x * (b.y - p.y) + b.x * (p.y - a.y)
    if n > 0
      return 1
    elsif n < 0
      return -1
    else
      return 0
    end
  end
end


class Triangle
  attr_accessor :a, :b, :c

  def initialize(a, b, c)
    @a = a
    @b = b
    @c = c
  end

  def pointInTriangle(p)
    ab = Line.new(@a, @b)
    bc = Line.new(@b, @c)
    ca = Line.new(@c, @a)

    pab = ab.side(p)
    pbc = bc.side(p)
    pca = ca.side(p)

    if ((0 < pab) && (0 < pbc) && (0 < pca))
      return 1
    end
    if ((0 > pab) && (0 > pbc) && (0 > pca))
      return 1
    end
    return 0
  end
end

while line = gets
  x1, y1, x2, y2, x3, y3, xp, yp = line.split().map{|i| i.to_f}
  triangle = Triangle.new(Point.new(x1, y1),
                          Point.new(x2, y2),
                          Point.new(x3, y3))
  state = triangle.pointInTriangle(Point.new(xp, yp)) 
  if state == 1
    puts "YES"
  else
    puts "NO"
  end
end

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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

ll w[100005];
ll v[100005];
ll dp[105][100005]; //[種類][価値]

ll MAX_N = 100;
ll MAX_V = 1000;

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

    ll K,N;
    cin >> N >> K;

    REP(i,N)cin >> w[i] >> v[i];

    Fill(dp,INF);   

    dp[0][0] = 0;
    REP(i,N){
        REP(j,MAX_N*MAX_V+1){
            if(j - v[i] < 0){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }
        }
    }

    for(int i = MAX_N*MAX_V;i >= 0;i--){
        if(dp[N][i] <= K){
            cout << i << endl;
            break;
        }
    }

    return 0;
}    

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

int main() {
  string S;
  cin >> S;

  string T = S;
  string Ans = "yes";

  rep(i, 0, S.size()) {
    int count = 0;
    rep(j, 0, S.size()) {
      if (T[i] == S[j]) count++;
      if (1 < count) {Ans = "no"; break;}
    }
  }

  cout << Ans << endl;
}


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

int main() {
  int h, w;
  cin>>h>>w;
  int s[h+2][w+2];
  for (int i=0; i<h; i++) {
    string t;
    cin>>t;
    for (int j=0; j<w; j++) {
      if (t[j] == '.') {
        s[i+1][j+1] = 2500;
      } else {
        s[i+1][j+1] = -1;
      }
    }
  }
  for (int i=0; i<h; i++) {
    s[i][0] = -1;
    s[i][w+1] = -1;
  }
  for (int i=0; i<w; i++) {
    s[0][i] = -1;
    s[h+1][i] = -1;
  }
  s[1][1] = 0;
  queue<pair<int, int> > q;
  q.push(make_pair(1, 1));

  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    int x = p.second;
    int y = p.first;
    if (s[y-1][x] != -1) {
      if (s[y][x] + 1 < s[y-1][x]) {
        s[y-1][x] = s[y][x] + 1;
        q.push(make_pair(y-1, x));
      }
    }
    if (s[y+1][x] != -1) {
      if (s[y][x] + 1 < s[y+1][x]) {
        s[y+1][x] = s[y][x] + 1;
        q.push(make_pair(y+1, x));
      }
    }
    if (s[y][x-1] != -1) {
      if (s[y][x] + 1 < s[y][x-1]) {
        s[y][x-1] = s[y][x] + 1;
        q.push(make_pair(y, x-1));
      }
    }
    if (s[y][x+1] != -1) {
      if (s[y][x] + 1 < s[y][x+1]) {
        s[y][x+1] = s[y][x] + 1;
        q.push(make_pair(y, x+1));
      }
    }
  }
  if (s[h][w] == 2500) {
    cout<<-1<<endl;
    return 0;
  }
  int ans = h * w - s[h][w] - 1;
  for (int i=1; i<=h; i++) {
    for (int j=1; j<=w; j++) {
      if (s[i][j] == -1) {
        --ans;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    string s; cin >> s;
    int n = s.size();
    int r = 0;
    rep(i, n){
        if(s[i] == '0') r++;
    }
    cout << n - abs(n - 2 * r) << endl;    
}

Measured memory_bytes: 512
#include <iostream>

int main()
{
  uint64_t x;
  std::cin >> x;

  uint64_t ret = 2 * (x/11);
  x %= 11;

  if(x == 0 ) {
  } else if(x<=6) {
    ret += 1;
  } else if(x < 11) {
    ret += 2;
  }

  std::cout << std::fixed << ret << std::endl;
  return 0;
}


Measured memory_bytes: 3600
using System;
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using Li = System.Collections.Generic.List<int>;
using Ll = System.Collections.Generic.List<long>;

namespace AtCoder0705
{
	class Program
	{
		static void Main(string[] args)
		{
			A();
		}

		private static void A()
		{
			var n = int.Parse(Console.ReadLine());
			Console.WriteLine((1000 - n % 1000) % 1000);
		}

		private static long[] ReadInts() => Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
	}
}


Measured memory_bytes: 27524
n,k=map(int,input().split())
S=input()
s_dict={
   'A':'a', 
   'B':'b',
   'C':'c'
   }
ans=''

for i,s in enumerate(S):
    if i!=(k-1):
        ans+=s
    else:
        ans+=s_dict[s]
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define S0RT(a,n) sort(a, a + n)
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);

/* NOTES TO SELF:
    Int overflow? Use all ll if in doubt.
    Edge cases? (n = 1, n = 0)
*/

ll h;

int main(){
    IOS;
    cin >> h;
    ll moves = 0;
    while (h > 0)
    {
        h /= 2;
        moves++;
    }
    ll ans = 1;
    F0R(i,moves){
        ans *= 2;
    }
    ans -= 1;
    cout << ans;
    return 0;
}

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


int main()
{
	string s;
	while (cin >> s,(s.length() > 1 || s[0]!= '0')){
		int sum = 0;
		for (int i = 0; i < s.length(); i++){
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1184
a = str(input())
b = len(a)
B = int(b/2)
c = 'hi'*B
if a == 'hi':
    print('Yes')
elif b/2 == 1 or b/2 == 2 or b/2 == 3 or b/2 == 4 or b/2 == 5:
    if a == c:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060
s = input()
# 97=122
ans = 100
for i in range(97, 123):
    c = chr(i)
    # シュミレーションする
    t = s
    while True:
        if t.count(c) == len(t):
            ans = min(ans, len(s) - len(t))
            break
        new = ""
        for j in range(len(t) - 1):
            if t[j] == c or t[j + 1] == c:
                new += c
            else:
                new += t[j]
        t = new
print(ans)


Measured memory_bytes: 3060
N = int(input())
*A, = map(int,input().split())
Q = int(input())
BC = [list(map(int,input().split())) for _ in [0]*Q]

cnt = {}
S = sum(A)
for a in A:
    cnt[a] = cnt.get(a,0)+1
for b,c in BC:
    n = cnt.get(b,0)
    S += (c-b)*n
    cnt[b] = 0
    cnt[c] = cnt.get(c,0)+n
    print(S)

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
	while (begin != end) {
		cerr << (*begin) << " ";
		*begin++;
	}
	cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
	for (int i = 0; i < height; i++) {
		for (int j = 0; j < width; j++) {
			cerr << " " << Array[i][j];
		}
		cerr << endl;
	}
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	std::cerr << head << " ";
	print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

const int mod = 1e9+7;

int Pow(int a, int b) {
	int ret = 1;
	while (b > 0) {
		if (b & 1) {
			ret = (ret % mod) * (a % mod) % mod;
		}
		a = (a % mod) * (a % mod) % mod;
		b /= 2;
	}

	return ret % mod;
}

int nCk(int n, int k) {
	int bunbo = 1, bunshi = 1;
	for (int ki = 1; ki <= k; ki++) {
		bunbo *= ki;
		bunshi *= n - ki + 1;
		bunbo %= mod;
		bunshi %= mod;
	}

	return bunshi * Pow(bunbo, mod - 2) % mod;
}

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

	int ans = Pow(2, n) - 1;
	ans -= nCk(n, a);
	ans %= mod;
	ans -= nCk(n, b);
	ans %= mod;

	ans = ((ans % mod) + mod) % mod;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int i,n,x[1001],y=0;
    double a=0,alpha,m;

    for(i=0;; i++)
    {
    scanf("%d",&n);
        if(n!=0)
        {
            a=0;y=0;
            for(i=0; i<n; i++)
            {
                scanf("%d",&x[i]);
                y=y+x[i];
            }
            m=(double)y/n;
    //printf("%.8lf\n",m);
    for(i=0;i<n;i++)
        a=a+((x[i]-m)*(x[i]-m));
    alpha=sqrt(a/n);
    printf("%.8lf\n",alpha);
    continue;
        }
        else if(n==0)
            break;
    }
    return 0;

}




Measured memory_bytes: 2064
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<functional>

using namespace std;

long long gcd(long long a, long long b)
{
	while (b)
	{
		a %= b;

		long long temp = a;
		a = b;
		b = temp;
	}

	return a;
}

int main()
{
	//freopen("input.txt", "r", stdin);

	int n;
	long long sol = 0;

	scanf("%d", &n);

	long long arr[1000001];

	scanf("%lld", &arr[0]);

	long long tot = arr[0];

	for (int i = 1; i < n; i++)
	{
		scanf("%lld", &arr[i]);

		tot = gcd(tot, arr[i]);
	}

	if (tot != 1)
	{
		printf("not coprime\n");

		return 0;
	}

	vector<long long> prime = { 2 };

	for (long long i = 3; i < 1000; i += 2)
	{
		bool isprime = true;

		for (int j = 0; j < prime.size() && prime[j] * prime[j] <= i; j++)
		{
			if (!(i%prime[j]))
			{
				isprime = false;

				break;
			}
		}

		if (isprime)
		{
			prime.push_back(i);
		}
	}

	set<long long> list;

	for (int i = 0; i < n; i++)
	{
		long long temp = arr[i];

		for (int j = 0; j < prime.size() && prime[j] <= temp; j++)
		{
			if (!(temp%prime[j]))
			{
				set<long long>::iterator ret = list.find(prime[j]);

				if (ret != list.end())
				{
					printf("setwise coprime\n");

					return 0;
				}

				list.insert(prime[j]);

				while (!(temp%prime[j]))
				{
					temp /= prime[j];
				}
			}
		}

		if (temp != 1)
		{
			set<long long>::iterator ret = list.find(temp);

			if (ret != list.end())
			{
				printf("setwise coprime\n");

				return 0;
			}

			list.insert(temp);
		}
	}

	printf("pairwise coprime\n");

	return 0;
}

Measured memory_bytes: 10996
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author rn-sshawish
 */
public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long first = input.nextLong();
        long secand = input.nextLong();
        int count = 0;
        while (first <= secand) {
            count++;
            first*=2;
        }
        System.out.println(count);
        

    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    bool same = true;
    for(int i = 0; i < (int)s.size(); i++) {
        if(s[i] != t[i]) same = false;
    }

    if(same) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto A = H.iota.map!(_ => readln.chomp).array;
    auto B = new int[][](H, W);
    auto C = new int[][](H, W-1);
    foreach (i; 0..H) foreach (j; 0..W-1) C[i][j] = A[i][j] == A[i][j+1];

    fill(B[H-1], 1); B[H-1][W-1] = 0;
    for (int j = 0; j < W - 1; j++) {
        for (int i = H - 2; i >= 0; i--) {
            if (C[i+1][j] == C[i][j]) B[i][j] = B[i+1][j] + 1;
            else B[i][j] = 1;
        }
    }

    
    int ans = max(H, W);
    
    foreach (i; 0..H) {
        DList!(Tuple!(int, int)) stack;
        foreach (j; 0..W) {
            if (stack.empty || stack.back[1] < B[i][j]) {
                stack.insertBack(tuple(j, B[i][j]));
            } else {
                int pos = j;
                while (!stack.empty && stack.back[1] > B[i][j]) {
                    int area = (j - stack.back[0] + 1) * stack.back[1];
                    ans = max(ans, area);
                    pos = stack.back[0];
                    stack.removeBack;
                }
                stack.insertBack(tuple(pos, B[i][j]));
            }
        }
    }

    ans.writeln;
}


Measured memory_bytes: 43132
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>     // std::vector
using namespace std;

int main(void){
    int num,a[4],i;
    cin >> num;
    
    a[0] = (num % 10); num /= 10;
    a[1] = (num % 10); num /= 10;
    a[2] = (num % 10); num /= 10;
    a[3] = (num % 10); num /= 10;

    if(a[0]==a[1] && a[1]==a[2] && a[2]==a[0]){
        cout << "Yes" << endl;
    }else if(a[3]==a[1] && a[1]==a[2] && a[2]==a[3]){
        cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int rate = 0;
  cin >> rate;
  if(rate>=2800){
    cout << "AGC" << endl;
  }else if(rate>=1200){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256