akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll n;
ll x[101010],y[101010];
char d[101010];

ll val(ll t){
  ll xM=-10000000000,xm=10000000000,yM=-10000000000,ym=10000000000;
  for(ll i=0;i<n;i++){
    ll a=x[i],b=y[i];
    if(d[i]=='R') a+=t;
    if(d[i]=='L') a-=t;
    if(d[i]=='U') b+=t;
    if(d[i]=='D') b-=t;
    xM=max(xM,a);
    xm=min(xm,a);
    yM=max(yM,b);
    ym=min(ym,b);
  }
  return (xM-xm)*(yM-ym);
}

int main(){
  ll i,j;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>x[i]>>y[i]>>d[i];
    x[i]*=2;
    y[i]*=2;
  }
  vector<ll> ts;

  ll xMR=-1e10,xML=-1e10,xMN=-1e10;
  for(i=0;i<n;i++){
    if(d[i]=='R')  xMR=max(xMR,x[i]);
    else if(d[i]=='L')  xML=max(xML,x[i]);
    else xMN=max(xMN,x[i]);
  }
  ts.pb(xMN-xMR);
  ts.pb(xML-xMN);
  ts.pb((xML-xMR)/2);

  ll xmR=1e10,xmL=1e10,xmN=1e10;
  for(i=0;i<n;i++){
    if(d[i]=='R')  xmR=min(xmR,x[i]);
    else if(d[i]=='L')  xmL=min(xmL,x[i]);
    else xmN=min(xmN,x[i]);
  }
  ts.pb(xmN-xmR);
  ts.pb(xmL-xmN);
  ts.pb((xmL-xmR)/2);

  ll yMR=-1e10,yML=-1e10,yMN=-1e10;
  for(i=0;i<n;i++){
    if(d[i]=='U')  yMR=max(yMR,y[i]);
    else if(d[i]=='D')  yML=max(yML,y[i]);
    else  yMN=max(yMN,y[i]);
  }
  ts.pb(yMN-yMR);
  ts.pb(yML-yMN);
  ts.pb((yML-yMR)/2);

  ll ymR=1e10,ymL=1e10,ymN=1e10;
  for(i=0;i<n;i++){
    if(d[i]=='U')  ymR=min(ymR,y[i]);
    else if(d[i]=='D')  ymL=min(ymL,y[i]);
    else ymN=min(ymN,y[i]);
  }

  ts.pb(ymN-ymR);
  ts.pb(ymL-ymN);
  ts.pb((ymL-ymR)/2);

  ts.pb(0);

  ll ans=1e18;
  for(i=0;i<ts.size();i++){
    if(ts[i]>=0&&ts[i]<1e9) {
      ll p=val(ts[i]);
      ans=min(ans,p);
      }
  }
  printf("%.15lf\n",ans/(double)4);
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t,n,temp,c=0;
    string s;
    cin>>s;
    int p=s.size()-1;
    if(s[p]=='2' ||s[p]=='4' ||s[p]=='5' ||s[p]=='7' ||s[p]=='9')
        cout<<"hon"<<endl;
    else if(s[p]=='0' ||s[p]=='1' ||s[p]=='6' ||s[p]=='8')
        cout<<"pon"<<endl;
    else if(s[p]=='3')
        cout<<"bon"<<endl;

    return 0;
}


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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;



void one_case() {
    int n;
    cin >> n;
    cout << n / 3;

}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char s[1001];
	cin>>s;
	for(int i=0;i<strlen(s);i++){
		switch(s[i]){
			case 'A':
			cout<<'X';
			break;
			case 'B':
			cout<<'Y';
			break;
			case 'C':
			cout<<'Z';
			break;
			default:
			cout<<(char)(s[i]-3);	
		}
	}
	cout<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 1132
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(a,b) memset(a,b,sizeof(a))
#define fora(x,a,b) for(re nti (x)=(a);(x)<=(b);++(x))
#define forb(x,a,b) for(re nit (x)=(a);(x)>=(b);--(x))
#define re register
#define stt struct
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(x) ((x)>(0)?(x):(-1)*(x))
#define maxx(a,b) ((a)>(b)?(a):(b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define pf(_) ((_)*(_))
#define in(a) freopen("D:/""/in"a".in","r",stdin)
#define out(a) freopen("D:/""/out"a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=10004;
const nit maxb=1e2;
const nit maxc=5;

char x;
tni n,dq=0,ans=0;

tin main()
{
	scanf("%d\n",&n);
	fora(i,1,n)
	{
		x=getchar();
		if(x=='I')
		{
			++dq;
		}
		else if(x=='D')
		{
			--dq;
		}
		//
		if(dq>ans)
		{
			ans=dq;
		}
	}
	//
	pritnf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys

# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret


def bunsu(n):
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = 0
            while (True):
                if n % i == 0:
                    tmp += 1
                    n //= i
                else:
                    break
            ret.append((i, tmp))

    ret.append((n, 1))
    return ret

MOD = 998244353
def solve():
    n, m = getList()
    print((n * 3 + m) // 2)

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    solve()

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

int n, q;

struct SEG {
	static const int mxn = 1 << 18;
	int mn[mxn << 1];
	void init() {
		memset(mn, 0x3f, sizeof(mn));
	}
	void upd(int l, int r, int v) {
		for (l += mxn, r += mxn; l < r; l >>= 1, r >>= 1) {
			if (l & 1) mn[l] = min(mn[l], v), l ++;
			if (r & 1) -- r, mn[r] = min(mn[r], v);
		}
	}
	int qry(int x) {
		int ans = n;
		for (x += mxn; x; x >>= 1) ans = min(ans, mn[x]);
		return ans;
	}
} row, col;

int main() {
	scanf("%d %d", &n, &q);
	n -= 2;
	ll tot = 1LL * n * n;
	row.init();
	col.init();
	rep(i, q) {
		int tp, x;
		scanf("%d %d", &tp, &x);
		x -= 2;
		if (tp == 1) {
			int kills = row.qry(x);
			tot -= kills;
			col.upd(0, kills, x);
		} else {
			int kills = col.qry(x);
			tot -= kills;
			row.upd(0, kills, x);
		}
	}
	printf("%lld\n", tot);
	return 0;
}


Measured memory_bytes: 7872
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, a, b, ans;

int main(){
    ios::sync_with_stdio(0);
    cin >> n;
    ans = 0;
    forn(i,n){
        cin >> a >> b;
        if(a > b) swap(a,b);
        ans += (b-a+1);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_i
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3000;
long double p[MAXN];
long double dp[MAXN][MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> p[i];
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= i; j++) {
      if (j)
        dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
      dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
    }
  }
  long double ans = 0.0;
  for(int i = 0; i <= n; i++){
    if(i > n - i) ans += dp[n][i];
  }
  cout << fixed << setprecision(12);
  cout << ans;
  return 0;
}


Measured memory_bytes: 139136
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int h[n], num = 0;
    for (int i = 0; i < n; i++){
        cin >> h[i];
        if (h[i]>= k){
            num++;
        }
    }
    cout << num;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
res = 0
right = 0
total = 0
for left in range(N):
    while right < N and (total ^ A[right]) == (total + A[right]):
        total += A[right]
        right += 1
    res += right - left
    if right == left:
        right += 1
    else:
        total -= A[left]
print(res)

Measured memory_bytes: 24840
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <iterator>
using namespace std;
typedef pair<vector<int>, int> P;

vector<int> ans = {1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3};

void roll1(vector<int>& vec){
	swap(vec[6], vec[21]);
	swap(vec[7], vec[22]);
	swap(vec[8], vec[23]);
	swap(vec[12], vec[17]);
	swap(vec[9], vec[11]);
}

void roll2(vector<int>& vec){
	swap(vec[0], vec[27]);
	swap(vec[1], vec[28]);
	swap(vec[2], vec[29]);
	swap(vec[14], vec[15]);
	swap(vec[18], vec[20]);
}

void roll3(vector<int>& vec){
	swap(vec[0], vec[23]);
	swap(vec[3], vec[26]);
	swap(vec[6], vec[29]);
	swap(vec[9], vec[20]);
	swap(vec[15], vec[17]);
}

void roll4(vector<int>& vec){
	swap(vec[2], vec[21]);
	swap(vec[5], vec[24]);
	swap(vec[8], vec[27]);
	swap(vec[11], vec[18]);
	swap(vec[12], vec[14]);
}

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

	int n;
	cin >> n;
	while(n > 0){
		vector<int> puzzle(30);
		for(int i = 0; i < 30; ++i){
			cin >> puzzle[i];
		}

		set<vector<int>> m;
		m.insert(puzzle);

		queue<P> que;
		que.push(P(puzzle, 0));

		int turn = 8;
		while(!que.empty()){
			P p = que.front();
			que.pop();
			int t = p.second;
			if(p.first == ans){
				turn = t;
				break;
			}

			vector<int> q1 = p.first;
			roll1(q1);
			if(m.find(q1) == m.end()){
				que.push(P(q1, t + 1));
				m.insert(q1);
			}

			vector<int> q2 = p.first;
			roll2(q2);
			if(m.find(q2) == m.end()){
				que.push(P(q2, t + 1));
				m.insert(q2);
			}

			vector<int> q3 = p.first;
			roll3(q3);
			if(m.find(q3) == m.end()){
				que.push(P(q3, t + 1));
				m.insert(q3);
			}

			vector<int> q4 = p.first;
			roll4(q4);
			if(m.find(q4) == m.end()){
				que.push(P(q4, t + 1));
				m.insert(q4);
			}
		}

		cout << turn << endl;
		--n;
	}

	return 0;
}

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

void Main() {
    // input
    int a, b;
    cin >> a >> b;


    // translate


    // output
    if((a * b) % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
  int n, m;
  std::cin >> n;
  std::cin >> m;

  int** matrix = new int*[n];
  for(int i = 0; i < n; i++){
    matrix[i] = new int[m];
    for(int k = 0; k < m; k++){
      std::cin >> matrix[i][k];
    }
  }
  int* vec = new int[m];
  for(int i = 0; i < m; i++){
    std::cin >> vec[i];
  }

  for(int i = 0; i < n; i++){
    int s = 0;
    for(int k = 0; k < m; k++){
      s += matrix[i][k] * vec[k];
    }
    std::cout << s << std::endl;
  }
  
  return 0;
}



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

#define S size()
#define EN end()
#define BE begin()
#define LEN length()

#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define ld double
#define ll long long

#define gcd __gcd
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation

#define si set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vi vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpi vector<pll>
#define msi multiset<ll>
#define msc multiset<char>
#define vvi vector<vector<ll> >

#define all(v) v.BE,v.EN
#define godv(v) sort(all(v))
#define god(ar,n) sort(ar,ar+n)
#define godvr(v) godv(v) ; reverse(all(v))
#define godr(ar,n) god(ar,n) ; reverse(ar,ar+n)

#define iter(s) for(auto it:s)
#define forl(i,n) for(ll i=0;i<n;i++)
#define fore(i,n) for(ll i=1;i<=n;i++)
#define fora(i,v) for(ll i=0;v[i];i++)
#define forn(i,n) for(ll i=n-1;i>=0;i--)
#define forls(i,l,r) for(ll i=l;i<r;i++)
#define forns(i,l,r) for(ll i=r-1;i>=l;i--)

#define pat ll n;cin>>n;
#define wq ll q;cin>>q;while(q--)
#define tak(s) string s;cin>>s;ll n=s.LEN;
#define nokay if(ok) cout<<"YES\n";else cout<<"NO\n";
#define pat1 ll n;cin>>n;ll ar[n];forl(i,n) cin>>ar[i];
#define pat2 ll n,k;cin>>n>>k;ll ar[n];forl(i,n) cin>>ar[i];

#define inf 1e18
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832
#define eness(x) __builtin_ctzll(x)//trailing 0s
#define nhigh(x) __builtin_popcountll(x)//number of high terms
//**********************************
void Fast();
ll mf(ll x,ll mod);
ll mi(ll x,ll mod);
ll C(ll n,ll r,ll mod);
ll bpow(ll a,ll b,ll mod);

void Fast(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}
ll mf(ll x,ll mod=mod1){
    if(x<2) return 1;
    return (x*mf(x-1))%mod;
}
ll mi(ll x,ll mod=mod1){
    return bpow(x,mod-2,mod);
}
ll C(ll x,ll y,ll mod=mod1){
    if(x<y) return 0;
    return (((mf(x)*mi(mf(y)))%mod)*mi(mf(x-y)))%mod;
}
ll bpow(ll x,ll y,ll mod){
    x%=mod;
    ll res=1;
    while(y>0){
        if(y&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        y>>=1;
    }
    return res;
}
//**********************************

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    Fast();
    ll n,d,ans=0;
    cin>>n>>d;
    while(n--){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d){
            ans++;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
  int p;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL) x=x->left;
  return x;

}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;

}

Node treeSuccessor(Node x){
  if(x->right!=NIL) return treeMinimum(x->right);
  Node y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
   Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL) y=z;
  else y = treeSuccessor(z);
  if(y->left != NIL){
    x=y->left;
  }
  else{
    x=y->right;
      }
  if(x!=NIL)
    x->parent=y->parent;

  if(y->parent==NIL)
    root=x;
  else {
    if(y==y->parent->left)
      y->parent->left=x;
    else
      y->parent->right=x;
  }
  if(y!=z)
    z->key=y->key;

  free(y);

}

void insert(int k){
  Node y = NIL;
  Node x = root;
 Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;



  
  while (x != NIL){
    y = x; // 親を設定
    if(z->key < x->key)
    x = x->left; // 左の子へ移動
    else 
      x = x->right; // 右の子へ移動
	       }
  z->parent = y;

  if(y == NIL) // T が空の場合
    root = z;
  else if (z->key < y->key)
    y->left = z ;// z を y の左の子にする
  else 
      y->right = z ;// z を y の右の子にする
  





}

void inorder(Node u){
  if(u== NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  
}

void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int i,n,x;
  char com[20];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
      
  }

  return 0;

}








Measured memory_bytes: 20492
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,k,q,m,a[200000],b,cou=0,res=0,poi[200000]={};

priority_queue<long long int>pq;
int main() {
	cout << fixed << setprecision(10);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
		pq.push(a[i]);
	}
	for(int i=0;i<m;i++){
		long long int ma=pq.top();
		pq.pop();
		pq.push(ma/2);
	}
	while(!pq.empty()){
		res+=pq.top();
		pq.pop();
	}
	cout<<res<<endl;
} 


Measured memory_bytes: 1912
#include<stdio.h>


unsigned long ans(int n)
{
  unsigned long a[2] = {2,1};

  if( n == 0 ) return a[0];
  if( n == 1 ) return a[1];
  for( int loop = 2; loop <= n; loop ++) {
    a[loop & 1] = a[0] + a[1];
  }
  
  return a[n&1];
}

int main(void)
{
  int N;
  
  scanf("%d", &N);
  
  printf("%lld\n", ans(N));
  
  return 0;
}


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

void fnInput(int &a_riElementCnt, vector<int> &a_rviElement, 
             int &a_riTargetCnt , vector<int> &a_rviTarget )
{
  cin >> a_riElementCnt;

  a_rviElement.resize(a_riElementCnt);
  for (int i = 0; i < a_riElementCnt; i++)
    cin >> a_rviElement[i];

  cin >> a_riTargetCnt;

  a_rviTarget.resize(a_riTargetCnt);
  for (int i = 0; i < a_riTargetCnt; i++)
    cin >> a_rviTarget[i];
}

int fnRcsSearch(int a_iPos, const vector<int> &a_cnrviElement, int a_iTarget,
                vector<vector<int>> &a_rvviOK)
{
  if (a_iPos == a_cnrviElement.size())  return 0;
  if (!a_iTarget)    return 1;
  if (a_iTarget < 0) return 0;
  if (a_rvviOK[a_iPos][a_iTarget] != -1)
    return a_rvviOK[a_iPos][a_iTarget];

  a_iPos++;
  int iRtn;
  int iSmallTarget;

  iRtn = fnRcsSearch(a_iPos, a_cnrviElement, a_iTarget, a_rvviOK);
  a_rvviOK[a_iPos][a_iTarget] = iRtn;
  if (iRtn)  return iRtn;

  iSmallTarget = a_iTarget - a_cnrviElement[a_iPos];
  iRtn = fnRcsSearch(a_iPos, a_cnrviElement, iSmallTarget, a_rvviOK);
  if (iSmallTarget >= 0)
  {
    a_rvviOK[a_iPos][iSmallTarget] = iRtn;
    return iRtn;
  }
}

void fnExhSearch(const vector<int> &a_cnrviElement, const vector<int> &a_cnrviTarget)
{
  vector<vector<int>> vviOK(21, vector<int>(2001, -1));
  
  for (int i = 0; i < a_cnrviTarget.size(); i++)
  {
    int iTarget = a_cnrviTarget[i];
    int iRtn;

    if (iRtn = fnRcsSearch(0, a_cnrviElement, iTarget, vviOK))
    {
      cout << "yes" << endl;
      vviOK[0][iTarget] = iRtn;
      continue;
    }

    int iSmallTarget = iTarget - a_cnrviElement[0];
    if (iRtn = fnRcsSearch(0, a_cnrviElement, iSmallTarget, vviOK))
      cout << "yes" << endl;
    else
      cout << "no" << endl;

    if (iSmallTarget >= 0)
      vviOK[0][iSmallTarget] = iRtn;
  }
}

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

  int iElementCnt, iTargetCnt;
  vector<int> viElement, viTarget;

  fnInput(iElementCnt, viElement, iTargetCnt, viTarget);
  fnExhSearch(viElement, viTarget);

  return 0;
}

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


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





Measured memory_bytes: 3648
import math

n,d=(int(a) for a in input().split())
#d=int(input())

count=0

for i in range(n):
    x,y=(int(a) for a in input().split())
    a=math.sqrt(x*x+y*y)
    
    if a<=d:
        count=count+1

print(count)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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;}


int main(){
    string s;cin>>s;
    rep(i,2) s.push_back('z');//sentinel

    ll ans=0;
    ll cnt=1;
    bool exist=false;
    rep(i,s.size()-1){
        if((s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C')){
            if((s[i+1]=='A' || s[i+1]=='T' || s[i+1]=='G' || s[i+1]=='C')) cnt++;
            exist=true;
        }else{
            ans=max(ans,cnt);
            cnt=1;
        }
    }
    if(!exist) cout<<0<<endl;
    else cout<<ans<<endl;
	return 0;
}

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

int m[12][12];

bool valid(int y, int x) {
  if(0 <= y && y < 12) {
    if(0 <= x && x < 12) {
      if(m[y][x] == 1) return true;
    }
  }
  return false;
}

void remove_island(int y, int x) {
  int nx, ny;
  int dx[4] = {1, 0, -1,  0};
  int dy[4] = {0, 1,  0, -1};

  m[y][x] = 0;
  for(int i = 0; i < 4; i++){
    ny = y + dy[i];
    nx = x + dx[i];
    if(valid(ny, nx)) remove_island(ny, nx);
  }
}

int main() {
  char c[12];
  int ans;
  while(1){
    for(int i = 0; i < 12; i++) {
      if(!(cin >> c)) return 0;
      for(int j = 0; j < 12; j++) {
        m[i][j] = (int)(c[j] - '0');
      }
    }

    ans = 0;
    for(int i = 0; i < 12; i++) {
      for(int j = 0; j < 12; j++) {
        if(valid(i, j)) {
          remove_island(i, j);
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1148
s = input()
start = 0
stop = 0
for i in range(len(s)):
  if s[i] == 'A':
    start = i
    break

for i in range(len(s) -1, start, -1):
  if s[i] == 'Z':
    stop = i
    break
print(stop - start + 1)

Measured memory_bytes: 3516
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)

struct eg{
    int a,b,c;
};

#define int ll

#define MAX_V 500
#define MAX_B 50

struct edge{pii to;int cost;};

void dijkstra(pii s, vector<vector<int>> &d, vector<edge> G[MAX_V][MAX_B]){
    priority_queue< pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>> > que;
    rep(i,MAX_V)rep(j,MAX_B)d[i][j]=INF;
    d[s.first][s.second]=0;
    que.push(make_pair(0,s));
    
    while(que.size()){
        pair<int,pii> p=que.top();
        que.pop();
        
        int v=p.second.first;
        int b=p.second.second;
        if(d[v][b]<p.first)continue;
        
        rep(i,G[v][b].size()){
            edge e=G[v][b][i];
            if(d[e.to.first][e.to.second]>d[v][b]+e.cost){
                d[e.to.first][e.to.second]=d[v][b]+e.cost;
                que.push(make_pair(d[e.to.first][e.to.second],e.to));
            }
        }
    }
}


signed main(){
    int v,e;
    cin>>v>>e;
    vector<pii> gr[MAX_V];
    rep(i,e){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        gr[a].pb(pii(b,c));
        gr[b].pb(pii(a,c));
    }
    
    int v0;
    cin>>v0;
    int a,b,c;
    cin>>a>>b>>c;
    
    vector<edge> G[MAX_V][MAX_B];
    rep(i,v){
        rep(vid,c){
            int vi = (a*vid+b)%c;
            for(auto e:gr[i]){
                G[i][vid].pb(edge{pii(e.first,vi),e.second*vid});
            }
        }
    }
    
    vector<vector<int>> d1(MAX_V,vector<int>(MAX_B));
    dijkstra(pii(0,v0),d1, G);

    int ans = INF;
    rep(i,c){
        vector<vector<int>> d2(MAX_V,vector<int>(MAX_B));
        dijkstra(pii(v-1,i),d2,G);
        int t = INF;
        rep(j,c){
            t = min(t,d1[v-1][i] + d2[0][j]);
        }
        ans = min(ans, t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 17776
#解説をみたあとで再帰的にやる
#方針1: 753数をすべて列挙する
#方針2: N以下の753数を数える

#1-1:
#準753数の末尾に3/5/7を追加することで1桁多い準753数を再帰的に生み出す
#
#1-1-1:seminanagosanの先頭の要素をとりだす
#1-1-2:その要素の末尾に3,5,7を追加したものをseminanagosanの末尾に追加
#1-1-3:上記を繰り返す(ここではN<=10**9が保証されているので,取り出した要素が9桁,つまり10**8以上になったところでストップする)

seminanagosan = [3,5,7]

i = 0
while True:
	if seminanagosan[i] >= 10**8:
		break
	else:
		for s in ['3','5','7']:
			seminanagosan.append(int(str(seminanagosan[i])+s))
		i += 1

#2.seminanagosanはすでにソートされているので,seminanagosanのうち本当に753数でありかつN以下のものを数える

N = int(input())
result = 0
for num in seminanagosan:
	if num > N:
		break
	else:
		nums = str(num)
		if '3' in nums and '5' in nums and '7' in nums:
			result += 1
print(result)

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,aa,bb;
cin>>a>>b>>c;
while(c){
if(a%2==1) a--;
  b+=a/2;
  a/=2;
  c--;
  if(c==0) break;
if(b%2==1) b--;
a+=b/2;
b/=2;
  c--;
}
cout<<a<<" "<<b<<endl;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int a;
  int b;
  cin >> a >> b;
  if(a - 2 * b < 0)
  {
    cout << 0;
  }
  else
  {
    cout << a- 2 * b;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int m=0;
  for(int i=0; i < N; i++){
    int x;
    cin >> x;
    if(x < K-x){
      m = m + x*2;
    }
    else{
      m = m + (K-x)*2;
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)
mod = 10**9 + 7

def comb(x, y, mod)
  m = [y, x - y].min
  return 1 if m == 0

  n = ((x - m + 1)..x).inject { |i, j| i * j % mod }
  d = (1..m).inject { |i, j| i * j % mod }.pow(mod - 2, mod)

  n * d
end

puts (2.pow(n, mod) - comb(n, a, mod) - comb(n, b, mod) - 1) % mod

Measured memory_bytes: 14296
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>; //pop_back pop_front push_back push_front front back clear empty
using L = vector<long long>;
using M = map<int,long long>;  //erase  (でキーごと削除) 追加削除検索O(log(N))
using A = vector<vector<long long>>;
using U = unordered_map<int,long long>; //map  (との違いはkeyの順番を保持していない)
using PQL = priority_queue<long long>; //erase  (でキーごと削除) push pop top 
using PQG = priority_queue<long long,L,greater<long long>>; //erase  (でキーごと削除) push pop top 

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vdel(vector,a) vector.erase(vector.begin()+a)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define max max<unsigned long>
#define min min<unsigned long>
#define inf 1000000000000000000+10
#define setans long long ans=0;

long long MOD=1000000007;

template <typename PQ>
long long pqsum(PQ pq){long long tmp=0;while(!pq.empty()){tmp+=pq.top();pq.pop();};return tmp;};

template <typename T>
void print(T a){for (auto b:a){cout<<b<<" ";};cout<<endl;}
template <>
void print(unsigned long a){cout<<a<<endl;}
template <>
void print(char a){cout<<a<<endl;}
template <>
void print(bool a){cout<<a<<endl;}
template <>
void print(long long a){cout<<a<<endl;}
template <>
void print(A a){for (auto b:a){for (auto c:b){cout<<c<<" ";}cout<<endl;};cout<<endl;}
template <>
void print(string a){cout<<a<<endl;}



//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ
//printf("%.16f", ans); 誤差落ち対応君

vector<long long> cumsum(vector<long long> numbers){
    for(int i=1  ;i<numbers.size()  ;i++){
        numbers[i]+=numbers[i-1];
    }
    return numbers;
}

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

    long long n;

    cin>>n;
    L a(n,0);

    for(long long i=0  ;i<n  ;i++){
        cin>>a[i];
    }
    long long l=0,r=vsum(a);
    L g;
    g.push_back(abs(l-r));
    
    for(long long i=0  ;i<n  ;i++){
        l+=a[i];
        r-=a[i];
        g.push_back(abs(r-l));
    }
    print(vmin(g));
}

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

int n, num[100005];
string a;
bool f(int p) {
    int t1,t2;
    t1 = (p - 1 + n) % n;
    t2 = (p + 1) % n;
    if (num[p] == 1 && (num[t1] == num[t2] && a[p] == 'o' || num[t1] != num[t2] && a[p] == 'x')) {
        return true;
    }
    if (num[p] == 2&& (num[t1] != num[t2] && a[p] == 'o' || num[t1] == num[t2] && a[p] == 'x')) {
        return true;
    }
    return false;
}
int main()
{
    int i, j, k, t1, t2;
//    freopen ("input.txt", "r", stdin);
    cin >> n;
    cin >> a;
    for (i = 1; i<= 2; i++) {
        for (j= 1; j<= 2; j++) {
            num[0] = i;
            num[1] = j;
//            if (i == j && a[1] == 'x' || i != j && a[2] == 'o') continue;
            for (k = 1; k < n - 1; k++) {
                if (num[k] == 1) {
                    if (a[k] == 'o') num[k + 1] = num[k - 1];
                    else num[k + 1] = 3 - num[k - 1];
                } else {
                    if (a[k] == 'o') num[k + 1] = 3 - num[k - 1];
                    else num[k + 1] = num[k - 1];
                }
            }
            for (k = 0; k < n; k++) {
                if (!f(k)) break;
            }
            if (k == n) {
                for (k = 0; k < n; k++) {
                    if (num[k] == 1) printf("S");
                    else printf("W");
                }
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

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

ll extgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  ll q = a / b;
  ll g = extgcd(b, a - q * b, x, y);
  ll z = x - q * y;
  x = y, y = z;
  return g;
}

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

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll X;

    cin >> X;

    cout << lcm(X, 360)/X << endl;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define db double

priority_queue<db> h;
db n, a[10001];

main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + (int)n + 1);
    db sum = (a[1] + a[2]) / 2;
    for(int i = 3; i <= n; ++i)
    {
        sum = (sum + a[i]) / 2;
    }
    cout << setprecision(12) << fixed << sum;
}


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

using namespace std;

typedef long long ll;

typedef vector<ll> vector_t;

struct knapsack:array<vector_t,2>
{
    ll max_value;
    
    knapsack(int n, int W) 
    { 
        vector<int> weight(n), value(n); 
        
        for(int i = 0; i < n; ++i)
            cin >> weight[i] >> value[i];
      
        int W1 = W+1; front().resize(W1,0);
            
        for (int i = 0; i < n; ++i) 
        {
	    	back() = front();

	        for (int v = value[i], w = weight[i], w1 = 0; w < W1; ++w, w1++) 
	            if((max_value = back().at(w1)+v) > front().at(w))
	               front().at(w) = max_value;
        }
     
        max_value = front().at(W); 
    }
};

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

    int n, W; cin >> n >> W; cout << knapsack(n,W).max_value; 
}

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


	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=B-A;
		int cnt=0;
		for(int i=1;i<=C;i++) {
			cnt+=i;
		}
		System.out.println(cnt-B);

	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
typedef tuple<int,int,int,int>T;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;

int main(){
  	string S;
  	cin >>S;
  	int N=S.size();
  	queue<int>hoshi;
  	queue<int>sank;
  	sank.push(-1);
  	rep(i,N-1){
    	if(S[i]=='R'&&S[i+1]=='L'){
        	hoshi.push(i);
        }
      	if(S[i]=='L'&&S[i+1]=='R'){
        	sank.push(i);
        }
    }
  	sank.push(N-1);
  	vector<int>memo(N,0);	
  	while(!hoshi.empty()){
    	int a,b,c;
    	a=1+sank.front();sank.pop();
    	c=sank.front();
    	b=hoshi.front();hoshi.pop();
      	memo[b]=((b-a+2)/2)+((c-b)/2);
      	memo[b+1]=((b-a+1)/2)+((c-b+1)/2);
    }
  	rep(i,N){
    	cout<<memo[i]<<' ';
    }
}

Measured memory_bytes: 1408
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;

    int m = int(floor(sqrt(N))) + 1;
    int s[m];
    REP(i ,m) s[i] = i;
    for (int i = 2; i <= m; ++i) {
        if (s[i] != i) continue;

        for (int j = i+i; j <= m; j += i) {
            s[j] = i;
        }
    }

    vector<int> _p;
    FOR(i, 2, m) {
        if (s[i] == i) _p.pb(i);
    }

    map<int, int> p;
    FOR(i, 1, N+1) {
        int n = i;
        REP(j, _p.size()) {
            if (n == 1) break;

            int cnt = 0;
            while(n % _p[j] == 0) {
                n /= _p[j];
                ++p[_p[j]];
            }
        }

        if (n != 1) ++p[n];
    }
    
    cout << fixed << setprecision(20);

    int cnt[p.size()+1][76];
    REP(i, p.size()+1) REP(j, 76) cnt[i][j] = 0;
    cnt[0][1] = 1;

    int pi = 0;
    for(auto it=p.begin(); it != p.end(); ++it) {
        int pp = it->fi;
        int c = it->se;
        ++pi;

        REP(i, 76) {
            if (cnt[pi-1][i] == 0) continue;
            REP(j, c+1) {
                int cc = i * (j + 1);
                if (cc > 75) break;
                cnt[pi][cc] += cnt[pi-1][i];
            }
        }
    }

    cout << cnt[pi][75] << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
ll n; int ans;

void f(ll x,bool f3,bool f5,bool f7){
    if(x>n) return;
    if(f3&&f5&&f7) ans++;
    f(x*10+3,true,f5,f7);
    f(x*10+5,f3,true,f7);
    f(x*10+7,f3,f5,true);
}
int main(){
  ans=0;
    cin >> n;
    f(0,0,0,0);
    cout << ans << endl;
    return 0;
}
   

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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};

int main(void){
	int n, k; cin>>n>>k;
	int x[n] = {};
	for(int i=0;i<n;i++) cin>>x[i];

	int mint = INF;
	for(int i=0;i + k - 1 < n;i++) {
		int d = abs(x[i + k - 1] - x[i]) + min(abs(x[i + k - 1]), abs(x[i]));
		mint = min(mint, d);
	}

	cout<< mint <<endl;
	
	return 0;
}

Measured memory_bytes: 640
unsigned long long d[2000*2000/64+1]={1};
N,A,S,i;
main(){
	for(scanf("%d",&N);N--;){
		scanf("%d",&A);
		S+=A;
		for(i=S/64;i>=0;--i){
			d[i+A/64]|=d[i]<<A%64;
			if(A%64){
				d[i+A/64+1]|=d[i]>>64-A%64;
			}
		}
	}
	for(i=-~S/2;;++i){
		if(d[i/64]>>i%64&1){
			printf("%d\n",i);
			break;
		}
	}
}


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

string xor_s(string lhs, string const& rhs) {
    const int m = lhs.size();
    for(int i = 0; i < m; ++i) {
        if(rhs[i] == '1') {
            lhs[i] = (lhs[i] == '0' ? '1' : '0');
        }
    }
    return lhs;
}

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<string> v(n);
        for(int i = 0; i < n; ++i) {
            cin >> v[i];
        }
        if(m <= 16) {
            vector<int> w(n);
            for(int i = 0; i < n; ++i) {
                for(int j = 0; j < m; ++j) {
                    w[i] |= (v[i][j] == '1') << j;
                }
            }
            vector<int> dp(1 << m, -1);
            dp[0] = 0;
            for(int i = 0; i < n; ++i) {
                auto nxt = dp;
                for(int S = 0; S < (1 << m); ++S) {
                    if(dp[S] == -1) continue;
                    nxt[S ^ w[i]] = max(nxt[S ^ w[i]], dp[S] + 1);
                }
                dp = move(nxt);
            }
            cout << dp[0] << endl;
        } else {
            const int n1 = n / 2, n2 = n - n1;
            const string z = string(m, '0');
            map<string, int> dp;
            for(int S = 0; S < (1 << n1); ++S) {
                string used = z;
                for(int i = 0; i < n; ++i) {
                    if(S & (1 << i)) {
                        used = xor_s(move(used), v[i]);
                    }
                }
                dp[used] = max(dp[used], __builtin_popcount(S));
            }
            int ans = 0;
            for(int S = 0; S < (1 << n2); ++S) {
                string used = z;
                for(int i = 0; i < n2; ++i) {
                    if(S & (1 << i)) {
                        used = xor_s(move(used), v[i + n1]);
                    }
                }
                if(dp.count(used) != 0) {
                    ans = max(ans, dp[used] + __builtin_popcount(S));
                }
            }
            cout << ans << endl;
        }
    }
}



Measured memory_bytes: 3836
w = list(input())
alp = list("qwertyuioplkjhgfdsazxcvbnm")
data = [0]*len(alp)
for item in w:
    key = alp.index(item)
    data[key] += 1

flag = 0
for num in data:
    if num%2 != 0:
        flag = 1
        break

print(["Yes","No"][flag])

Measured memory_bytes: 3060
n = int(input())
S = list(map(int,input().split(' ')))

q = int(input())
T = list(map(int,input().split(' ')))


C = 0
def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right) // 2
        if A[mid] == key:
            global C
            C+= 1
            break
        elif A[mid] < key:
            left = mid + 1
        else:
            right = mid
    
            
for key in T:
    binarySearch(S, key)
    
print(C)



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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int def(string ma, string mi) {
  rep(i, 0, 8) {
    if(ma == mi) return i;
    mi[mi.size() - 1]++;
      for(int j = mi.size() - 1; j >= 0; --j) {
        if(mi[j] != '9' + 1) break;
        else if(j - 1 > 0) mi[j - 1]++;
        else mi.insert(0, "1");
      }
  }
  if(ma == mi) return 8;
  return 9;
}

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

  string s;
  cin >> s;

  int sz = s.size();
  int ans = INF;
  {
    rep(i, 1, sz) {
      if(sz % i) continue;

      string Max, Min;
      Max = Min = s.substr(0, i);
      for(int j = 0; j < sz; j += i) {
        Max = max(Max, s.substr(j, i));
        Min = min(Min, s.substr(j, i));
      }

      ans = min(ans, def(Max, Min));
    }
  }
  {
    int Max = 0, Min = 10;
    int i = 0, num;
    while(i < sz) {
      num = s[i] - '0';
      if(s[i] == '1' && i + 1 < sz) {
        i++;
        num = 10 + (s[i] - '0');
      }

      i++;
      Max = max(Max, num);
      Min = min(Min, num);
    }
    if(Max != 0) ans = min(ans, Max - Min);
  }
  cout << ans << endl;
}



Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
  int n,sum=0;
  cin >> n;
  vector<int> d(n);
  rep(i,n)
    cin >> d.at(i);
  for(int i=0;i<n-1;i++){
    for(int j=1;j<n;j++){
      if((i+j)<n)
        sum+=d.at(i)*d.at(i+j);
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var a, b string
	con.Scan(&a, &b)
	for i := 0; i < len(a); i++ {
		con.Print(a[i : i+1])
		if i < len(b) {
			con.Print(b[i : i+1])
		}
	}
	con.Println()
	return nil
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin

#define lset(h, n) memset(h, n, sizeof(h));
    

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n;
    cin >> n;

    int a[n],b[n],c[n];
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n-1){
        cin >> c[i];
    }
    int ans = 0;
    int bk=100000;
    rep(i,n){
        ans +=b[i];
            if(bk==a[i]-1){
                ans += c[a[i-1]-1];
            }
        bk=a[i]; 
    }
    pri(ans);




}











Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;cin >>n;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int l,r;cin>>l>>r;
        sum+=r-l+1;
        
        
    }
    cout<<sum;
    
}


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


int main(){
  ll a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
}

Measured memory_bytes: 3632
from math import gcd
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        t = gcd(a, b)
        if t == 1:
            ans += k
            continue
        for c in range(1, k+1): ans += gcd(t, c)
print(ans)

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	int H, N;
	cin >> H >> N;
	int damage = 0;
	int each;
	rep(i, N) {
		cin >> each;
		damage += each;
	}
	if (damage >= H) y();
	else n();
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    char a;
    cin>>a;
    printf("%c\n",((a-'a'+1)%26+'a'));
    return 0;
}

Measured memory_bytes: 256
import collections

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

ans = sum(a)
cnter = collections.Counter(a)

for _ in range(q):
    b, c = map(int, input().split())
    diff = c - b
    cnter[c] += cnter[b]
    ans += diff * cnter[b]
    print(ans)
    cnter[b] = 0



Measured memory_bytes: 23976
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,kk;
int main()
{
    cin>>a>>b>>c;
    if(b>=a)
    {
        cout<<"1"<<endl;
        return 0;
    }
    if(c>=b)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    if((a-b)%(b-c)>=1)
		kk=1;
    cout<<((a-b)/(b-c)+kk)*2+1<<endl;
    return 0;
}

Measured memory_bytes: 256