akhauriyash/Code-Regression huggingface dataset:
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


s = data()
answer = 0
for i in s:
    answer += int(i)
    answer %= 9
if answer == 0:
    out("Yes")
    exit()
out("No")


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

int main(){
    int n,p; cin >> n >> p;
    int e = 0, o = 0;
    for(int i = 0; i < n; i++){
        int b; cin >> b;
        if(b%2 == 1) o++;
        else e++;
    }
    if(o == 0){

        if(p == 0) printf("%ld\n", (ll)pow(2, n));
        else cout << 0 << endl;
    }else{
        printf("%ld\n", (ll)pow(2, n-1));
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

const int N = 5011;
const long long oo = 1e18;

int n,sz[N];
vector <int> e[N],children[N];
long long a[N],f[N][N],w[N],tmp[N];
bool g[N][N],g1[N];

void dfs(int u,int p = 0){
    w[u] = a[u];
    sz[u] = 1;
    
    for(auto &v : e[u]){
        if(v == p) continue;
        dfs(v,u);
        w[u] += w[v];
        children[u].push_back(v);
        sz[u] += sz[v];
    }
    
    f[u][0] = w[u];

    if(sz[u] <= 1){
        g[u][0] = a[u] > 0;
    }else{
        int c = 0;
        tmp[0] = a[u];
        g1[0] = a[u] > 0;
        for(int i = 0; i <= sz[i]; ++i) f[u][i] = oo;

        for(auto &v: children[u]){
            for(int i = 0; i <= c + sz[v]; ++i) f[u][i] = oo,g[u][i] = 0;

            for(int i = 0; i <= c; ++i){
                for(int j = 0; j <= sz[v]; ++j){
                    f[u][i + j] = min(f[u][i + j],tmp[i] + f[v][j]);
                    if(!g[u][i + j]) g[u][i + j] = (g1[i] && g[v][j]);
                }
            }
            c += sz[v];
            for(int i = 0; i <= c + sz[v]; ++i) tmp[i] = f[u][i],g1[i] = g[u][i];
        }
    }
    
    f[u][sz[u]] = oo;
    g[u][sz[u]] = 0;
    for(int i = sz[u] - 1; i >= 0; --i){
        if(f[u][i] < 0 || g[u][i]){
            f[u][i + 1] = min(f[u][i + 1],0LL);
            g[u][i + 1] = 1;
        }
    }

    /*for(int i = 0; i <= sz[u]; ++i){
        cout << "f["<<u<<"]["<<i<<"] = " << f[u][i] << endl;
        cout << "g["<<u<<"]["<<i<<"] = " << g[u][i] << endl;
    }*/
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();

    cin >> n;

    for(int i = 1; i <= n; ++i) cin >> a[i];

    for(int i = 1; i < n; ++i){
        int u,v;
        cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    dfs(1);

    for(int i = 0; i < n; ++i){
        if(f[1][i] < 0 || g[1][i]){
            cout << i;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 221184
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static int n = 26, d;
	static int[] c;
	static int[][] s;

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		d = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = Integer.parseInt(sa[i]);
		}
		s = new int[d][n];
		for (int i = 0; i < d; i++) {
			sa = br.readLine().split(" ");
			for (int j = 0; j < n; j++) {
				s[i][j] = Integer.parseInt(sa[j]);
			}
		}
		br.close();

		int[] t = new int[d];
		int[] last = new int[n];
		for (int i = 0; i < d; i++) {
			int max = -1;
			int idx = -1;
			for (int j = 0; j < n; j++) {
				int val = s[i][j] + c[j] * (i + 1 - last[j]);
				if (val > max) {
					max = val;
					idx = j;
				}
			}
			t[i] = idx;
		}

		while (System.currentTimeMillis() - start < 1800) {
			for (int i = 0; i < d; i++) {
				int max = Integer.MIN_VALUE;
				int idx = t[i];
				for (int j = 0; j < n; j++) {
					t[i] = j;
					int val = calc(t, i);
					if (val > max) {
						max = val;
						idx = j;
					}
				}
				t[i] = idx;
			}
		}

		for (int i = 0; i < d; i++) {
			System.out.println(t[i] + 1);
		}
	}

	static int calc(int[] t, int end) {
		int[] last = new int[n];
		int ret = 0;
		for (int i = 0; i <= end; i++) {
			ret += s[i][t[i]];
			last[t[i]] = i + 1;
			for (int j = 0; j < n; j++) {
				ret -= c[j] * (i + 1 - last[j]);
			}
		}
		return ret;
	}

//	static int[] calc(int[] t, int end) {
//		int[] last = new int[n];
//		int[] ret = new int[end];
//		for (int i = 0; i < end; i++) {
//			if (i > 0) {
//				ret[i] += ret[i - 1];
//			}
//			ret[i] += s[i][t[i]];
//			last[t[i]] = i + 1;
//			for (int j = 0; j < n; j++) {
//				ret[i] -= c[j] * (i + 1 - last[j]);
//			}
//		}
//		return ret;
//	}
}


Measured memory_bytes: 52636
#include <stdio.h>
#include <stdbool.h>

#define MAX 300000

bool Trampoline(void);

int d[MAX];
int N;

int main(void) {
  int i, tmp;

  scanf("%d", &N);

  for(i=0; i<N; ++i) {
    scanf("%d", &d[i]);
  }

  if(!Trampoline()) {
    printf("no\n");
    return 0;
  }

  for(i=0; i<N/2; ++i) {
    tmp = d[i];
    d[i] = d[N-1-i];
    d[N-1-i] = tmp;
  }

  if(Trampoline()) printf("yes\n");
  else printf("no\n");

  return 0;
}

bool Trampoline(void) {
  int i, dmax = 0;

  for(i=0; i<N; ++i) {
    if(dmax < 10*i) return false;
    if(dmax < 10*i+d[i]) dmax = 10*i + d[i];
  }

  return true;
}



Measured memory_bytes: 2856
import sys

def solve():
    input = sys.stdin.readline
    mod = 7 + 10 ** 9
    N, M = map(int, input().split())
    S = [int(s) for s in input().split()]
    T = [int(t) for t in input().split()]

    DP = [[0 for j in range(M+1)] for i in range(N + 1)]
    DP[0] = [1] * (M + 1)
    for i in range(1, N + 1): DP[i][0] = 1
    for i in range(N):
        for j in range(M):
            if S[i] == T[j]:
                DP[i+1][j+1] = (DP[i+1][j] + DP[i][j+1]) % mod
            else: 
                DP[i+1][j+1] = (DP[i+1][j] + DP[i][j+1] - DP[i][j]) % mod
    print(DP[N][M])
    return

if __name__ == "__main__":
    solve()

Measured memory_bytes: 74332
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


ll ans=0;

int main(){
	ll A, B;
	cin >> A >> B;
	if(A<10 && B<10){
	ans = A*B;
	}else{
	ans = -1;
	}
	
	cout << ans << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

long long read(){
	long long i;
	cin >> i;
	return i;
}

int main(void){
	vector<pair<int, int> > sets;
	while(1) {
		int n = read();
		int x = read();
		if(n == 0 && x == 0) break;
		sets.push_back(make_pair(n, x));
	}
	REP(i, sets.size()) {
		int n = sets[i].first;
		int x = sets[i].second;
		int count = 0;
		FOR(j, 1, n - 1) {
			FOR(k, j + 1, n) {
				FOR(l, k + 1, n + 1) {
					if (j + k + l == x) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}



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

using namespace std;
int main() {
  int a;
  vector<int> r(4);
  bool cond = true;
  while (cin >> a) {
    ++r[a-1];
    if(r[a-1]>2) cond = false;
  }
  cout << (cond ? "YES" : "NO") << endl;
  return 0;
}


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

int main(){
	std::string s1, s2;
	std::cin >> s1;
	std::cin >> s2;

	std::vector<std::vector<int>> dp(s2.size()+1,std::vector<int>(s1.size()+1));

	for(int j = 0; j < s2.size(); ++j){
		for(int i = 0; i < s1.size(); ++i){
			if(s2[j] == s1[i]){
				if(dp[j][i]+1 > dp[j+1][i+1])
					dp[j+1][i+1] = dp[j][i] + 1;
			}

			if(dp[j+1][i] > dp[j+1][i+1])
				dp[j+1][i+1] = dp[j+1][i];
			if(dp[j][i+1] > dp[j+1][i+1])
				dp[j+1][i+1] = dp[j][i+1];
		}
	}

	int x = s1.size();
	int y = s2.size();
	std::string s = "";

	while(x > 0 && y > 0){
		while(x > 1 && dp[y][x-1] == dp[y][x])
			x -= 1;
		while(y > 1 && dp[y-1][x] == dp[y][x])
			y -= 1;
	
		if(s1[x-1] == s2[y-1] && y > 0)
			s += s2[y-1];
		y--;
	}

	std::reverse(s.begin(), s.end());
	std::cout << s;
}


Measured memory_bytes: 38636
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;

  long long sum = 0;
  vector<bool> k(N,false);
  for(int i = 0;i < K;i++) k.at(i) = true;

  
  for(int i = 0;i < K;i++) {
    bool same = true;
    for(int j = i+K;j < N;j+=K) {
      if(T.at(j) == T.at(j-K)){
        if(!same) {
          same = true;
          k.at(j) = true;
        }else {
          same = false;
        }
      }else {
        k.at(j) = true;
        same = true;
      }
    }
  }

  for(int i = 0;i < N;i++) {
    if(!k.at(i)) continue;
    if(T.at(i) == 'p') sum += S;
    else if(T.at(i) == 's') sum += R;
    else sum += P;
  }

  // for(int i = 0;i < N;i++) {
  //   if(k.at(i)) cout << 1;
  //   else cout << 0;
  // }

 

  cout << sum << endl;
  
}


Measured memory_bytes: 512
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        long X = sc.nextLong();
        int count=0;
        long base=100;
        for(int i=0;true;i++){
            if(base>=X){
                break;
            }
            else{
                base=base+(base/100);
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35804
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	string t="CODEFESTIVAL2016";
	cin>>s;
	ll ret=0;
	REP(i,16) {
		if(s[i]!=t[i]) ++ret;
	}
	cout<<ret<<endl;
}


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

int main()
{
    string s;
    while(cin>>s){
    int a=0;
    for(int i=0;i<s.length();i=i+2){
    	if(s[i]=='h'&&s[i+1]=='i') continue;
		else a=1; 
	}
	if(a==1) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

void solve()
{
    vector<int> ar(5);
    for(auto &i:ar)
        cin>>i;
    for(int i=0;i<5;i++)
    {
        if(ar[i]==0)
        {
            cout<<i+1;
            return ;
        }
    }
}
int32_t main()
{
    
    //_READ
    
    int t;
    t=1;
    while(t--)
        solve();

    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string A,B,C;
    cin >> A >> B >> C;
    if(A[A.size()-1]==B[0]&&B[B.size()-1]==C[0]){
      cout << "YES";
    }else{
      cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize 03
#pragma GCC optimize ("unroll-loops")
#define int long long
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
const int N = 2e6 + 2e5;
const int inf = 2e9;
const int MOD = 998244353;
const int LogN = 30;

struct vrt {
    int m, min_m, max_m, mn, pos, push_m;
};

vrt m[N];

void recalc(int u) {
    m[u].mn = min(m[2*u + 1].mn, m[2*u + 2].mn);
    m[u].max_m = max(m[2*u + 1].max_m, m[2*u + 2].max_m);
    m[u].min_m = min(m[2*u + 1].min_m, m[2*u + 2].min_m);
}

void push(int u, int vl, int vr) {
    if (m[u].push_m != -1) {
        m[2*u + 1].push_m = m[u].push_m;
        m[2*u + 2].push_m = m[u].push_m;
        m[2*u + 1].min_m = m[u].push_m;
        m[2*u + 2].min_m = m[u].push_m;
        m[2*u + 1].max_m = m[u].push_m;
        m[2*u + 2].max_m = m[u].push_m;
        m[2*u + 1].mn = m[u].push_m - (vl + vr) / 2;
        m[2*u + 2].mn = m[u].push_m - (vr - 1);
        m[u].push_m = -1;
    }
}

void build(int v, int vl, int vr) {
    if (vr - vl == 1) {
        m[v].m = vl;
        m[v].mn = 0;
        m[v].max_m = m[v].min_m = vl;
        m[v].pos = vl;
        m[v].push_m = -1;
    } else {
        build(2*v + 1, vl, (vl + vr) / 2);
        build(2*v + 2, (vl + vr) / 2, vr);
        recalc(v);
        m[v].push_m = -1;
    }
}


void maxupd(int v, int vl, int vr, int from, int mm) {
    if (m[v].min_m >= mm || m[v].max_m < from) {
        return;
    }
    if (m[v].max_m <= mm && m[v].min_m >= from) {
        m[v].push_m = mm;
        m[v].min_m = mm;
        m[v].max_m = mm;
        m[v].mn = mm - (vr - 1);
    } else {
            push(v, vl, vr);
            maxupd(2*v + 1, vl, (vl + vr) / 2, from, mm);
            maxupd(2*v + 2, (vl + vr) / 2, vr, from, mm);
            recalc(v);
        }
}

void solve() {
    int i, j, k, n, h, w, a, b;
    cin >> h >> w;
    build(0, 1, w + 1);
    for (int i = 1; i <= h; ++i) {
        cin >> a >> b;
        int c = (b == w) ? inf : b + 1;
        maxupd(0, 1, w + 1, a, c);
        if (m[0].mn >= inf / 2)
            cout << -1 << "\n";
        else
            cout << m[0].mn + i << "\n";
    }
}

signed main() {
    #ifdef local
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(0);
    solve();
}


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

using namespace std;

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

    int A[N];
    int freq[100001];
    memset(freq, 0, sizeof freq);

    long long int sum=0;
    for(int i=0;i<N;i++)
    {
        cin >> A[i];
        freq[A[i]]++;
        sum+=A[i];
    }

    int Q;
    cin >> Q;

    for(int i=0;i<Q;i++)
    {
        int B, C;
        cin >> B >> C;
        sum=sum+(C-B)*freq[B];
        //cout << freq[C] << " " << freq[B] << endl;
        freq[C]+=freq[B];
        freq[B]=0;
        cout << sum << endl;
    }

}


Measured memory_bytes: 4244
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
  int n, k, s=0;
  cin>>n>>k;
  int a[n+2], i, j;
  for(i=0; i<n; i++)
  {
      cin>>a[i];
  }
  sort(a,a+n);
  for(i=0; i<k; i++)
  {
      s+=a[i];
  }
  cout<<s<<endl;
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

int n;
vector<int> a, num;
map<int, int> mp;

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

  cin >> n;
  a.resize(n);

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (mp[a[i]] == 0) {
      num.push_back(a[i]);
      mp[a[i]]++;
    }
    else {
      mp[a[i]]++;
    }
  }

  int ans = 0;

  for (auto x : num) {
    if (mp[x] > x) {
      ans += mp[x] - x;
    }
    else if (mp[x] < x) {
      ans += mp[x];
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n, ans = 1;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n - 1; ++i)
		ans += (s[i] != s[i + 1] ? 1 : 0);
	cout << ans << '\n';
}


Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int dist[306][306];

int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			scanf("%d", &dist[i][j]);

	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			for (int k = 1; k <= n; k++)
			{
				if (dist[i][j] + dist[j][k] < dist[i][k])
				{
					printf("-1\n");
					return 0;
				}
			}
		}
	}

	i64 ans = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			bool hasMid = false;

			for (int k = 1; k <= n; k++)
			{
				if (k == i || k == j)
					continue;

				if (dist[i][k] + dist[k][j] == dist[i][j])
					hasMid = true;
			}

			if (!hasMid)
				ans += dist[i][j];
		}
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 640
# O(nloglogn) https://mathtrain.jp/eratosthenes
def sieve(n):
	s = [True] * n
	s[0] = s[1] = False
	for x in range(2, int(n ** 0.5) + 1):
		if s[x]:
			for i in range(2 * x, n, x):
				s[i] = False
	return s

is_prime = sieve(10 ** 5 + 1)
is_like2017 = [False] * (10 ** 5 + 1)
for i in range(10**5 + 1):
	if is_prime[i] and is_prime[(i + 1) // 2]:
		is_like2017[i] = True

# 区間内のlike2017を求める
# 累積和を用いて高速化
c = [0] * (10 ** 5 + 1)
for i in range(1, 10 ** 5 + 1):
	if is_like2017[i]:
		c[i] = c[i - 1] + 1
	else:
		c[i] = c[i-1]

# 出力
q = int(input())

for i in range(q):
	l, r = map(int, input().split())
	print(c[r] - c[l-1])


Measured memory_bytes: 53464
import java.util.*;

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

        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long c = a + b;

        long d = n / c;

        if (n % c > a) {
            System.out.println(d * a + a);
        } else {
            System.out.println(d * a + n % c);
        }


    }

}


Measured memory_bytes: 23124
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll INM = 114514;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ld x[3], y[3];
	for (int i = 0; i < 3; i++) {
		cin >> x[i] >> y[i];
	}
	ld A = sqrt(pow(x[2] - x[0], 2) + pow(y[2] - y[0], 2));
	ld B = sqrt(pow(x[2] - x[1], 2) + pow(y[2] - y[1], 2));
	ld C = sqrt(pow(x[0] - x[1], 2) + pow(y[0] - y[1], 2));
	ld a = x[2] - x[0], b = y[2] - y[0];
	ld c = x[1] - x[0], d = y[1] - y[0];
	ld s   = abs(a * d - b * c);
	ld r   = s / (A + B + C);
	ld ans = r * max({A, B, C}) / (2 * r + max({A, B, C}));
	dumpf(ans, 10);
	return 0;
}


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

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const LL MAX_N=1e5;
LL bit[MAX_N+1],n;

LL sum(LL i){
    LL s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}


LL add(LL i,LL x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
    return 0;
}

int main(){
    LL X,K,Q;
    cin>>X>>K;n=K;
    vector<LL>r(K),dr(K);
    REP(i,K)cin>>r[i];
    cin>>Q;
    CLR(bit);
    dr[0]=r[0];
    REP(i,K-1){
        dr[i+1]=r[i+1]-r[i];
    }
    REP(i,K)add(i+1,dr[i]);
    vector<LL>res_m(K+1),res_n(K+1),res_l(K+1),crtdir(K+1);
    //a<=dr[0]のとき
    res_m[0]=X;
    res_n[0]=0;
    res_l[0]=0;
    crtdir[0]=-1;
    LL dir=-1;
    REP(i,K){
        res_n[i+1]=res_n[i]+dir*dr[i];
        res_m[i+1]=max(0LL,min(X,res_m[i]+dir*dr[i]));
        res_l[i+1]=max(0LL,min(X,res_l[i]+dir*dr[i]));
        dir*=-1;
        crtdir[i+1]=dir;
    }
    REP(i,Q){
        LL t,a;
        cin>>t>>a;
        auto itr=upper_bound(r.begin(),r.end(),t);
        int pos=itr-r.begin();
        LL ue=a;
        if(pos==0){
            ue=max(0LL,ue-t);
            cout<<ue<<endl;
        }else{
            //pos--;
            LL diff=t-r[pos-1];
            LL base=max(res_l[pos],min(res_m[pos],a+res_n[pos]));
            cout<<max(0LL,min(X,base+crtdir[pos]*diff))<<endl;
        }
    }
    return 0;
}
/*
100
5
48 141 231 314 425
2
143 30
342 0
*/

Measured memory_bytes: 6656
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int,P> PP;
typedef pair<P, int>PP2;
struct segtree {
	int n = 1;
	vector<int>node, lazy;
	vector<bool>lazyF;
	void init(int N) {
		while (n < N)n *= 2;
		node.resize(2 * n - 1,inf);
		lazy.resize(2 * n - 1);
		lazyF.resize(2 * n - 1, false);
	}
	void eval(int k, int l, int r) {
		if (!lazyF[k])return;
		node[k] = lazy[k];
		if (k < n - 1) {
			for (int i = 1; i <= 2; i++)lazy[2 * k + i] = lazy[k];
			for (int i = 1; i <= 2; i++)lazyF[2 * k + i] = true;
		}
		lazyF[k] = false;
	}
	void update(int a, int b, int x, int k, int l, int r) {
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyF[k] = true;
			eval(k, l, r);
			return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		node[k] = min(node[k * 2 + 1] ,node[k * 2 + 2]);
	}
	int calc(int a, int b, int k, int l, int r) {
		eval(k, l, r);
		if (r <= a || b <= l)return inf;
		if (a <= l && r <= b)return node[k];
		int vl = calc(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = calc(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl , vr);
	}
	void replace(int a, int b, int x) {
		update(a, b, x, 0, 0, n);
	}
	int getmin(int a, int b) {
		return calc(a, b, 0, 0, n);
	}
};
segtree seg,seg2;
int l[100006], r[100006], c[100006];

signed main() {
	int n, m; cin >> n >> m;
	vector<PP>V;
	rep(i, m) {
		cin >> l[i] >> r[i] >> c[i];
		V.push_back(PP(c[i], P(l[i], r[i])));
	}
	sort(V.begin(), V.end());
	/*
	seg.init(n);
	for (int i = m - 1; i >= 0; i--) {
		int C = V[i].first, L = V[i].second.first, R = V[i].second.second;
		seg.replace(L, R, C);
	}
	*/
	vector<PP2>V2;
	rep(i, m) {
		V2.push_back(PP2(P(r[i],l[i]),c[i]));
	}
	sort(V2.begin(), V2.end());
	seg2.init(n);
	seg2.replace(0, 1, 0);
	rep(i, m) {
		int L = V2[i].first.second, R = V2[i].first.first, C = V2[i].second;
		int s = seg2.getmin(L-1, R) + C;
		int now = seg2.getmin(R - 1, R);
		if (now > s) {
			seg2.replace(R - 1, R, s);
		}
	}
	int res = seg2.getmin(n - 1, n);
	if (res == inf)res = -1;
	cout << res << endl;
}

Measured memory_bytes: 11888
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

const int INF = 1000000000;
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

using PP = pair<int, pair<int, int>>;

void solve() {
    int H, W; cin >> H >> W;
    int x0, y0; cin >> x0 >> y0, x0--, y0--;
    int x1, y1; cin >> x1 >> y1, x1--, y1--;
    vector<string> s(H);
    for (int i = 0; i < H; i++) cin >> s[i];

    vector<vector<int>> d(H, vector<int>(W, INF));
    d[x0][y0] = 0;
    priority_queue<PP, vector<PP>, greater<PP>> pq;
    pq.push(make_pair(0, make_pair(x0, y0)));

    while (!pq.empty()) {
        PP pp = pq.top(); pq.pop();
        int cost = pp.first;
        int x = pp.second.first, y = pp.second.second;

        if (d[x][y] < cost) continue;

        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (0 <= nx && nx < H && 0 <= ny && ny < W) {
                if (s[nx][ny] == '.') {
                    if (d[nx][ny] > cost) {
                        d[nx][ny] = cost;
                        pq.push(make_pair(d[nx][ny], make_pair(nx, ny)));
                    }
                }
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (i == 0 && j == 0) continue;
                int nx = x + i, ny = y + j;
                if (0 <= nx && nx < H && 0 <= ny && ny < W) {
                    if (s[nx][ny] == '.') {
                        if (d[nx][ny] > cost + 1) {
                            d[nx][ny] = cost + 1;
                            pq.push(make_pair(d[nx][ny], make_pair(nx, ny)));
                        }
                    }
                }
            }
        }
    }

    if (d[x1][y1] == INF) cout << -1 << '\n';
    else cout << d[x1][y1] << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 8408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;

int main(){
        int A,B,C; cin>>A>>B>>C;
        string ans ="No";
        if(A+B>=C) ans="Yes";
        cout << ans << endl;

        return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define pb push_back
#define bp __builtin_popcount
#define sz size()
#define ff first
#define ss second
#define vll vector<ll>
#define vbool vector<bool>
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vllv vector<vector<ll>>
#define setpri(x) cout<<setprecision(x)<<fixed;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){if(n%x==0)return n/x; else return (n/x)+1;}
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll modinv(ll n,ll mod){
    return pow1(n,mod-2,mod);
}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
    if(a.ff != b.ff)return a.ff < b.ff;
    return a.ss > b.ss;
}
ll n;
string ans[100005];
string s[100004];
void dfs(ll i,ll a,ll b,ll c){
	if(i==n){
		cout<<"Yes\n";
		for(ll j=0;j<n;j++){
			cout<<ans[j]<<endl;
		}
		exit(0);
	}
	if(s[i]=="AB"){
		if(a)ans[i]='B',dfs(i+1,a-1,b+1,c);
		if(b)ans[i]='A',dfs(i+1,a+1,b-1,c);
	}
	if(s[i]=="AC"){
		if(a)ans[i]='C',dfs(i+1,a-1,b,c+1);
		if(c)ans[i]='A',dfs(i+1,a+1,b,c-1);
	}
	if(s[i]=="BC"){
		if(b)ans[i]='C',dfs(i+1,a,b-1,c+1);
		if(c)ans[i]='B',dfs(i+1,a,b+1,c-1);
	}
}
void solve(){
    ll i,j,k,l,m,x,y,z,r;
	
	ll a,b,c;
	cin>>n>>a>>b>>c;
	// vector<string> s(n);
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	dfs(0,a,b,c);
	cout<<"No\n";
	
}
int main(){
    FS;
    ll i,j,k,n,m,x,y,z,q;
    q=1;
    // cin>>q;
    while(q--){
        solve();
    }
    return 0;
}

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

ll GetSum(ll power) {
	vector<ll> v(power + 1, 0);
	v[0] = 1;
	for (ll i = 1; i < (ll)v.size(); i++) {
		v[i] = v[i - 1] * 2;
	}

	return accumulate(v.cbegin(), v.cend(), 0LL);
}

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

	ll power = static_cast<ll>(log2(h));
	cout << GetSum(power) << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<int, int>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	int x, y;
	cin >> x >> y;
	for (int i = 0; i <= x; i++) {
		for (int j = 0; j <= x; j++) {
			if (i + j == x && ((2 * i + 4 * j) == y)) {
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}













Measured memory_bytes: 3596
#include<stdio.h>

int main()
{
  int n;
  int arr[10000];
  int count = 0;
  int t;
  scanf("%d", &n);

  for(int i = 1; i <= n; i++)
    {
      t = i;
      if(t%3 == 0 || t%10 == 3)
	{
	  arr[count] = i;
	  count++;
	}
      else
	{
	  while(t)
	    {
	      t /=10;
	      if(t%10 == 3)
		{
		  arr[count] = i;
		  count++;
		  t = 0;
		}
	    }
	}
    }
  for(int i = 0; i<count; i++)
    {
      printf(" %d", arr[i]);
    }
  printf("\n");
}



Measured memory_bytes: 2140
#include "bits/stdc++.h"

#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,d;
	cin>>n>>d;
	cout << (n + 2 * d) / (2 * d + 1) << endl;
}

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

int main() {
	string t,sub1,sub2;
	while(cin >> t){
		if(t == "-") break;
		int m;
		cin >> m;
		for(int i=0; i<m; i++){
			int n=0;
			cin >> n;
			sub1 = t.substr(0, n);
			sub2 = t.substr(n, t.size()-n);
			t = sub2+sub1;
		}
		cout << t << endl;
		//printf("%s\n", t);
	}
	return 0;
}


Measured memory_bytes: 3184
n=int(input())
a=[int(input()) for _ in range(n)]
ma=max(a)
b=a
for i in range(n):
  if b[i]==ma:
    b[i]=0
    p=i
    break
    
maa=max(b)
A=[]
for i in range(n):
  if i!=p:
    A.append(ma)
  else:
    A.append(maa)
    
for i in range(n):
  print(A[i])


Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forr(i,p,n) for(ll i=p;i<n;i++)
#define tam 1034567
#define offset 1000000000
using namespace std;
typedef long long  ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
string txt;
int ansiz,ansder;
void go(char algo)
{
    int tot=0,iz=0;
    forr(i,0,txt.size())
    {
        if (txt[i]!=algo)
            tot--;
        else
            tot++;
        if (tot<0)
        {
            iz=i+1;
            tot=0;
        }
        else
        {
            if (tot>0&& i-iz>0)
            {
                ansiz=iz+1;
                ansder=i+1;
                //cout<<ansiz<<" "<<ansder<<endl;
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    
    cin>>txt;
    ansiz=ansder=-1;
    forr(i,'a','z'+1)
    {
        go(i);
    }
    cout<<ansiz<<" "<<ansder<<endl;
}


Measured memory_bytes: 512
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  cout << fixed << setprecision(12) << pow(a*a+b*b-2*a*b*cos(M_PI*(60*h-11*m)/360),0.5) << endl;
}


Measured memory_bytes: 4268
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<stdlib.h>
using namespace std;
queue<int> tmp;
const int MAX1=2010,MAX2=200010;
int a[MAX1],s[MAX2],k,sum,fin=2000010;
int main(){
    srand(9949);
    scanf("%d",&k);
    for(int i=0;i<k;i++) scanf("%d",&a[i]),sum+=a[i];
    for(int i=0;i<k;i++){
        for(int j=0;j<k;j++) if(rand()%2) swap(a[i],a[j]);
    }
    tmp.push(0);
    for(int i=0;i<k;i++){
        int l=tmp.size();
        for(int j=0;j<l;j++){
            int t=tmp.front(),l=abs(t-a[i]),r=abs(t+a[i]);
            tmp.pop();
            if(l<=MAX2) if(s[l]==0) s[l]=1,tmp.push(l);
            if(r<=MAX2) if(s[r]==0) s[r]=1,tmp.push(r);
        }
        for(int j=0;j<MAX2;j++) s[j]=0;
    }
    while(!tmp.empty()) fin=min(tmp.front(),fin),tmp.pop();
    printf("%d\n",(sum+fin)/2);
}


Measured memory_bytes: 1408
N, X = map(int, input().split())  # レベルNバーガー, 下からX層食べる

# そのレベルのバーガーにどれだけパティが含まれているかP
# そのレベルのバーガーが何層で成り立っているかA
P = [1]
A = [1]

for i in range(1, N+1):
    P.append(2**(i+1)-1)
    A.append(2**(i+2)-3)

# print(P)
# print(A)


def f(N, X):  # レベルNバーガーの下からX層に含まれる肉の数
    if N == 0:
        return 0 if X <= 0 else 1  # レベル0バーガーは肉1枚という仕様, レベル0バーがーの下から1枚（X > 0）を食べたら肉を1枚食べたことになる, 両方0のときにのみ肉は0
    elif X <= 1 + A[N-1]:  # 下半分の領域について（真ん中の肉にたどりついていない）
        return f(N-1, X-1)
    else:  # 下半分と真ん中の肉を全部食べて、上半分の処理に取り掛かっている
        return P[N-1] + 1 + f(N-1, X-(2+A[N-1]))


print(f(N, X))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
int R, C, N, X1, Y1, X2, Y2;
vector<pair<int, int>>v;
set<int>st;

bool f(int x, int y) {
	if (x == 0 || x == R || y == 0 || y == C)return true;
	else return false;
}
pair<int, int> ff(){
	int a, b;
	if (Y1 == 0) {
		a = X1;
	}
	else if(Y1 == C){
		a = R + C + R - X1;
	}
	else if (X1 == 0) {
		a = R + C + R + C - Y1;
	}
	else if (X1 == R) {
		a = R + Y1;
	}
	if (Y2 == 0) {
		b = X2;
	}
	else if(Y2 == C){
		b = R + C + R - X2;
	}
	else if (X2 == 0) {
		b = R + C + R + C - Y2;
	}
	else if (X2 == R) {
		b = R + Y2;
	}
	
	if (a > b)swap(a, b);
	return mkp(a, b);
}
int main() {
	cin >> R >> C >> N;
	for (int i = 0; i < N; ++i) {
		cin >> X1 >> Y1 >> X2 >> Y2;
		if (f(X1, Y1) && f(X2, Y2)) {
			v.push_back(ff());
		}
	}
	sort(v.begin(), v.end());
	st.insert(-1);
	for (int i = 0; i != v.size(); ++i) {
		auto it = st.insert(v[i].second).first;
		--it;
		if (*it > v[i].first) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 5748
// https://marycore.jp/prog/c-lang/convert-nber-to-char/

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

using ll = long long;

int main() {
   int N, K;
   cin >> N >> K;

   int D[10];
   for (int i = 0; i < K; i++) {
      cin >> D[i];
   }

   ll n = N;
   while (1) {
      string s = to_string(n); // 数字を文字列にする・・・・検索を用意にするため

      bool ok = true; // 嫌いな数字が存在しないならtrue・・・初期設定ではtrueにしておくほうがあとの処理が楽
      // 嫌いな数字の有無を判定
      for (int i = 0; i < K; i++) {
         if (count(s.begin(), s.end(), D[i]+'0')) { //count・・・指定された値と同じ値を取る要素数を調べる D[i]+'0'でintからchar変換
            ok = false;
            n++;
            break;
         }
      }

      // 嫌いな数字が無ければnを出力して終了
      if (ok) {
         cout << n << endl;
         return 0;
      }
   }

   return 0;
}

Measured memory_bytes: 256
import decimal
N=decimal.Decimal(int(input()))
if N%2==1:
    print(0)
else:
    five=decimal.Decimal(5)
    ans=decimal.Decimal(0)
    while(five<N):
        ans+=N//decimal.Decimal(five)//decimal.Decimal(2)
        five*=decimal.Decimal(5)
    print(ans)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD = 998244353;

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

int comb[4001][4001];

void comb_calc(int limit){
	for(int i = 0;i <= limit;i++){
		comb[i][0] = 1;
		comb[i][i] = 1;
	}
	for(int i = 1;i <= limit;i++){
		for(int j = 1;j <= limit;j++){
			comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
		}
	}
}

int cmb(int a,int b){
	if(b >= 0) return comb[a][b];
	else if(a != b) return 0;
	else return 1;
}

signed main(){
	int k,n,ans[4010],dp[2010][2010] = {},sum[2010][2010] = {};
	comb_calc(4000);
	cin >> k >> n;
	dp[0][0] = 1;
	for(int i = 0;i <= n;i++) sum[0][i] = 1;
	for(int i = 0;i < k;i++){
		dp[i + 1][0] = 1;
		sum[i + 1][0] = 1;
		for(int j = 1;j <= n;j++){
			dp[i + 1][j] = (sum[i][j] + sum[i][j - 1]) % MOD;
			sum[i + 1][j] = (sum[i + 1][j - 1] + dp[i + 1][j]) % MOD;
		}
	}
	for(int i = 2;i <= 2 * k;i++){
		if(i > k + 1) cout << ans[2 * k + 2 - i] << endl;
		else{
			for(int j = 0;j <= n;j++) (ans[i] += dp[(i - 1) / 2][j] * cmb(n - j + k - i,k - i)) %= MOD;
			if(i % 2 == 0){
				for(int j = 0;j <= n - 1;j++) (ans[i] += dp[(i - 1) / 2][j] * cmb(n - 1 - j + k - i,k - i)) %= MOD;
			}
			cout << ans[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 188416
#include <stdio.h>

int main() {

  int n;
  char c;
  long int array[10000];
  long int i = 0, max, min;
  long int total;
  
  scanf("%d", &n);
  while(i < 10000) {
    scanf("%ld%c", &array[i], &c);
    i++;
    if(c == '\n')
      break;
  }

  max = array[0];
  min = array[0];
  total = 0;
  for(i = 0; i < n; i++) {
    total += array[i];
    if(max < array[i])
      max = array[i];
    if(min > array[i])
      min = array[i];
  }

  printf("%ld %ld %ld\n", min, max, total);
  
  return 0;
}

Measured memory_bytes: 676
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    switch (S) {
      case "AAA":
      case "BBB":
        System.out.println("No");
        break;
      case "AAB":
      case "ABA":
      case "BAA":  
      case "BBA":
      case "BAB":
      case "ABB":
        System.out.println("Yes");
        break;
    }
  }
}

Measured memory_bytes: 35700
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long sum = 0;
    if (2 * c < a + b) {
        sum = 1ll * min(x, y) * 2 * c;
        int val = min(x,y);
        x -= val;
        y -= val;
    }

    if (x > 0) {
        if (2 * c < a) {
            sum += (1ll * 2 * c * x);
        } else {
            sum += 1ll * a * x;
        }
    }

    if (y > 0) {
        if (2 * c < b) {
            sum += (1ll * 2 * c * y);
        } else {
            sum += 1ll * b * y;
        }
    }
    cout << sum;
    return 0;
}


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

int main() {
    int n,temp;
    cin>>n;
    ll ans=0;
    rep(i,n) {
        cin>>temp;
        ans+=temp;
    }
    cout<<ans-n<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

ll b[200010];
int main(){
  int a,b;
  cin >> a >> b;
  int M = max(a,b);
  if(M > 10 || M == 9) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}






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

int main() {
    long long N;
    long long M;
    cin >> N >> M;
    long long A[M];
    long long sum = 0;
    for (long long i = 0; i < M; ++i) {
        cin >> A[i];
        sum += A[i];
    }
    long long difference = (N - sum);
    if (difference < 0) {
        difference = -1;
    }
    cout << difference << endl;
    return 0;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
map<int,int>t;
int n,a,s;
int main()
{
    cin>>n;
    while(cin>>a)
	{
        s+=t[a]*-2+1;
        t[a]=!t[a];
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 4864