akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

struct node {
  int key;
  node *parent, *right, *left;
};

node *NIL, *root;

void insert(int k) {
  node *y = NIL;
  node *x = root;
  node *z = (node *)malloc(sizeof(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) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

node *find(int k) {
  node *x = root;
  while (x != NIL && x->key != k) {
    if (k < x->key) {
      x = x->left;
    } else if (k > x->key) {
      x = x->right;
    }
  }
  return x;
}

node *treeMinimum(node *x) {
  while (x->left != NIL) {
    x = x->left;
  }
  return x;
}

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 deleteNode(node *n) {
  node *y;
  node *x;
  if (n->left == NIL || n->right == NIL) {
    y = n;
  } else {
    y = treeSuccessor(n);
  }

  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 != n) {
    n->key = y->key;
  }

  free(y);
}

void inorderBody(node *u) {
  if (u == NIL) return;
  inorderBody(u->left);
  cout << " " << u->key;
  inorderBody(u->right);
}

void inorder() {
  inorderBody(root);
  cout << endl;
}

void preorderBody(node *u) {
  if (u == NIL) return;
  cout << " " << u->key;
  preorderBody(u->left);
  preorderBody(u->right);
}

void preorder() {
  preorderBody(root);
  cout << endl;
}

int main() {
  int m, tmp;
  string s;
  root = NIL;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> s;
    if (s == "insert") {
      cin >> tmp;
      insert(tmp);
    } else if (s == "print") {
      inorder();
      preorder();
    } else if (s == "find") {
      cin >> tmp;
      if (find(tmp) != NIL) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else if (s == "delete") {
      cin >> tmp;
      deleteNode(find(tmp));
    }
  }
}


Measured memory_bytes: 21900
n = gets.to_i
ary = gets.split.map &:to_i
ary = ary.sort.reverse

alice = 0
bob   = 0

for i in 0 .. n - 1
  if i % 2 == 0
    alice += ary[i]
  else
    bob   += ary[i]
  end
end

puts alice - bob


Measured memory_bytes: 3836
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>
 
#define N 200005
#define M 8000005
 
#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)
 
#define mk make_pair
#define pb push_back
#define fi first
#define se second
 
#define Mo 1000000007
 
using namespace std;
 
int i,j,m,n,p,k,s[N],q,l,r,g[N];
 
vector<int>v[N];
 
int f[N],tree[N*4];
 
int ask(int ll,int l,int r,int t)
{
		if (l==r) return tree[t];
		else 
		{
				if (ll<=mid) return min(tree[t],ask(ll,l,mid,ls));
				else return min(tree[t],ask(ll,mid+1,r,rs));
		}
}
 
void insert(int ll,int rr,int c,int l,int r,int t)
{
		if (ll<=l&&r<=rr) tree[t]=min(tree[t],c);
		else 
		{
				if (ll<=mid) insert(ll,rr,c,l,mid,ls);
				if (rr>mid)  insert(ll,rr,c,mid+1,r,rs);
		}
}
 
 
void build_tree(int l,int r,int t)
{
		tree[t]=(int)1e9;
		if  (l==r) return;
		build_tree(l,mid,ls);
		build_tree(mid+1,r,rs);
}
 
int main()
{
		scanf("%d",&n);
		for (i=1;i<=n;++i) scanf("%d",&s[i]),s[i]=(1-s[i])+s[i-1];
		scanf("%d",&q);
		for (i=1;i<=q;++i) 
			scanf("%d%d",&l,&r),v[r].pb(l);
		memset(f,60,sizeof(f));
		memset(g,60,sizeof(g));
		f[0]=0; g[0]=0;
		build_tree(0,n,1);
		for (i=1;i<=n;++i)
		{
				g[i]=g[i-1]+(s[i]-s[i-1]==0);
				int G;
				for (int j: v[i])
					G=min(g[j-1]-s[j-1],ask(j-1,0,n,1)),
					insert(j,i,G,0,n,1),
					g[i]=min(g[i],G+s[i]);
		}
		printf("%d\n",g[n]);
}

Measured memory_bytes: 15232
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 105
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
double EPS= 1e-10;
const double PI=acos(-1.0);
double add(double a,double b)
{
    if(abs(a+b)<EPS*(abs(a)+abs(b))) return 0;
    return a+b;
}
struct P
{
    double x,y;
    int id;
    P(){}
    P(double x,double y):x(x),y(y){}
    P operator +(P p)
    {
        return P(add(x,p.x),add(y,p.y));
    }
    P operator -(P p)
    {
        return P(add(x,-p.x),add(y,-p.y));
    }
    P operator *(double d)
    {
        return P(x*d,y*d);
    }
    double dot(P p)
    {
        return add(x*p.x,y*p.y);
    }
    double det(P p)
    {
        return add(x*p.y,-y*p.x);
    }
};
bool cmp_x(const P& p,const P& q)
{
    if (p.x!=q.x) return p.x<q.x;
    return p.y<q.y;
}
vector<P> convex_hull(P* ps,int n)
{
    sort(ps,ps+n,cmp_x);
    int k=0;
    vector<P> qs(n*2);
    for(int i=0;i<n;i++)
    {
        while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
        qs[k++]=ps[i];
    }
    for(int i=n-2,t=k;i>=0;i--)
    {
        while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
        qs[k++]=ps[i];
    }
    qs.resize(k-1);
    return qs;
}
double dist(P p,P q)
{
    return sqrt((p-q).dot(p-q));
}
int N;
P ps[MAXN];
double ans[MAXN];
int main()
{
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%lf %lf",&ps[i].x,&ps[i].y);
        ps[i].id=i;
    }
    vector<P> qs=convex_hull(ps,N);
    for(int i=0;i<(int)qs.size();i++)
    {
        int last=i-1;if(last<0) last+=(int)qs.size();
        int nxt=i+1;if(nxt>=(int)qs.size()) nxt-=(int)qs.size();
        double ang1=atan2((qs[i]-qs[last]).x,(qs[i]-qs[last]).y);
        double ang2=atan2((qs[i]-qs[nxt]).x,(qs[i]-qs[nxt]).y);
        double ang=ang2-ang1;
        while(ang<0) ang+=2*PI;
        while(ang>2*PI) ang-=2*PI;
        if(ang>PI) ang=2*PI-ang;
        ans[qs[i].id]=(PI-ang)/(2*PI);
    }
    for(int i=0;i<N;i++) printf("%.15f\n",ans[i]);
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
int keta(int val)
{
    long long k = 0;
    if (val == 0)
    {
        return 1;
    }
    while (val > 0)
    {
        val /= 10;
        k++;
    }
    return k;
}
int main(void)
{
    int n, m;
    cin >> n >> m;

    map<int, int> mp;
    REP(i, m)
    {
        int s, c;
        cin >> s >> c;
        if (mp.count(s) != 0 and mp[s] != c)
        {
            cout << "-1" << endl;
            return 0;
        }
        mp[s] = c;
    }

    for (int i = 0; i <= 999; i++)
    {
        if (keta(i) != n)
            continue;
        string s = to_string(i);
        bool flag = true;
        for (auto j : mp)
        {
            if (s[j.first - 1] - '0' != j.second)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
    {
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
      primes(i) = primes(i) + primes(i-1)
      primes(i+1) = primes(i+1) + primes(i)
    }

    for(i<-Math.sqrt(n).toInt+1 to n)
      primes(i) = primes(i)+primes(i-1)

    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(1000000)
    println{
       { for(i <- stdin.getLines) yield p(i.toInt) }.mkString("\n")
    }
  }
}

Measured memory_bytes: 63500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;

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

    int cnt = 1;
    int d = 0;
    for (int i = 0; i < n; i++)
    {
        d += l[i];
        if (d <= x)
        {
            cnt++;
        }
        else
        {
            break;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[])
{
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      char c_ij;
      std::cin >> c_ij;
      if (i == j) {
        std::cout << c_ij;
      }
    }
  }
  std::cout << std::endl;
  return 0;
}


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

int main()
{
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			cout << i << "x" << j << "=" << i * j << endl;
		}

	}



	return 0;
}




Measured memory_bytes: 2928
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int r= s.nextInt();
		int D= s.nextInt();
		int Xn= s.nextInt();
		
		for(int i=0;i<10;i++) {
			Xn = r*Xn-D;
			System.out.println(Xn);
		}	
		s.close();
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

// seiyaku[i][0] : 値iは行seiyaku[i][0]で最大値でないといけない
// seiyaku[i][1] : 値iは列seiyaku[i][0]で最大値でないといけない
int seiyaku[1000001][2] = {};

int main()
{
	int n, m;
	cin >> n >> m;
	long long int ans = 1;
	for(int i = 1; i <= n; i++){
		int a;
		cin >> a;
		if(seiyaku[a][0] > 0) ans = 0;
		else seiyaku[a][0] = i;
	}
	for(int i = 1; i <= m; i++){
		int b;
		cin >> b;
		if(seiyaku[b][1] > 0) ans = 0;
		else seiyaku[b][1] = i;
	}
	set<int> alreadymax_r,alreadymax_g;

	for(int i = n * m; i>= 1; i--){
		int g = seiyaku[i][0];
		int r = seiyaku[i][1];
		if(g > 0 && r > 0){
			// 行と列どちらにも制約がある(最大値となる)場合
			// g行目r列目にiを埋めないといけない
			if(alreadymax_g.find(g) != alreadymax_g.end() || alreadymax_r.find(r) != alreadymax_r.end()){
				ans = 0;
			} else {
				alreadymax_g.insert(g);
				alreadymax_r.insert(r);
			}
		} else if(g > 0 && r == 0){
			// 行にのみ制約がある場合
			// g行目に埋めることは確定しているが、列は確定していない
			if(alreadymax_g.find(g) != alreadymax_g.end()){
				// g行目にすでに最大値が埋まっていたらアウト
				ans = 0;
			} else {
				alreadymax_g.insert(g);
				// g行目で制約を気にせず入れられるマスの数はalreadymax_r.size()
				ans = (ans * alreadymax_r.size()) % mod;
			}
		} else if(g == 0 && r > 0){
			// 列のみに制約がある場合
			// 上と同様
			if(alreadymax_r.find(r) != alreadymax_r.end()){
				ans = 0;
			} else {
				alreadymax_r.insert(r);
				ans = (ans * alreadymax_g.size()) % mod;
			}
		} else {
			// 行にも列にも制約がない場合
			ans = (ans * (alreadymax_g.size() * alreadymax_r.size() - (n * m - i))) % mod;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
n,k = map(int, input().split())
ans=0
mn = 0
mx = n

nowmin=0
nowmax=n

for i in range(n+1):
    if i>=k-1:
        ans+=mx-mn+1
        ans%=(10**9+7)
    nowmin+=1
    nowmax-=1
    mn+=nowmin
    mx+=nowmax
print(ans)

Measured memory_bytes: 64532
import math
n,b=map(int,input().split())
def kaijo(x):
  return math.factorial(x)

def C(x,y):
  if x>=y:
    return(kaijo(x)//(kaijo(y)*kaijo(x-y)))

r=n-b

for i in range(1,b+1):
  if r+1<i:
    print(0)
    continue
  print((C(b-1,i-1)*C(r+1,i))%(10**9+7))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }


int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    int k=1;
    while(k<b){
        ans++;
        k--;
        k+=a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
	int s, a, b, dista, distb;
  	cin >> s >> a >> b;
  	dista = abs(s - a);  	
  	distb = abs(s - b);
	if(dista < distb){
    	cout << "A";
    } else {
    	cout << "B";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define mx 1e18
#define mod 998244353
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll bino()
{
        vector<ll>inv(200005);vector<ll>fact(200005); vector<ll>inversef(200005);
    inv[0] = 1;inv[1]=1;
for(int i = 2; i < 200005; ++i)
    inv[i] = (inv[mod%i]*(mod-mod/i)) % mod;
    
    fact[0]=1;
    for(int i=1;i<200005;i++)
    fact[i]=(i*fact[i-1])%mod;
   
    inversef[0]=1;inversef[1]=1;
    for(int i=2;i<200005;i++)
    inversef[i]=(inversef[i-1]*inv[i])%mod;
}
ll powe(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return powe(((x%mod)*(x%mod))%mod,n/2);
    else                             //n is odd
        return ((x%mod*(powe(((x%mod)*(x%mod))%mod,(n-1)/2))%mod)%mod);
}
vector<vector<ll>>dp(3001,vector<ll>(3001,-1));

ll fun(int i,int j,vector<int>&a,int n)
{
    if(i==j)dp[i][j]=a[i];
 //   if(i>n-1)return 0;
 //   if(j<0)return 0;
   // else if(j==i+1)dp[i][j]= max(a[i],a[j]);
    
    if(dp[i][j]!=-1)return dp[i][j];
    else return dp[i][j]=max(a[i]-fun(i+1,j,a,n),a[j]-(fun(i,j-1,a,n)));
   
  //  else  return dp[i][j]= max(a[i]+min(dp[i+1][j-1],dp[i+2][j]),a[j]+min(dp[i][j-2],dp[i+1][j-1]));
    
}
int main()
{
   io
  int n;cin>>n;vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  cout<<fun(0,n-1,a,n);
}

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

using namespace std;

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> ii;
typedef pair<lli, lli> ll;

int main() {
	int n, a, b, temp = 0, maxi = 0;
	scanf("%d", &n);
	while (n--) {
		scanf("%d %d", &a, &b);
		if (a == b)
			temp++;
		else
			temp = 0;
		maxi = max(maxi, temp);
	}
	if (maxi > 2)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<int> > c(h, vector<int>(w));
    rep(i, 0, h){
        rep(j, 0, w){
            if(i < b){
                c[i][j] = (j < a);
            }else{
                c[i][j] = !(j < a);
            }
        }
    }
    rep(i, 0, h){
        for(int ii = 0; ii < c[i].size(); ii++){
            cout << c[i][ii];
        }
        cout << endl;
    }
}

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

int main(){
    int k, n; cin >> k >> n;
    vector<int> v(n);
    rep(i, n) cin >> v.at(i);
    v.push_back(v.at(0)+k);
    int ans = 0;
    rep(i, n) ans = max(ans, v.at(i+1)-v.at(i));
    cout << k - ans << endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define all(a) a.begin(),a.end()
#define f(i,l,u) for(ll i=l;i<u;i++)
#define lb lower_bound
#define ub upper_bound
ll fac[200001];

 long long power( long long x, 
                         ll y, ll p) 
{ 
    long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
 long long modInverse( long long n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
 long long nCrModPFermat(long long n, 
                                 ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    
    
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
  

void powe(ll p)
{
    fac[0] = 1; 
    for (int i = 1; i <= 200000; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
    
}

int main() {
ll n;
cin>>n;
ll arr[n+1];

f(i,0,n)
{
    cin>>arr[i];
}
sort(arr, arr + n, greater<int>()); 
ll sum=arr[0];
f(i,2,n)
sum+=arr[i/2];
cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

struct pct{
    long long x,y,id;
} a[100005];

bool comp1(pct a, pct b){
    return a.x<b.x;
}

bool comp2(pct a, pct b){
    return a.y<b.y;
}

int n,v[100005];

long long t;

set <pl> s;

vector <pl> g[100005];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i].x >> a[i].y;
        a[i].id=i;
    }
    sort(a+1,a+n+1,comp1);
    for(int i=1;i<n;i++){
        g[a[i].id].pb({a[i+1].id,a[i+1].x-a[i].x});
        g[a[i+1].id].pb({a[i].id,a[i+1].x-a[i].x});
    }
    sort(a+1,a+n+1,comp2);
    for(int i=1;i<n;i++){
        g[a[i].id].pb({a[i+1].id,a[i+1].y-a[i].y});
        g[a[i+1].id].pb({a[i].id,a[i+1].y-a[i].y});
    }
    for(pl i : g[1]){
        s.insert({i.y,i.x});
    }
    v[1]=1;
    while(s.size()){
        pl i=*(s.begin());
        s.erase(s.begin());
        if(v[i.y]) continue;
        v[i.y]=1;
        t+=i.x;
        for(pl j : g[i.y]){
            s.insert({j.y,j.x});
        }
    }
    cout << t;
}



Measured memory_bytes: 25728
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(a==1){a=14;}
if(b==1){b=14;}
if(a>b){printf("Alice\n");}
if(a==b){printf("Draw\n");}
if(a<b){printf("Bob\n");}
}

Measured memory_bytes: 128
n,x = map(int,input().split())
l = list(map(int,input().split()))
d = [0]

for i in range(n):
	d.append(d[i] + l[i])

ans  = 0
for i in range(n+1):
	if d[i] <= x:
		ans += 1

print(ans)




Measured memory_bytes: 3060
S = str(input())
Q = int(input())
flip = 0
front,back = '',''
for i in range(Q):
  j = input()
  if len(j) == 1:
    flip += 1
    continue
  else:
    if j[2] == '1' and flip % 2 == 0:
      front = j[4] + front
      continue
    elif j[2] == '2' and flip % 2 == 0:
      back = back + j[4]
      continue
    elif j[2] == '1' and flip % 2 ==1:
      back= back + j[4]
      continue
    elif j[2] == '2' and flip % 2 ==1:
      front = j[4] + front
      continue
S = front + S + back
if flip % 2 == 1:
  S = S[::-1]
print(S)

Measured memory_bytes: 9936
#include <bits/stdc++.h>
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
int main() {
  ll n,k,q,tmp;
  cin >> n >> k >> q;
  vector<ll>b(n,k-q);
  for(ll i=0;i<q;i++){
 		cin >> tmp;
 		b.at(tmp-1)+=1;
  }
  for(ll i=0;i<n;i++){
    if(b.at(i)<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}


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

using namespace std;

#define ll long long

int main(){
    int w, a, b;

    cin >> w >> a >> b;

    int ans = min(abs(b -(a+w)), abs(b+w -a));

    if((b <= a+w && a <= b)||(a<=b+w && b+w <= a+w))
        cout << 0 << endl;
    else
        cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
 
int main(){
     string N;
     cin >> N;
     cout << N.at(0) << N.at(1) << N.at(2) << endl;
}

Measured memory_bytes: 3040
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next())-1;
    
    for(int i= A; i <= B; i++){
      if((i <= A+K && i >= A) || (i >= B-K && i <= B)){
        System.out.println(i);
      }
    }
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }
const int MAXN = 5e5;
int seg[MAXN];
int n;

void update(int i, int val) {
	for(seg[i += n] = val; i > 1; i >>= 1) seg[i >> 1] = max(seg[i], seg[i ^ 1]);
}

int query(int l, int r) {
	r++; int a = 0;
	for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
		if (r & 1) a = max(a, seg[--r]);
		if (l & 1) a = max(seg[l++], a);
	}
	return a;
}


int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cin >> n;
	vector<int> h(n); for (int o = 0; o < n; o++) { int y; cin >> y; h[y - 1] = o; }
	vector<int> a(n); for (int o = 0; o < n; o++) { cin >> a[o]; }
	for (int i = 0; i < n; ++i) update(h[i], query(0, h[i]) + a[h[i]]);
	cout << query(0, n - 1);
}

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

const ll mod = 1e9 + 7;
ll n, a, b, c, d;
ll dp[1010][1010];
ll fact[1010], fact_inv[1010], inv[1010];

long long mod_pow(long long x, long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x * x % mod, n / 2);
    if(n & 1) res = res * x % mod;
    return res;
}

long long combination(long long n, long long k){
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

int main(){
    cin >> n >> a >> b >> c >> d;
    
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < 1010; i++) dp[i][0] = 1;    
    fact[0] = fact_inv[0] = 1;
	for(int i = 1; i < 1010; i++){
        inv[i] = mod_pow(i, mod - 2);
        fact[i] = fact[i - 1] * i % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }


    for(int i = a; i <= b; i++){
        for(int j = 1; j <= n; j++){
            ll p = 1;
            dp[i][j] += dp[i - 1][j];
            for(int k = 1; k <= d; k++){
                if(j - i * k < 0) break;
                p = p * combination(n - j + i * k, i) % mod * inv[k] % mod;
                if(c <= k && k <= d){
                    (dp[i][j] += (dp[i - 1][j - i * k]) * p % mod) %= mod;
                }
            }
        }
    }
    cout << dp[b][n] << endl;
    
}

Measured memory_bytes: 8192
#include<iostream>

using namespace std;

string str;
int main(){
    getline(cin, str);
    for(int i = 0; i < str.length(); ++i){
        if(isupper(str[i])) str[i] += 32;
        else if(islower(str[i])) str[i] -= 32;
    }
    cout << str << endl;
}


Measured memory_bytes: 3160
#カードゲームでプレイヤーが二人います。二人は出すカードの順番でALPHABETICALORDER 
#が高い人に三点DRAWになったときは一点で点数を表示する
#最初に何回やるかを表示必要

score=[0,0]                  #点数のためにアレー二つゼロに作っておく

num = gets.to_i
        num.times do
            taro,hanako = gets.split
            if      taro   > hanako
                score[0]+=3
            elsif   hanako > taro
                score[1]+=3
            else
                score[0]+=1
                score[1]+=1
            end
        end
puts score.join(" ")



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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = 2019;

signed main()
{
    int l, r;
    cin >> l >> r;

    int mn = INF;
    for (int i = l; i <= min(l + 3000LL, r); i++)
        for (int j = i + 1; j <= min(l + 3000L, r); j++)
            mn = min(mn, (i * j) % MOD);

    cout << mn << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX], color[MAX];
    
    for(int i = 0; i < n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    while(1){
        minv = INFTY;
        int u = -1;
        for(int i = 0; i < n; i++){
            if( (minv > d[i]) && (color[i] != BLACK) ){
                u = i;
                minv = d[i];
            }
        }
        
        if(u == -1) break;
        color[u] = BLACK;
        for(int v = 0; v < n; v++){
            if(  (color[v] != BLACK) && (M[u][v] != INFTY) ){
                if(d[v] > (d[u] + M[u][v]) ){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    
    for(int i = 0; i < n; i++){
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = INFTY;
        }
    }
    
    int k, c, u, v;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        for(int j = 0; j < k; j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}


Measured memory_bytes: 3140
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

long long connect(int a, int b)
{
    ostringstream oss;
    oss << a << b;

    istringstream iss(oss.str());
    long long ret;
    iss >> ret;
    return ret;
}

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

    multiset<int> ms;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        ms.insert(a);
        if(ms.size() > 10)
            ms.erase(--ms.end());
    }

    vector<long long> ret;
    for(multiset<int>::iterator it1=ms.begin(); it1!=ms.end(); ++it1){
        for(multiset<int>::iterator it2=ms.begin(); it2!=ms.end(); ++it2){
            if(it1 != it2)
                ret.push_back(connect(*it1, *it2));
        }
    }
    sort(ret.begin(), ret.end());

    cout << ret[2] << endl;

    return 0;
}

Measured memory_bytes: 1256
H,W,K = map(int, input().split())

def cv(S,cn,pr):
  SS=S
  ans = []
  for i in range(cn):
    ans += [pr+i+1]*(SS.find("#")+1)
    if SS.find("#")<len(SS):
      SS = SS[SS.find("#")+1:]
    else:
      SS = ""
  ans += [pr+cn]*len(SS)
  return ans
    
cnt_pre = 0 #最初のall #no
cnt = 0 # "#"の個数
for i in range(H):
  Lin = input()
  tmp = Lin.count("#")
  if tmp == 0 and cnt == 0:
    cnt_pre +=1
  elif tmp == 0:
    print(*pS)
  else:
    pS = cv(Lin,tmp,cnt)
    for i in range(0,cnt_pre+1):
      print(*pS)
    cnt_pre = 0
  cnt += tmp

Measured memory_bytes: 3572
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
H = list(map(int, input().split()))

print(sum(1 for i in range(N) if i == 0 or max(H[:i]) <= H[i]))



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

int main() {
	char a;
		cin >> a;
		if (('a'<=a&&a<='z')) {
			printf("a");
		}
		else if(('A' <= a && a <= 'Z')){
			printf("A");
		}


	return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	s := make([]int, n)
	sum := 0
	cnt := 0
	for i := range s {
		fmt.Scan(&s[i])
		sum += s[i]
		if s[i] % 10 != 0 {
			cnt++
		}
	}
	
	sort.Ints(s)
	
	if sum % 10 != 0 {
		fmt.Println(sum)
		return
	} 
	
  	if cnt == 0 {
		fmt.Println(0)
		return
    }
  
	for i := range s {
		if s[i] % 10 != 0 {
			fmt.Println(sum - s[i])
			return
		}
	}
	
}

Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
 



int main(){
    ll X; cin >> X;
    for(int i = -1000; i <= 1000; i++){
        for(int j = -1000; j <= 1000; j++){
            if(pow(i, 5) - pow(j, 5) == X){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  ll n; cin >> n;
  COUT(n*(n-1)/2);
  return 0;
}

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0028?year=2004

#include <bits/stdc++.h>

using namespace std;

int main() {
    int a;
    map<int, int> mp;

    int mx = 0;
    while (cin >> a) {
        mp[a]++;
        mx = max(mx, mp[a]);
    }

    for (auto m : mp) {
        if (m.second == mx) {
            cout << m.first << endl;
        }
    }
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3016
#include<stdio.h>

int main()
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if (!(x-r >= 0 && x+r <= W)) {
		printf("No\n");
	} else if (!(y-r >= 0 && y+r <= H)) { 
		printf("No\n"); 
	} else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r =
            new BufferedReader(new InputStreamReader(System.in), 1);
        String is = r.readLine();
        String[] sp = is.split(" ");

        int a = Integer.parseInt(sp[0]);
        int b = Integer.parseInt(sp[1]);
        int c = Integer.parseInt(sp[2]);
        int count=0;
        for(int i=a; i<=b; i++){
        	if(c%i==0)
        		count++;
        }
        System.out.println(count);
    }
}

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

int main(void) {
  
  int a, i, n;
  int *ret;
  scanf("%d", &n);
  ret = calloc(n, sizeof(int));
    for (i = 1; i < n; i++){
        scanf("%d", &a);
        ret[a-1]++;
    }
    for (i = 0; i < n; i++){
        printf("%d\n", ret[i]);
    }
  
  return 0;
}

Measured memory_bytes: 2892
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> pr;
typedef vector<int> VI;
typedef vector<pr> VP;
typedef vector<string> VS;
typedef vector<vector<int>> VV;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
const int INF = 1e9;
int fast_pow(int x, int y, int p);

string s;
int d;
int dp[10001][2][101];
int rec(int pos,int br,int md){
    if(pos==s.size()){
        return md==0 ;
    }
    int& ans =dp[pos][br][md];
    if(ans!=-1)return ans;
    ans=0;
    int en = 9;
    if(br)
        en = s[pos]-'0';
    for(int i=0;i<=en;i++){
        ans+=rec(pos+1,br&(i==(s[pos]-'0')),(md+i)%d);
        ans%=MOD;
    }
    return ans;
}
void solve() {
    cin>>s>>d;
    memset(dp,-1,sizeof dp);
	int ans = rec(0,1,0);
	ans=(ans-1+MOD)%MOD;
	cout<<ans;

}


int32_t main() {

	IOS;
	int test = 1;
	// cin>>test;
	for (int i = 1; i <= test; i++) {
//        cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}
int fast_pow(int x, int y, int p) {
	int res = 1;
	x = x % p;
	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

Measured memory_bytes: 20176
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

void solve(void)
{
  int H,W; cin>>H; cin>>W; 
  int COUNT = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      char c; cin>>c;
      if(c == '#')COUNT++;
      
    }
    
  }
  if(COUNT == H + W -1)
  {
    cout<<"Possible"<<endl;
  }
  else
  {
    cout<<"Impossible"<<endl;
  }
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
#define INF (1e9)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> P;

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
    int N, T;
    cin >> N >> T;
    bool f = false;
    int tmp = INF;
    REP(i, N) {
        int c,t;
        cin >> c >> t;
        if (t <= T) {
            if (c < tmp) {
                tmp = c;
                f = true;
            }
        }
    }
    if (f) {
        printf("%d", tmp);
    } else {
        printf("TLE");
    }
}

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

typedef long long ll;

int main() {        
	int n;
	cin >> n;
	ll val;
	cin >> val;
	for (ll i = 0; i <= n; ++i) {
		for (ll j = 0; j <= n; ++j) {
			ll k = n - i - j;
			if (k >= 0) {
				if (i * 10000 + j * 5000 + k * 1000 == val) {
					cout << i << " " << j << " " << k;
					return 0; 
				}
			}
		} 
	}
	cout << "-1 -1 -1";
}






Measured memory_bytes: 3552
#include<stdio.h>

int main(void) {
	int h, n;
	int all = 0;
	scanf("%d%d", &h, &n);
	for (int i = 0; i < n; i++) {
		int k;
		scanf("%d", &k);
		all+=k;
	}
	
	if (all>=h) {
		printf("Yes");
	}
	else printf("No");
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>

const int SIZE = 20+1;

int main() {
	long int n, i, ii, m, r;
	long int gp[SIZE], gp_[SIZE], *gpp, *gpp_, *tmpp;
	memset(gp, 0, sizeof(gp));
	gpp = gp;
	gpp_ = gp_;

	std::cin >> n;
	std::cin >> m;
	gpp[m] = 1;

	for (i=2; i<n; i++) {
		memset(gpp_, 0, sizeof(gp_));
		std::cin >> m;
		for (ii=0; ii<SIZE; ii++) {
			if (r=gpp[ii]) {
				if (ii+m<SIZE)
					gpp_[ii+m] += r;
				if (ii-m>=0)
					gpp_[ii-m] += r;
			}
		}
		tmpp = gpp;
		gpp = gpp_;
		gpp_ = tmpp;
	}

	std::cin >> m;
	std::cout << gpp[m] << '\n';
	return 0;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int len = s.length();
  int k = (len / 2) + 1;
  int i = 0, j = len / 2 - 1, l = len - 1;
  //cout << i << " " << j << " " << k << " " << l << endl;
  while(i <= j){
  	if( s[i]!=s[j] || s[k]!=s[l] || s[j]!=s[k])
      return cout << "No", 0;
    i++, j--, k++, l--;
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
vl A;
vl B;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    A = vl(N);
    B = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        cin >> B[i];
    }
    solve();
}

// 2 <= N <= 2 × 10^5
// 1 <= A_i <= B_i <= 10^9
// 入力はすべて整数である。

// ll N, vl A, vl B
// 答えを出力せよ。
void solve(){
    vl mi,ma;
    rep(i,N){
        mi.push_back(A[i]);
        ma.push_back(B[i]);
    }
    sort(all(mi));
    sort(all(ma));
    
    if(N%2){
        cout<<ma[N/2]-mi[N/2]+1<<endl;
    }else{
        cout<<ma[N/2-1]+ma[N/2]-mi[N/2-1]-mi[N/2]+1<<endl;
    }
}


Measured memory_bytes: 9820
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] N = sc.nextLine().toCharArray();
		sc.close();
		boolean isYes = false;
		if (N[0] != N[1]) {
			if (N[1] == N[2] && N[2] == N[3]) {
				isYes = true;
			}
		} else if (N[3] != N[2]) {
			if (N[2] == N[1] && N[1] == N[0]) {
				isYes = true;
			}
		} else if (N[2] == N[1] && N[1] == N[0] && N[2] == N[3]) {
			isYes = true;
		}
		
		if (!isYes) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <map>
#include <set>

using namespace std;

long long H,W;
set<pair < int, int> > p;
long long ans[10] = {};

void proc(int a, int b) {
	int count = 0;
	for (int dx = -1; dx <= 1; dx ++) {
		for (int dy = -1; dy <= 1; dy++) {
			auto it = p.find(make_pair(a+dy,b+dx));
			if ( it == p.end() ) {
			} else {
				count++;
			}
		}
	}
	ans[count -1] --;
	ans[count] ++;

}


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

	ans[0] = (H - 2) * (W - 2);

	for (int i = 0; i < N; i++) {
		int a,b;
		cin >> a >> b;
		a--; b--;
		p.insert(make_pair(a,b));
		for (int dx = -1; dx <= 1; dx ++) {
			if (b + dx - 1 < 0)
				continue;
			if (b + dx + 1 >= W)
				continue;
			for (int dy = -1; dy <= 1; dy++) {
				if (a + dy - 1 < 0)
					continue;
				if (a + dy + 1 >= H)
					continue;
				proc(a + dy, b + dx);
			}
		}
	}

	for (int i = 0; i < 10 ;i++) { 
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 5752
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;

int main() {

    ll N;
    cin >> N;
    ll x[N];
    ll y[N];
    rep(i,N){
        cin >> x[i] >> y[i];
    }
    double out = 0.0;
    rep(i,N){
        rep(j,N){
            if(i!=j){
                out += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]))/2;
            }
        }
    }
    out = out / (N*(N-1)/2.0) * ((N*(N-1)/2.0)-((N-1)*(N-2)/2.0));
    cout << fixed << setprecision(6) << out << endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
x = list(map(int, input().split()))
d = [None]*(n-k+1)
for i in range(n-k+1):
  d[i] = min(abs(x[i]),abs(x[i+k-1]))*2+max(abs(x[i]),abs(x[i+k-1])) if  x[i] <= 0 <= x[i+k-1] else max(abs(x[i]),abs(x[i+k-1]))

print(min(d))

Measured memory_bytes: 62576
<?php
fscanf(STDIN,'%d',$N);
fscanf(STDIN,'%d%d',$T,$A);
$H=explode(" ",trim(fgets(STDIN)));
$X=10000;
$C=0;
for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  $temp=$T-$H[$i]*0.006;
  if(abs($temp-$A)<$X){
    $X=abs($temp-$A);
    $C=$i;
  }
}
echo $C+1;

 ?>


Measured memory_bytes: 3700
n = int(input())
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))

max_sum = 0
for i in range(n):
    temp_sum = 0
    row_index = 0
    for j in range(n):
        temp_sum += a[row_index][j]
        if j == i:
            row_index += 1
            temp_sum += a[row_index][j]
    if temp_sum > max_sum:
        max_sum = temp_sum

print(max_sum)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const double pi = 3.1415926535897932;
const double eps = 0.000000000001;
const int inf = 1145141919;
struct edge { int to, cost; };
typedef pair<int, int>P;
typedef pair<int, P> PP;
int a[200005], b[200005];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i]>>b[i];
	int cnt = 0;
	rep(i, n)if (a[i] == b[i])cnt++;
	if (cnt == n)puts("0");
	else {
		cnt = 0;
		rep(i, n)cnt += a[i];
		int mn = inf;
		rep(i, n) {
			if (a[i] > b[i])mn = min(mn, b[i]);
		}

		cout << cnt-mn << endl;
	}
}

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

using namespace std;
int abs(int a)
{
	return(a < 0 ? -a : a);
}

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> Vec(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec[i];
		}
		int mi = 999999999;
		int a = 0;
		int b = 0;
		for(int i = 0; i < (1 << n); ++i)
		{
			a = b = 0;
			for(int j = 0; j < n; ++j)
			{
				if((1 << j) & i)
				{
					a += Vec[j];
				}
				else
				{
					b += Vec[j];
				}
			}
			mi = min(mi, abs(a - b));
		}
		cout << mi << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;cin>>n;
	string s;cin>>s;ll r=0,b=0,g=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R')r++;
		else if(s[i]=='G')b++;
		else if(s[i]=='B')g++;
	}ll sum=r*g*b;
for(int i=1;i<=(n-1)/2;i++)
for(int k=0;k<n-2*i;k++)
{
if(s[k]!=s[k+i]&&s[k+i]!=s[k+i+i]&&s[k]!=s[k+i+i])
sum-- ;
}
cout<<sum<<endl;
	}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX_R 10
#define MAX_C 10000
int R, C;
int a[MAX_R][MAX_C];
int flg[MAX_R];
int ans;
int count(void) {
  int c = 0;
  int v;
  for(int i = 0; i < C; i++) {
    v = 0;
    for(int j = 0; j < R; j++) {
      if((!flg[j] && a[j][i]) || (flg[j] && !a[j][i])) v++;
    }
    c+= max(v, R - v);
  }
  return c;
}
void dfs(int r) {
  if(r == R) {
    ans = max(ans, count());
    return;
  }
  flg[r] = 0;
  dfs(r + 1);
  flg[r] = 1;
  dfs(r + 1); 
}
int main(void) {
  int n = sizeof(flg);
  while(cin) {
    ans = 0;
    memset(flg, 0, n);
    cin >> R >> C;
    if(R == 0 && C == 0) return 0;
    for(int i = 0; i < R; i++) {
      for(int j = 0; j < C; j++) cin >> a[i][j];
    }
    dfs(0);
    cout << ans << endl;
  }
  return 1;
}

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

using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int sum = 0;
    int mx = -1;
    for (int i = 1; i < n; i++)
    {
        sum += (a[i] - a[i - 1]);
        mx = max(mx, a[i] - a[i - 1]);
    }
    sum += (k - a[n - 1] + a[0]);
    mx = max(mx, k - a[n - 1] + a[0]);
    sum -= mx;
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 1024