akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int L, R;
  int ans = 2018;
  cin >> L >> R;
  bool flag = false;
  repi(i, L, R+1){
    repi(j, i+1, R+1){
      int l = i % 2019;
      int r = j % 2019;
      ans = min((l*r)%2019, ans);
      if (ans==0){
        flag=true;
        break;
      }
    }
    if (flag==true) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
int main(){

  char s[27];
  int i,j;

  scanf("%s",s);

  for(i	= 0; s[i+1] != '\0'; i++){

    for(j = i+1; s[j] != '\0'; j++){

      if(s[i] == s[j]){

        printf("no\n");
        return 0;

      }

    }

  }

  printf("yes\n");

  return 0;

}






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

typedef long long ll;

ll dfs(ll x, bool a, bool b, bool c, ll n) {
    if (x > n) return 0;

    ll res = 0;

    if (x <= n && x != 0 && a && b && c) res++;

    res += dfs(10*x+3, true, b, c, n);
    res += dfs(10*x+5, a, true, c, n);
    res += dfs(10*x+7, a, b, true, n);

    return res;
}

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

    ll ans = dfs(0LL, false, false, false, n);

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = ip(br.readLine());
        int[] s = createListInt(br.readLine());
        int q = ip(br.readLine());
        int[] t = createListInt(br.readLine());
        int count = 0;
        // Arrays.sort(s);
        for (int i = 0; i < q; i++) {
            if (binarySearch(s, t[i])) {
                count++;
            }
        }
        System.out.println(count);
    }

    static boolean binarySearch(int[] a, int key) {
        int left = 0;
        int right = a.length;
        while (left < right) {
            int mid = (left + right) / 2;
            if (a[mid] == key) {
                return true;
            } else if (key < a[mid]) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return false;
    }

    static boolean isNumber(String num) {
        return Pattern.compile("^\\-?[0-9]*\\.?[0-9]+$").matcher(num).find();
    }

    static int[] createListInt(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        int[] list = new int[n];
        while (n-- > 0) {
            list[n] = Integer.parseInt(lines[n]);
        }
        return list;
    }

    static long[] createListLong(String line) {
        String[] lines = line.split(" ");
        int n = lines.length;
        long[] list = new long[n];
        while (n-- > 0) {
            list[n] = Long.parseLong(lines[n]);
        }
        return list;
    }

    static int ip(String s) {
        return Integer.parseInt(s);
    }

    static long lp(String s) {
        return Long.parseLong(s);
    }
}

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < n - 1; i++){
        if (s[i] != s[i + 1]) cnt++;
        else ans++;
    }
    ans += min(cnt / 2, k) * 2;
    k -= cnt / 2;
    cnt = cnt % 2;
    if (k >= 1 && cnt) ans++;
    cout << ans << endl;
}

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

MOD = 10 ** 9 + 7

s = input()

ans = 0
ans += 1 if 0 < int(s[:2]) < 13 else 0
ans += 2 if 0 < int(s[2:]) < 13 else 0

if ans == 0:
    print('NA')
elif ans == 1:
    print('MMYY')
elif ans == 2:
    print('YYMM')
elif ans == 3:
    print('AMBIGUOUS')




Measured memory_bytes: 2940
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/




int main() {

int N;
cin>>N;
int count[4];
rep(i,4){
  count[i]=0;
}
rep(i,N){
  string s;
  cin>>s;
  if(s=="AC"){
    count[0]++;
  }
  else if(s=="WA"){
    count[1]++;
  }
  else if(s=="TLE"){
    count[2]++;
  }
  else{
    count[3]++;
  }
}
cout<<"AC x "<<count[0]<<endl;
cout<<"WA x "<<count[1]<<endl;
cout<<"TLE x "<<count[2]<<endl;
cout<<"RE x "<<count[3]<<endl;

return 0;
}

Measured memory_bytes: 3628
L = input()
mod = 10 ** 9 + 7

dp = [[0] * 2 for _ in range(len(L)+1)]
dp[0][0] = 1
for i in range(len(L)):
    for smaller in range(1):
        bit = int(L[i])
        dp[i+1][0] = (dp[i][0] * (1 + bit)) % mod
        dp[i+1][1] = (dp[i][0] * bit + dp[i][1] * 3) % mod

print(sum(dp[-1]) % mod)


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

int main(){
    string s;
    cin >>s;
    int l = s.length();
    int count = 1;
    vector<string> ss(2);
    ss[0]=s[0];
    rep(i,1,l){
        ss[1] += s[i];
        if(ss[0] != ss[1]){
            ss[0] = ss[1];
            ss[1] = "";
            count++;
        }
    }
    cout<<count<<endl;
    
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll a[3][3];rep(i,0,3)rep(j,0,3)cin>>a[i][j];
  ll n;cin>>n;
  bool check[3][3];CLR(check,false);

  rep(k,0,n){
    ll b;cin>>b;
    rep(i,0,3){
      rep(j,0,3)if(a[i][j]==b){
        check[i][j]=true;
      }
    }
  }

  rep(i,0,3){
    bool e=true;
    rep(j,0,3){
      if(!check[i][j])e=false;
    }
    if(e){
      out("Yes");
      return 0;
    }
  }
  rep(j,0,3){
    bool e=true;
    rep(i,0,3){
      if(!check[i][j])e=false;
    }
    if(e){
      out("Yes");
      return 0;
    }
  }
  if((check[0][0]&&check[1][1]&&check[2][2])||(check[2][0]&&check[1][1]&&check[0][2]))out("Yes");
  else out("No");


  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
// #define MOD ll(1e9) + 7
#define ll long long
const double PI = atan(1.0) * 4;
// const int N = 1e5 + 5 ;
// const ll INF = (int)1e9 ;
const int dx[4] = { -1, 0, 1, 0} ;
const int dy[4] = {0, -1, 0, 1} ;
// const ll INF = (ll)2e18 + 50;
const ll INF = 1e9 ;
const ll MOD = 1e9 + 7 ;


ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a % MOD ;
		a =  a * a % MOD ;
		e /= 2 ;
	}
	return res ;
}
vector<int> complement(const vector<int> &vec) {
	int n = vec.size() ;
	vector<bool> occur(n + 1 , true) ;
	vector<int> ans ;
	for (int i = 0 ; i < (int)vec.size() ; i++) {
		occur[vec[i]] = false ;
	}
	for (int i = 1 ; i <= n ; i++) {
		if (occur[i]) ans.push_back(i) ;
	}
	return ans ;
}

ll intlog(double base, double x) {
	return (ll)(log(x) / log(base));
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t ;
	// cin >> t;
	// while (t--) {
	int x ;
	cin >> x ;
	for (int k = 1 ;  ; k++) {
		if (k * x % 360 == 0) {
			cout << k << "\n";
			return 0 ;
		}
	}



	// }

	// return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
#define print(a) printf("%d",a)
#define sc1(a) scanf("%d",&a)
using namespace std;

typedef unsigned long  ull;
typedef long long int lli;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0);
	
	string s;
	cin>>s;
	
	int a=0,b=0;
	for(int i=0;i<3;++i)
	{
		if (s[i]=='A') ++a;
		else ++b;
	}	
	if (a==3 || b==3) cout<<"No\n";
	else cout<<"Yes\n";
		

 return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    vector<int>v(n),a(n);
    rep(i,n)cin >> v[i],v[i]--,a[v[i]]=i;
    int cnt = 1;
    int tmp = a[0];
    int mx = 0;
    for(int i=1;i<n;i++){
        if(tmp<a[i]){
            cnt++;
            tmp = a[i];
        }else{
            mx = max(mx,cnt);
            cnt = 1;
            tmp = a[i];
        }
    }
    mx =max(mx,cnt);
    cout << n-mx << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
list_FF = []

for i in range(N):
  list_F = list(map(int, input().split()))
  list_FF.append(list_F)

list_PP = []

for i in range(N):
  list_P = list(map(int, input().split()))
  list_PP.append(list_P)  
  
count = 1
quota = 0

for i in range(N):
  quota+= list_PP[i][list_FF[i].count(1)]

maxquota = quota
    
while count < 2** 10:
  l = list(bin(count))
  lc_tdc = l[2:]
  l_tdc = []
  while lc_tdc:
    l_tdc.append(int(lc_tdc.pop(0)))
  
  while len(l_tdc) < 10:
    l_tdc.insert(0, 0)

  quota = 0
  
  for i in range(N):
    corresp = 0
    for j in range(10):
      corresp+= l_tdc[j]* list_FF[i][j]
    quota+= list_PP[i][corresp]
  maxquota = max(quota, maxquota)
      
  count+= 1

print(maxquota)

Measured memory_bytes: 3188
#include <stdio.h>
#define mod 1000000007

int main(void) {

	long long n, k, ans = 0;

	scanf("%lld%lld", &n, &k);

	for (; k <= n + 1; k++) {
		ans += (n - k + 1) * k + 1;
		ans %= mod;
	}
	printf("%lld\n", ans);


	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h, w;
	cin >> h >> w;
	int ch, cw;
	cin >> ch >> cw;
	int dh, dw;
	cin >> dh >> dw;
	map<ii, int> grid;
	for (int i = 0 ; i < h ; i++) {
		string li;
		cin >> li;
		for (int j = 0 ; j < li.size() ; j++) {
			if (li[j] == '.')
				grid[make_pair(i,j)] = 1e7;
		}
	}
	grid[make_pair(ch-1,cw-1)] = 0;
	set<ii> visited;
	vector<vector<bool>> can(h, vector<bool>(w));
	for (auto g : grid) {
		can[g.first.first][g.first.second] = true;
	}
	vector<ii> close;
	close.emplace_back(ch-1, cw-1);
	list<ii> far;
	while (!close.empty() || !far.empty()) {
		ii a;
		if (!close.empty()) {
			a = close.back();
			close.pop_back();
		} else {
			a = far.front();
			far.pop_front();
		}
		if (visited.count(a))
			continue;
		visited.insert(a);
		can[a.first][a.second] = false;
		ii t;
		t = make_pair(a.first - 1, a.second);
		if (t.first > -1 && t.first < h && t.second > -1 && t.second < w && can[t.first][t.second] && 
				!visited.count(t) && grid.count(t) && grid[t] > grid[a]) {
			grid[t] = grid[a];
			close.push_back(t);
		}
		t = make_pair(a.first + 1, a.second);
		if (t.first > -1 && t.first < h && t.second > -1 && t.second < w && can[t.first][t.second] && 
				!visited.count(t) && grid.count(t) && grid[t] > grid[a]) {
			grid[t] = grid[a];
			close.push_back(t);
		}
		t = make_pair(a.first, a.second - 1);
		if (t.first > -1 && t.first < h && t.second > -1 && t.second < w && can[t.first][t.second] && 
				!visited.count(t) && grid.count(t) && grid[t] > grid[a]) {
			grid[t] = grid[a];
			close.push_back(t);
		}
		t = make_pair(a.first, a.second + 1);
		if (t.first > -1 && t.first < h && t.second > -1 && t.second < w && can[t.first][t.second] && 
				!visited.count(t) && grid.count(t) && grid[t] > grid[a]) {
			grid[t] = grid[a];
			close.push_back(t);
		}
		for (int i = -2 ; i < 3 ; i++) {
			for (int j = -2 ; j < 3 ; j++) {
				ii t = make_pair(a.first - i, a.second - j);
				if (t.first > -1 && t.first < h && t.second > -1 && t.second < w && can[t.first][t.second] && 
					!visited.count(t) && grid.count(t) && grid[t] > grid[a] + 1) {
					grid[t] = grid[a] + 1;
					far.push_back(t);
				}
			}
		}
	}
	if (grid[make_pair(dh-1,dw-1)] == 1e7)
		cout << -1 << "\n";
	else
		cout << grid[make_pair(dh-1,dw-1)] << "\n";
	return 0;
}



Measured memory_bytes: 58564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n+1];
    rep(i,1,n){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    bool dp[2][n+2][k];
    rep(i,0,1){
        rep(j,0,n+1){
            rep(K,0,k-1){
                dp[i][j][K]=false;
            }
        }
    }
    rep(i,1,k-1){
        dp[0][0][i]=false;
        dp[1][n+1][i]=false;
    }
    dp[0][0][0]=true;
    dp[1][n+1][0]=true;
    rep(i,1,n){
        rep(j,0,k-1){
            if(j-a[i]<0){
                if(dp[0][i-1][j])dp[0][i][j]=true;
            }else{
                if(dp[0][i-1][j] || dp[0][i-1][j-a[i]])dp[0][i][j]=true;
            }
        }
    }
    for(ll i=n;i>=1;i--){
        rep(j,0,k-1){
            if(j-a[i]<0){
                if(dp[1][i+1][j])dp[1][i][j]=true;
            }else{
                if(dp[1][i+1][j] || dp[1][i+1][j-a[i]])dp[1][i][j]=true;
            }
        }
    }
    ll ans=n;
    rep(i,1,n){
        ll now=0;
        bool bol=false;
        for(ll j=k-1;j>=0;j--){
            if(!dp[1][i+1][j])continue;
            rep(K,max(now,k-j-a[i]),k-j-1){
                if(dp[0][i-1][K])bol=true;
            }
            now=k-j;
        }
        if(bol)ans--;
    }
    cout<<ans<<endl;
    
    return 0;
}





Measured memory_bytes: 52460
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

bool judge(int A, int B, int C, int D) {
    if (B > A) return false;
    if (B > D) return false;
    if (C >= B) return true;
    int G = __gcd(B, D);
    int temp = B + (A % G) - G;
    return temp <= C;
}

signed main() {
    int T;
    cin >> T;
    for (int i = 0; i < T; i++) {
        int A, B, C, D;
        cin >> A >> B >> C >> D;
        cout << (judge(A, B, C, D) ? "Yes" : "No") << endl;
    }

}


Measured memory_bytes: 256
n = int(input())
dp = [[0]*64 for _ in [0]*n]
mod = 10**9+7

A = 0
C = 1
G = 2
T = 3

AGC = 16*A+4*G+C
ACG = 16*A+4*C+G
GAC = 16*G+4*A+C

for j in range(64):
  if j==AGC or j==ACG or j==GAC:
    dp[2][j] = 0
  else:
    dp[2][j] = 1

for i in range(3, n):
  tot = [sum(dp[i-1][k::16]) for k in range(16)]
  for j in range(64):
    c1 = j//16
    c2 = j//4%4
    c3 = j%4
    d = tot[j//4]

    if j==AGC or j==ACG or j==GAC:
      d = 0
    elif c2==G and c3==C:
      d -= dp[i-1][c1*4+G]
    elif c1==G and c3==C:
      d -= dp[i-1][G*4+c2]
    dp[i][j] = d % mod

print(sum(dp[-1]) % mod)

Measured memory_bytes: 9288
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  ll n,m;
  cin>>n>>m;
  if (min(n,m)==1) {
    if (max(n,m)!=1) {
      cout<<max(m,n)-2<<endl;
    }
    else{
      cout<<1<<endl;
    }
  }
  else{
    cout<<(n-2)*(m-2)<<endl;
  }
}

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

void fnInput(string& rsLine)
{
  int nSize;
  cin >> nSize;
  cin >> rsLine;
}

int fnAttention(const string& cnrsLine)
{
  int nCumlSum = 0;
  for (int i = 1; i < cnrsLine.size(); i++)
    if (cnrsLine[i] == 'E')  nCumlSum++;

  int nMinSum = nCumlSum;
  for (int i = 1; i < cnrsLine.size(); i++)
  {
    if (cnrsLine[i - 1] == 'W')  nCumlSum++;
    if (cnrsLine[i]     == 'E')  nCumlSum--;

    nMinSum = min(nMinSum, nCumlSum);
  }
  return nMinSum;
}
    
int main()
{
  string sLine;
  
  fnInput(sLine);
  cout << fnAttention(sLine) << endl;

  return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  string s;
  cin>>s;
  int m=s.size();
  rep(j,m){
    s.pop_back();
    bool ok=true;
    int n=s.size();
    if(n%2==1)continue;
    rep(i,n/2){
      if(s[i]!=s[n/2+i])ok=false;
    }
    if(ok){
      cout<<n<<endl;
      return(0);
    }
  }
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    ll ans = 0, n;
    cin >> n;
    ll a[n+2] = {};
    forn(i, 1, 101){
        forn(j, 1, 101){
            forn(k, 1, 101){
                ll z = i*i + j*j + k*k + i*j + j*k + k*i;
                if(z<=n){
                    a[z]++;
                }
            }
        }
    }
    forn(i, 1, n+1){
        cout<<a[i]<<endl;
    }
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

signed main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <lli> ar(n);
	lli sum = 0;
	
	for(lli &x: ar){
		cin >> x;
		sum += abs(x);
	}

	int last_minus = -1;
	int first_minus = -1;
	bool on_minus = 0;
	for(int i=0; i<n; i++){
		if(ar[i] <= 0){
			if(first_minus == -1)
				first_minus = i;
			if(!on_minus){
				on_minus = 1;
			}else{
				on_minus = 0;
				last_minus = i;
			}
		}
	}

	if(!on_minus){
		cout << sum;
		return 0;
	}

	lli mn = LLONG_MAX;
	for(int i=0; i<n; i++){
		mn = min(mn, abs(ar[i]));
	}

	cout << sum - 2*mn;
	return 0;
}	

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    int ans = 0;
    for (int i = 0; i < N-1; i++) {
        if (S[i] == S[i+1]) {
            ans++;
        }
    }
    ans += K * 2;
    ans = min(ans, N - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b="kstnhmyr";
	cin>>a;
	for(int i=0;i<a.size();i+=2){
		if(a[i]>'1')
			cout<<b[a[i]-'2'];
		if(a[i]=='0'){
			if(a[i+1]=='T')
				cout<<"wa";
			if(a[i+1]=='U')
				cout<<"nn";
			if(a[i+1]=='D')
				cout<<"wo";
		}
		else{
			if(a[i+1]=='T')
				cout<<"a";
			if(a[i+1]=='L')
				cout<<"i";
			if(a[i+1]=='U')
				cout<<"u";
			if(a[i+1]=='R')
				cout<<"e";
			if(a[i+1]=='D')
				cout<<"o";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1184
/*
#include <stdio.h>
#include <string.h>

int main()
{
    int n;
    char s[300050];
    scanf("%d%s",&n,s);
    int ans=100000,i,j;
    for(i=0;i<n;i++)
    {
        int t=0;
        for(j=0;j<i;j++)
            if(s[j]=='W')
                t++;
        for(j=i+1;j<n;j++)
            if(s[j]=='E')
                t++;
        if(t<ans)
            ans=t;
    }
    printf("%d\n",ans);
    return 0;
}
*/



#include <stdio.h>

int main()
{
    int n,i,j,ze=0,zw=0;
    char a[300050];
    scanf("%d ",&n);
    for(i=0;i<n;i++)
    {
        scanf("%c",&a[i]);
        if(a[i]=='E')
            ze++;
        else
            zw++;
    }
    a[i]='\0';
    int le=0,lw=0,re=ze,rw=zw,ans=3000000;
    for(i=0;i<n;i++)
    {
        int t;
        if(a[i]=='E')
        {
            t=(re-1)+lw;
            re--;
        }
        if(a[i]=='W')
        {
            t=re+lw;
            lw++;
        }
        if(t<ans)
            ans=t;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<vector>
#include<utility>
#include<map>
#define ll long long
const long double PI = acos(-1);
using namespace std;
void Weak_Man()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main()
{
	Weak_Man();
	int x;
	cin >> x;
	if (x % 1000 == 0)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 1000 - (x % 1000) << endl;
	}
}

Measured memory_bytes: 3144
n = int(input())
A = [int(i) for i in input().split()]

dp = [-1 for i in range(n+50)]
import sys
sys.setrecursionlimit(1000000)
def brute(i):
    if i>=n-1:
        return 0
    if dp[i]!=-1:
        return dp[i]
    ans = 10**10
    if i+1 < n:
        ans = min(ans, abs(A[i] - A[i+1]) + brute(i+1))
    if i+2 < n:
        ans = min(ans, abs(A[i] - A[i+2]) + brute(i+2))
    dp[i] = ans
    return ans

print(brute(0))


Measured memory_bytes: 96656
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		//String word_before = sc.next();
		//int K = sc.nextInt();
		
		int N = sc.nextInt();
		int arr[] = new int[N];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int sum_min =0;

		for (int i = arr[0]; i < arr[N-1]; i++) {
			int sum = 0;
			for (int j = 0; j < arr.length; j++) {
				sum += (i-arr[j])*(i-arr[j]);
			}
			if(sum_min ==0){
				sum_min = sum;
			}else if (sum<sum_min) {
				sum_min=sum;
			}

		}
		
		System.out.println(sum_min);
      	sc.close();
    }
		
		
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int x,a,b;
signed main(){
	cin>>x>>a>>b;
	if(abs(x-a)<abs(x-b))puts("A");
	else puts("B");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;

int ans = 0 ;
string s ;
map<char,int>mp;

int32_t main(){IOS;
     
     cin >> s ;
     mp['A'] = mp['C'] = mp['T'] = mp['G'] = 1 ;
     for(int i=0;i<(int)s.size();i++){
		 if(mp[s[i]]!=1) continue;
		 for(int j=i ; j < (int)s.size();j++){
			 if(mp[s[j]]!=1) break;
			 ans = max(ans,j-i+1);
		 }
	 }
     cout << ans << endl; 
     return 0;
}


Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

V<PLL> ranges;
V<ll> r_idxv;
V<ll> l_idxv;

int main() {
    ll N;
    cin >> N;
    
    for(ll i = 0; i < N; i++) {
        ll l, r;
        cin >> l >> r;
        ranges.emplace_back(l, r);
        l_idxv.push_back(i);
        r_idxv.push_back(i);
    }

    sort(ALL(l_idxv),
         [&](ll i, ll j) { return ranges[i].first > ranges[j].first; });
    sort(ALL(r_idxv),
         [&](ll i, ll j) { return ranges[i].second < ranges[j].second; });

    V<ll> l_sum(N + 1), r_sum(N + 1);
    for(ll i = 0; i < N; i++) {
        l_sum[i + 1] = l_sum[i] + ranges[l_idxv[i]].first;
        r_sum[i + 1] = r_sum[i] - ranges[r_idxv[i]].second;
    }

    ll ans = 0;
    for(ll i = 0; 2 * i < N; i++) {
        for(ll j = 0; j <= 2; j++) {
            ll l_cnt = i + !!(j & 1);
            ll r_cnt = i + !!(j & 2);
            if(l_cnt + r_cnt > N) continue;
            ll tmp = l_sum[l_cnt + 1] + r_sum[r_cnt + 1];
            chmax(ans, 2 * tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5492
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
 
const int MAXN = 1e6 + 10;
 
LL gcd(LL p, LL q) {
    return q ? gcd(q, p % q) : p;
}
vector<int> pm;
int vis[55555];
LL a[55555];
vector<int> f;
int N;
 
const int m = 22;
LL magic[m] = {148491793ll,148492177ll,148492609ll,148493027ll,
148491799ll,148492181ll,148492613ll,148493041ll,1000000007ll,122420729ll,163227661ll,
217636919ll,290182597ll,386910137ll,515880193ll,687840301ll,12357ll,-1ll,-2ll,-3ll,-5ll,-7ll};
 
bool check(LL x) {
    for (int o = 0; o < m; o++) {
        LL ret = a[N] % x;
        LL P = magic[o];
        for (int i = N - 1; i >= 0; i--) {
            ret = (ret * P + a[i]) % x;
        }
        if (ret != 0) return false;
    }
    return true;
}
 
int main(){
    srand(time(NULL));
    N = 33333;
    for (int i = 2; i < N; ) {
        pm.push_back(i);
        for (int j = i; j < N; j += i)
            vis[j] = 1;
        while (i < N && vis[i]) i++;
    }
    // int cnt = 0;
    // for (auto &x:pm) if (x<=10000) cnt++;
    // for (auto &x:pm) if (x<=10) cout << x << ' ';
    // cout << cnt << endl;
    scanf("%d", &N);
    for (int i = N; i >= 0; i--)
        scanf("%lld", &a[i]);
    LL ret = abs(a[N]);
    for (int i = 0; i < N; i++)
        ret = gcd(ret, abs(a[i]));
    for (auto &x : pm) 
        if (ret % x == 0) {
            f.push_back(x);
            vis[x] = 2;
            while (ret % x == 0) ret /= x;
        }
    if (ret != 1) f.push_back(ret);
    for (auto &x : pm) 
        if (x <= N && vis[x] != 2) {
            if (check(x))
                f.push_back(x);
        }
    sort(f.begin(), f.end());
    f.resize(unique(f.begin(), f.end()) - f.begin());
    for (auto &x : f)
        printf("%d\n", x);
    return 0;
}

Measured memory_bytes: 512
<?php
fscanf(STDIN, '%d', $n);
$l = array_map('intval', explode(' ', trim(fgets(STDIN))));
sort($l);

$ans = 0;
for ($i = 0; $i < $n-2; $i++) {
    for ($j = $i+1; $j < $n-1; $j++) {
        if ($l[$j+1] >= $l[$i]+$l[$j]) {
            continue;
        }

        if ($l[$j+1] > abs($l[$i]-$l[$j])) {
            $start = $j + 1;
        } else {
            $left = $j+1;
            $right = $n-1;

            while ($right - $left > 1) {
                $mid = floor(($left + $right) / 2);
                if ($l[$mid] > abs($l[$i]-$l[$j])) $right = $mid;
                else $left = $mid;
            }
            $start = $right;
        }

        if ($l[$n-1] < $l[$i]+$l[$j]) {
            $end = $n -1;
        } else {
            $left = $j+1;
            $right = $n-1;

            while ($right - $left > 1) {
                $mid = floor(($left + $right) / 2);
                if ($l[$mid] < $l[$i]+$l[$j]) $left = $mid;
                else $right = $mid;
            }
            $end = $left;
        }

        $ans += $end - $start + 1;
    }
}
echo $ans.PHP_EOL;

Measured memory_bytes: 4856
H, W = map(int, input().split())
S = [input() for _ in range(H)]

## 下準備(1)：　H*Wマスの周囲を0で囲む
S.insert(0, "0"*W)
S.append("0"*W)
S = ["0" + s + "0" for s in S]
S = [s.replace("#", "1") for s in S]

## 下準備(2): 8方向をforループで回すためのリストを作る
delta_H = [-1, -1, -1, 0, 0, 1, 1, 1]
delta_W = [-1, 0, 1, -1, 1, -1, 0, 1]


## 実行：　一文字ずつ見ていき、"."の場合、周囲8方向の数字を足し算する
S_new = [""]*H

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == ".":
            ans = 0
            
            for k in range(8):
                if S[i + delta_H[k]][j + delta_W[k]] != ".":
                    ans += int(S[i + delta_H[k]][j + delta_W[k]])
                    
            S_new[i-1] += str(ans)
            
        else:
            S_new[i-1] += "#"
            
print(*S_new, sep="\n")

Measured memory_bytes: 9180
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args){
		int i, q, order;
		String key;
		TreeMap<String, Integer> tm = new TreeMap<String, Integer>();
		try (Scanner sc = new Scanner(System.in)) {
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				order = sc.nextInt();
				key = sc.next();
				if(order == 0) {
					tm.put(key, sc.nextInt());
				}else {
					System.out.println(tm.get(key));
				}
			}
		}
	}
}



Measured memory_bytes: 195332
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

ll po2(int x) {
  ll ret = 1;
  rep (i, x) {
    ret *= 2;
  }
  return ret;
}

int main() {
  int n, p;
  scanf("%d %d", &n, &p);
  vi cnt(2, 0);
  rep (i, n) {
    int a;
    scanf("%d", &a);
    cnt[a % 2] += 1;
  }

  ll ans;
  if (cnt[1] == 0) {
    if (p == 1) {
      ans = 0;
    } else {
      ans = po2(n);
    }
  } else {
    ans = po2(n-1);
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 888
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll a, b;
    cin >> a >> b;
    cout << max(0LL, a - 2 * b) << endl;
    return 0;
}


Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3 1
ABC
---+/

void main(string[] args) {
  long N, K;
  readf(" %d %d ", &N, &K);
  --K;

  auto S = readln.chomp;

  import std.ascii;
  (S[0..K] ~ S[K].to!char.toLower.to!char ~ S[K+1..$]).writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[100000];
int res[100000];
int main(){
  int i, x;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=1;i<N;i++){
    res[i] = A[i-1] - res[i-1];
  }
  x = (A[N-1] - res[N-1]) / 2;
  for(i=0;i<N;i++){
    if(i%2==0){
      res[i]+=x;
    }
    else{
      res[i]-=x;
    }
  }
  {
    int KL2GvlyY;
    if(N==0){
      putchar_unlocked('\n');
    }
    else{
      for(KL2GvlyY=0;KL2GvlyY<N-1;KL2GvlyY++){
        wt_L(2*res[KL2GvlyY]);
        wt_L(' ');
      }
      wt_L(2*res[KL2GvlyY]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190708-1

// --- original code ---
// int N, A[1d5];
// 
// int res[1d5];
// {
//   int i, x;
// 
//   rd(N,A(N));
// 
//   rep(i,1,N) res[i] = A[i-1] - res[i-1];
// 
//   x = (A[N-1] - res[N-1]) / 2;
//   rep(i,N) res[i] if[i%2==0, +=, -=] x;
// 
//   wt(2res(N));
// }


Measured memory_bytes: 2048
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num/*, char delim*/)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		int input;
		for (int i = 0; i < num; ++i)
		{
			sstr >> input;
			retval.push_back(input);
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int s_num = GetValue<1>(stream)[0];
	std::vector<int> s = GetValue(stream, s_num);
	int t_num = GetValue<1>(stream)[0];

	std::sort(s.begin(), s.end());
	int count = 0;
	int t;

	for (int i = 0; i < t_num; ++i)
	{
		stream >> t;
		if (std::binary_search(s.begin(), s.end(), t))
		{
			++count;
		}
	}

	std::cout << count << std::endl;
}



Measured memory_bytes: 3336
/* 
    @author : srinathbalaji_99
*/


#include<bits/stdc++.h>

#define PB push_back
#define MP make_pair
#define endl '\n'
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define rep(i, a, b, inc) for(long long i = a; i < b; i += inc)
#define REP(i, n) rep(i, 0, n, 1)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define PLL pair<long long, long long>
#define VL vector<long long>
#define VS vector<string>
#define VLL vector<PLL>
#define VVL vector<VL>
#define MPLL map<long long, long long>
#define UMPLL unordered_map<long long, long long>
#define SETL set<long long>
#define MSETL multiset<long long>
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) (a * b)/GCD(a, b)
#define ff first
#define ss second
#define pall(a) REP(i, sizeof(a)/sizeof(a[0]))cout << a[i] << " ";cout << endl;
#define pvall(v) REP(i, v.size())cout << v[i] << " ";cout << endl;
#define gall(a, n) REP(i, n)cin >> a[i];
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;


using namespace std;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

VL adj[100001];
LL indeg[100001], dist[100001];
bool vis[100001];

void dfs(LL i){
    vis[i] = true;
    REP(j, adj[i].size()){
        dist[adj[i][j]] = max(dist[adj[i][j]], dist[i] + 1);
        indeg[adj[i][j]]--;
        if(indeg[adj[i][j]] == 0){
            dfs(adj[i][j]);
        }     
    }
}

int main()
{
    fast();

    LL t,n,i,j,k,x,y,c,m;
    cin >> n >> m;
    MEM(dist, 0);
    MEM(indeg, 0);
    MEM(vis, false);
    REP(i, m){
        cin >> x >> y;
        adj[x].PB(y);
        indeg[y]++;
    }
    rep(i, 1, n + 1, 1){
        if(!indeg[i] && !vis[i]){
            dfs(i);
        }
    }
    cout << *max_element(dist, dist + 100001);
}

Measured memory_bytes: 12032
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

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

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
constexpr int MOD = 1e9+7;

string a, b, c;
ll dp[51][3];

int main() {

  while(cin >> a) {
    if(a == "0") break;
    cin >> b >> c;
    reverse(all(a));
    reverse(all(b));
    reverse(all(c));
    int n = a.size();
    vector<vector<int>> va(n), vb(n), vc(n);
    rep(i, n) {
      if(a[i] == '?')
        REP(k, i==n-1, 10) va[i].push_back(k);
      else
        va[i].push_back(a[i]-'0');

      if(b[i] == '?')
        REP(k, i==n-1, 10) vb[i].push_back(k);
      else
        vb[i].push_back(b[i]-'0');

      if(c[i] == '?')
        REP(k, i==n-1, 10) vc[i].push_back(k);
      else
        vc[i].push_back(c[i]-'0');
    }

    zero(dp);
    dp[0][0] = 1;

    rep(i, n) rep(carry, 3) {
      for(auto& da: va[i]) for(auto& db: vb[i]) for(auto& dc: vc[i]) {
        int num = (da + db + carry) % 10;
        int ncr = (da + db + carry) / 10;
        if(num == dc) {
          dp[i+1][ncr] += dp[i][carry];
          dp[i+1][ncr] %= MOD;
        }
      }
    }

    cout << dp[n][0] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	fast;
	int t=1;
	while(t--)
	{
		int k;
		cin >> k;
		int cnt=0;
		for(int i=1;i<=k;i++)
		{
			for(int j=1;j<=k;j++)
			{
				for(int r=1;r<=k;r++)
				{
					cnt+=(__gcd(i,__gcd(j,r)));	
				}
			}
		}
		cout << cnt;
	}
}




Measured memory_bytes: 3604
import java.io.*;
class Main{
  public static void main(String args[]) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    int a[]=new int[n];
    String input = br.readLine();
    String b[]=input.split(" ");
    for(int i=0;i<a.length;i++){
      a[i]=Integer.parseInt(b[i]);
    }
    int sum=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        sum = sum+(a[i]*a[j]);
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

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

	ll ans = N / (A + B) * A;
	ans += min(N - N / (A + B) * (A + B), A);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        if(x<y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}


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

int main(){
	int n , r;	
	while(cin>>n>>r,n|r){
		vector< pair<int,int> > v(r);
		vector<int> h(n);
		for(int i=0;i<n;++i){
			h[i]=n-i;
		}
		for(int i=0;i<r;++i){
			int p , c;
			cin >> p >> c;
			rotate(h.begin() , h.begin()+p-1 , h.begin()+p-1+c);
		}
		cout << h[0] << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

vector<ll> len;
vector<ll> np;

ll solve(ll n, ll x){
    if(n == 0){
        return (ll)(x > 0);
    }else if(x < len.at(n - 1) + 2){
        return solve(n - 1, x - 1);
    }else{
        return np.at(n - 1) + 1 +
            solve(n - 1, x - len.at(n - 1) - 2);
    }
}

int main(){
    ll n, x;
    cin >> n >> x;
    len.resize(n + 1, 1);
    np.resize(n + 1, 1);
    for(int i = 1; i <= n; ++i){
        len.at(i) = 2 * len.at(i - 1) + 3;
        np.at(i) = 2 * np.at(i - 1) + 1;
    }
    cout << solve(n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
ll sum=0,n;
ll a[maxn],b[maxn],c[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i=0;i<=n;i++){
        c[i]=b[i]*(b[i]-1)/2;
        sum+=c[i];
    }
    for(int i=1;i<=n;i++){
        cout<<sum-b[a[i]]+1<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum;
}


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

int main() {
    string S;
    cin >> S;
    if(S.at(2)==S.at(3) && S.at(4) == S.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  a,b = map(int,input().split())
  if b != 100:
    print(100**a*b)
  else:
    print(100**a + b**(a+1))
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940