akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> times = new ArrayList<Integer>();

        for(int i = 0; i < 101; i++)    times.add(0);

        while(sc.hasNext()) {
            int i = sc.nextInt();
            times.set(i, times.get(i) + 1);
        }

        int max = Collections.max(times);

        for(int i = 0; i < 101; i++) {
            if (times.get(i) == max)    System.out.println(i);
        }

    }
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map> 
#include <stack>
#include <sstream>
#include <set>
#pragma GCC optimize(2)

//#define int long long
#define mm(i,v) memset(i,v,sizeof i);
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define fi first
#define se second
//你冷静一点，确认思路再敲！！！ 

using namespace std;
typedef long long ll;
typedef pair<int, int > PII;
priority_queue< PII, vector<PII>, greater<PII> > que;
stringstream ssin; //  ssin << string   while ( ssin >> int)

const int N = 1e5 + 5, M = 2e5 + 5, mod = 1e9 + 9, INF = 0x3f3f3f3f;
char s[N];
int k;

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

int main()
{
    ll x;
    cin >> x;
    ll tmp = x / 500;
    ll ans = tmp * 1000;
    x %= 500;
    tmp = x / 5;
    ans += tmp * 5;
    cout << ans << endl;
    // system("pause");
    return 0;
}
/*
niuniu
1
abca
2
abcabc
2
*/

Measured memory_bytes: 3648
def is_prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return n != 1


L = []
for i in range(1, int(1e5) + 5):
    flg = i % 2 != 0 and is_prime(i) and is_prime((i + 1) // 2)
    L.append(flg)

cumsum = [0]
for l in L:
    if l:
        cumsum.append(cumsum[-1] + 1)
    else:
        cumsum.append(cumsum[-1])

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


Measured memory_bytes: 5144
#include <cstdio>
#include <list>
#include <vector>
#include <utility>

using namespace std;

int main(){
    int n, q, c, t, x;
    vector<list<int>> v;
    scanf("%d %d", &n, &q);
    for(int i = 0; i < n; i++){
        v.push_back(list<int>());
    }
    for(int i = 0; i < q; i++){
        scanf("%d %d", &c, &t);
        switch(c){
            case 0: // insert
                scanf("%d", &x);
                v.at(t).push_back(x);
                break;
            case 1: // dump
                for(auto j = v.at(t).begin(); j != v.at(t).end(); j++){
                    if(j != v.at(t).begin()){
                        printf(" ");
                    }
                    printf("%d", *j);
                }
                printf("\n");
                break;
            case 2:
                scanf("%d", &x);
                v.at(x).splice(v.at(x).end(), move(v.at(t)));
        }
    }
    return 0;
}


Measured memory_bytes: 18288
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;
    string st;
    while(cin>>a>>b>>c)
    {
        if(b<a)swap(a,b);
        if(c<a)swap(a,c);
        if(c<b)swap(c,b);
        if(a==5&&b==5&&c==7)cout<<Y;
        else cout<<N;
    }
}



Measured memory_bytes: 3620
#include <iostream>
#include <cmath>


using namespace std;

int main(){

 int n,k;
  cin >> n >> k;
  
  int a[n];
  
  for(int i=0;i<n;i++)
   cin >> a[i];  
  
  cout << ceil(((double)n-1)/((double)k-1)) << endl;
    
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        int times = sc.nextInt();
        long max = -1000000, min = 1000000, total = 0;
        int num;

        for(int i=0; i<times; i++){
            num = sc.nextInt();
            total += num;
            if(max < num){
                max = num;
            }
            if (min > num){
                min = num;
            }
        }

        System.out.println(min + " " + max + " " +  total);

    }
}


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

int main(){
    string s;
    cin >> s;
    string a = "abc";
    vector<int> cnt(3, 0);
    for (int i = 0; i < s.size(); i++){
        for (int j = 0; j < 3; j++){
            if (s[i] == a[j]) cnt[j]++;
        }
    }
    sort(cnt.begin(), cnt.end());
    if (cnt.back() - cnt.front() <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

int w,h;
ll p[111111],q[111111];

int main(){
	cin.sync_with_stdio(false);
	cin>>w>>h;
	rep(i,w)cin>>p[i];
	rep(i,h)cin>>q[i];
	sort(p,p+w);
	sort(q,q+h);
	int wn=0,hn=0;
	ll res=0;
	while(1){
		if(wn==w){
			res+=(w-wn+1)*q[hn++];
		}else if(hn==h){
			res+=(h-hn+1)*p[wn++];
		}else{
			if(p[wn]<q[hn]){
				res+=(h-hn+1)*p[wn++];
			}else{
				res+=(w-wn+1)*q[hn++];
			}
		}
		if(wn==w&&hn==h)break;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

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

    int a = abcd.at(0) - '0';
    int b = abcd.at(1) - '0';
    int c = abcd.at(2) - '0';
    int d = abcd.at(3) - '0';

    if (a+b+c+d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << endl;
    else if (a+b+c-d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << endl;
    else if (a+b-c+d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << endl;
    else if (a+b-c-d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << endl;
    else if (a-b+c+d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << endl;
    else if (a-b+c-d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << endl;
    else if (a-b-c+d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << endl;
    else if (a-b-c-d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=" << 7 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  string board[50];
  cin >> h >> w;
  int dw[8] = {1,1,0,-1,-1,-1,0,1};
  int dh[8] = {0,1,1,1,0,-1,-1,-1};
  for(int i=0;i<h;i++){
    cin >> board[i];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(board[i][j] == '.'){
        int count=0;
        for(int k=0;k<8;k++){
          int x = j + dw[k];
          int y = i + dh[k];
          if(x>=0 && x <w && y>=0 && y<h && board[y][x] == '#'){
            count++;
          }
          board[i][j] = '0' + count;
        }
      }
    }
  }
  for(int i=0;i<h;i++){
    cout << board[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
	static final int r = 1000000000 + 7;

	public static int binarypow(long a, long b) {
		if (b == 0)
			return 1;
		if (b == 1)
			return (int) (a % (long) r);
		if (b % 2 == 1)
			return (int) ((a * binarypow(a, b - 1)) % (long) r);
		long tmp = binarypow(a, b / 2);
		return (int) ((tmp * tmp) % (long) r);
	}

	public static int combination(int n, int k) {
		long tmpx = 1, tmpy = 1;
		int ans = 0;
		for (int i = 0; i < k; ++i) {
			tmpx *= (long) (n - i);
			tmpy *= (long) (i + 1);
			tmpx %= (long) r;
			tmpy %= (long) r;
		}
		tmpy = (long) binarypow(tmpy, (long) (r - 2));
		ans = (int) ((tmpx * tmpy) % (long) r);
		return ans;
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		int ans = binarypow(2, n) - 1;
		ans %= r;
		int comb = combination(n, a);
		ans -= comb;
		ans = (ans <= 0 ? (ans + r) % r : ans % r);
		comb = combination(n, b);
		ans -= comb;
		ans = (ans <= 0 ? (ans + r) % r : ans % r);
		sc.close();
		System.out.println(ans);
	}
}


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


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		char	ball  = 'A';
		String	trade = null;

		while ((trade = parseStdin()) != null) {
			ball = (ball == trade.charAt(0)) ? trade.charAt(2) : (ball == trade.charAt(2)) ? trade.charAt(0) : ball;
		}

		System.out.println(ball);
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}
}

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

int a,b,c;
string s;
int main(){
	cin>>a>>s>>b;//s[b-1]
	string ans;
	for (int i = 0; i < a; i++)
	{
		if (s[i]!=s[b-1])
		{
			ans+='*';
		}else{
			ans+=s[i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N = INT()
a = LIST()

dp = [[0]*3010 for _ in range(3010)]

for i in range(1, N+1):  # 区間幅
	for j in range(N-i+1):  # 左端
		k = j + i

		if (N-i)%2 == 0:  # 先手番
			dp[j][k] = max(dp[j+1][k]+a[j], dp[j][k-1]+a[k-1])
		else:
			dp[j][k] = min(dp[j+1][k]-a[j], dp[j][k-1]-a[k-1])

print(dp[0][N])


Measured memory_bytes: 132952
#include<iostream>

using namespace std;

int main(){
    int N;
    int min = -1;
    int p;
    int i;
    int count=0;

    cin >> N;
    for(i=0;i<N;i++){
        cin >> p;
        if( min == -1 || min >= p){
            min = p;
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 998244353;

ll seg[524288], rec[200010];

void raq(ll s, ll t, ll v, ll k = 1, ll l = 0, ll r = 262143) {
	if (t < l || r < s)
		return;
	if (s <= l && r <= t) {
		seg[k] += v;
		return;
	}
	raq(s, t, v, k * 2, l, (l + r) / 2);
	raq(s, t, v, k * 2 + 1, (l + r) / 2 + 1, r);
}

ll gets(ll k) {
	k += 262144;
	ll ans = 0;
	while (k) {
		ans += seg[k];
		k /= 2;
	}
	return ans;
}

int main() {
	for (ll i = 0;i < 524288;i++)seg[i] = 0;
	for (ll i = 0;i < 200010;i++)rec[i] = 0;
	ll N, K;
	cin >> N >> K;
	for (ll i = 0;i < N;i++) {
		cin >> rec[i];
	}
	for (ll t = 0;t < min(K, 42LL);t++) {
		for (ll i = 0;i < N;i++) {
			raq(max(0LL, i - rec[i]), min(N - 1, i + rec[i]), 1);
		}
		for (ll i = 0;i < N;i++) {
			rec[i] = gets(i);
		}
		for (ll i = 0;i < 524288;i++) {
			seg[i] = 0;
		}
	}
	
	for (ll i = 0;i < N;i++) {
		cout << rec[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 9288
al = "abcdefghijklmnopqrstuvwxyz"
k  = int(input())
def dfs(s: "char", i):
    if(len(s)==k):
        print(s)
    else:
        for j in range(i+1):
            if al[j]==al[i]:
                dfs(s+al[j], i+1)
            else:
                dfs(s+al[j], i)




def main():
    #sの後ろを変えていくdfs
    dfs("", 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4340
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
   #ifndef ONLINE_JUDGE
	freopen("/home/abhinav/c++ codes/input output c++/input.txt", "r", stdin);
	freopen("/home/abhinav/c++ codes/input output c++/output.txt", "w", stdout);
   #endif
   
   int d, t, s;
   cin >> d >> t >> s;
   //float left = float(d/s) - d/s;
   //left /= 0.6;
   //float res = left + d/s;
   if (d <= t * s ) {
   		cout << "Yes\n";

   }
   else cout << "No\n";
}
 
int32_t main()
{
    c_p_c();
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll sum = 0;
	for(int i=0;i<(int)s.length();++i){
		sum += (s[i]-'0');
	}
	cout<<((sum%9==0) ? "Yes" : "No")<<'\n';
	return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 105, maxm = 10005;
vector<pair<int,int>>g[maxn],gr[maxn];
vector<int>U(maxm),V(maxm),W(maxm),candidate(maxm);
int n,m;
void CandidateEdgesForShortestPathFromSingleSource(int s){
	vector<int>dis(n+1,1e15);
	vector<int>inq(n+1);
	queue<int>q;
	dis[s]=0;
	inq[s]=1;
	q.push(s);
	while( q.size() ){
		int u = q.front();q.pop();inq[u]=0;
		for(auto [v,i]:g[u]){
			if( dis[v] > dis[u] + W[i] ){
				dis[v] = dis[u] + W[i];
				if( !inq[v] ){
					inq[v]=1;
					q.push(v);
				}
			}
		}
	}
	for(int i=1;i<=m;i++){
		if( dis[U[i]] + W[i] == dis[V[i]] ||  dis[V[i]] + W[i] == dis[U[i]] ){
			candidate[i]=1;
		}
	}
}
int32_t main(){
	IOS
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>U[i]>>V[i]>>W[i];
		g[U[i]].push_back({V[i],i});
		g[V[i]].push_back({U[i],i});
	}
	for(int i=1;i<=n;i++){
		CandidateEdgesForShortestPathFromSingleSource(i);
	}
	int ans = m;
	for(int i=1;i<=m;i++){
		ans -= candidate[i];
	}
	cout << ans << endl;
	
	
}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 3976
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

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

  int N;
  std::cin >> N;
  std::vector<std::pair<double, double>> towns(N, {0, 0});
  for (int i = 0; i < N; i++) {
    std::cin >> towns[i].first >> towns[i].second;
  }

  std::sort(towns.begin(), towns.end());

  double dist = 0;
  int c = 0;
  do {
    for (int i = 1; i < N; i++) {
      dist += std::sqrt(std::pow(towns[i - 1].first - towns[i].first, 2) + std::pow(towns[i - 1].second - towns[i].second, 2));
    }
    c++;
  } while (std::next_permutation(towns.begin(), towns.end()));

  std::cout << std::setprecision(10) << (dist / c) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool ifsq(ll x){
    for(ll i=1; i*i<=x; i++){
        if(i*i==x) return true;
    }
    return false;
}

ll fac(ll x){
    ll res=x;
    for(ll i=1; i*i<=x; i++){
        if(x%i!=0) continue;
        if(i*i==x){
            if(ifsq(i)) res+=i;
            else res-=i;
        }else if(i==1){
            res+=1;
        }else{
            if(ifsq(i)) res+=i;
            else res-=i;

            if(ifsq(x/i)) res+=x/i;
            else res-=x/i;
        }
    }
    return res;
}

ll pow(ll n, ll p, ll m){
    if(p==0) return 1;
    if(p%2==0){
        ll t=pow(n,p/2,m);
        t*=t;
        return t%m;
    }
    return (n*pow(n,p-1,m))%m;
}

int main(){
    ll n,k; cin>>n>>k;
    ll mod=1e9+7;
    ll res=0;
    vector<ll> memo(k+1);
    for(ll i=k; i>=1; i--){
        ll tmp=pow(k/i, n, mod);
        tmp%=mod;
        for(ll j=i*2; j<=k; j+=i){
            tmp-=memo[j];
            tmp%=mod;
            if(tmp<0) tmp+=mod;
        }
        memo[i]=tmp;
        res+=tmp*i;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3956
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int n,k;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i];
  int l=1,r=1e9,ans=r;
  for(int i=1;i<=40;i++){
    int mid=(l+r)/2;
    LL cnt=0;
    for(int j=1;j<=n;j++){
      if(a[j]<=mid)continue;
      cnt+=(a[j]/mid);
    }
    if(cnt<=k)ans=mid,r=mid;
    else l=mid;
  }
  cout<<fixed<<setprecision(0)<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4432
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main() {
    int N; cin >> N;
    vector<ll> ar(N);
    vector<ll> p(N);
    vector<ll> q(N);
    for(int i=0; i<N; i++){
        ar[i] = i;
    }
    for(int i=0; i<N; i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i=0; i<N; i++){
        cin >> q[i];
        q[i]--;
    }
    
    ll cnt = 0;
    ll a = -1;
    ll b = -1;
    do {
        bool pf = true;
        bool qf = true;
        for(int i=0; i<N; i++){
            if(ar[i] != p[i]){
                pf = false;
            }
            if(ar[i] != q[i]){
                qf = false;
            }
            if(!pf && !qf){
                break;
            }
        }
        if(pf){
            a = cnt;
        }
        if(qf){
            b = cnt;
        }
        cnt++;
    } while (next_permutation(ar.begin(), ar.end()));
    
    ll ans = max(a,b) - min(a,b);
    
    cout << ans <<endl;
    
    return 0;
}

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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TC int tc; cin >> tc; while(tc--)

using namespace std;

const int INF = 1e9 + 7;


int main(void)
{
	FAST
	int n; cin >> n;
	long double d; cin >> d;

	int ans = 0;

	while(n--){
		long double x, y; cin >> x >> y;

		if(sqrt(x*x + y*y) <= d) ans++;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>
 #include<string.h>
 #include<stdlib.h>

int compare_string(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
}
 
int main(void)
{
 
  int i, j;
 
  /* 文字列の数 */
  int num;
  scanf("%d", &num);
 
  /* 文字列 */
  char *moji[num], tmp[num][11];
  
 
  /* 3つの文字列を入力 */
  for (i=0;i<num;i++) {
    scanf("%s", tmp[i]);
    moji[i] = tmp[i];
  }
  
  qsort(moji, num, sizeof *moji, compare_string);

  int max = 0;
  int now = 0;
  int times[num];
  for (i=0;i<num-1;i++){
    if (strcmp(moji[i], moji[i+1])==0){
      now++;
      times[i]=now;
    }else{
      now++;
      times[i]=now;
      if (now > max){
        max = now;
      }
      now = 0;
    }
  }
  if (strcmp(moji[num-1], moji[num-2])==0){
    now++;
    times[num-1] = now;
    if (now > max){
        max = now;
    }
  }else{
    times[num-1] = 1;
  }
  for(i=0;i<num;i++){
    if(times[i]==max){
      printf("%s\n", moji[i]);
    }
  }
 
  return 0;
}



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

//constexpr long double PIL = 3.141592653589793238462643383279502884L;
//constexpr double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	string s; cin >> s;
	int x = 0;
	int base = 1;
	map<int,int> cnt;
	for (int i = s.size() - 1; i >= 0; --i) {
		x += base * (s[i] - '0');
		x %= 2019;
		++cnt[x];
		base = (base * 10) % 2019;
	}

	ll answer = cnt[0];
	for (const auto& p : cnt) {
		/* cerr << p.first << ": " << p.second << '\n'; */
		answer += (ll)p.second * (p.second - 1) / 2;
	}
	cout << answer << '\n';
}


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

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double theta0 = 2 * M_PI * (H + 1.0 * M / 60) / 12;
    double theta1 = 2 * M_PI * (H + 1.0 * M / 60);

    double ans = A * A + B * B - 2 * A * B * cos(theta0 - theta1);
    cout << setprecision(16) << sqrt(ans) << endl;
}


Measured memory_bytes: 4200
n = int(input())
p = [0 for i in range(n)]
for i in range(n):
    p[i] = int(input())

visited = [0 for i in range(n+1)]

"""
for i in reversed(range(n)):
    if visited[i] == 0:
        visited[i] = 1
        count = 1
        target = p[i] - 1

        for j in reversed(range(i)):
            if p[j] == target:
                count += 1
                visited[j] = count
                target -= 1
"""
for i in range(n):
    visited[p[i]] = visited[p[i] - 1] + 1
print(n - max(visited))


Measured memory_bytes: 19728
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a;
	cin>>a;
	map<int,int>ma;
	int t=0;
	while(1){
		t++;
		if(ma[a]){
			cout<<t<<endl;
			return 0;
		}
		ma[a]=1;
		if(a%2)a=a*3+1;
		else a/=2;
	}
}






Measured memory_bytes: 256
a, b = map(int, input().split())

def cal_xor(n):
    if n % 2 == 0:
        if (n // 2) % 2 == 0:
            return 0 ^ n
        else:
            return 1 ^ n
    else:
        if ((n+1)//2) % 2 == 0:
            return 0
        else:
            return 1

print(cal_xor(b)^cal_xor(a-1))

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll ans=0;
    ll add=n/500;
    ans+=add*1000;
    n=n-(500*add);
    add=n/5;
    ans+=add*5;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vint = vector<int>;

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

	int a, b, c, x, y, r = 0;
	cin >> a >> b >> c >> x >> y;
	if (a + b <= c*2){
		cout << a*x + b*y << "\n";
		return 0;
	}
	int m = min(x, y);
	r += c * (m * 2);
	x -= m;
	y -= m;
	if (x > 0){
		if (a/2 < c){
			r += a*x;
		}else{
			r += c*x*2;
		}
	}
	if (y > 0){
		if (b/2 < c){
			r += b*y;
		}else{
			r += c*y*2;
		}
	}
	cout << r << "\n";
	return 0;
}

Measured memory_bytes: 256
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) {
	ll ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

const int N = 1e6 + 10;
bool composite[N];
int present[N];

void solve() {
	int n;
	cin >> n;
	memset(composite,0,sizeof(composite));
	memset(present, 0, sizeof(present));
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		++present[a];
	}	
	if (present[1]) {
		present[1] > 1 ? cout << 0 << endl : cout << 1 << endl;
		return;
	}
	int ans = 0;
	for (int i = 2; i < N; ++i) {
		if (composite[i] or !present[i]) {
			continue;
		}
		if (present[i] > 1) {
			composite[i] = 1;
		}
		for (int j = 2*i; j < N; j += i) {
			composite[j] = 1;
		}
	}
	for (int i = 2; i < N; ++i) {
		if (!composite[i] and present[i]) {
			++ans;
		}
	}
	cout << ans << endl;
}

int main() {
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 8544
#include <iostream>

using namespace std;

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

    int odd=0;
    for(int i = 1; i <= num; i++){
        if(i%2==1){
            odd++;
        }
    }

    float result = (float)odd / num;

    printf("%f", result);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define contests_de_diya_kar 0
#define PB push_back
#define MP make_pair
#define int long long
#define MOD ((long long) (1000*1000*1000 + 7))
#define exit(a, b) return cout << a, b;
#define eps (double)1e-8
#define forn(a, b, i) for (int i = a; i < b; i += 1)
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(), v.end()
#define ll long long 
#define pii pair<int, int>
#define mii map<int, int> 
#define print(stuff) cout << stuff << endl
#define len(stuff) stuff.size()

signed main () {
	start_routine;
	#ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	#endif
	const int inf = (int) 1e15;
	int n, t; cin >> n >> t;
	int mn = inf;
	for (int i = 1; i <= n; i++) {
		int a, b; cin >> a >> b;
		if (b <= t) {
			mn = min(a, mn);
		}
	}

	if (mn == inf) {
		cout << "TLE";
	}
	else cout << mn;
	end_routine;
}


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

int main(){
	int n;
	scanf("%d", &n);
	char s[n];
	scanf("%s", s);
	if(n%2==1){
		printf("No");
	}else{
		for (int i = 0; i < n/2; ++i){
			if(s[i]!= s[i+(n/2)]){
				printf("No");
				return 0;
			}
		}
		printf("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 256
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int arr[5];
  for (int i = 0; i < 5; i++) cin >> arr[i];
  for (int i = 0; i < 5; i++) {
    if (arr[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll x;
    cin >> x;
    cout << (1000 * (x / 500)) + (5 * ((x % 500) / 5)) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
klist = list(map(int,input().split()))
hlist = klist[::-1]
for i in range(n-1):
  if hlist[i]+1 < hlist[i+1]:
    print('No')
    break

  if hlist[i]+1 == hlist[i+1]:
    hlist[i+1] -= 1
else:print('Yes')

Measured memory_bytes: 63984
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import numpy as np

n = ii()
a = li()

def cmb(n, r):
    if n - r < r: r = n - r
    if n == 0: return 0
    if n == 1: return 0
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
        for k in range(p-1,r,p):
            numerator[k - offset] /= pivot
            denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result


memo_cnt = [0]*n
memo_cmb = [0]*(n+1)
memo_cmb2 = [0]*(n+1)

for i in range(n):
    memo_cnt[a[i]-1] += 1

for k,i in enumerate(memo_cnt):
    if i >= 3:
        memo_cmb[k+1] = cmb(i,2)
        memo_cmb2[k+1] = cmb(i-1,2)
    elif i == 2:
        memo_cmb[k+1] = cmb(i,2)

cmb_cumsum = np.array(memo_cmb).cumsum()

# print('cumsum')
# print(memo_cnt)
# print(memo_cmb)
# print(cmb_cumsum)

for i in range(n):
    a_now = a[i]
    itself = memo_cmb2[a_now]
    
    other = cmb_cumsum[a_now-1] + cmb_cumsum[-1] - cmb_cumsum[a_now]

    print(itself + other)
    


Measured memory_bytes: 35988
a = input()
N = int(a.split(" ")[0])
K = int(a.split(" ")[1])
count = 0
if K%2 == 1:
    count = int(N/K)**3
else:
    count = int(N/K)*int(N/K)*int(N/K)*2
    if int(N/K)*K + K/2 <= N:
        count = int(count/2) + (int(N/K)+1)**3
print(count)


Measured memory_bytes: 3064
#C
N,x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
for i in range(N):
    if i == 0:
        pass
    else:
        if A[i-1]+A[i] > x:
            ans+=(A[i-1]+A[i]-x)
            A[i] = max(0,x-A[i-1])
            
print(ans)


Measured memory_bytes: 14052
function main(input) {
  var N = input[0]-0;
  var list = [];
  for(var i=1;i<=N;i++) list.push(input[i]-0);
  list.sort((a,b)=>b-a);
  var ans = list[0]/2;
  for(var i=1;i<list.length;i++){
    ans += list[i];
  }
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

int main() {
//#ifnedef ONLINE_JUDGE
//	freopen("a.in", "r", stdin);
//	freopen("a.out", "w", stdout);
//#endif
	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2 * b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 1000000007
typedef long long ll;

int main(){
  int n,k;
  string s;
  cin>>n>>s>>k;

  for(int i=0;i<s.size();i++){
    if(s[i]!=s[k-1]) s[i]='*';
  }
  cout<<s<<endl;
}


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

int main(){

	int i;
	char str[20],temp;
	
	scanf("%s",str);
	
	for(i=0;i<(strlen(str)/2);i++){
		temp=str[i];
		str[i]=str[strlen(str)-i-1];
		str[strlen(str)-i-1] = temp;
	}
	printf("%s\n",str);

	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;
public class Main {

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

		int N = sc.nextInt();
		int cnt = 0;
		int ans = 0;
		for(int i=1;i<=N;i++) {
			ans = String.valueOf(i).length();

			if(ans %2 != 0) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 27092
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;

int main()
{
	char a;
	cin>>a;
	if(a=='A')
	{
		cout<<'T';
	}
	if(a=='T')
	{
		cout<<'A';
	}
	if(a=='C')
	{
		cout<<"G";
	}
	if(a=='G')
	{
		cout<<"C";
	}
	return 0;
}


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

using namespace std;

#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long

const int N = 1010;

int a[N], sum[N * N];
bool chk[N * N];

signed main()
{
    fastio;
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    int ptr = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = i; j <= n; ++j)
            sum[ptr++] = a[j] - a[i - 1];

    int ans = 0;
    for (int x = 42; x >= 0; --x)
    {
        int cnt = 0;
        for (int i = 1; i < ptr; ++i)
        {
            if (!chk[i] && ((sum[i] >> x) & 1))
            {
                ++cnt;
            }
        }
        if (cnt >= k)
        {
            ans ^= (1ll << x);
            for (int i = 1; i < ptr; ++i)
            {
                if (!((sum[i] >> x) & 1))
                    chk[i] = true;
            }
        }
    }
    cout << ans;
    return 0;
}

/* input

*/

Measured memory_bytes: 5888
import java.util.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String s=sc.next();
        String t=sc.next();
        int a=2*n;
        for (int i = 0; i <= n; i++) {
            String p=s.substring(n-i,n);
            String q=t.substring(0,i);
            if(p.equals(q))a=2*n-i;
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<long long int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    bool flag = true;
    long long int top = 0;
    for(int i = 0;i < n;i++)
    {
        if(v.at(i) > top)
        {
            top = v.at(i);
        }
        if(top - v.at(i) >= 2)
        {
            flag = false;
            break;
        }
    }
    if(flag)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
      
    return 0;
}

Measured memory_bytes: 1400
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

// 3,6,7,11,14
// 1,0,1,1,0
//  1,1,0,1

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	k := nextInt()
	q := nextInt()
	d := make([]int, k)
	d2 := make([]int, k)

	for i := range d {
		d[i] = nextInt()
	}
	for i := 0; i < q; i++ {
		n := nextInt()
		x := nextInt()
		m := nextInt()
		count := (n - 1) / k
		lastNum := (n - 1) % k
		numEq := 0
		cntEq := 0
		lastA := uint64(x)
		for j := range d {
			d2[j] = d[j] % m
			if d2[j] == 0 {
				numEq++
				if j < lastNum {
					cntEq++
				}
			} else {
				lastA += uint64(count) * uint64(d2[j])
				if j < lastNum {
					lastA += uint64(d2[j])
				}
			}
		}
		cntEq += numEq * count
		cntUp := lastA/uint64(m) - uint64(x)/uint64(m)
		ans := n - 1 - int(cntEq) - int(cntUp)
		//debugf("n:%d, x:%d, m:%d, count:%d, lastNum:%d, lastA:%d, cntEq:%d, cntUp:%d, ans:%d, d2:%v\n", n, x, m, count, lastNum, lastA, cntEq, cntUp, ans, d2)
		_, _ = fmt.Fprintf(writer, "%d", ans)
		if i != q-1 {
			_, _ = fmt.Fprint(writer, "\n")
		}
	}
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a+=d-1;
	c+=b-1;
	if(a/d>=c/b){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define INF (1e9)
#define LINF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define F first
#define S second
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World";
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b;
	}
}


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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, K;
    ll count = 0;
    vector<ll> A;
    cin >> N >> K;
    A.resize(N);
    for(ll i = 0;i < K;i++) {
        ll d;
        cin >> d;
        for(ll j = 0;j < d;j++) {
            ll temp;
            cin >> temp;
            A[temp - 1]++;
        }
    }
    for(ll i = 0;i < A.size();i++) {
        if(A[i] == 0) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<queue>
#include<bitset>
int main()
{
	int n,a,b,c;
	std::bitset<1000001>s;
	std::queue<int>q;
	while(scanf("%d%d%d",&n,&a,&b),n)
	{
		s.reset();
		q.push(a);
		q.push(b);
		while(!q.empty())
		{
			c=q.front();q.pop();
			if(n<c||s[c])continue;
			s[c]=1;
			q.push(c+a);q.push(c+b);
		}
		printf("%d\n",n-s.count());
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
inline long long getnum()
{
    long long now=0;long long fh=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')fh=-1;ch=getchar();}
    while(ch>='0' && ch<='9'){now=(now<<3)+(now<<1)+ch-'0';ch=getchar();}
    return now*fh;
}
int x[100003],n,ans;
void ck(int pl)
{
  ans++;
  if (x[pl+1]==pl+1||x[pl-1]==pl) swap(x[pl+1],x[pl]);
  swap(x[pl-1],x[pl]);
}
int main()
{
  n=getnum();
  for (int i=1;i<=n;i++)
  {
    x[i]=getnum();
  }
  for (int i=1;i<=n;i++)
  {
    if (x[i]==i) ck(i);
  }
  printf("%d\n", ans);
}


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

using namespace std;

int N, M;
vector<int> edge[55];

int ans;
int memo[55];
int inp[55][2];

void dfs(int u, int ban) {
    //  0: visited
    // -1: not visited
    if (0 == memo[u]) return;
    memo[u] = 0;
    for (int i = 0; i < edge[u].size(); i++) {
        int v = edge[u][i];
        if (inp[ban][0] == u && inp[ban][1] == v) continue;
        if (inp[ban][0] == v && inp[ban][1] == u) continue;
        dfs(v, ban);
    }
}

bool is_bridge() {
    for (int i = 0; i < N; i++) {
        if (memo[i] == -1) return true;
    }
    return false;
}

void solve() {
    for (int i = 0; i < M; i++) {
        memset(memo, -1, sizeof(memo));
        dfs(0, i);
        ans += (int)is_bridge();
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
        inp[i][0] = u;
        inp[i][1] = v;
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w,n,i,j,num=0;
  scanf("%d%d%d",&h,&w,&n);
  int a,mass[h+1][w+1];
  for(i=0;i<n;i++){
    scanf("%d",&a);
    while(a!=0){
      if((num/w)%2==0)
        mass[num/w][num%w]=i+1;
      else
        mass[num/w][w-1-num%w]=i+1;
      a--;
      num++;
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)
      printf("%d ",mass[i][j]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
def cntData(num,MaxData):
    if num == MaxData:
        return 0;
    ans = MaxData - num;
    
    return int(ans/2);
    

data = input().split(" ");
A = int(data[0]);
B = int(data[1]);
C = int(data[2]);
cnt = 0;

if not( (A%2==0 and B%2==0 and C%2==0) or (A%2==1 and B%2==1 and C%2==1) ):
    if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
        A+=1;
        B+=1;
    elif (A%2==0 and C%2==0) or (A%2==1 and C%2==1):
        A+=1;
        C+=1;
    else:
        B+=1;
        C+=1;
    cnt+=1;
    
MaxData = max(A,B,C);

cnt += cntData(A,MaxData);
cnt += cntData(B,MaxData);
cnt += cntData(C,MaxData);
print(cnt);

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
from collections import deque

# グラフの作成(無向グラフでは#を消す)
n, q = map(int, input().split())
ans = [0]*n
ki = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)
for i in range(q):
    p, q = map(int, input().split())
    ans[p-1] += q

# 深さ優先探索
stack = deque([0])
visited = [-1]*n
while stack:
    ne = stack.popleft()
    if visited[ne] == -1:
        visited[ne] = 1
        for j in ki[ne]:
            if visited[j] == -1:
                ans[j] += ans[ne]
                stack.append(j)
                
print(*ans)


Measured memory_bytes: 56168
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K<=A) {
    cout << K << endl;
  }
  else {
    if (K<=A+B) {
      cout << A << endl;
    }
    else {
      cout << 2*A+B-K << endl;
    }
  }
}


Measured memory_bytes: 3608