akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sgn(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

long long mod_pow(long long a, long long n, int m) {
    a %= m;
    long long ret = 1;
    while (n) {
        if (n & 1) { (ret *= a) %= m; }
        (a *= a) %= m;
        n >>= 1;
    }
    return ret;
}

int N;
string X;
signed main() {
    cin >> N >> X;
    int p = 0;
    rep(i, N) { p += X[i] - '0'; }
    auto f = [](int n) {
        int ret = 0;
        while (n) {
            n %= __builtin_popcountll(n);
            ret++;
        }
        return ret;
    };
    map<int, int> mp;
    for (int i = -1; i <= 1; i++) {
        if (p + i < 1) { continue; }
        rep(j, N) {
            (mp[i] += (X[j] - '0') * mod_pow(2, N - j - 1, p + i)) %= (p + i);
        }
    }
    rep(j, N) {
        if (p == 1 && X[j] == '1') {
            cout << 0 << endl;
            continue;
        }
        int i = X[j] == '0' ? 1 : -1;
        cout << f((mp[i] + p + i + mod_pow(2, N - j - 1, p + i) * i) % (p + i)) + 1 << endl;
    }

}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#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(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
const string MINUSINF = "-";

void chmax(string &a, string b){
    if(a == MINUSINF)a = b;
    else if(a.size() < b.size())a = b;
    else if(a.size() == b.size()){
        if(a < b)a = b;

    }
}

//dp[i]:　i本使って作れる数字の最大値
int cost[] = {0, 2, 5, 5, 4, 5, 6, 3, 7,6};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,M;
    cin>>N>>M;
    vector<int> A(M);
    rep(i,M)cin>>A[i];
    vector<string> dp(N+1, MINUSINF);
    dp[0] = "";
    rep(i,N){
        if(dp[i] == MINUSINF)continue;
        rep(j,M){
            if(i + cost[A[j]] > N)continue;
            chmax(dp[i+cost[A[j]]], dp[i] + char('0' + A[j]));
        }
    }
    cout<<dp[N]<<endl;
}

Measured memory_bytes: 43776
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int a,b,c,x;cin>>a>>b>>c>>x;
    int cnt=0;
    rep(i,a+1)rep(j,b+1)rep(k,c+1)if(500*i+100*j+50*k==x)cnt++;
    cout<<cnt<<endl;
}



Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]

count = 0

for i in range(N):
    point = 0
    for j in range(M):
        point += A[i][j]*B[j]
    point += C
    if point > 0:
        count += 1

print(count)

Measured memory_bytes: 3064
h,w = (int(x) for x in input().split())
ab = []
count = 0
for _ in range(h):
    a = input()
    a = a+'.'
    ab.append(list(a))
ab.append(list('.'*w))

for i in range(h):
    for j in range(w):
        if ab[i][j] == '#':
            if ab[i+1][j] == '#' :
                continue
            elif ab[i][j+1] == '#' :
                continue
            elif ab[i-1][j] == '#' :
                continue
            elif ab[i][j-1] == '#' :
                continue
            else:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 38896
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define umap unordered_map<ll, ll>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, a, ans = 0;
    cin >> n;
    
    umap x;
    for(ll i=0; i<n; i++){
        cin >> a;
        x[a]++;
    }
    a = 0;
    for(auto i:x){
        if(i.first > i.second){
            ans += i.second;
        }
        if(i.first < i.second){
            ans += (i.second - i.first);
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,L;

struct ei{
    ei *to[2];
    ei(){to[0]=to[1]=NULL;}
};

void add(ei *t,string &s,int k){
    if(k==s.size())return;
    int c=s[k]-'0';
    if(t->to[c]==NULL)t->to[c]=new ei();
    add(t->to[c],s,k+1);
}

int dfs(ei *t,int k){
    int ret=0;
    rep(i,2)if(t->to[i]!=NULL)ret^=dfs(t->to[i],k+1);

    int cnt=0;
    if(t->to[0]!=NULL)cnt++;
    if(t->to[1]!=NULL)cnt++;
    if(cnt==1){
        int x=L-k;
        ret^=x&-x;
    }
    return ret;
}


signed main(){
    cin>>N>>L;

    ei *root=new ei();
    rep(i,N){
        string s;cin>>s;
        add(root,s,0);
    }

    if(dfs(root,0))cout<<"Alice"<<endl;
    else cout<<"Bob"<<endl;
    return 0;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];

  sort(A.begin(), A.end());
  if (N % 2 > 0) {
    // 0 2 2 4 4 ...
    for (long i = 0; i < N; i++) {
      if (A[i] != ((i+1)/2)*2) {
        cout << 0 << endl;
        return;
      }
    }
    long ret = 1;
    rep (i, N/2) {
      ret *= 2;
      ret %= MOD;
    }
    cout << ret << endl;
  } else {
    // 1 1 3 3 ...
    for (long i = 0; i < N; i++) {
      if (A[i] != ((i/2)*2+1)) {
        cout << 0 << endl;
        return;
      }
    }
    long ret = 1;
    rep (i, N/2) {
      ret *= 2;
      ret %= MOD;
    }
    cout << ret << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int n1000 = n / 1000;
  int n100 = (n - (n1000 * 1000)) / 100;
  int n10 = (n- (n1000 * 1000 + n100 * 100)) / 10;
  int n1 = n -(n1000 * 1000 + n100 * 100 + n10 * 10 );
  
  if ((n1000 == n100 && n100 == n10) || (n100 == n10 && n10 == n1)) {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

long calc(int max, int count) {
  int i;
  long mx = 0, mn = 0;
  for(i = 0;i < count;i++) mn += i;
  //mn = ((count - 1) * count) / 2;
  mx = max * count - mn;
  return mx - mn + 1;
}

int main(void) {
  int n, k;
  
  scanf("%d %d", &n, &k);
  if(k > n) {
    printf("1\n");
    return 0;
  }
  int i;
  long ret = 0;
  for(i = k;i <= n + 1;i++) {
    ret += calc(n, i);
  }
  ret %= 1000000007;
  printf("%ld\n", ret);
  return 0;
}

Measured memory_bytes: 2156
#include<iostream>
using namespace std;
int main()
{
    float s;
    int a,b,c;
    cin>>a>>b;
    if(a>=1 && b<=100)
    {
        s=(a+b)/2.0;
        c=s+.5;
        cout<<c<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,i;
	cin>>n;
	int a[n],b[200005]={0};
	for(i=0;i<n-1;i++)
	{
	cin>>a[i];
	b[a[i]]++;
    }
    for(i=0;i<n;i++)
    {
        cout<<b[i+1]<<endl;
    }
	return 0;
}

Measured memory_bytes: 5184
n = gets.chop.to_i
delta = 1e-11

n.times do
  x1, y1, x2, y2, x3, y3, x4, y4 = gets.chop.split(/\s+/).map { |s| s.to_f }
  #p [x1, y1, x2, y2, x3, y3, x4, y4].join(", ")

  dxa = x2 - x1
  dya = y2 - y1
  dxb = x4 - x3
  dyb = y4 - y3

  d = (dxa * dyb - dya * dxb).abs

  puts (d <= delta) ? "YES" : "NO"
end

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

int main() {
	// your code goes here
	int n,i;
	cin>>n;
	int a[n];
	for( i =0 ;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for( i=1;i<n;i++) if(a[i]==a[i-1])break;
	if(i<n) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 1024
H, W, K = map(int, input().split(' '))
ls, rst = [], 0
for i in range(H):
    ls.append(input())

for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for s in range(H):
            if i >> s & 1:
                continue
            for t in range(W):
                if j >> t & 1:
                    continue
                if ls[s][t] == '#':
                    cnt += 1
        if cnt == K:
            rst += 1
print(rst)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==25){
		cout<<"Christmas"<<endl;
	}
	else if(n==24){
		cout<<"Christmas Eve"<<endl;
	}
	else if(n==23){
		cout<<"Christmas Eve Eve"<<endl;
	}
	else if(n==22){
		cout<<"Christmas Eve Eve Eve"<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;

int X, Y, Z;

int main() {
	cin >> X >> Y >> Z;
	int R = Z;
	for (int i = 1; i <= 1000000; i++) {
		R += (Z + Y);
		if (R > X) { cout << i - 1 << endl; break; }
	}
	return 0;
}

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

int main()
{
    int a,b,c,d,e,ma=-1000;
    cin>>a>>b;
    c=a+b;
    d=a-b;
    e=a*b;
    ma=max(max(c,d),e);
    cout<<ma<<endl;
    return 0;
}


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

int main(){
    int r,d,x2000;
    cin>>r>>d>>x2000;
    vector<int>ans(10);
    for(int i = 0; i < 10; i++){
        if(i == 0){
            ans[i] = (r*x2000) - d;
            cout<<ans[i]<<endl;
        }
        else{
            ans[i]=(r*ans[i-1]) - d;
            cout<<ans[i]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 200003;
int n;
LL s[N], ans = 1e18;
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i <= n;i ++) scanf("%lld", s + i), s[i] += s[i - 1];
	for(Rint b = 2;b <= n - 2;b ++){
		int a = lower_bound(s + 1, s + b, s[b] >> 1) - s;
		if(a == b) -- a;
		if(a > 2 && abs(s[b] - s[a] * 2) > abs(s[b] - s[a - 1] * 2)) -- a;
		int c = lower_bound(s + b + 1, s + n, (s[n] + s[b]) >> 1) - s;
		if(c == n) -- c;
		if(c > b + 1 && abs(s[n] + s[b] - s[c] * 2) > abs(s[n] + s[b] - s[c - 1] * 2)) -- c;
		ans = min(ans, max(s[a], max(s[b] - s[a], max(s[c] - s[b], s[n] - s[c]))) - min(s[a], min(s[b] - s[a], min(s[c] - s[b], s[n] - s[c]))));
	}
	printf("%lld", ans);
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	int n, k, maxn = 0;
	vector<int>list;
	int a, b;
	cin >> a >> b;

	int num = 0;

	if (a >= 13) {
		num = b;
	}
	else if (a >= 6 && a <= 12) {
		num = b / 2;
	}
	else {
		num = 0;
	}

	cout << num << endl;








	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
n=int(input())
list1=[]
for i in range(n):
    list1.append(int(input()))
list2=sorted(list1)
#print(list2)
big1=list2[-1]
big2=list2[-2]
for i in range(n):
    if big1==list1[i]:
        print(big2)
    else:
        print(big1)

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

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

const int MAX_V = 1010;
int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v){
	used[v] = true;
	for (int i = 0; i < G[v].size(); ++i){
		int u = G[v][i], w = match[u];
		if(w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res = 0;
	memset(match, -1, sizeof(match));
	for (int v = 0; v < V; ++v){
		if (match[v] < 0){
			memset(used, 0, sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}

int main(void){
	int m, n;
	while (cin >> m >> n, V=m+n) {
		for (int i = 0; i < V; ++i) G[i].clear();
		vector<int> b(m), r(n);
		for (int i = 0; i < m; ++i) cin >> b[i];
		for (int i = 0; i < n; ++i) cin >> r[i];
		for (int i = 0; i < m; ++i){
			for (int j = 0; j < n; ++j){
				if (gcd(b[i], r[j]) != 1){
					add_edge(i, j+m);
				}
			}
		}
		cout << bipartite_matching() << endl;
	}
	return 0;
}


Measured memory_bytes: 4932
#include "bits/stdc++.h"
using namespace std;

struct StronglyConnectedComponentDecomposition {
    vector<vector<int>> graph, igraph, sccbucket;
    vector<int> vs, sccid;
    int nscc;
    void dfs(int v) {
        sccid[v] = 0;
        for (int u : graph[v]) {
            if (sccid[u] == -1) dfs(u);
        }
        vs.push_back(v);
    }
    void rdfs(int v, int k) {
        sccid[v] = k;
        for (int u : igraph[v]) {
            if (sccid[u] == -1) rdfs(u, k);
        }
    }
    void sccd() {
        sccid.assign(graph.size(), -1);
        for (int v = 0; v < (int)graph.size(); ++v) {
            if (sccid[v] == -1) dfs(v);
        }
        sccid.assign(graph.size(), -1);
        nscc = 0;
        while (!vs.empty()) {
            int v = vs.back(); vs.pop_back();
            if (sccid[v] == -1) rdfs(v, nscc++);
        }
        sccbucket.resize(nscc);
        for (int v = 0; v < (int)graph.size(); ++v) {
            sccbucket[sccid[v]].push_back(v);
        }
    }
};

int main() {
    int V, E;
    cin >> V >> E;
    StronglyConnectedComponentDecomposition sccd;
    sccd.graph.resize(V);
    sccd.igraph.resize(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        sccd.graph[s].push_back(t);
        sccd.igraph[t].push_back(s);
    }
    sccd.sccd();

    for (auto& b : sccd.sccbucket) {
        for (int v : b) cout << v << endl;
    }
}


Measured memory_bytes: 4640
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

int N;
int A[200000];
ll sum[200001];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum[i + 1] = sum[i] + A[i];
	}

	ll ans = 1145141919810;
	for (int center = 2; center <= N - 2; center++) {
		//centerとcenter-1の間で真ん中の仕切りを入れる
		
		int leftpos;
		auto leftpos1 = lower_bound(sum, sum + center, (sum[center] - sum[0]) / 2);
		auto leftpos2 = leftpos1 - 1;
		ll a = abs(*leftpos1 - (sum[center] - sum[static_cast<int>(leftpos1 - sum)]));
		ll b = abs(*leftpos2 - (sum[center] - sum[static_cast<int>(leftpos2 - sum)]));
		if (a > b)leftpos = leftpos2 - sum;
		else leftpos = leftpos1 - sum;
		
		int rightpos;
		auto rightpos1 = lower_bound(sum + center + 1, sum + N + 1, (sum[N] + sum[center]) / 2);
		auto rightpos2 = rightpos1 - 1;
		a = abs((*rightpos1 - sum[center]) - (sum[N] - *rightpos1));
		b = abs((*rightpos2 - sum[center]) - (sum[N] - *rightpos2));
		if (a > b)rightpos = rightpos2 - sum;
		else rightpos = rightpos1 - sum;

		ll tmp = 0;

		tmp = max(max(sum[leftpos], sum[center] - sum[leftpos]),
			max(sum[N] - sum[rightpos], sum[rightpos] - sum[center])) -
			min(min(sum[leftpos], sum[center] - sum[leftpos]),
				min(sum[N] - sum[rightpos], sum[rightpos] - sum[center]));

		ans = min(ans, tmp);

	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int d, g; cin >> d >> g;
	VE p(d), c(d);
	rep(i, d) {
		cin >> p[i] >> c[i];
	}
	int ans = INF;
	rep(bit, 1 << d) {
		int sum = 0;
		int cnt = 0;
		rep(i, d) {
			if (bit & (1 << i)) {
				sum += p[i] * (100 * (i + 1)) + c[i];
				cnt += p[i];
			}
		}
		if (sum >= g) {
			chmin(ans, cnt);
		}
		else {
			int tmp = g - sum;
			bool ok = false;
			for (int i = d - 1; i >= 0; i--) {
				if (!(bit&(1 << i))) {
					int tmp2 = 100 * (i + 1);
					if ((tmp + tmp2 - 1) / tmp2 < p[i]) {
						ok = true;
						cnt += (tmp + tmp2 - 1) / tmp2;
						break;
					}
					else {
						
					}
				}
			}
			if(ok)chmin(ans, cnt);
		}
	ex:;
	}
	cout << ans << endl;
	return 0;
}


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

#define N_MAX 200000
#define M_MAX 200000
#define INF 10000000
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;
typedef   signed long long dll;

int n, m;
int i, j, k;
int a;

typedef struct {
	int in;
	int out;
} twoway;

void deb(){
	return;
}

void solve(){
	int result;
	int prev = 0;

	return;
}

int main (void) {
	scanf("%d%d%d%d", &n, &m, &i, &j);
	a = n * m;
	if (i * j > a) a = i * j;
	printf("%d\n", a);

	solve();
	return 0;
}




Measured memory_bytes: 128
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 200005;

/*******************************************************************/




int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t, z = 1; cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n; cin >> n;
	string ans = "";
	while (n != 0) {
		int x = n % 26, f = 0;
		x--;
		if (n % 26 == 0) x = 25, f = 1;
		ans = (char)('a' + x) + ans;
		n /= 26;
		if (f == 1) n--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
m[15][15],D[15][15];X,Y,x,y,d;main(){for(;scanf("%d%d",&X,&Y),X;printf("%d\n",d)){for(y=0;y<Y;y++)for(x=X;x--;D[x][y]=d){scanf("%d",m[x]+y);if(!y)d=*m[x]!=1;else{d=0;if(m[x][y]-1)d+=m[x][y-1]?0:D[x][y-1],d+=y<2||m[x][y-2]-2?0:D[x][y-2];if(!m[x][y])d+=x<1||m[x-1][y-1]?0:D[x-1][y-1],d+=x+2>X||m[x+1][y-1]?0:D[x+1][y-1];}}for(d=0;X--;d+=Y<2||m[X][Y-2]-2?0:D[X][Y-2])d+=D[X][Y-1];}exit(0);}

Measured memory_bytes: 0
#include<cstdio>
const int maxn=300;
int a[maxn+10][maxn+10],n,m,cnt[maxn+10],ans=500; bool used[maxn+10];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j) scanf("%d",&a[i][j]);
	for(int i=1;i<=m;++i) used[i]=1;
	for(int i=1;i<=m;++i){
		for(int j=1;j<=m;++j) cnt[j]=0;
		for(int j=1;j<=n;++j)
			for(int k=1;k<=m;++k) if(used[a[j][k]]){
				++cnt[a[j][k]]; break;
			}
		int id=0;
		for(int j=1;j<=m;++j) if(cnt[j]>cnt[id]) id=j;
		if(cnt[id]<ans) ans=cnt[id]; used[id]=0;
	}
	printf("%d",ans); return 0;
}

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

const ll MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ok(n + 1, true);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ok[a] = false;
  }
  vector<ll> dp(n + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < n + 1; i++) {
    if (i > 0 && ok[i - 1]) dp[i] = (dp[i] + dp[i - 1]) % MOD;
    if (i > 1 && ok[i - 2]) dp[i] = (dp[i] + dp[i - 2]) % MOD;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	int i=0,x=0,y,ans;
	cin>>s;
	int ls=s.length();
	while(i<ls)
	{
		if(s[i]=='p') x++;
		i++; 
	}
	y=i/2;
	ans=y-x;
	cout<<ans;
	return 0;
 } 


Measured memory_bytes: 512
#include<stdio.h>
int main(){
int i,s;
scanf("%d",&s);
for(i=1;i<=s;i++){
	if(i%3==0){
	printf(" %d",i);
	}
	else if(i%10==3){
	printf(" %d",i);
	}
	else if(i%100/10==3){
	printf(" %d",i);
	}
	else if(i%1000/100==3){
	printf(" %d",i);
	}
	else if(i%10000/1000==3){
	printf(" %d",i);
	}
}
printf("\n");
return 0;
}


Measured memory_bytes: 2024
// AOJ 1060: No Story
// 2017.10.7 bal4u@uu
// 2017.12.15

#include <stdio.h>
#include <math.h>

#define MAX 1000004
int power[100], sz;
char tbl[1000006];

int psz;
int ptbl[78500] = {			// ptbl[166] = 997, ptbl[78498] = 999983
         3,   5,   7,  11,  13,  17,  19,  23,  29,
   31,  37,  41,  43,  47,  53,  59,  61,  67,  71,
   73,  79,  83,  89,  97, 101, 103, 107, 109, 113,
  127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
  179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
  233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
  283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
  353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
  419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
  467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
  547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
  607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
  661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
  739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
  811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
  877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
  947, 953, 967, 971, 977, 983, 991, 997 };

void sieve()
{
	int i, j, k;

	for (i = 0; i < 167; i++) {
		k = ptbl[i];
		for (j = k*k; j < MAX; j += k) tbl[j] = 1;
	}
	for (psz = 166, i = 997; i <= MAX; i += 2) if (!tbl[i]) ptbl[psz++] = i;
	ptbl[psz] = 0;
}

void prime_factor(long long n)
{
    int a, k;
    int *pp;

    sz = 0;
    if (!(n & 1)) {
        power[sz] = 0;
        do n >>= 1, power[sz]++;
        while (!(n & 1));
        sz++;
    }
	if (n <= 1) return;
	if (n <= MAX && !tbl[n]) { power[sz++] = 1; return; }
    k = (int)sqrt((double)n);
	for (pp = ptbl; n > 1; pp++) {
        if (*pp > k || n <= MAX && !tbl[n]) { power[sz++] = 1; break; }
		if (n % *pp) continue;
		a = *pp, power[sz] = 0;
		do n /= a, power[sz]++;
	    while (n % a == 0);
		sz++;
	}
}

int main()
{
	long long n, ans;
	int i;

	sieve();
	while (scanf("%lld", &n) && n > 0) {
		if (n == 1) { puts("1"); continue; }
		if (n <= MAX && (n & 1) && !tbl[n]) { puts("2"); continue; }
        prime_factor(n);
		for (ans = 1, i = 0; i < sz; i++) ans = ans * (1 + (power[i] << 1));
        printf("%lld\n", (ans+1)>>1);
	}
	return 0;
}

Measured memory_bytes: 2960
<?php

fscanf(STDIN, "%d %d", $a, $b);


$cnt = 0;
for ($i = $a; $i <= $b; $i++) {
    $array = str_split((string) $i);
    $array2 = $array;

    $is_same = true;
    $first = true;
    foreach ($array as $value) {
        if ($first) {
            $first = false;
            $value2 = end($array2);
        } else {

            $value2 = prev($array2);
        }
        if ($value !== $value2) {
            $is_same = false;
            break;
        }
    }
    if ($is_same) {
        $cnt++;
    }
}

echo $cnt;

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main()
{
  int H, N;
  cin >> H >> N;
  vector<int> M;
  M.resize(N);
  ll sum = 0;
  for (int i = 0; i < N; ++i) {
    cin >> M[i];
    sum += M[i];
  }
  if (H > sum) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
  return 0;
}


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

int main(){
  long long x,k,d;
  cin >> x >> k >> d;
  if(x > 0){
  if(x / d >= k){
    cout << x - k * d << endl;
  }else{
    k -= x/d;
    if(k % 2 == 0){
      cout << (x - x / d * d) << endl;
    }else{
      cout << abs(x - x / d * d - d) << endl;
    }
  }
  }else if(x == 0){
    if(k % 2 == 0) cout << 0 << endl;
    else cout << d << endl;
  }else{
    if(abs(x) / d >= k){
      cout << abs(x + k * d) << endl;
    }else{
      k -= abs(x)/d;
      if(k % 2 == 0){
        cout << abs(x+abs(x)/d*d) << endl;
      }else{
        cout << (x+abs(x)/d*d>=0 ? abs(x+abs(x)/d*d-d):abs(x+abs(x)/d*d+d)) << endl;
      }
    }
  }
}

Measured memory_bytes: 3528
#include<stdio.h>
int main(){
	int r,x,y,W,H;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(0<=x-r && 0<=y-r){
		if(W>=x+r && H>=y+r) printf("Yes\n");
		else printf("No\n");
	}
	else printf("No\n");

	return 0;
}


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

int main(){
    int N=0,i=0,odd=0,even=0,san=1,ni=1;
    cin >> N;
    int A[N]={};
    for(i=0;i<N;i++){
        san *=3;
        cin >> A[i];
        if(A[i]%2==0)even++;
        else odd++;
    }
    for(i=0;i<even;i++){
        ni *= 2;
    }   
    cout << san - ni << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdio>
#include<set>
#include<cstdlib>
using namespace std;
int n;
int l[228];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int i;
	cin>>n;
	for(i=0;i<2*n;i++)
    {
        cin>>l[i];
    }
    sort(l,l+2*n);
    int sum=0;
    for(i=0;i<2*n;i+=2)
    {
        sum+=l[i];
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
l = list(map(int,input()))


l.reverse()
l.append(0)

l_copy = l.copy()

N = len(l)

pay = []
for i in range(N):
    if l[i] == 5 and l[i+1]>4:
        pay.append(0)
        l[i+1] += 1
    elif l[i] <= 5:
        pay.append(l[i])
    elif 10 > l[i] > 5:
        pay.append(0)
        l[i+1] += 1
    elif l[i] == 10:
        pay.append(0)
        l[i+1] += 1

pay_copy = pay.copy()

remain = []
for i in range(N):
    k = pay[i] - l_copy[i]
    if  k >= 0:
        remain.append(k)
    else:
        remain.append(k+10)
        pay[i+1] -= 1

result = 0
for i in pay_copy:
    result += i
for i in remain:
    result += i

print(result)

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

using namespace std;

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if ((m - j) * i + (n - i) * j == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

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

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

int main() {
	ios::sync_with_stdio(false);
	
	int w[3]={}, k[3]={};
	int a;
	
	rep(i, 10) {
		cin >> a;
		if(w[0]<a) {
			w[2]=w[1];
			w[1]=w[0];
			w[0]=a;
		}else if(w[1]<a) {
			w[2]=w[1];
			w[1]=a;
		}else if(w[2]<a) {
			w[2]=a;
		}
	}
	
	rep(i, 10) {
		cin >> a;
		if(k[0]<a) {
			k[2]=k[1];
			k[1]=k[0];
			k[0]=a;
		}else if(k[1]<a) {
			k[2]=k[1];
			k[1]=a;
		}else if(k[2]<a) {
			k[2]=a;
		}
	}
	
	rep(i, 2) {
		w[2]+=w[i];
		k[2]+=k[i];
	}
	
	cout << w[2] << " " << k[2] << endl;
	
	return 0;
}

Measured memory_bytes: 1196
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;

int n,K;
int li[maxn],ri[maxn],cnt;
bool if2[maxn];
ll fl[maxn],fr[maxn];
ll re;

struct segment{int lc,rc,c;}seg[maxn*100]; int root,tot;
int lx,rx,c;
void pushdown(const int x)
{
	if(!seg[x].c) return;
	int &lc=seg[x].lc,&rc=seg[x].rc;
	if(!lc) lc=++tot;
	if(!rc) rc=++tot;
	seg[lc].c=seg[x].c;
	seg[rc].c=seg[x].c;
	seg[x].c=0;
}
void upd(int &x,const int l,const int r)
{
	if(rx<l||r<lx) return;
	if(!x) x=++tot;
	if(lx<=l&&r<=rx) { seg[x].c=c; return ; }
	pushdown(x);
	int mid=l+r>>1;
	upd(seg[x].lc,l,mid); upd(seg[x].rc,mid+1,r);
}
int loc;
int query(const int x,const int l,const int r)
{
	if(l==r) return seg[x].c;
	pushdown(x);
	int mid=l+r>>1;
	if(loc<=mid) return query(seg[x].lc,l,mid);
	else return query(seg[x].rc,mid+1,r);
}

int dis(int x,int y) { return x<y?y-x:K-x+y; }
ll cal(int x,int i) { return min((ll)dis(x,li[i])+fl[i],(ll)dis(x,ri[i])+fr[i]); }

int main()
{
	scanf("%d%d",&n,&K); ll sum=0;
	for(int i=1;i<=n;i++) 
	{
		int x,y; scanf("%d%d",&x,&y); re+=(ll)x<<1;
		sum=(sum+(ll)x)%K;
		li[++cnt]=sum,ri[cnt]=x;
		if(y==1)
		{
			if(x*2>K) return puts("-1"),0;
		}
		else if2[cnt]=true;
	}
	for(int i=cnt,las=0;i>=1;i--)
	{
		int templ=(li[i]-las+K)%K,tempr=((ll)li[i-1]-ri[i]-las+(ll)K*2)%K;
		if(if2[i]) templ=0,tempr=K-1;
		las=(las+ri[i])%K;
		li[i]=templ,ri[i]=tempr;
	}
	for(int i=1;i*2<=cnt;i++) swap(li[i],li[cnt-i+1]),swap(ri[i],ri[cnt-i+1]);
	seg[root=++tot].c=cnt+1;
	for(int i=cnt;i>=1;i--)
	{
		int tmp;
		loc=ri[i]; tmp=query(1,0,K-1);
		fr[i]=tmp==n+1?0:cal(ri[i],tmp);
		
		loc=li[i]; tmp=query(1,0,K-1);
		fl[i]=tmp==n+1?0:cal(li[i],tmp);
		
		c=i;
		if(li[i]<=ri[i])
		{
			if(li[i]) lx=0,rx=li[i]-1,upd(root,0,K-1);
			if(ri[i]<K-1) lx=ri[i]+1,rx=K-1,upd(root,0,K-1);
		}
		else if(li[i]-1>ri[i])
		{
			lx=ri[i]+1,rx=li[i]-1,upd(root,0,K-1);
		}
	}
	seg[1].c=-1; ll ans=LLONG_MAX;
	for(int i=1;i<=cnt;i++)
	{
		loc=li[i]; if(query(1,0,K-1)==-1) ans=min(ans,fl[i]);
		loc=ri[i]; if(query(1,0,K-1)==-1) ans=min(ans,fr[i]);
		
		c=i;
		if(li[i]<=ri[i])
		{
			if(li[i]) lx=0,rx=li[i]-1,upd(root,0,K-1);
			if(ri[i]<K-1) lx=ri[i]+1,rx=K-1,upd(root,0,K-1);
		}
		else if(li[i]-1>ri[i])
		{
			lx=ri[i]+1,rx=li[i]-1,upd(root,0,K-1);
		}
	}
	printf("%lld\n",re+ans);
	
	return 0;
}


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

char S[100010] = {0};
char dream[] = {'m','a','e','r','d'},dreamer[] = {'r','e','m','a','e','r','d'}
    ,eraser[] = {'r','e','s','a','r','e'},erase_[] = {'e','s','a','r','e'};

void solve()
{
    int i = strlen(S) - 1;
    while(i >= 0)
    {
        bool flag = true;
        for(int j = 0; j <= 5; j++)
        {
            if(j == 5)
            {
                i = i - 5;flag = false;
            }
            if(i - j == -1 || S[i - j] != dream[j])break;
        }
        for(int j = 0; j <= 7; j++)
        {
            if(j == 7)
            {
                i = i - 7;flag = false;
            }
            if(i - j == -1 || S[i - j] != dreamer[j])break;
        }
        for(int j = 0; j <= 5; j++)
        {
            if(j == 5)
            {
                i = i - 5;flag = false;
            }
            if(i - j == -1 || S[i - j] != erase_[j])break;
        }
        for(int j = 0; j <= 6; j++)
        {
            if(j == 6)
            {
                i = i - 6;flag = false;
            }
            if(i - j == -1 || S[i - j] != eraser[j])break;
        }
        if(flag)
        {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
    return;
}

int main()
{
    scanf("%s",S);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

int main() {
    long n, num, s=0;
    cin >> n;
    
    vector<long> v;
    for (long i=0; i<n; i++) {
        cin >> num;
        v.push_back(num);
    }
    
    sort(v.begin(), v.end());
    for (long i=0; i<n; i++) {
        s += v.at(i);
    }
    
    cout << v.at(0) << " " << v.at(n-1) << " " << s << endl;
    
    return 0;		 
}


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

#define ll long long int

int main()
{
    ll a,b;
    cin>>a>>b;
    ll mn=999999999999999;
    ll ans=a*b;
    for(ll i=2;i<=min(a,b);i++)
    {
        if(ans%i==0 && ((ans/i)%a==0 && (ans/i)%b==0))
            mn=min(mn,(ans/i));
    }
    cout<<min(ans,mn)<<endl;
    return 0;
}


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

int main() {
    int N, a = 1000000000, b = 0;
    cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; ++i) {
        cin >> v.at(i);
    }
    for (int i = 0; i < N; ++i) {
        a = min(a, v.at(i));
        b = max(b, v.at(i));
    }
    cout << b - a << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
students = []
check = []
for i in range(n):
  students.append(list(map(int, input().split())))

for i in range(m):
  check.append(list(map(int, input().split())))

for i in students:
  dis = []
  for j in check:
    dis.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
  
  print(dis.index(min(dis)) + 1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N, X; cin >> N >> X;
    vector<int> L(N);
    for(int i = 0; i < N; ++i){
        cin >> L[i];
    }
    vector<int> hane(N + 1);
    for(int i = 0; i < N; ++i){
        hane[i+1] = hane[i] + L[i];
    }

    int ans = 0;
    for(int i = 0; i < N + 1; ++i){
        if(hane[i] > X){
            break;
        }
        ++ans;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  char dir; //direction                                                         
  int x,y,j,k;
  int dist; //distance                                                          
  int xy[21][21];
    while (cin >> j && j){
      memset(xy,0,sizeof(xy));
      for(int i=0;i<j;i++){
        cin >> x >> y;
        xy[x][y]=1;
      }
      cin >> k;
      x=10;
      y=10;
      int m=0;
      for(int i=0;i<k;i++){
        cin >> dir >> dist;
        for(int l=0;l<dist;l++){
          if(dir == 'N')
            y++;
          else if(dir=='S')
            y--;
          else if(dir=='W')
            x--;
          else if(dir=='E')
            x++;
          if(xy[x][y]==1){
            m++;
            xy[x][y]=0;
          }
        }
      }
      if(j==m)
          cout << "Yes" << endl;
        else
          cout << "No" << endl;
    }
}

Measured memory_bytes: 3000
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] dice = br.readLine().split(" ");
		List<String> sf1 = Arrays.<String>asList(dice[1], dice[2], dice[4], dice[3], dice[1]);
		List<String> sf2 = Arrays.<String>asList(dice[5], dice[2], dice[0], dice[3], dice[5]);
		List<String> sf3 = Arrays.<String>asList(dice[1], dice[5], dice[4], dice[0], dice[1]);
		List<String> sf4 = Arrays.<String>asList(dice[1], dice[0], dice[4], dice[5], dice[1]);
		List<String> sf5 = Arrays.<String>asList(dice[0], dice[2], dice[5], dice[3], dice[0]);
		List<String> sf6 = Arrays.<String>asList(dice[4], dice[2], dice[1], dice[3], dice[4]);
		int q = Integer.parseInt(br.readLine());
		for (int i = 0; i < q; i++) {
			String[] input = br.readLine().split(" ");
			if (input[0].equals(dice[0])) System.out.println(sf1.get(sf1.indexOf(input[1]) + 1));
			else if (input[0].equals(dice[1])) System.out.println(sf2.get(sf2.indexOf(input[1]) + 1));
			else if (input[0].equals(dice[2])) System.out.println(sf3.get(sf3.indexOf(input[1]) + 1));
			else if (input[0].equals(dice[3])) System.out.println(sf4.get(sf4.indexOf(input[1]) + 1));
			else if (input[0].equals(dice[4])) System.out.println(sf5.get(sf5.indexOf(input[1]) + 1));
			else if (input[0].equals(dice[5])) System.out.println(sf6.get(sf6.indexOf(input[1]) + 1));
		}
	}
}

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

bool u[1000010];
long long n,m,x;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    int i=1;
    int j=n;
    while (m--){
        x=j-i-2;
        if (!u[x] && !u[n-x-2]){
            u[x] = u[n-x-2] = true;
            cout<<i<<' '<<j<<'\n';
            i++, j--;
        }
        else j--, m++;
    }
}


Measured memory_bytes: 3796
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar[4] = {{0,1},{0,-1},{1,0},{-1,0}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n,m;cin>>n>>m;
  int ans[n];
  for(int i = 0; n > i; i++){
    ans[i] = -1;
  }
  for(int i = 0; m > i; i++){
    int a,b;cin>>a>>b;
    a--;
    if(!(ans[a] == -1 || ans[a] == b)){
      cout << -1 << endl;
      return 0;
    }
    ans[a] = b;
  }
  if(n==1 && ans[0] < 1){
    cout << 0 << endl;
    return 0;
  }
  if(ans[0] == 0){
    cout << -1 << endl;
    return 0;
  }
  for(int i = 0; n > i; i++){
    if(!i){
      cout << (ans[i]!=-1?ans[i]:1);
    }else{
      cout << (ans[i]!=-1?ans[i]:0);
    }
  }cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a=sc.nextInt();
int b=sc.nextInt();
long arr[]=new long[n];
for(int i=0;i<n;i++) {
	arr[i]=sc.nextLong();
}
long res=0;
for(int i=0;i<n-1;i++) {
	if(((arr[i+1]-arr[i])*a)>b){
		res+=b;
	}else {
		res+=(arr[i+1]-arr[i])*a;
	}
}
System.out.println(res);

}

}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

const int D = 60;
const int MAX_N = 200005;

int to[D][MAX_N];

int main()
{
    int k;
    string n;
    cin >> k >> n;
    if (n.size() <= k)
    {
        cout << n << endl;
    }
    else
    {
        string ans = n.substr(0, k) + "...";
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

LL a[55];

int main()
{
    a[0]=49;
    rer(i,1,49)a[i]=0;
    LL k;
    cin>>k;
    cout<<50<<endl;
    if(k==0)
    {
        cout<<a[0];
        rer(i,1,49)cout<<' '<<a[i];
        cout<<endl;
    }
    else
    {
        rep(i,50)a[i]=i;
        LL r=(k-1)/50;
        rep(i,50)a[i]+=r;
        LL t=k%50;
        if(t==0)
        {
            rep(i,50)a[i]++;
            cout<<a[0];
            rer(i,1,49)cout<<' '<<a[i];
            cout<<endl;
        }
        else if(t>0)
        {
            while(t--)
            {
                sort(a,a+50);
                a[0]+=50;
                rer(i,1,49)a[i]--;
            }
            cout<<a[0];
            rer(i,1,49)cout<<' '<<a[i];
            cout<<endl;
        }

    }

    return 0;
}


Measured memory_bytes: 256
package main
import(
  "fmt"
  "sort"
)
func main(){
  var n, i int
  fmt.Scan(&n)
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
  }
  sort.Sort(sort.IntSlice(a))
  ans:=a[n-1]/2
  for i=0;i<n-1;i++{
    ans+=a[i]
  }
  fmt.Println(ans)
}

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

	int a, b = 1, c = 0, d = 2, n = 3, m;
	string str,str2,str3;

	cin >> a;
    if (a >= 64) {
		cout << 64 << endl;
	}
	else if (a >= 32) {
		cout << 32 << endl;
	}
	else if (a >= 16) {
		cout << 16 << endl;
	}
	else if (a >= 8) {
		cout << 8 << endl;
	}
	else if (a >= 4) {
		cout << 4 << endl;
	}
	else if (a >= 2) {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}


	



	return 0;
}

Measured memory_bytes: 256