akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin>>N;

  set<int> se;

  rep(i,N){
    int aa;
    cin>>aa;
    se.insert(aa);
  }

  cout << se.size()-(se.size()%2==0) <<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 4992
n,a = map(int,input().split())
x = list(map(int,input().split()))
M = max(x)
M = max(M,a)
dp = [[[0]*(n*M+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for j in range(n):
    for k in range(n+1):
        for s in range(n*M+1):
            if dp[j][k][s]:
                dp[j+1][k][s] += dp[j][k][s]
                dp[j+1][k+1][s+x[j]] += dp[j][k][s]

ans = 0
for k in range(1,n+1):
    ans += dp[n][k][k*a]

print(ans)

Measured memory_bytes: 62960
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
const int INF=1e9;
const LL LINF=1ll<<60;
const int N=1010;
int n;
int a[N];
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
}
int b[2][N];
LL sum[2];
void solve(){
	for(int i=1;i<=n;i++)
		if(a[i]>0){
			sum[i&1]+=a[i];
			b[i&1][++b[i&1][0]]=i;
		}
	for(int k=0;k<2;k++)
		if(!b[k][0]){
			int maxs=-INF,maxpos=-1;
			for(int i=1;i<=n;i++)
				if((i&1)==k){
					if(a[i]>maxs){
						maxs=a[i];
						maxpos=i;
					}
				}
			b[k][++b[k][0]]=maxpos;
			sum[k]=maxs;
		}
	int who=sum[0]>sum[1]?0:1;
	printf("%lld\n",sum[who]);
	int optCnt=0;
	optCnt+=b[who][1]-1;
	for(int i=2;i<=b[who][0];i++)
		optCnt+=(b[who][i]-b[who][i-1])>>1;
	optCnt+=n-b[who][b[who][0]];
	printf("%d\n",optCnt);
	for(int i=1;i<=b[who][1]-1;i++) printf("1\n");
	for(int i=2;i<=b[who][0];i++){
		for(int j=1;j<((b[who][i]-b[who][i-1])>>1);j++) printf("3\n");
		printf("2\n");
	}
	for(int i=n-b[who][b[who][0]]+1;i>1;i--)
		printf("%d\n",i);
}
int main(){
	readData();
	solve();
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    long long N, x; cin >> N >> x;
    vector < long long > a(N);
    long long count = 0;
    rep(i, N) {
        cin >> a[i];
        count += a[i];
    }
    long long A = abs(x - count);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    rep(i, N) {
        if (A <= 0) {
            cout << N-i << endl;
            return 0;
        }
        A -= a[i];
    }
    cout << 0 << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	//freopen("I3.in","r",stdin);
	//freopen("I3.out","w",stdout);
	int a[4];
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	int z=a[3]-a[2];
	a[2]+=z;a[1]+=z;
	int q=a[3]-a[1];
	if(q&1){
		printf("%d\n",q/2+z+2);
	}else printf("%d\n",q/2+z);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using pii = pair<int, int>;

signed main() {
    int n, u, v, m;
    cin >> n >> u >> v >> m;

    map<int,vector<pii>>usagi,neko;
    vector<vector<int>>usagi_vv(n,vector<int>(n));
    auto neko_vv = usagi_vv;

    rep(i,0,n){
        rep(j,0,n){
            int x;cin>>x;
            usagi[x].emplace_back(i,j);
            usagi_vv[i][j]=x;
        }
    }
    rep(i,0,n){
        rep(j,0,n){
            int x;cin>>x;
            neko[x].emplace_back(i,j);
            neko_vv[i][j]=x;
        }
    }

    vector<int>card(m);
    rep(i,0,m)cin>>card[i];

    auto simulate=[&](int turn,map<int,vector<pii>>&mp,vector<vector<int>>&vv){
        vector<vector<bool>>ok(n,vector<bool>(n,false));

        rep(i,0,turn){
            int c=card[i];
            for(auto &p:mp[c]){
                int x,y;
                tie(x,y)=p;
                ok[x][y]=true;
            }
        }

        set<set<int>>st;

        int score=0;
        rep(i,0,n){
            int cnt=0;
            set<int>tmp;
            rep(j,0,n){
                if(ok[i][j]){
                    tmp.insert(vv[i][j]);
                }
            }
            if(tmp.size()==n)st.insert(tmp);
        }
        rep(j,0,n){
            int cnt=0;
            set<int>tmp;
            rep(i,0,n){
                if(ok[i][j]){
                    tmp.insert(vv[i][j]);
                }
            }
            if(tmp.size()==n)st.insert(tmp);
        }

        set<int>tmp;
        rep(i,0,n){
            if(ok[i][i])tmp.insert(vv[i][i]);
        }
        if(tmp.size()==n)st.insert(tmp);
        tmp.clear();
        rep(i,0,n){
            if(ok[i][n-1-i])tmp.insert(vv[i][n-1-i]);
        }
        if(tmp.size()==n)st.insert(tmp);
        return st.size();
    };

    int x = simulate(m,usagi,usagi_vv)<u;
    int y = simulate(m,neko,neko_vv)<v;
    //cout<<"x:"<<x<<", y: "<<y<<endl;

    if( x && y){
        cout<<"DRAW"<<endl;
        return 0;
    }
    else if(x){
        cout<<"NEKO"<<endl;
        return 0;
    }
    else if(y){
        cout<<"USAGI"<<endl;
        return 0;
    }

    auto bs=[&](map<int,vector<pii>>&mp,int z,vector<vector<int>>&vv){
        int l=1,r=m;
        while(r-l>1){
            int mid=(l+r)/2;
            if(simulate(mid,mp,vv)>=z){
                r=mid;
            }
            else{
                l=mid;
            }
        }
        return r;
    };


    int a=bs(usagi,u,usagi_vv);
    int b=bs(neko,v,neko_vv);

//    cout<<"a:"<<a<<", b: "<<b<<endl;
    if(a==b){
        cout<<"DRAW"<<endl;
    }
    else if(a<b){
        cout<<"USAGI"<<endl;
    }
    else{   
        cout<<"NEKO"<<endl;
    }

    return 0;
}



Measured memory_bytes: 42312
A, B, K = map(int, input().split())

if B-A+1 <= 2*K:
    for ans in range(A,B+1):
        print(ans)
else:
    for ans in range(A, A+K):
        print(ans)
    for ans in range(B-K+1, B+1):
        print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    double r;
    cin >> r;
    double area = PI * r * r;
    double circum = 2 * PI * r;

    printf("%1.8lf %1.8lf\n", area, circum);

    return 0;
}


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

using namespace std;

const double EPS = 1e-8;

int dcmp(double d) {
    if (fabs(d) < EPS) {
        return 0;
    } else {
        return d < 0 ? -1 : 1;
    }
}

struct Vector {
    double x, y;

    Vector(double x = 0, double y = 0) : x(x), y(y) {
    }

    bool operator<(const Vector& other) const {
        return dcmp(x - other.x) < 0 || (dcmp(x - other.x) == 0 && dcmp(y - other.y) < 0);
    }
};

typedef Vector Point;

double dot(const Vector& a, const Vector& b) {
    return a.x * b.x + a.y * b.y;
}

double cross(const Vector& a, const Vector& b) {
    return a.x * b.y - a.y * b.x;
}

Vector operator+(const Vector& a, const Vector& b) {
    return Vector(a.x + b.x, a.y + b.y);
}

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

Vector operator*(const Vector& a, const double& p) {
    return Vector(a.x * p, a.y * p);
}

double angle(const Vector& a) {
    return atan2(a.y, a.x);
}

double length(const Vector& a) {
    return sqrt(dot(a, a));
}

struct Circle {
    Point c;
    double r;

    Circle(double x = 0, double y = 0, double r = 0) : c(Point(x, y)), r(r) {
    }

    Point point(double rad) const {
        return Point(c.x + r * cos(rad), c.y + r * sin(rad));
    }
};

int intersect(const Circle& a, const Circle& b) {
    int count = 0;
    Vector v = b.c - a.c;
    double d = length(v);

    if (dcmp(d - a.r - b.r) > 0) {
        count = 4;
    } else if (dcmp(d - a.r - b.r) == 0) {
        count = 3;
    } else if (dcmp(d - fabs(a.r - b.r)) < 0) {
        count = 0;
    } else if (dcmp(d - fabs(a.r - b.r)) == 0) {
        count = 1;
    } else {
        count = 2;
    }
    return count;
}

int main() {
    double x, y, r;
    cin >> x >> y >> r;
    Circle c1(x, y, r);

    cin >> x >> y >> r;
    Circle c2(x, y, r);

    int ans = intersect(c1, c2);

    cout << fixed << setprecision(8);

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3220
#include<iostream>

using namespace std;
int main()
{

  class dice {

    int ue,shita,migi,hidari,temae,oku,sum;

  public:
    dice(){ue=1;shita=6;migi=3;hidari=4;temae=2;oku=5;sum=1;};
    
    void north(){int tmp;tmp = ue;ue = temae ;temae  = shita;shita = oku   ;oku = tmp  ;sum += ue;};
    void east() {int tmp;tmp = ue;ue = hidari;hidari = shita;shita = migi  ;migi= tmp  ;sum += ue;};
    void west() {int tmp;tmp = ue;ue = migi  ;migi = shita  ;shita = hidari;hidari=tmp ;sum += ue;};
    void south(){int tmp;tmp = ue;ue = oku   ;oku = shita;  ;shita = temae ;temae = tmp;sum += ue;};
    void right(){int tmp;tmp = temae;temae = migi;migi = oku;oku = hidari;hidari = tmp;sum += ue;};
    void left() {int tmp;tmp = temae;temae = hidari;hidari = oku;oku = migi;migi = tmp;sum += ue;};
    void print(){cout << ue << shita << migi << hidari << temae << oku << "sum=" <<sum <<endl;};
    void ans(){cout << sum << endl;};
  }; 


  while(1){
    dice d;
    int n;
    cin >>n;
    if(n==0) break;

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

      if(str == "North") d.north();
      else if(str == "East") d.east();
      else if(str == "South") d.south();
      else if(str == "West") d.west();
      else if(str == "Right") d.right();
      else if(str == "Left") d.left();
    }

    d.ans();
  }

  return 0;

}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  cout << min(A,B)+min(C,D) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
DP = [[0] * 3 for _ in range(n+1)]
A = []
for i in range(n):
    A.append(list(map(int, input().split())))
for i in range(1, n+1):
    for j in range(0, 3):
        for k in range(0, 3):
            if j != k:
                DP[i][j] = max(DP[i][j], DP[i-1][k] + A[i-1][j])
print(max(DP[-1]))

Measured memory_bytes: 50360
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。

import math
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = 10**18 #べき乗 C++ の pow(10, 18) or 1e18;
PI = math.pi

large_P = 1000000007
#large_P = 1000000009
#large_P = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。


A = int(input())
B = int(input())

for i in range (1, 4):
    if(i != A and i != B):
        print(i)
        break



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

int main(){
  long long n,k; cin >> n >> k;
  long long p = (n/k)*(n/k)*(n/k);
  
  if(k%2!=0){cout << p;}
  else{
    long long p2 = (n+k/2)/k;
    cout << p2*p2*p2+p;
  }
  
  return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp(x,y)     make_pair(x,y) 
#define exit(x)     cout<<x<<"\n",return
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)
const ll N=500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
  ll T=1;
  //cin>>T;
  while(T--)
  {
 // string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>n;
  ll a[n+1][3];
  ll dp[n+1][3];
  for (ll i = 1; i <= n; ++i)
  {
   cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  dp[1][0]= a[1][0];
  //dp[1][0] = 0;
  dp[1][1]= a[1][1];
 // dp[1][1].second = 1;
  dp[1][2] = a[1][2];
//  dp[1][2].second = 2;
  for (ll i = 2; i <= n; ++i)
  { 
    for (ll j = 0; j < 3; ++j)
    {
      dp[i][j] =  a[i][j] + max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);

    }  
   }
  ans = max(max(dp[n][0],dp[n][1]),dp[n][2]);
  c(ans);  
 }
}

signed main(){

        ios_base::sync_with_stdio(false);   
        cin.tie(NULL);
       solve();
    return 0;
    }


Measured memory_bytes: 4992
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll A = a;
  
  if(a > k){
    cout << k << endl;
    return 0;
  }else if(a + b >= k){
    cout << a << endl;
    return 0;
  }else{
    for(int i = 1; i <= k - a - b; i++){
      A -= 1;
    }
    cout << A << endl;
    return 0;
  }
}

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


int main(){
	int N, K;
	string S;
	cin >> N >> S >> K;
	char s = S[K-1];
	for(int i=0;i<N;i++){
		if(S[i] != s){
			cout << '*';
		}
		else{
			cout << s;
		}
	}
    return 0;
}

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

int main()
{
	ll n;
	cin >> n;
	ll arr[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	ll max = arr[0];
	ll stool = 0;
	for (int i = 1; i < n; i++)
	{
		if (arr[i] < max)
		{
			stool += max - arr[i];
		}
		else if (arr[i] >= max)
		{
			max = arr[i];
		}
	}
	cout << stool << "\n";
	return 0;
}

Measured memory_bytes: 5168
import java.util.Scanner;

public class Main {

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

        int W = in.nextInt();
        int H = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int r = in.nextInt();

        if (y - r >= 0 && y + r <= H && x - r >= 0 && x + r <= W) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        System.exit(0);
    }
}



Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int N,H,W;cin>>N>>H>>W;
    int a[2][N];
    for(int i = 0; i < N; i++){
        long long int A,B;cin>>A>>B;
        a[0][i] = A;
        a[1][i] = B;
    }
    int co = 0;
    for(int i = 0 ; i < N; i++){
        if(a[0][i] >= H && a[1][i] >= W){
            co += 1;
        }
    }
    cout<<co<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main {

    public static void main(String[] args) {
	// write your code here
        BufferedReader bf;
        try {
                bf = new BufferedReader(new FileReader("in1.log"));
        }
        catch (FileNotFoundException e)
        {
            bf = new BufferedReader(new InputStreamReader(System.in));
        }

        try {
            pA p = new pA( bf.readLine());
            if(p.res==2)
                System.out.println("Yes");
            else {
                System.out.println("No");
            }
        } catch (IOException e) {
            System.exit(0);
        }
    }

}
class pA {
    int res;
    char[] bucket;
    pA() {} ;
    pA(String msg)
    {
        res=0;
        bucket=new char[msg.length()];
        for(int i=0;i<msg.length();i++)
        {
            bucket[i]=msg.charAt(i);
        }
        solver();
    }
    int solver()
    {
        boolean duplicateFlag=false;
        for(int i=0;i<bucket.length;i++)
        {
            duplicateFlag=false;
            for(int j=0;j<i;j++)
            {
                if(bucket[i]==bucket[j])
                    duplicateFlag=true;
            }
            if(duplicateFlag==false)
                res+=1;
        }
        return 0;
    }
}


Measured memory_bytes: 21332
#include <stdio.h>

int main(void)
{
	int a,b,c[100],i,n;
	scanf("%d",&b) ;
	i=0;
	while(b != 0){
	a=1000-b;
	c[i]=0;
	c[i]+=a/500;
	a=a%500;
	c[i]+=a/100;
	a=a%100;
	c[i]+=a/50;
	a=a%50;
	c[i]+=a/10;
	a=a%10;
	c[i]+=a/5;
	a=a%5;
	c[i]+=a/1;
	i+=1;
	scanf("%d",&b) ;
	}
	for(n=0;n<i;n++){
	printf("%d\n",c[n]);
	}
	return 0;
}

Measured memory_bytes: 600
a,b = map(int,input().split())
li = []
if a>b:
  for i in range(a):
    li.append(b)
  ans = ''.join(map(str, li))
  print(ans)
elif a<b:
  for i in range(b):
    li.append(a)
  ans = ''.join(map(str, li))
  print(ans)
elif a==b:
  for i in range(a):
    li.append(b)
  ans = ''.join(map(str, li))
  print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);

		int N = stdIn.nextInt();
		int i = stdIn.nextInt();

		System.out.println(N-i+1);

	}

}


Measured memory_bytes: 35520
#include<iostream>
#include <string>
#include<vector>
typedef long long ll;

using namespace std;
int main()
{
	int a,b,c;
	cin >> a>>b>>c;
	int kotae = 0;
	int max = a;
	char ma = 'a';
	if (max < b) {
		max = b;
		ma = 'b';
	}
	if (max < c) {
		max = c;
		ma = 'c';
	}

	if (ma == 'a') {
		kotae = 10 * a + b + c;
	}
	else if (ma == 'b') {
		kotae = 10 * b + a + c;
	}
	else if (ma == 'c') {
		kotae = 10 * c + a + b;
	}
	cout << kotae << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 105

using namespace std;
typedef short int l;

int dp[SIZE][SIZE][SIZE];
int nxt[SIZE][SIZE][SIZE];
char mp[SIZE][SIZE];
int cnt[SIZE][SIZE];
int h,w;

int gt(int a,int b,int c,int d)//[a,b],[c,d]
{
	int ret=cnt[b][d];
	if(a>0) ret-=cnt[a-1][d];
	if(c>0) ret-=cnt[b][c-1];
	if(a>0&&c>0) ret+=cnt[a-1][c-1];
	return ret;
}
int main()
{
	scanf("%d %d",&h,&w);
	int gx,gy;
	for(int i=0;i<h;i++)
	{
		scanf("%s",&mp[i]);
		for(int j=0;j<w;j++)
		{
			if(mp[i][j]=='E')
			{
				gx=i;
				gy=j;
			}
		}
	}
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cnt[i][j]=mp[i][j]=='o'?1:0;
			if(i>0) cnt[i][j]+=cnt[i-1][j];
			if(j>0) cnt[i][j]+=cnt[i][j-1];
			if(i>0&&j>0) cnt[i][j]-=cnt[i-1][j-1];
		}
	}
	int ret=0;
	for(int L=h+w;L>=2;L--)
	{
		for(int a=0;a<h;a++)
		{
			for(int b=a;b<h;b++)
			{
				if(b-a+1>=L) continue;
				for(int c=0;c<w;c++)
				{
					int d=c+(L-(b-a+1))-1;
					if(d>=w) continue;
					if(L==2)
					{
						ret=max(ret,dp[a][b][c]+(mp[a][c]=='o'?1:0));
						continue;
					}
					int ex=gx+a,sx=gx-(h-b-1);
					int ey=gy+c,sy=gy-(w-d-1);
					int ly=max(sy,c),ry=min(ey,d);
					int lx=max(sx,a),rx=min(ex,b);
					int vl;
					if(a<b)
					{
						vl=0;
						if(sx<=a&&a<=ex) vl=gt(a,a,ly,ry);
						nxt[a+1][b][c]=max(nxt[a+1][b][c],dp[a][b][c]+vl);
						vl=0;
						if(sx<=b&&b<=ex) vl=gt(b,b,ly,ry);
						nxt[a][b-1][c]=max(nxt[a][b-1][c],dp[a][b][c]+vl);
					}
					if(c<d)
					{
						vl=0;
						if(sy<=c&&c<=ey) vl=gt(lx,rx,c,c);
						nxt[a][b][c+1]=max(nxt[a][b][c+1],dp[a][b][c]+vl);
						vl=0;
						if(sy<=d&&d<=ey) vl=gt(lx,rx,d,d);
						nxt[a][b][c]=max(nxt[a][b][c],dp[a][b][c]+vl);
					}
				}
			}
		}
		for(int a=0;a<h;a++)
		{
			for(int b=a;b<h;b++)
			{
				if(b-a+1>=L) continue;
				for(int c=0;c<w;c++)
				{
					dp[a][b][c]=nxt[a][b][c];
				}
			}
		}
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 5120
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
int n,A,B,C;vll l(8);
int dfs(ll x,ll a,ll b,ll c){
  if(x==n){
    if(a==0||b==0||c==0){
      return 1e9;
    }
    else{return abs(a-A)+abs(b-B)+abs(c-C)-30;}
  }
  else{
    int no=dfs(x+1,a,b,c);
    no=min(no,dfs(x+1,a+l[x],b,c)+10);
    no=min(no,dfs(x+1,a,b+l[x],c)+10);
    no=min(no,dfs(x+1,a,b,c+l[x])+10);
    return no;
  }
}
int main(){
  cin>>n>>A>>B>>C;
  rep(i,0,n){
    cin>>l[i];
  }
  cout<<dfs(0,0,0,0)<<endl;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int n, m, p;

  cin>> n>> m>> p;
  vi d(m);
  for(int i=0;i<m;i++){
    int a;
    cin>> a;
    d[i]=(a-p+n)%n;
  }

  sort(d.begin(), d.end());
  int ret=min(n-d[0], d[m-1]);
  for(int i=0;i<m;i++){
    if(i>0) ret=min(ret, 2*(n-d[i])+d[i-1]);
    if(i<m-1) ret=min(ret, 2*d[i]+n-d[i+1]);
  }

  cout<< ret*100<< endl;
}

Measured memory_bytes: 1252
N = int(input())
A = list(map(int, input().split()))
Ad = [A[i]-(i+1) for i in range(N)]
Ad.sort()
l = len(Ad)
if l % 2 == 1:
    b = Ad[l//2]
    ans = sum(map(lambda x:abs(x-b), Ad))
else:
    b1, b2 = Ad[l//2], Ad[l//2-1]
    ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))
print(ans)


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

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

using namespace std;

typedef long long ll;

long long extgcd(long long a,long long b,long long& x,long long& y)
{
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m)
{
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

ll modmultiply(ll a,ll b,ll c) {
  ll x = 0,y = a%c; 
  while(b > 0) {
    if(b%2 == 1) x = (x+y)%c; 
    y = (y*2)%c;
    b /= 2; 
  }
  return x%c;
}

ll modpow(ll x, ll y, ll mod) {
  ll ret = 1;// ret = x^y%mod;
  while(y) {
    if(y&1)
      //ret = (ret*x)%mod;
      ret = modmultiply(ret, x, mod);
    //x = (x*x)%mod;
    x = modmultiply(x, x, mod);
    y >>= 1;
  }
  return ret;
}

#define MR_MAX 40
bool MillerRabin(long long v) {
  if( v == 2 ) return true;
  if( v < 2 || !(v&1LL) ) return false;
  srand((unsigned int)time(NULL));
  long long d = v - 1;
  while( ( d & 1LL ) == 0 ) d >>= 1LL;
  for(int i=0;i<MR_MAX;++i) {
    long long a = rand() % (v-2) + 1LL;
    long long t = d;
    long long y = modpow(a,t,v);
    while( t != v-1LL && y != 1LL && y != v-1LL ) {
      y = ( y * y ) % v;
      t <<= 1LL;
    }
    if( y != v-1LL && ( t & 1LL ) == 0  ) return false;
  }
  return true;
}

int main() {
  int n,v,cnt=0;
  cin >> n;
  rep(i,n) {
    cin >> v;
    cnt += MillerRabin(v);
  }
  cout << cnt <<endl;
  /*
  string pi;
  cin >> pi;
  rep(i,(int)pi.size()-10) {
    assert(i+10-1<(int)pi.size());
    string tmp = pi.substr(i,10);
    long long prim = atoll(tmp.c_str());
    if( MillerRabin(prim) ) {
      cout << "Found!!! : " << prim << endl;
    }
  }
  puts("Not Found...");
  */
  return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<P> start_point, end_point;
multiset<Int> stop_point;
int main(){
    int n, q, s, t, x, d;
    cin >> n >> q;
    for(int i = 0;i < n;i++){
        cin >> s >> t >> x;
        start_point.push_back(P(s-x, x));
        end_point.push_back(P(t-x, x));
    }
    sort(start_point.begin(), start_point.end());
    sort(end_point.begin(), end_point.end());
    auto sit = start_point.begin();
    auto eit = end_point.begin();
    for(int i = 0;i < q;i++){
        int d;
        cin >> d;
        while(sit != start_point.end() &&
              sit->first <= d){
            stop_point.insert(sit->second);
            sit++;
        }
        
        while(eit != end_point.end() &&
              eit->first <= d){
            stop_point.erase(stop_point.find(eit->second));
            eit++;
        }
        if(stop_point.empty())cout << -1 << endl;
        else cout << *stop_point.begin() << endl;
    }
    return 0;
}

Measured memory_bytes: 16860
import java.util.*;

import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ2199();
	}
	final int INF=1<<28;
	
	class AOJ2199{
		AOJ2199(){
			while(sc.hasNext()){
				N=sc.nextInt();
				M=sc.nextInt();
				if((N|M)==0)	break;
				solve();
			}
		}
		int N,M;
		void solve(){
			int[] c=new int[M];
			for(int i=0; i<M; ++i)	c[i]=sc.nextInt();
			int[] x=new int[N];
			for(int i=0; i<N; ++i)	x[i]=sc.nextInt();
			
			int[][] dp=new int[N+1][256];
			for(int i=0; i<=N; ++i)for(int j=0; j<=255; ++j)	dp[i][j]=INF;
			dp[0][128]=0;
			for(int i=1; i<=N; ++i)for(int j=0; j<=255; ++j)for(int k=0; k<M; ++k){
				int tmp=max(0, min(255, j+c[k]));
				dp[i][tmp]=min(dp[i][tmp], dp[i-1][j]+(x[i-1]-(tmp))*(x[i-1]-(tmp)));
			}
			int ans=INF;
			for(int i=0; i<=255; ++i)	ans=min(ans, dp[N][i]);
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 124084
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

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

   vector<char> ans;
   while (N > 0) {
     N--;
     ans.push_back(N % 26 + 'a');
     N /= 26;
   }

   for (int i = ans.size() - 1; i >= 0; i--) cout << ans.at(i);
   cout << endl;
 }


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define r(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;

int main(void){
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  cout << s[0][0] << s[1][1] << s[2][2] << endl;
  return 0;
}


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

int main(){
  int n,i=0,j=0;
  int cash=1;
  int dp[100010];
  cin>>n;
  dp[0]=0;
  for(i=1;i<n;i++){
    dp[i]=10000000000;
  }
  for(i=1;i<n+1;i++){
    dp[i]=dp[i-1]+1;
    if(i>=6){
      for(j=0;j<n;j++){
        cash=cash*6;
        if(cash>i)
          break;
        if(dp[i]>dp[i-cash]+1){
          dp[i]=dp[i-cash]+1;
        }
      }
    }
    cash=1;
    if(i>=9){
      for(j=0;j<n;j++){
        cash=cash*9;
        if(cash>i)
          break;
        if(dp[i]>dp[i-cash]+1){
          dp[i]=dp[i-cash]+1;
        }
      }
    }
    cash=1;
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    long long v,w;
    cin >> a >> v;
    cin >> b >> w;
    long long t;
    cin >> t;
    long long aa,bb;
    if(a>=b){
        for(long long i=0; i<=t; i++){
            aa = a-v*i;
            bb = b-w*i;
            if(aa<=bb){
                cout << "YES" << endl;
                return 0;
            }
        }
    }else{
        for(long long i=0; i<=t; i++){
            aa = a+v*i;
            bb = b+w*i;
            if(bb<=aa){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int n, k, q;
int main() {
    cin >> n >> k >> q;
    vector<int> ap(n, q);
    for(int i = 0; i < q; ++i) {
        int a;
        cin >> a;
        a--;
        ap.at(a)--;
    }

    for(int i = 0; i < n; ++i) {
        if((k-ap.at(i)) <= 0) {
            cout << "No" << endl;
        }else {
            cout << "Yes" << endl;
        }
    }
}

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

void print(const vector<int>& num) {
    int n = num.size();
    for (int i = 0; i < n; ++i) {
        cout << num[i];
        if (i != n - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}

void swap(int& a, int& b) {
    int tmp = a;
    a = b;
    b = tmp;
}

void insertion_sort(vector<int>& a) {
    int n = a.size();

    for (int i = 1; i < n; ++i) {
        // この状態では，[0, i - 1]はソートされている．
        int x = a[i];
        int j = i - 1;
        // a[i]より大きいものがあれば，ずらしていく．
        while (j >= 0 && a[j] > x) {
            a[j + 1] = a[j];
            --j;
        }
        a[j + 1] = x;
    }
}

void bubble_sort(vector<int>& a) {
    int n = a.size();
    bool flag = true;
    while (flag) {
        flag = false;
        // 配列の後ろから，隣接する要素を交換していく．
        for (int i = n - 1; i >= 0; --i) {
            if (a[i - 1] > a[i]) {
                swap(a[i - 1], a[i]);
                flag = true;
            }
        }
    }
}

void selection_sort(vector<int>& a) {
    int n = a.size();
    for (int i = 0; i < n; ++i) {
        // a[i]からa[n - 1]までの最小値をa[i]と交換する．
        int mini = i;
        for (int j = i; j < n; ++j) {
            if (a[j] < a[mini]) { mini = j; }
        }
        swap(a[i], a[mini]);
    }
}

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

    vector<int> a(3);
    for (int i = 0; i < 3; ++i) { cin >> a[i]; }

    selection_sort(a);
    print(a);

    return 0;
}


Measured memory_bytes: 3108
import math
n, m = [int(i) for i in input().split()]
t = 0
tt = 0
def com(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if n > 1:
    t = com(n,2)
if m > 1:
    tt = com(m,2)

print(t+tt)

Measured memory_bytes: 9184
#include<iostream>
#include<queue>
#include<vector>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;



int main(){
	ll n;cin >> n;
	string s;cin >> s;

	ll r = 0;
	ll g = 0;
	ll b = 0;

	for (ll i = 0;i < n;i++){
		if (s[i] == 'R'){
			++r;
		}else if (s[i] == 'G'){
			++g;
		}else{
			++b;
		}
	}

	const ll total = r * g * b;
	ll total_wrong = 0;
	for (ll i = 0;i < n - 2;i++){
		for (ll j = 1;i+2*j < n;j++){
			bool is_false = s[i] == s[i+j] || s[i] == s[i+2*j] || s[i+j] == s[i+2*j];
			if (!is_false){
				total_wrong++;
			}
		}
	}
	const ll ans = total - total_wrong;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
import scala.io.StdIn._

object Main extends App {


  val Array(n, m) = readLine().split(" ").map(_.toInt)
  val hintArr = Array.fill(m)(readLine().split(" ").map(_.toInt))

  def solve(): Int = {
    val default = Map.empty[Int, Int]
    val digitAndNumMap = hintArr.foldLeft(default) { (acc, hint) =>
      acc.get(hint(0)) match {
        case Some(v) =>
          if(v == hint(1)) acc else return -1
        case None =>
          if(n != 1 && hint(0) == 1 && hint(1) == 0) return -1
          else acc.updated(hint(0), hint(1))
      }
    }
    val ansStr = (1 to n).map { i =>
      digitAndNumMap.getOrElse(i, 0)
    }.mkString("")
    if(n != 1 && ansStr.startsWith("0")) ansStr.updated(0, '1').mkString("").toInt
    else ansStr.toInt
  }

  println(solve())

}



Measured memory_bytes: 54756
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef double D;
typedef complex<D> P;
int K,N;
P ps[100],as[100];
bool up(P s,P t,P p){			//line over point
	D sx=s.real(),tx=t.real(),sy=s.imag(),ty=t.imag(),x=p.real(),y=p.imag();
	D ly=sy+(ty-sy)/(tx-sx)*(x-sx);
	return ly>y;
}
void addpath(vector<int>& vc,P s,P t){
	vector<int> ad;
	D sx=s.real(),tx=t.real(),sy=s.imag(),ty=t.imag();
	bool sw=0;
	if(sx>tx){
		sw=1;
		swap(sx,tx);
		swap(sy,ty);
	}
	rep(i,N){
		D x=as[i].real(),y=as[i].imag();
		if(sx<x&&x<tx){
			if(up(s,t,as[i])) ad.pb(i*2);
			else ad.pb(i*2+1);
		}
	}
	if(sw) reverse(all(ad));
	vc.insert(vc.end(),all(ad));
}
bool cancel(vector<int>& vc){
	bool update=0;
	int A=vc.size();
	vector<bool> gomi(A,0);
	rep(i,A-1){
		if(vc[i]==vc[i+1]){
			gomi[i]=gomi[i+1]=1;
			update=1;
			i++;
		}
	}
	vector<int> nvc;
	rep(i,A) if(!gomi[i]) nvc.pb(vc[i]);
	vc=nvc;
	return update;
}
P point(int id){
	return as[id/2];
}
D calclen(P S,P T,vector<int>& vc){
//	show(S);
//	show(T);
	int A=vc.size();
//	show(A);
//	for(int v:vc) cout<<v<<" ";
//	puts("");
	D dp[110];
	rep(i,A+2) dp[i]=1e9;
	dp[0]=0;
	rep(i,A+1){
		P t=(i==A?T:point(vc[i]));
		rep(j,i+1){
			P s=(j==0?S:point(vc[j-1]));
			bool ok=1;
			for(int k=j;k<i;k++){
				if(up(s,t,point(vc[k]))==(vc[k]&1)){
					ok=0;
					break;
				}
			}
			if(ok) chmin(dp[i+1],dp[j]+abs(s-t));
		}
	}
	return dp[A+1];
}
int main(){
	while(true){
		cin>>K>>N;
		if(K==0) break;
		rep(i,K){
			D x,y;
			cin>>x>>y;
			ps[i]=P(x,y)*polar(1.0,1.0);
		}
		rep(i,N){
			D x,y;
			cin>>x>>y;
			as[i]=P(x,y)*polar(1.0,1.0);
		}
		rep(i,N-1) rep(j,N-1) if(as[j].real()>as[j+1].real()) swap(as[j],as[j+1]);
		vector<int> vc;
		rep(i,K-1) addpath(vc,ps[i],ps[i+1]);
		while(cancel(vc));
		D ans=0;
		int M=vc.size();
		int l=-1;
		for(int r=1;r<=M;r++){
			if(r==M||(vc[r]^vc[r-1])==1){
				vector<int> tmp;
				P s,t;
				if(l==-1) s=ps[0];
				else s=point(vc[l]);
				if(r==M) t=ps[K-1];
				else t=point(vc[r]);
				if(r==M) r++;
				for(int i=l+1;i<r-1;i++) tmp.pb(vc[i]);
				ans+=calclen(s,t,tmp);
//				show(calclen(s,t,tmp));
				l=r;
			}
		}
		printf("%.12f\n",ans);
	}
}

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

int main() {
  long long int N, M, D;
  cin >> N >> M >> D;
  double ans;
  if (D == 0) ans = 1.0 * (M - 1) / N;
  else ans = 2.0 * (N - D) * (M - 1) / (N * N);
  cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 3736
function main(input:string) {
    const i = input.split("\n");
    const n =  parseInt(i[0].split(" ")[0]);
    const k = parseInt(i[0].split(" ")[1]);
    let answer = [];
    
    const h = i.slice(1,n+1).map(x => parseInt(x)).sort((a,b) => { return a-b });
        
    for (let j = 0; j < n - k + 1; j++) {
        answer.push(h[k - 1 + j] - h[j]);
    }
    console.log(answer.reduce((a,b)=>Math.min(a,b)));
    
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

string query(int n) {
	cout << n << '\n' << flush;
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	return s;
}

int main() {
	int n; cin >> n;
	int l = 0;
	int r = n - 1;
	string L = query(l);
	string R = query(r);

	while (true) {
		int m = (l + r) / 2;
		R = query(m);
		if (m % 2) {
			if (L == R) r = m;
			else l = m;
		} else {
			if (L == R) l = m;
			else r = m;
		}
	}
	return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include<iomanip>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
using namespace std;

const int NN=1;

int main()
{
    long long ans;
    long long a;
    scanf("%ld",&a);
    ans=3*a*a;
    printf("%ld\n",ans);;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
struct S{
	int t,n,m,s;
	S(int t,int n,int m,int s):t(t),n(n),m(m),s(s){}
};
int main(){
	int r,q,t,n,m,s,ans;
	while(cin>>r>>q,r){
		vector<S> lg; cin>>r;
		rep(i,r)cin>>t>>n>>m>>s,lg.push_back(S(t,n,m,s));
		cin>>q; rep(i,q){
			cin>>s>>t>>m; n=ans=0;
			rep(i,r-1){
				n+=lg[i].m==m&&lg[i].s;
				if(n>0)ans+=max(min(lg[i+1].t,t)-max(lg[i].t,s),0);
				n-=lg[i+1].m==m&&!lg[i+1].s;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
struct box{
	ll strength, weight, value;
	bool operator<(box& b){
		return strength + weight < b.strength + b.weight;
	};
};
void solve(){
	ll n;
	cin>>n;
	vector<box> v(n);
	for(auto &u : v){
		cin>>u.weight>>u.strength>>u.value;
	}
	ll dp[20004];
	memset(dp,-1,sizeof dp);
	dp[0]=0;
	sort(all(v));
	rep(i,0,n){
		for(ll j=v[i].strength;j>=0;j--)
			if(dp[j]!=-1)
				dp[j+v[i].weight]=max(dp[j+v[i].weight],dp[j]+v[i].value);
	}
	ll ans=0;
	rep(i,0,20004)ans=max(ans,dp[i]);
	cout<<ans<<endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct edge{ int to,cost; };
std::vector<int> articulationPoint(const vector<vector<edge>> &g) {
    int n = g.size(), idx;
    std::vector<int> low(n), ord(n), art;
    std::function<void(int)> dfs = [&](int v) {
        low[v] = ord[v] = ++idx;
        for (auto& e : g[v]) {
            int w = e.to;
            if (ord[w] == 0) {
                dfs(w);
                low[v] = std::min(low[v], low[w]);
                if ((ord[v] == 1 && ord[w] != 2) || (ord[v] != 1 && low[w] >= ord[v]))
                    art.push_back(v);
            } else
                low[v] = std::min(low[v], ord[w]);
        }
    };
    for (int u = 0; u < n; u++)
        if (ord[u] == 0) {
            idx = 0;
            dfs(u);
        }
    sort(art.begin(), art.end());
    art.erase(unique(art.begin(), art.end()), art.end());
    return art;
}
signed main(){

  int n,m; cin >> n >> m;
  vector<vector<edge>> G(n);
  for(int i = 0; i < m; i++){
    int x,y; cin >> x >> y;
    G[x].push_back({y,1});
    G[y].push_back({x,1});
  }

  auto ans = articulationPoint(G);
  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}



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

int main() {
	int W, H, N;
	cin >> W >> H >> N;
	int xl, xr, yd, yu;
	xl = yd = 0;
	xr = W;
	yu = H;
	for (int i = 0; i < N; ++i) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			if (xl < x) xl = x;
		}
		else if (a == 2) {
			if (x < xr) xr = x;
		}
		else if (a == 3) {
			if (yd < y) yd = y;
		}
		else if (y < yu) yu = y;
	}
	if (xr - xl > 0 && yu - yd > 0) {
		cout << (xr - xl) * (yu - yd) << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 3168
import sys
import math
from collections import deque
s=int(input())

if s<=599:
    print(8)
elif s<=799:
    print(7)
elif s<=999:
    print(6)
elif s<=1199:
    print(5)
elif s<=1399:
    print(4)
elif s<=1599:
    print(3)
elif s<=1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 64988
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int h, w;
string s[2000];
int A[2000][2000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; ++i)
        cin >> s[i];

    for (int i = 0; i < h; ++i)
    {
        int l = -1, r = w;
        for (int j = 0; j < w; ++j)
        {
            if (s[i][j] == '#')
                l = j;
            if (s[i][w - j - 1] == '#')
                r = w - j - 1;

            A[i][j] += j - l;
            A[i][w - j - 1] += r - (w - j - 1);
        }
    }
    for (int j = 0; j < w; ++j)
    {
        int u = -1, d = h;
        for (int i = 0; i < h; ++i)
        {
            if (s[i][j] == '#')
                u = i;
            if (s[h - i - 1][j] == '#')
                d = h - i - 1;

            A[i][j] += i - u;
            A[h - i - 1][j] += d - (h - i - 1);
        }
    }
    int mx = 0;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            mx = max(mx, A[i][j] - 3);
    cout << mx;
}


Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<int,Pii> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
struct Point{
    double x,y;
    Point(){}
    Point(double _x,double _y){
        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(k*x,k*y);
    }
  
    Point operator / (double k){
        return Point(x/k,y/k);
    }
 
    bool operator<(const Point &p)const{
        return x!=p.x?x<p.x:y<p.y;
    }
  
};
double dot(Point p, Point q){
    return p.x*q.x+p.y*q.y;
}
  
double cross(Point p,Point q){
    return p.x*q.y-q.x*p.y;
}
  
double norm(Point p){
    return p.x*p.x+p.y*p.y;
}
  
double pabs(Point p){
    return sqrt(norm(p));
}
typedef vector<Point> Polygon;
struct Line : Polygon{
    Line(){}
    Line(Point p,Point q){
        PB(p);
        PB(q);  
    }
};
struct Circle{
    Point p; //中心点
    double r; //半径
    Circle(){}
    Circle(Point _p,double _r){
        p = _p;
        r = _r;
    }
};
int ccw(Point a,Point b,Point c){
    b = b-a;
    c = c-a;
    if(cross(b,c) > 0)return +1; //a→b で反時計に折れてc ccw
    if(cross(b,c) < 0)return -1; //a→b で時計に折れてc ccw
    if(dot(b,c) < 0)return +2; // c--a--b;
    if(pabs(b)<pabs(c))return -2; //a--b--c
    return 0; //a--c--b
}
bool intersectSS(Line l,Line m){
    //lとmが交差してるかどうか
    return (ccw(l[0],l[1],m[0])*ccw(l[0],l[1],m[1])<=0)&&
            (ccw(m[0],m[1],l[0])*ccw(m[0],m[1],l[1])<=0);
}

bool intersectLL(Line l,Line m){
	return fabs(cross(l[1]-l[0],m[1]-m[0])) > EPS || //平行でない
			fabs(cross(l[1]-l[0],m[0]-l[0])) < EPS; //同一の線
}


double TriangleArea(Point a,Point b,Point c){
    b = b - a;
    c = c - a;
    return cross(b,c)*0.5; //負になることもあるので注意
}
 
double VertexArea(Polygon v){
    double subArea = 0.0;
    rep(i,v.size()-1){
        subArea += TriangleArea(v[0],v[i],v[i+1]);
    }
    return subArea; //負になることもあるので注意
}

Point crosspoint(Line l,Line m){
    if(intersectSS(l,m) == false)return Point(INF,INF);
    return m[0]+(m[1]-m[0])*cross(l[1]-l[0],l[1]-m[0])/cross(l[1]-l[0],m[1]-m[0]);
}
 
Polygon ConvexHull(Polygon v){
	int n = v.size();
	int k = 0;
	sort(v.begin(),v.end());
	Polygon e(2*n);
	for(int i=0;i<n;e[k++]=v[i++])
		while(k>=2&&ccw(e[k-2],e[k-1],v[i])<=0)k--;
	for(int i=n-2,t=k+1;i>=0;e[k++]=v[i--])
		while(k>=t&&ccw(e[k-2],e[k-1],v[i])<=0)k--;
	e.resize(k-1);
	return e;
}

int main(){
	int N;
	while(scanf("%d",&N),N){
		Polygon v;
		rep(i,N){
			double x,y;
			scanf("%lf,%lf",&x,&y);
			v.PB(Point(x,y));
		}
		printf("%d\n",N-ConvexHull(v).size());
	}
    return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xdist = x2-x1;
    int ydist = y2-y1;
    int x3,y3,x4,y4;
    x3 = x2-ydist;
    y3 = y2+xdist;
    x4 = x3-xdist;
    y4 = y3-ydist;
    cout << x3 << " " << y3 << " "<< x4 << " " << y4 << endl;
    return 0;
}

Measured memory_bytes: 256