akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    ll n; cin >> n;
    ll sn = sqrt(n);

    ll d = 1;
    for (ll i=1;i<=sn;++i) {
        if (n % i == 0) d = max(d, i);
    }
    ll e = n / d;
    cout << (d + e -2) << endl;
}

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

if not(1 in a):
    print(-1)
    exit(0)

l = []
min_num = 0
for i in a:
    if i == min_num + 1:
        l.append(i)
        min_num += 1

print(N-len(l))

Measured memory_bytes: 32372
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 100000000
#define eps (1e-11)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(0,0),Point p2=Point(0,0)):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

static const int COUNTER_CLOCKWISE=1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;

int ccw(Point p0,Point p1,Point p2){
  Vector a=p1-p0;
  Vector b=p2-p0;
  if(cross(a,b)>eps)return COUNTER_CLOCKWISE;
  if(cross(a,b)<-eps)return CLOCKWISE;
  if(dot(a,b)<-eps)return ONLINE_BACK;
  if(a.norm()<b.norm())return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0 &&
          ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}

bool intersect(Segment s1,Segment s2){
  return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

Point getCrossPointSS(Segment s1,Segment s2){
  Vector base=s2.p2-s2.p1;
  double d1=abs(cross(base,s1.p1-s2.p1));
  double d2=abs(cross(base,s1.p2-s2.p1));
  double t=d1/(d1+d2);
  return (s1.p1+(s1.p2-s1.p1)*t);
}

int main()
{
  int n,N,a,b,c,d,e,f;
  Segment AB;
  vector<pair<Segment,pair<int,int> > > railroad;

  cin>>n;
  for(int k=0;k<n;k++){
    railroad.clear();
    cin>>AB.p1.x>>AB.p1.y>>AB.p2.x>>AB.p2.y;
    cin>>N;
    for(int i=0;i<N;i++){
      cin>>a>>b>>c>>d>>e>>f;
      railroad.push_back(mp(Segment(Point(a,b),Point(c,d)),mp(e,f)));
    }
    vector<pair<Point,pair<int,int> > > vp;
    for(int i=0;i<N;i++){
      if(!intersect(AB,railroad[i].f))continue;
      Point p=getCrossPointSS(AB,railroad[i].f);
      vp.push_back(mp(p,mp(railroad[i].s.f,railroad[i].s.s)));
    }
    sort(vp.begin(),vp.end());
    if(AB.p1<AB.p2)reverse(vp.begin(),vp.end());
    int ans=0,s;

    for(int i=0;i<vp.size();i++){
      if(i==0){
	if(vp[i].s.f==1)s=vp[0].s.s;
	if(vp[i].s.f==0)s=(vp[0].s.s+1)%2;
      }
      else {
	if(vp[i].s.f==1){
	  if(vp[i].s.s!=s){
	    ans++;
	    s=vp[i].s.s;
	  }
	}
	if(vp[i].s.f==0){
	  if(vp[i].s.s==s){
	    ans++;
	    s=(vp[i].s.s+1)%2;
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

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

ll n;

int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    ll sum=0;
     for(ll i=1;i<=n;++i){
         for(ll j=1;j<=n;++j){
             ll g1=gcd(i,j);
             for(ll k=1;k<=n;++k){
                 ll g2=gcd(g1,k);
                 sum+=g2;
             }
         }
     }

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

    return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long


main(){


	string s; cin >> s;

	int n = s.size();


	int cnt = 0;

	
	for(int i = 0; i < n; i++){
		if(s[i] != '0' + i % 2){
			cnt++;
		}
	}


	cout << min(cnt, n - cnt) << endl;



	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;                                                                                          int main()
{

	int N;
	int t[110000], x[110000], y[110000];
	cin >> N;
	t[0] = x[0] = y[0] = 0;
	for ( int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];
	bool can = true;
	for ( int i = 0; i < N; ++i) {
		int dt = t[i+1] - t[i];
		int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
		if ( dt < dist) can = false;
		if ( dist % 2 != dt % 2) can = false;
	}

	if (can) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

using namespace std;
#define ll long long
#define size 100001
ll *weight, *price;
ll dp[101][size];
ll n, capacity;

ll Knapsack2(ll max_profit){
	ll inf = 1e11;
	for(ll N=0; N<=n; N++){
		for(ll profit=0; profit<=max_profit; profit++){
			if(N==0 && profit==0){
				dp[N][profit]=0;
			}
			else if(N == 0){
				dp[N][profit]=inf;
			}
			else if(price[N-1]<=profit){
				dp[N][profit]= min(weight[N-1]+dp[N-1][profit-price[N-1]], dp[N-1][profit]);
			}
			else{
				dp[N][profit]= dp[N-1][profit];
			}

		}
	}
	ll ans=0;
	for(int i=0; i<=max_profit; i++){
		if(dp[n][i]<=capacity){
			ans =i;
		}
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n>>capacity;
	weight = new ll[n];
	price = new ll[n];
	ll max_profit=0;
	for(int i=0; i<n; i++){
		cin>>weight[i]>>price[i];
		max_profit += price[i];
	}

	cout<<Knapsack2(max_profit)<<endl;
	
}

Measured memory_bytes: 79232
#include <stdio.h>

int	ft_sqrt(int nb)
{
	int i;
	int count;

	i = 1;
	count = 0;
	while (i <= nb)
	{
		if (i % 2)
		{
			nb -= i;
			count++;
		}
		i++;
	}
	return (count);
}

int	prime(int nb)
{
	int i;

	if (nb < 2)
		return (0);
	if (nb == 2)
		return (1);
	i = 2;
	while (i <= ft_sqrt(nb))
	{
		if (nb % i == 0)
			return (0);
		i++;
	}
	return (1);
}

int	next_prime(int nb)
{
	while (1)
	{
		if (!prime(nb))
			nb++;
		if (prime(nb))
			break ;
	}
	return (nb);
}

int	main(void)
{
	int x;
	scanf("%d", &x);
	printf("%d", next_prime(x));
	return (0);
}


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

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for (auto &e : h) cin >> e;

    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }

    cout << dp[n - 1] << endl;
}

#if false

// メモ化再帰による解法

int solve(vector<int> &memo, const vector<int> &h, int i) {
    if (i == 0) return 0;
    if (i == 1) return abs(h[1] - h[0]);
    if (memo[i] != -1) return memo[i];
    return memo[i] = min(solve(memo, h, i - 1) + abs(h[i - 1] - h[i]), solve(memo, h, i - 2) + abs(h[i - 2] - h[i]));
}

int main() {
    int n; cin >> n;
    vector<int> h(n);
    for (auto &e : h) cin >> e;

    vector<int> memo(n, -1);
    cout << solve(memo, h, n - 1) << endl;
}

#endif



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

int main(){
	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);
	if(b > a + x) printf("dangerous\n");
	else if(b <=  a) printf("delicious\n");
	else printf("safe\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    cout<<fixed<<setprecision(10);
    double n,m,d;
    cin>>n>>m>>d;
    double x=n-d;
    if(d){
        x*=2.0;
    }
    cout<<x/pow(n,2)*(m-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def remove_bit(num, i):
    high = (num >> (i + 1)) << i
    low = num & ((1 << i) - 1)
    return high + low

def insert_bit(num1, num2, i):
    high = num1 >> i << (i + 1)
    low = num1 & (-1 + (1 << i))
    insert = num2 & (1 << i)
    return high + insert + low

def solve(N, A, B):
    if N == 1:
        return [A, B]

    r_bit = -1
    for i in range(N):
        if (A >> i) & 1 != (B >> i) & 1:
            r_bit = i
            break
    if r_bit == -1:
        import pdb; pdb.set_trace()

    AA = remove_bit(A, r_bit)
    BB = remove_bit(B, r_bit)

    C = -1
    for C in range(2**(N-1)):
        if bin(AA ^ C).count('1') % 2 == 1 and  bin(AA ^ C).count('1') % 2 == 1:
            break
    A_list = solve(N - 1, AA, C)
    B_list = solve(N - 1, C, BB)

    A_list = list(map(lambda x: insert_bit(x, A, r_bit), A_list))
    B_list = list(map(lambda x: insert_bit(x, B, r_bit), B_list))

    return A_list + B_list


def main(N, A, B):
    if (bin(A).count('1') + bin(B).count('1')) % 2 == 0:
        print('NO')
        sys.exit()

    print('YES')
    ans_list = solve(N, A, B)

    assert A == ans_list[0]
    assert B == ans_list[-1]
    for i in range(len(ans_list) - 1):
        assert bin(ans_list[i] ^ ans_list[i+1]).count('1') == 1

    for num in ans_list:
        sys.stdout.write('%d '%num)
    print()



if __name__ == '__main__':
    N, A, B = map(int, input().split())
    main(N, A, B)


Measured memory_bytes: 11948
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
//void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void Yes() { cout << "Yes" << endl; } 
void No() { cout << "No" << endl; }

signed main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int n = a + b;
	int m = c + d;
	if (n == m) cout << "Balanced" << endl;
	if (n > m) cout << "Left" << endl;
	if (n < m) cout << "Right" << endl;
	return 0;
}




Measured memory_bytes: 3628
n = int(input().strip())
x = list(map(int, input().strip().split()))
count=0
for i in range(0,n-2):
    for j in range(i,n-1):
        if(x[i]==x[j]):
            continue
        for k in range(j,n):
            if((x[i]==x[k])or(x[j]==x[k])):
                continue
            if ((x[i]+x[j]>x[k])and(x[i]+x[k]>x[j])and(x[j]+x[k]>x[i])):
                count+=1
print(count)

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}
int no=1,n1;
int recu(int n,int k,int val){


	if(n==n1){
		return min(val*2,val+k);
	}
	return min( recu(n+1,k,2*val),recu(n+1,k,val+k)              );


}
int digit(int n){

	int temp=0;
	while(n){
		temp+=n%10;
		n=n/10;
		// temp++;
	}



	return temp;
}

bool check(int a[],int n){
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if(a[i]%2)
			return false;
	}
	return true;
}


int main() {
    int i,m,n,k,c=0,sum=0;
    c_p_c();
    // cout<<"Sd"<<endl;>
  	cin>>n;
  	int a[n];
  	int temp=0;
  	fo(i,n) cin>>a[i];


  	while(check(a,n)){
  		for (int i = 0; i < n; ++i)
  		{
  			/* code */
  			a[i]/=2;
  		}
  		c++;
  	}
  	cout<<c<<endl;

   }

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int a, int b)
{
	return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}

long long kaijo(long long x){
  long long l=10*10*10*10*10*10*10*10*10+7;
  long long sum=1;
  for(int i=x;i>0;i--){
    sum*=i;
    if(sum>l){
      sum%=l;
    }
  }
  return sum;
}






int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string s;
  for(int i=0;i<ty-sy;i++){
    s+='U';
  }
  for(int i=0;i<tx-sx;i++){
    s+='R';
  }
  for(int i=0;i<ty-sy;i++){
    s+='D';
  }
  for(int i=0;i<tx-sx;i++){
    s+='L';
  }
  s+='L';
  for(int i=-1;i<ty-sy;i++){
    s+='U';
  }
  for(int i=-1;i<tx-sx;i++){
    s+='R';
  }
  s+='D';
  s+='R';
  for(int i=-1;i<ty-sy;i++){
    s+='D';
  }
  for(int i=-1;i<tx-sx;i++){
    s+='L';
  }
  s+='U';
  cout<<s<<endl;




}



  

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

constexpr int MaxN = 500;

int main()
{
	int N, M, Q;

	cin >> N >> M >> Q;

	int C[MaxN][MaxN];
	memset(C, 0, MaxN * MaxN * sizeof(int));

	for (int i = 0; i < M; ++i)
	{
		int L, R;
		cin >> L >> R;
		++C[L-1][R-1];
	}

	for (int i = 1; i < N; ++i)
	{
		C[i][0] += C[i-1][0];
		C[0][i] += C[0][i-1];
	}

	for (int i = 1; i < N; ++i)
	{
		for (int j = 1; j < N; ++j)
		{
			C[i][j] += C[i-1][j] + C[i][j-1] - C[i-1][j-1];
		}
	}

	for (int i = 0; i < Q; ++i)
	{
		int p, q;
		cin >> p >> q;
		--p;
		--q;

		int count = C[q][q];

		if (p > 0)
		{
			count -= C[p-1][q];
			count -= C[q][p-1];
			count += C[p-1][p-1];
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    double t, x;
    cin>>t>>x;
    cout<<fixed<<setprecision(3)<<t/x<<endl;
    
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		System.out.println(N*N-A);
	}

}


Measured memory_bytes: 21972
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans =0
count = 0

n=int(input())
A=list(map(int,input().split()))
SA=sum(A)
SA2=SA/2
mindis=SA
for ai in A:
    count+=ai
    mindis=min(mindis,abs(count*2-SA))
print(mindis)



Measured memory_bytes: 92272
#include <stdio.h>

int main(void)
{
  int n;
  int a,b;
  int tmp;
  scanf("%d",&n);
//   printf("%d\n",n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d %d",&a,&b);
    tmp = tmp + b - a + 1;
    // printf("%d\n",tmp);
  }
  printf("%d\n",tmp);
  return (0);
}

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


int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N-1; ++i) {
		int a;
		cin >> a;
		A[a-1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << A[i] << endl;
	}
    return 0;
}


Measured memory_bytes: 3996
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	while (true) {
		int dp[31][50] = {};
		int n;
		cin >> n;
		if (n == 0) return;
		vector<int> gogo[50];
		REP(i, n) {
			dp[0][i] = (1LL << i);
			int b;
			cin >> b;
			REP(q, b) {
				int a;
				cin >> a;
				gogo[a].push_back(i);
			}
		}
		int days = -1;
		for (int i = 1; i <= 30; ++i) {
			REP(q, n) {
				dp[i][q] = dp[i - 1][q];
			}
			REP(j, gogo[i].size()) {
				REP(t, gogo[i].size()) {
					dp[i][gogo[i][j]] |= dp[i][gogo[i][t]];
				}
			}
			REP(q, n) {
				if (dp[i][q] == (1LL << n) - 1LL) {
					days = i;
					break;
				}
			}
			if (days != -1) break;
		}
		cout << days << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3224
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(0, n - 1):
    diff = h[i + 1] - h[i]
    if diff >= 1:
        h[i + 1] -= 1
    elif diff < 0:
        print("No")
        exit()
print("Yes")

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

int main(){
    int a,b;
    cin>>a>>b;
    int r = 0;
    for(int i = a;i <= b;i++){
        int l = i%10,f = i/10000;
        int sl = i/10%10,fl = i/1000%10;
        if(l==f&&sl==fl)r++;
    }
    cout<<r;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	string s; cin>>s;
	if(s=="SAT"){
		cout<<1;
	}
	else if(s=="FRI"){
		cout<<2;
	}
	else if(s=="THU"){
		cout<<3;
	}
	else if(s=="WED"){
		cout<<4;
	}
	else if(s=="TUE"){
		cout<<5;
	}
	else if(s=="MON"){
		cout<<6;
	}
	else if(s=="SUN"){
		cout<<7;
	}
	
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a, b, sum;
    double s, d=0;
    int average;
    
    while (scanf("%d,%d",&a,&b) !=EOF) {
        sum += a*b;
        s += b;
        d++;
    }
    average = (double)s / (double)d +0.5;
    printf("%d\n%d\n", sum, average);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=2e5+9,inf=1e18;
int n,m,sum,tr[4*N],lz[4*N];
vector <pair<int,int> > ev[N];
void shift(int id){
    tr[2*id]+=lz[id],lz[2*id]+=lz[id];
    tr[2*id+1]+=lz[id],lz[2*id+1]+=lz[id];
    lz[id]=0;
}
void upt(int x,int y,int d,int id=1,int l=0,int r=n){
    if(x>r or l>y)return;
    if(l>=x and r<=y){
        tr[id]+=d,lz[id]+=d;
        return;
    }
    int mid=(l+r)/2;
    shift(id);
    upt(x,y,d,2*id,l,mid);
    upt(x,y,d,2*id+1,mid+1,r);
    tr[id]=max(tr[2*id],tr[2*id+1]);
}
int ask(int x,int y,int id=1,int l=0,int r=n){
    if(x>r or l>y)return -inf;
    if(l>=x and r<=y)return tr[id];
    int mid=(l+r)/2;
    shift(id);
    return max(ask(x,y,2*id,l,mid),ask(x,y,2*id+1,mid+1,r));
}
int32_t main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int l,r,x;
        cin >> l >> r >> x;
        ev[r].push_back({l,x});
        sum+=x;
    }
    upt(0,n,sum);
    for(int i=1;i<=n;i++){
        upt(i,i,ask(0,i-1)-sum);
        for(auto j:ev[i])
            upt(0,j.f-1,-j.s);
    }
    cout << tr[1] << endl;
}


Measured memory_bytes: 24960
using System;
using System.Collections.Generic;
using System.Linq;

namespace EXA2019A
{
    class MainClass
    {

        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            if(s[0]==s[1] && s[1] == s[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<vector>
#include<queue>
#include<ctime>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<cstring>
using namespace std;

typedef long long LL;

const int INF = 2147483647;
const int maxn = 1000010;
const int crz = 1e9 + 7;

int n,a[maxn],inv[maxn];
int ans,fac;

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

inline int qpow(int a,int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = 1ll * ret * a % crz;
		a = 1ll * a * a % crz;
		b >>= 1;
	}
	return ret;
}

inline int mod(int x)
{
	return x >= crz ? x - crz : x;
}

int main()
{
	#ifdef AMC
		freopen("AMC1.txt","r",stdin);
		// freopen("AMC2.txt","w",stdout);
	#endif
	fac = 1;
	
	n = getint();
	for (int i = 1; i <= n; i++)
		a[i] = getint() , fac = 1ll * fac * i % crz;
	
	for (int i = 1; i <= n; i++)
		inv[i] = mod(qpow(i,crz - 2) + inv[i - 1]);
	
	for (int i = 1; i <= n; i++)
	{
		int x = mod(mod(inv[i] + inv[n - i + 1]) - 1 + crz);
		ans = mod(ans + 1ll * x * a[i] % crz);
	}
	
	printf("%lld\n",1ll * ans * fac % crz);
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const int N = 2e5 + 5;
const ll mod = 1000000007;
using namespace std;

ll fpower(ll n) {
	for (int i = -200; i <= 200; i++) {
		if (n == i * i * i * i * i) {
			return i;
		}
	}

	return 0;
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
//	cin >> tc;

	while (tc--) {
		ll n, m, i;

		ll x;
		cin >> x;

		ll a, b;

		for (a = -200; a <= 200; a++) {
			for (b = -200; b <= 200; b++) {
				if (a * a * a * a * a - b * b * b * b * b == x) {
					cout << a << " " << b << endl;
					exit(0);
				}
			}
		}

		cout << a << " " << b << endl;


	}
}


Measured memory_bytes: 3604
import sys
N = int(input())
A = list(map(int, input().split()))

money = 1000
kabu = 0 

for i in range(N-1):
  if A [i] < A[i + 1] and kabu == 0 :
    kabu = money // A[i]
    money = money - kabu*A[i]
  elif A[i] > A[i + 1] and kabu > 0:
    money = money + kabu*A[i]
    kabu = 0
    
if kabu > 0 :
  print(money + kabu*A[N-1])
else :
  print(money)

Measured memory_bytes: 9124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())

def bs(ok, ng, cond):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if cond(mid):
            ok = mid
        else:
            ng = mid
    return ok

ans = bs(n, 0, lambda x: x * 1.08 >= n)
if n == int(ans * 1.08):
    print(ans)
else:
    print(':(')


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

int main(void){
    using namespace std;
    int n,x=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        if(i%2==0)x+=a[i];
        else x-=a[i];
    }
    cout<<x<<" ";
    for(int i=1;i<=n-1;i++){
        x=2*a[i-1]-x;
        cout<<x<<" ";
    }
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10000000)
def dfs(s):
  if len(s)==11:
    return
  if s!="":
    a.append(int(s))
  for c in "0123456789":
    if s=="" and c=="0":continue
    if len(s)>0:
      if abs(ord(s[-1])-ord(c))<=1:
        dfs(s+c)
    else:
        dfs(s+c)
k=int(input())
a=[]
dfs("")
a=list(set(a))
a.sort()
print(a[k-1])


Measured memory_bytes: 29292
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
#define maxn 5010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
char s[2*maxn],t[2*maxn];
int n,k;
int main()
{
	n=read(); k=read();
	scanf("%s",s);
	char mn='z';
	for(int i=0;i<n;i++)
		mn=std::min(mn,s[i]);
	for(int i=0;i<n;i++)
		t[i]=t[2*n-i-1]=s[i];
	if(k==1){
		int pos=0;
		for(int i=1;i<n;i++){
			int x=i,y=pos;
			while(x<2*n&&y<2*n&&t[x]==t[y])++x,++y;
			if(t[x]<t[y])pos=i;
		}
		for(int i=pos;i<pos+n;i++)
			putchar(t[i]);
		putchar('\n');
		return 0;
	}
	int len=0,last=-1;
	for(int i=0;i<2*n;i++)
		if(t[i]==mn)len=std::max(len,i-last);
		else last=i;
	int pos=n-1;
	for(int i=n;i<2*n;i++){
		int x=i,y=pos;
		while(~x&&~y&&t[x]==t[y])--x,--y;
		if(y>=0&&t[x]<t[y])pos=i;
	}
	for(int i=0;i<n;i++)
		s[i]=t[pos-n+i+1];
	// printf("%s ***\n%s ***\n",s,t);
	for(int j=2;j<=k&&len<n;j++){
		for(int i=0;i<n;i++)
			t[i]=t[2*n-i-1]=s[i];
		if(j==k){
			for(int i=0;i<n;i++)
				s[i]=t[i+n-len];
		}
		else{
			for(int i=0;i<n;i++)
				s[i]=t[i+len];
		}
		len<<=1;
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        int count = 0;

        for (int i=100;i>0;i--){
            if (a%i==0&&b%i==0){
                count++;
                if (count==k){
                    System.out.println(i);
                    break;
                }
            }
        }

    }
}

Measured memory_bytes: 21844
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0];
  loop(i, 1, v.size()) ss << sep << v[i];
  return ss.str();
}

void solve() {
  int n;
  vs out;
  while (cin >> n, n) {
    vector<pair<int, string>> v;
    while (n--) {
      string name;
      int w, l, d;
      cin >> name >> w >> l >> d;
      v.emplace_back(w * 3 + d, name);
    }
    stable_sort(all(v), [](auto a, auto b) { return a.fi > b.fi; });
    ostringstream ss;
    for (auto &x : v) ss << x.se << ',' << x.fi << endl;
    out.pb(ss.str());
  }
  cout << join(out, "\n");
}

Measured memory_bytes: 3144
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int n, m;
	cin >> n >> m;
	V<ll> d(n), dp(n, 0);
	V<V<ll>> e(n);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		e[a].push_back(b);
		d[b]++;
	}
	queue<int>q;
	REP(i, n)if (d[i] == 0)q.push(i);
	while (q.size()) {
		int p = q.front();
		q.pop();
		for(auto j: e[p]){
			dp[j] = max(dp[p] + 1, dp[j]);
			d[j]--;
			if(d[j]==0)	q.push(j);
		}
	}
	cout << *max_element(ALL(dp)) << endl;
	
	return 0;
}

Measured memory_bytes: 7296
# Aizu Problem 0008: Sum of 4 Integers
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def sum4(n):
    ans = 0
    for i in range(10):
        for j in range(10):
            for k in range(10):
                for l in range(10):
                    if n == i + j + k + l:
                        ans += 1
    return ans


mem = {}
for line in sys.stdin:
    n = int(line)
    if n in mem:
        print(mem[n])
    else:
        ans = sum4(n)
        mem[n] = ans
        print(ans)

Measured memory_bytes: 7848
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>

using namespace std;

string N;
int n;

int dfs(long long num,bool three,bool five,bool seven) {
    if(num>n){
       return 0;
    }
    int res=0;
    if(three&&five&&seven){
        res++;
    }
    res+=dfs(num*10+3,true,five,seven);
    res+=dfs(num*10+5,three,true,seven);
    res+=dfs(num*10+7,three,five,true);
    return res;
}
int main() {
    int i;
    cin>>N;
    n=atoi(N.c_str());
    cout<<dfs(0,false,false,false);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

charc = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = []

for i in range(len(S)):
    Si = S[i]
    ind = charc.index(Si)
    if ind + N <= 25:
        ans.append(charc[ind+N])
    else:
        ind = ind + N - 26
        ans.append(charc[ind])
    
print(''.join(ans))


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

int main() {


    int N, M, C;
    cin >> N >> M >> C;

    int B[21];
    int A[21];

    int count = 0;
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    for (int j = 0; j < N; j++) {
        int sum = 0;
        for (int i = 0; i < M; i++) {
            cin >> A[i];
            sum += A[i] * B[i];
        }
        if (sum + C > 0) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n;cin >> n;
    vector<int> v(n),x(100001);
    lint s = 0;
    REP(i,n){
        cin >> v[i];
        s += v[i];
        x[v[i]]++;
    }
    int q;
    cin >> q;
    REP(i,q){
        int b, c;
        cin >> b >> c;
        s += (c - b) * x[b];
        x[c] += x[b];
        x[b] = 0;
        cout << s << "\n";
    }
    return 0;
}

Measured memory_bytes: 4048
def abc():
    input()
    t, a = map(int, input().rstrip().split())
    h = [(i + 1, abs(a - (t - x * 0.006))) for i, x in enumerate(map(int, input().rstrip().split()))]
    h.sort(key=lambda x: x[1])
    print(h[0][0])


abc()


Measured memory_bytes: 3188
N = int(input())
X = list(map(int,input().split()))
import copy
Y = copy.deepcopy(X)
Y.sort()
a = Y[int(N/2)-1]
b = Y[int(N/2)]
for i in range(N):
    if X[i] <= a:
        print(b)
    else:
        print(a)

Measured memory_bytes: 25620
s = gets.chomp.reverse
sents = [] << 'dream'.reverse
sents << 'erase'.reverse
sents << 'eraser'.reverse
sents << 'dreamer'.reverse

loop do
  if s.empty?
    puts 'YES'
    exit
  end
  if s[0,5] == sents[0]
    s = s[5..-1]
    next
  elsif s[0,5] == sents[1]
    s = s[5..-1]
    next
  elsif s[0,6] == sents[2]
    s = s[6..-1]
    next
  elsif s[0,7] == sents[3]
    s = s[7..-1]
    next
  end
    puts 'NO'
    exit
end

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> A >> B >> C >> K;
	int tmp = max(A, max(B, C));
	ans = A + B + C - tmp;
	for (int i = 0; i < K; i++)
	{
		tmp *= 2;
	}
	cout << tmp + ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((10 * b + c )% 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#include <stdio.h>
int main()
{
char Str[100];
    int i , j , k=1 , f;
    cin >>Str ;
    for(i=0;i<100;i++)
    {
        if(Str[i]=='\0')
            break;
    }
    f=i;
    for(i=0 ,j=f-1 ; i<f && j>0; i++ , j--)
    {
        if(Str[i] != Str[j])
            k++;
    }
    printf("%d",k/2);

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main(){
	int n;
	int total;
	string mv, N = "North", S = "South", W = "West", E = "East";
	string R = "Right", L = "Left";


	while(cin >> n){
	 	int side[7] = {0, 1, 2, 3, 4, 5, 6};
		total = 1;

		if (n == 0){
			break;
		}

		for (int i = 0; i < n; i++){
			cin >> mv;

			if(mv == N){
				swap(side[1], side[2]);
				swap(side[2], side[6]);
				swap(side[6], side[5]);
			}
			else if(mv == S){
				swap(side[1], side[5]);
				swap(side[5], side[6]);
				swap(side[6], side[2]);
			}
			else if(mv == W){
				swap(side[1], side[3]);
				swap(side[3], side[6]);
				swap(side[6], side[4]);
			}
			else if(mv == E){
				swap(side[1], side[4]);
				swap(side[4], side[6]);
				swap(side[6], side[3]);
			}
			else if(mv == R){
				swap(side[2], side[3]);
				swap(side[3], side[5]);
				swap(side[5], side[4]);
			}
			else {
				swap(side[2], side[4]);
				swap(side[4], side[5]);
				swap(side[5], side[3]);
			}

			total += side[1];
		}
		cout << total << endl;
	}
}

Measured memory_bytes: 3068
from operator import mul
from functools import reduce


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


N = int(input())
ans = 0
amari = int(N % 3)
shou = int(N // 3)

for i in range(shou):

    ans = (ans + combinations_count((amari + shou - 1), amari)) % (10**9 + 7)
    amari += 3
    shou -= 1
print(ans)


Measured memory_bytes: 9536
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;cin>>N>>M;
  vector<int> d(0);
  for(int p=1;p*p<=M;p++){
    if(M%p==0){
      d.push_back(p);
      d.push_back(M/p);
    }
  }
  int m=1;
  for(int i=0;i<d.size();i++){
    if(M/d[i]>=N)m=max(m,d[i]);
  }
  cout<<m<<endl;
}


Measured memory_bytes: 256
# coding:utf-8
import collections


def main():
    n = int(input())
    v = list(map(int, input().split()))

    va = []
    vb = []
    for i in range(0, n, 2):
        va.append(v[i])
        vb.append(v[i + 1])

    if va == vb and len(set(va)) == 1:
        print(len(va))
        return

    c1mc = collections.Counter(va).most_common()
    c2mc = collections.Counter(vb).most_common()

    if c1mc[0][0] != c2mc[0][0]:
        print(n - c1mc[0][1] - c2mc[0][1])
        return

    else:
        a = n - c1mc[1][1] - c2mc[0][1]
        b = n - c1mc[0][1] - c2mc[1][1]

        if a < b:
            print(a)
        else:
            print(b)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

vector<ll> G[51];
bool used[51];

void dfs(ll x,ll A,ll B){
	used[x]=true;
	rep(i,sz(G[x])){
		if((x==A && G[x][i]==B) || (x==B && G[x][i]==A)) continue;
		else if(!used[G[x][i]]) dfs(G[x][i],A,B);
	}
}

int main(){
	ll N,M; cin>>N>>M;
	vector<ll> A(M);
	vector<ll> B(M);
	ll ans=0;

	rep(i,M){
		cin>>A[i]>>B[i];
		G[A[i]].pb(B[i]);
		G[B[i]].pb(A[i]);
	}
	rep(i,M){
		rep1(j,N) used[j]=false;
		dfs(1,A[i],B[i]);

		rep1(j,N){
			if(!used[j]){
				ans++;
				break;
			}
		}
	}
	cout<<ans;
}

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

int main()
{
    string S, T;
    string ans;
    cin >> S >> T;
    for (int i = 0; i < S.size();i++){
        if (S[i] == T[i]){
            ans = "Yes";
        }else{
            ans = "No";
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3624
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct P {
    int cost, count;
}
 
void main() {
    int[] a = new int[3];
    int d, e;
    int[] n = new int[3];
    P[] p = new P[3];
    bool input() {
        foreach (i; 0 .. 3) { scanf("%d", &a[i]); }
        scanf("%d %d\n", &d, &e);
        if (a.all!"a == 0" && d == 0 && e == 0) return false;
        foreach (i; 0 .. 3) { scanf("%d", &n[i]); }
        foreach (i; 0 .. 3) { p[i] = P(a[i], n[i]); }
        return true;
    }
    void solve() {
        p.sort!("a.cost > b.cost");
        //p.writeln;
        if (p[2].cost >= e) {
            writeln(reduce!"a + b.count"(0, p) * e);
            return;
        }
        int ans = reduce!"a + b.cost * b.count"(0, p);
        int i = 0;
        int[3] set = [0, 0, 0];
        while (true) {
            int set_cost = 0;
            foreach (x; 0 .. 3) {
                set_cost += set[x] * p[x].cost;
            }
            int set_count = set.reduce!"a + b";
            set_cost = min(set_cost, max(d, set_count) * e);
            int other_cost = 0;
            foreach (x; 0 .. 3) {
                other_cost += (p[x].count - set[x]) * p[x].cost;
            }
            int cur_cost = set_cost + other_cost;

            //if (prev < cur_cost) break;

            //writeln(set, " -> ", cur_cost);
            ans = min(ans, cur_cost);

            if (set[i] == p[i].count) i++;
            else {
                set[i]++;
            }
            if (i == 3) break;
        }
        ans.writeln;
    }
    while (input) solve;
}

Measured memory_bytes: 1068
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt(), N = sc.nextInt(), minDiff = X, pNot[] = new int[102], ans = 0;
		for (int i = 0; i <= 101; i++)
			pNot[i] = 1;
		for (int i = 0; i < N; i++)
			pNot[sc.nextInt()] = 0;
		for (int i = 0; i <= 101; i++)
			if (pNot[i] == 1)
				if (minDiff > Math.abs(X - i)) {
					minDiff = Math.abs(X - i);
					ans = i;
				}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35716
#include<bits/stdc++.h>
#define int long long
#define maxn 100005
using namespace std;
int arr[maxn],brr[maxn],crr[maxn];
int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x,y,n,m,k;
	cin >> x >> y >> n >> m >> k;
	for(int i=1;i<=n;i++)	cin >> arr[i];	sort(arr+1,arr+1+n,greater<int>());
	for(int i=1;i<=m;i++)	cin >> brr[i];	sort(brr+1,brr+1+m,greater<int>());
	for(int i=1;i<=k;i++)	cin >> crr[i];	sort(crr+1,crr+1+k,greater<int>());
	
	vector<int> v;
	v.push_back(0);
	for(int i=1;i<=x;i++)	v.push_back(arr[i]);
	for(int i=1;i<=y;i++)	v.push_back(brr[i]);
	sort(v.begin()+1,v.end(),greater<int>());
	for(int i=2;i<=x+y;i++)		v[i] += v[i-1];
	for(int i=2;i<=k;i++)	crr[i] += crr[i-1];
	
	int ans = 0;
	for(int i=0;i<=min(x+y,k);i++)
		ans = max(ans,v[x+y-i] + crr[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4852
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  if B[i] <= A[i]:
    ans += B[i]
  elif A[i] + A[i+1] <= B[i]:
    ans += A[i] + A[i+1]
    A[i+1] = 0
  else:
    ans += B[i]
    A[i+1] -= (B[i] - A[i])
print(ans)

Measured memory_bytes: 19156
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		int i,j,cnt=0;
		// TODO Auto-generated method stub
   Scanner sca=new Scanner(System.in);
    int hair1[]=new int[sca.nextInt()];
    for(i=0;i<hair1.length;i++){
    	hair1[i]=sca.nextInt();
    }
    int hair2[]=new int[sca.nextInt()];
    for(i=0;i<hair2.length;i++){
    	hair2[i]=sca.nextInt();
    }
    for(i=0;i<hair2.length;i++){
    	j=0;
    	while(j<hair1.length){
    		if(hair1[j]==hair2[i]){
    			cnt++;
    			break;
    		}
    		j++;
    		}
    	}
    System.out.println(cnt);
	}

}



Measured memory_bytes: 40688