akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, K; cin >> n >> K;
    using DT = tuple<int, int>;
    vector<DT> dt(n);
    rep(i, n){
        int t, d; cin >> t >> d;
        t--;
        dt[i] = DT(d, t);
    }
    sort(_all(dt), greater<DT>());

    ll nkind = 0LL;
    ll dsum = 0LL;
    vi num(n);
    rep(i, K){
        int t, d; tie(d, t) = dt[i];
        dsum += d;
        if(num[t]++ == 0){
            nkind++;
        }
    }

    ll res = dsum + nkind * nkind;
    int k = K - 1;
    rep(i, K, n){
        int t, d; tie(d, t) = dt[i];
        if(num[t] > 0) continue;

        bool ok = false;
        int tj, dj;
        while(k >= 0){
            int j = k--;
            tie(dj, tj) = dt[j];
            if(num[tj] > 1){
                ok = true;
                break;
            }
        }
        if(not ok) break;

        num[tj]--;
        num[t]++;
        dsum += (d - dj);
        nkind++;

        ll cur = dsum + nkind * nkind;
        chmax(res, cur);
    }

    cout << res << endl;

    return 0;
}


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


int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int ans;
	if(A + B > 2 * C){
		if(X > Y){
			ans = Y * 2 * C + min((X - Y) * A, (X - Y) * 2 * C);
		}
		else{
			ans = X * 2 * C + min((Y - X) * B, (Y - X) * 2 * C);
		}
	}
	else{
		ans = A * X + B * Y;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
flag = [1]*n
for _ in range(k):
    d = int(input())
    a = [int(x) for x in input().split()]
    for i in a:
        flag[i - 1] = 0
ans = 0
for j in flag:
    ans += j
print(ans)

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

int main(){
  int i,a,b,k,count=0,ans;
  cin >> a >> b >> k;
  for(i=min({a,b});i>0;i--){
    if(a%i==0 && b%i==0){count++;}
    if(count == k){ cout << i; return 0;}
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

int main()
{
    std::multimap<int, int> sunuke;

    int N, K;
    std::cin >> N >> K;

    for (int k = 0; k < K; ++k)
    {
        int d;
        std::cin >> d;

        for (int i = 0; i < d; ++i)
        {
            int a;
            std::cin >> a;

            sunuke.emplace(a, k);
        }
    }

    int result = 0;
    for (int n = 0; n < N; ++n)
    {
        result += ((sunuke.count(n + 1) == 0) ? 1 : 0);
    }

    std::cout << result << std::endl;
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,ans,sum,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]*4*m>=sum)ans++;
	}
	if(ans>=m)puts("Yes");
	else puts("No");
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int count=0;
  for(int i=0;i<S.size()-1;i++){
    if(S.at(i)!=S.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
} 

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

int main()
{
	string S;
	cin >> S;

	string rev_S = S;
	reverse(rev_S.begin(), rev_S.end());

	if (rev_S != S) {
		cout << "No" << endl;
		return 0;
	}

	string S1 = S.substr(0, (S.length() - 1) / 2);
	string S2 = S.substr(((S.length() + 3) / 2)-1, (S.length() - 1) / 2);
	//cout << "S1:" << S1 << endl;
	//cout << "S2:" << S2 << endl;

	string rev_S1 = S1;
	if (rev_S1 != S1) {
		cout << "No" << endl;
		return 0;
	}

	string rev_S2 = S2;
	if (rev_S2 != S2) {
		cout << "No" << endl;
		return 0;
	}

	if (S1 != S2) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}






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

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

  int n;
  cin >> n;
  int a[100000];
  rep(i, n) cin >> a[i];

  ll ans[2];
  int sum[2][100001] = {};

  rep(i, n) {
    sum[i%2][i+1] = sum[i%2][i] + a[i];
    if (sum[i%2][i+1] <= 0) {
      ans[i%2] += abs(1-sum[i%2][i+1]);
      sum[i%2][i+1] = 1;
    }

    sum[(i+1)%2][i+1] += sum[(i+1)%2][i] + a[i];
    if (sum[(i+1)%2][i+1] >= 0) {
      ans[(i+1)%2] += abs(-1-sum[(i+1)%2][i+1]);
      sum[(i+1)%2][i+1] = -1;
    }
  }

  rep(i, n) {
    cerr << sum[0][i] << " " << sum[1][i] << endl;
  }
  cerr << endl;
  cerr << ans[0] << endl;
  cerr << ans[1] << endl;
  cout << min(ans[0], ans[1]) << endl;
}


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int r; cin >> r;
	cout << r*r << endl;

	return 0;
}


Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def f(N, A):
    S = {}
    
    for a in A:
        if not a in S:
            S[a] = 1
        else:
            S[a] += 1


    if len(S) == 1:
        if 0 in S:
            return 'Yes'
        else:
            return 'No'
    elif N%3 > 0 or len(S) > 3:
        return 'No'

    keys = list(S)

    if len(keys) == 2:
        if 0 in S and S[0] == N//3:
            return 'Yes'

        return 'No'

    if (keys[0] ^ keys[1]) != keys[2]:
        return 'No'

    if S[keys[0]] != S[keys[1]] or S[keys[0]] != S[keys[2]]:
        return 'No'

    return 'Yes'



def main():
    N = int(input())
    A = list(map(int, input().split()))

    print(f(N, A))

 


if __name__ == '__main__':
    main()


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

maze = [input() for i in range(H)]
ans = [[0] * W for i in range(H)]

def count_mine(y, x):
  count = 0
  for i, j in [1, 0], [-1, 0], [0, 1], [0, -1], [-1, 1], [1, 1], [-1, -1], [1, -1]:
    if -1 < i + y < H and -1 < j + x < W:
      if maze[i+y][j+x] == '#':
        count += 1
  return count

for i in range(H):
  for j in range(W):
    if maze[i][j] == '.':
      ans[i][j] = count_mine(i, j)
    else:
      ans[i][j] = '#'

      
for i in range(H):
  for j in range(W):
    print(ans[i][j], end = "")
  print()

Measured memory_bytes: 45164
#include<bits/stdc++.h>
using namespace std;
int  main()
{
	int n,l[100001],r[100001];
	int ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	cin>>l[i]>>r[i];
	ans+=(r[i]-l[i]+1) ;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(m);
  vector<int> d(m);
  rep(i, 0, n) cin >> a[i] >> b[i];
  rep(i, 0, m) cin >> c[i] >> d[i];
 
  rep(i, 0, n) {
    int mini = abs(a[i]-c[0]) + abs(b[i]-d[0]);
    int checkpoint = 1;
    rep(j, 1, m) {
      int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(mini > dist) {
        mini = dist;
        checkpoint = j+1;
      }
    }
    cout << checkpoint << "\n";
  }
  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

int INF = INT_MAX / 100;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int dy[] = {0, -1, 0, 1};
int dx[] = {-1, 0, 1, 0};

struct flow_network {
	int n;
	struct edge { int v; ll c; int rev; };
	vector< vector<edge> > G;
	flow_network(int _n) : n(_n), G(_n) {}
	void add_edge(int u, int v, ll c) {
		edge e = {v, c, (int)G[v].size()}, _e = {u, 0, (int)G[u].size()};
		G[u].push_back(e); G[v].push_back(_e);
	}
	ll dfs(int u, int t, ll f, vector<bool>& vis) {
		if (u == t) return f;
		vis[u] = true;
		for (int i = 0; i < G[u].size(); i++) {
			edge& e = G[u][i];
			if (vis[e.v] || e.c == 0) continue;
			ll d = min(e.c, dfs(e.v, t, min(f, e.c), vis));
			if (d == 0) continue;
			e.c -= d;
			G[e.v][e.rev].c += d;
			return d;
		}
		return 0;
	}
	ll max_flow(int s, int t) {
		ll res = 0;
		for (;;) {
			vector<bool> vis(n);
			ll f = dfs(s, t, LLONG_MAX, vis);
			if (f == 0) return res;
			res += f;
		}
	}
};

int main() {
	int H, W; cin >> H >> W;
	vector<vector<bool> > a(H, vector<bool>(W));
	rep(y, H) {
		string s; cin >> s;
		rep(x, W) a[y][x] = (s[x] == 'X');
	}
	rep(y, H) rep(x, W)
		if (a[y][x] && (y==0 || y==H-1 || x==0 || x==W-1)) {
			cout << -1 << endl;
			return 0;
		}
	flow_network fn(H * W * 2 + 2);
	int s = H * W * 2, t = s + 1;
	rep(y, H) rep(x, W) fn.add_edge(y*W+x, H*W + y*W+x, 1);
	rep(y, H) rep(x, W) {
		if (a[y][x])fn.add_edge(s, H*W + y*W+x, INF);
		if (y==0 || y==H-1 || x==0 || x==W-1) fn.add_edge(H*W + y*W+x, t, INF);
		else {
			rep(k, 4) {
				int _y = y + dy[k], _x = x + dx[k];
				fn.add_edge(H*W + y*W+x, _y*W+_x, INF);
			}
		}
	}
	cout << fn.max_flow(s, t) << endl;
}


Measured memory_bytes: 4480
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int gcd( int a, int b ) {
    int temp;
    if( a < b ) { temp = a; a = b; b = temp; }
    if( b < 1 ) return -1;
    if( a % b == 0 ) return b;
    return gcd( b, a % b );
}

int main() {
    int N, X;
    cin >> N >> X;

    vector<int> x(N);
    for(int i=0; i<N;i++) cin >> x[i];

    sort(x.begin(), x.end());

    bool flag = true;
    vector<int> new_vec(N+1);
    for(int i=0; i<N+1;i++) {
        if(i == N && flag) {
            new_vec[i] = X;
            break;
        }

        if(flag && x[i] > X) {
            new_vec[i] = X;
            new_vec[i+1] = x[i];
            flag=false;
            i++;
        } else if(flag) {
            new_vec[i] = x[i];
        } else {
            new_vec[i] = x[i-1];
        }
    }
    int prev = new_vec[1];
    int ans = new_vec[1] - new_vec[0];
    for(int i=2; i<N+1;i++) {
        ans = gcd(ans, new_vec[i]-prev);
        prev = new_vec[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
	
	int H, W; cin >> H >> W;
	vector<string> Grid(H);
	for( string &k : Grid ) cin >> k;
	
	string none;
	for( int i = 0 ; i < W ; i++ ){
		none += '.';
	}
	
	for( int i = 0 ; i < H ; i++ ){
		if( Grid[i] == none ){
			Grid.erase(Grid.begin() + i);
			H--;   i--;
		}
	}
	
	for( int i = 0 ; i < W ; i++ ){
		for( int j = 0 ; j < H ; j++ ){
			if( Grid[j][i] == '#' ) goto out;
		}
		for( int k = 0 ; k < H ; k++ ){
			Grid[k].erase(i,1);
			if( k == H - 1 ){
				W--; i--;
			}
		}
		out:;
	}
	
	for( string &k : Grid ) cout << k << endl;
	
}

Measured memory_bytes: 256
def judge(x,y):
    global xx,yy,xy,axby
    if min(x,y) >= 0 and x+y <= xy:
        if x+y < xy or (x+y == xy and a*x+b*y < axby):
            xy = x+y
            axby = a*x+b*y
            xx,yy = x,y
    
while 1:
    a,b,d = map(int,raw_input().split())
    if a == 0: break
    xy = axby = 10**10
    for y in xrange(50001):
        if (d+b*y)%a == 0: judge((d+b*y)/a,y)
        if (b*y-d)%a == 0: judge((b*y-d)/a,y)
        if (d-b*y)%a == 0: judge((d-b*y)/a,y)
    print xx,yy

Measured memory_bytes: 4240
using System;
using System.Linq;

class PG{
    static void Main(string[] args){
        int[] nums=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int a,b,c,n;
        n=0;
        a=nums[0];
        b=nums[1];
        Console.WriteLine("{0} {1} {2}",a/b,a%b,(decimal)a/b);
    }
}


Measured memory_bytes: 18472
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	ll N, M;
	cin >> N >> M;
	vector<pii> a(N), b(M);
	rep(i,N) cin >> a[i].fi >> a[i].se;
	rep(i,M) cin >> b[i].fi >> b[i].se;
	rep(i,N) {
		ll c = 0;
		rep(j,M) {
			ll d, e;
			d = abs(a[i].fi-b[j].fi) + abs(a[i].se-b[j].se);
			e = abs(a[i].fi-b[c].fi) + abs(a[i].se-b[c].se);
			if(d < e)
				c = j;
		}
		cout << c+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
int K;

long long koyaku_max(long long a,long long b){
    long long r;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
ll sum = 0;
int main(){


    
    cin >> K;
    rep(ni,K){
        rep(ki,K){
            rep(li,K){
                sum += koyaku_max(koyaku_max(ni+1,ki+1),li+1);

            }
        }
    }
    cout << sum << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define MAXN 2510
using namespace std;

int dist[MAXN];
vector<pair<pair<int, int>, int> > edges;
vector<int> gr_inv[MAXN];

bool reachable[MAXN];
void dfs(int u){
    if(reachable[u])
        return ;
    reachable[u] = true;
    for(auto &p : gr_inv[u]){
        dfs(p);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, M, P;
    cin >> N >> M >> P;
    for(int i = 1; i <= N; i++)
        reachable[i] = false;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edges.push_back(make_pair(make_pair(a, b), P-c));
        gr_inv[b].push_back(a);
    }
    dfs(N);
    for(int j = 0; j <= N; j++){
        dist[j] = 2e9;
    }

    dist[1] = 0;

    for (int i = 1; i <= N - 1; i++) { 
        for (int j = 0; j < M; j++) { 
            int u = edges[j].first.first;
            int v = edges[j].first.second; 
            int weight = edges[j].second; 
            if (dist[u] != 2e9 && dist[u] + weight < dist[v]) 
                dist[v] = dist[u] + weight; 
        } 
    } 
  
    bool has_answer = true;
    for (int i = 0; i < M; i++) { 
        int u = edges[i].first.first;
        int v = edges[i].first.second; 
        int weight = edges[i].second; 
        if (dist[u] != 2e9 && dist[u] + weight < dist[v]) { 
            if(reachable[u])
                has_answer = false;
        } 
    } 
    if(!has_answer){
        cout << "-1\n";
    } else {
        cout << max(0, -dist[N]) << "\n";
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

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

    vector<ll> dp(k + 2, 1); // cumulative sum
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        vector<ll> after(k + 2);
        for (int now = 0; now <= k; now++) {
            after[now + 1] = dp[now + 1] - dp[max(0, now - a)];
            if (after[now + 1] < 0)after[now + 1] += MOD;
        }
        for (int j = 1; j <= k + 1; j++) after[j] += after[j - 1], after[j] %= MOD;
        dp = after;
    }

    ll ret = dp[k + 1] - dp[k];
    cout << (ret + MOD) % MOD << endl;
    return 0;
}

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

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    map<int, bool> m;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(m[a]) m.erase(a);
        else m[a] = true;
    }
    cout << m.size() << "\n";
}


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

const int N = 100010;

int n, k;

int main(){
	scanf("%d%d", &n, &k);
	int max = 0, gcd = 0;
	for (int i = 0, x; i < n; ++ i){
		scanf("%d", &x);
		max = std::max(max, x);
		gcd = std::__gcd(gcd, x);
	}
	return printf(!(k % gcd) && k <= max ? "POSSIBLE\n" : "IMPOSSIBLE\n"), 0;
}

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

int main(){
  long long n,a,b,answer = 0;
  cin >> n >> a >> b;
  answer += n/(a+b) * a;
  if(n % (a + b) > a) answer += a;
  else answer += n % (a + b);
  cout << answer << endl;
}

Measured memory_bytes: 3604
#!/usr/bin/env python3
import sys
import itertools


def solve(N: int, P: "List[int]", Q: "List[int]"):
    index = 0
    p = -1
    q = -1
    P = tuple(P)
    Q = tuple(Q)
    for perm in itertools.permutations(range(1, N+1)):
        if perm == P:
            p = index
        if perm == Q:
            q = index
        index += 1
    print(abs(p-q))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    Q = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P, Q)


if __name__ == '__main__':
    main()


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

int main() {
int N, number;
cin >> N;
vector<int> vec(N);

for (int i = 0; i < N-1; i++) {
 cin >> number;
 vec.at(number-1)++;
}

for (int i = 0; i < N; i++) {
 cout << vec.at(i) << endl;
}

}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    KAMEHAMEHA
//    #ifdef _soumik
//        freopen("input.txt", "r", stdin);
//    #endif
    int n,temp,mn=INT_MAX,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        if(temp<=mn)
            cnt++;
        mn=min(mn,temp);
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

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

    int right = -1, left = -1; //????????´, ????????´
    int rp, lp;
    rep(i,s.size() - 2){
        string sub = s.substr(i,2);
        if(sub == "><"){
            left = 1;
            lp = i;
            break;
        }else if(sub == "<>"){
            left = 2;
            lp = i;
            break;
        }
    }
    for(int i = s.size() - 1; i >= 0; i--){
        string sub = s.substr(i,2);
        if(sub == "><"){
            right = 1;
            rp = i;
            break;
        }else if(sub == "<>"){
            right = 2;
            rp = i;
            break;
        }
    }
    lp++;
    rp = n - rp - 1;
    //show(lp) show(rp)

    if(right == 2 && left == 2){
        cout << max(n - lp, n - rp) << endl;
    }else{
        cout << n << endl;
    }
}

Measured memory_bytes: 3288
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iomanip>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  while(1){
  int num=0,i=0;
  double ave=0,sum=0,ans=0;
  double s[1000]={0};

    cin >>num;
    if(num==0) break;
    for(i=0;i<num;i++){
      cin >>s[i];
      ave+=s[i];
    }
    ave=ave/num;
    for(i=0;i<num;i++){
      sum+=((s[i]-ave)*(s[i]-ave));
    }
    sum=sum/num;
    ans=sqrt(sum);
    cout <<fixed <<ans  <<endl;
  }

  return 0;
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for (int i=9;i>=1;i--)
	{
		if (n%i==0)
		{
			if (n/i<10)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			else
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <queue>
using namespace std;
typedef pair<string, int> psi;

int q;
queue<psi> Q;

void process()
{
    int time = 0;

    while (!Q.empty())
    {
        psi work = Q.front();
        Q.pop();

        if (work.second > q)
        {
            time += q;
            work.second -= q;
            Q.push(work);
        }
        else
        {
            time += work.second;
            cout << work.first << " " << time << endl;
        }
    }
    return;
}

int main()
{
    int n;
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        Q.push(make_pair(s, p));
    }
    process();
}


Measured memory_bytes: 6464
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;
    
    int main()
    {
        FAST
        int t;
        t = 1;

        while(t--)
        {
           string s;
           cin >> s;
           
           int len = s.length() ,sum = 0;
           
           for(int i = 0 ; i < len ; i++)
           {
               sum += (s[i] - '0');
           }
           
           if(sum % 9 == 0)cout << "Yes\n";
           else cout << "No\n";
        }
    }



Measured memory_bytes: 3724
#include<stdio.h>
int main(){
    int x;
    scanf("%d", &x);
    if(400<=x && x<=599) printf("%d", 8);
    if(600<=x && x<=799) printf("%d", 7);
    if(800<=x && x<=999) printf("%d", 6);
    if(1000<=x && x<=1199) printf("%d", 5);
    if(1200<=x && x<=1399) printf("%d", 4);
    if(1400<=x && x<=1599) printf("%d", 3);
    if(1600<=x && x<=1799) printf("%d", 2);
    if(1800<=x && x<=1999) printf("%d", 1);
    return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void judge(bool b){b?Yes():No();}

template<typename T>
void ppp(T n){cout << n << endl;}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<string> vstr;



vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;

    FOR(i,1,n){
        ll cnt = 0;
        for(char c = 'a'; c <= 'z'; c++){
            bool l = false, r = false;
            rep(j, i){
                if(s[j] == c)
                    l = true;
            }
            FOR(j, i, n){
                if(s[j] == c)
                    r = true;
            }

            if(l&&r)
                cnt++;
        }
        ans = max(ans, cnt);
    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////


int main() {
    ll N; cin >> N;
    Rep(h, 1, 3500){
        Rep(n, 1, 3500){
            if(4*h*n-N*n-N*h <= 0) continue;
            if(N*h*n%(4*h*n-N*n-N*h)==0) {
                ll w = N*h*n/(4*h*n-N*n-N*h);
                co(h << " " << n << " " << w);
                return 0;
            }
        }
    }


    return 0;
}
 
 


Measured memory_bytes: 3604
#include<stdio.h>
int main(void)
{
	int s1[6],s2[6],s3[6],s4[6],i,j,x;
	char a[]="ABCDE";
	while(1){
		scanf("%d %d",&s1[0],&s2[0]);
		if(s1[0]==0&&s2[0]==0) break;
		else s3[0]=s1[0]+s2[0];
		for(i=1;i<5;i++){
			scanf("%d %d",&s1[i],&s2[i]);
			s3[i]=s1[i]+s2[i];
		}
		for(i=0;i<5;i++) s4[i]=s3[i];
		for(i=0;i<4;i++){
			for(j=i+1;j<5;j++){
				if(s3[i]<s3[j]){
					x=s3[i]; s3[i]=s3[j]; s3[j]=x;
				}
			}
		}
		for(i=0;i<5;i++){
			if(s3[0]==s4[i]){
				printf("%c %d\n",a[i],s3[0]);
				break;
			}
		}
	}	
	return 0;
}

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

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

    int h[100010];
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }

    sort(h, h+n);

    int mi = INT_MAX;
    for(int i = 0;i <= n-k;i++)
        mi = min(mi, h[i+k-1]-h[i]);

    cout << mi << endl;

    return 0;
}

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

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

	int count=0;
	int flag=1;	//????????£??\????´??????????????????????
	while(flag){
		flag=0;
		for(int i=N-1;i>=1;i--){
			if(A[i-1] > A[i]){
				flag=1;
				int tmp = A[i];
				A[i] = A[i-1];
				A[i-1] = tmp;
				count++;
			}
		}
	}

	for(int i=0;i<N-1;i++){
		cout << A[i] << " ";
	}
	cout << A[N-1] << endl;
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n] <- readInts
  putStrLn $ solve n

solve n = if isJust $ foldM (\a x -> if x == n then Nothing else Just ()) () [x * y | x <- [1 .. 9], y <- [1 .. 9]]
  then "No"
  else "Yes"

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

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

int main() {
  int N, m = 0;
  string s;
  cin >> N;
  map<string, int> cnt{};

  for (int i = 0; i < N; i++) {
    cin >> s;
    cnt[s]++;
    m = max(m, cnt[s]);
  }

  for (const auto& [k, v] : cnt) {
    if (v == m) cout << k << endl;
    // cout << k << endl;
  }
}


Measured memory_bytes: 18756
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(){
	int N;
	int count = 0;
	scanf("%d",&N);
	for(int i = 1;i <= N;i += 2){
		int sum = 0;
		for(int j = 1;j <= i;j ++){
			if(i % j == 0){
				sum ++;
			}
		}
		if(sum == 8) count ++;
	}
	printf("%d",count);
	return(0);
}

Measured memory_bytes: 256
from functools import reduce
import math
from collections import deque
from collections import defaultdict

def bfs(i,d,N):
    q = deque()
    q.append(i)
    d_from_1 = [-1]*(N+1)
    d_from_1[i] = 0
    i = 1
    while q:
        l = len(q)
        for j in range(l):
            next_node = q.popleft()
            for succ in d[next_node]:
                if d_from_1[succ] == -1:
                    d_from_1[succ] = i
                    q.append(succ)
        i += 1
    return d_from_1
    
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    a = []
    b = []
    d = defaultdict(list)
    
    for i in range(N-1):
        s1,s2 = list(int(_) for _ in input().split())
        d[s1].append(s2)
        d[s2].append(s1)       
    f= 0
    s= 0
    d_from_1 = bfs(1,d,N)
    d_from_N = bfs(N,d,N)
        
    # print(d_from_1)
    # print(d_from_N)
    for i in range(1,N+1):
        if(d_from_1[i] <= d_from_N[i]):
            f += 1
        else:
            s += 1
    if(f>s):
        print('Fennec')
    else:
        print('Snuke')
if __name__ == '__main__':
    main()


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

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

	long long a, b, c;
	cin >> a >> b >> c;
	string ans = a + b < c && 2*a*b + 2*b*c + 2*c*a < a*a + b*b + c*c ? "Yes" : "No";
	cout << ans << "\n";
}

Measured memory_bytes: 256
W,H,x,y,r = gets.split.map &:to_i

if (0 <= x + r) && (x + r <= W) && (0 <= x - r) && (x - r <= W) && (0 <= y + r) && (y + r <= H) && (0 <= y - r) && (y - r <= H)
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 6876
#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;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, a, b;

	cin >> n >> a >> b;


	if (abs(a - b) == 1) {
		cout << "Borys" << endl;
	}
	else {

		bool  flaga = false;

		while (abs(a - b) > 1)
		{
			if (a < b) {
				a++;
			}
			else {
				a--;
			}

			if (abs(a - b) == 1) {
				cout << "Alice" << endl;
				break;
			}


			if (a < b) {
				b--;
			}
			else {
				b++;
			}


			if (abs(a - b) == 1) {
				cout << "Borys" << endl;
				break;
			}

		}


	}






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

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

int main(void){
   string S;
   cin>>S;
   if(S=="RRR") cout<<3<<endl;
   if(S=="RRS") cout<<2<<endl;
   if(S=="RSS") cout<<1<<endl;
   if(S=="SSS") cout<<0<<endl;
   if(S=="RSR") cout<<1<<endl;
   if(S=="SRR") cout<<2<<endl;
   if(S=="SSR") cout<<1<<endl;
   if(S=="SRS") cout<<1<<endl;
   return 0;
}


Measured memory_bytes: 3628
import sys
from itertools import cycle
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    c, hands, field = f.readline().strip(), [0] * n, 0
    
    for player, ci in zip(cycle(range(n)), c):
        if ci == 'S':
            field += hands[player] + 1
            hands[player] = 0
        elif ci == 'L':
            hands[player] += field + 1
            field = 0
        else:
            hands[player] += 1
    
    hands.sort()
    print(' '.join(map(str, hands)), field)

Measured memory_bytes: 6732
#include<iostream>
typedef long long ll;
using namespace std;

int main(){
    string x, y;
    cin >> x >> y;
    if(x>y){
        cout << ">" << endl;
    }else if(x<y){
        cout << "<" << endl;
    }else{
        cout << "=" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int k;
    cin>>k;
    map<pair<int,int>,int> primes;
    for(int i=1; i<=k; i++){
        for(int j=0; j<=k; j++){
            primes[make_pair(i,j)]=GCD(i,j);
        }
    }
    ll ans=0;
    for(int i=1; i<=k; i++){
        for(int j=1; j<=k; j++){
            int gcd=primes[make_pair(min(i,j),max(i,j))]; 
            for(int l=1; l<=k; l++){
                int g2=GCD(gcd,l);
                ans+=g2;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6012
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(f) printf("%lf\n",f)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
int x[50][26];
int min(int a,int b){
  if(a<b)return a;
  return b;
}
int main(){
  int n;
  scanf("%d",&n);
  char s[51];
  FOR(n){
    scanf("%s",s);
    for(int j=0;j<strlen(s);j++)x[i][s[j]-'a']++;
  }
  for(int j=0;j<26;j++){
    int y=50;
    FOR(n)y=min(y,x[i][j]);
    FOR(y)PRC(j+'a');
  }
  PRS("");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
 
using namespace std;
 
#define endl '\n'
#define ll long long
#define int long long
const int32_t INFint = 1e9;
const ll INFll = 1e18;
#define MOD 1000000007ll
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define foreach(it,v) for( __typeof((v).begin())it = (v).begin() ; it != (v).end() ; it++ )
 
#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
#define For(i, a, b) for (ll i = a; i < b; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define gint(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define setZero(a,n) for(int i=0;i<n;i++) a[i]=0;
#define printArray(a,s,e) for(int i=s;i<e;i++) {cout << a[i] << " ";} cout << endl;
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------- 
int32_t main(){fast;
	

	int t;
	// cin >> t;
	t = 1;
	while(t--){
		int n, w;
		cin >> n >> w;
		int val[n];
		int wt[n];
		for(int i=0;i<n;i++) cin >> wt[i] >> val[i];

		int dp[n+1][w+1];
		memset(dp, 0, sizeof(dp));

		for(int i=1;i<=n;i++){
			for(int j=1;j<=w;j++){
				if(j<wt[i-1]) dp[i][j] = dp[i-1][j];
				else dp[i][j] = max(dp[i-1][j], val[i-1] + dp[i-1][j - wt[i-1]]);
			}
		}

		cout << dp[n][w] << endl;
	}
}







Measured memory_bytes: 79232
#include <stdio.h>
int main(void)
{
	int n,d[101],i,j,tmp,z=0;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&d[i]);
	}
	for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			if(d[i]>d[j]){
				tmp=d[i];
				d[i]=d[j];
				d[j]=tmp;
			}
		}
	}
	for(i=0; i<n; i++){
		if(d[i]==d[i+1]){
			z=z+1;
		}
	}
	printf("%d\n",n-z);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;



int main() {
	
	
	int n; cin >> n;
	
	vector<int> a(n); rep(i,n) cin >> a[i];
	
	
	int ans = 0;

	rep(i,n){
		int j = i+1;
		if(j*a[i] % 2 == 1) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

long long dp[51][51][2501];

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

  dp[0][0][0] = 1;
  for (int j = 0; j <= n; j++) {
    for (int k = 0; k <= n; k++) {
      for (int s = 0; s <= n*a+1; s++) {
        if (j >= 1 && s < x[j]) {
          dp[j][k][s] = dp[j-1][k][s];
        }
        else if (j >= 1 && k >= 1 && s >= x[j]) {
          dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j]];
        }
      }
    }
  }

  long long ans = 0;
  for (int k = 1; k <= n; k++) {
    ans += dp[n][k][k*a];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 50048
S = input()
E = input()
ans = ''
if len(S) - len(E) == 0:
  for i in range(len(S)):
    ans = ans + S[i] + E[i]
else:
  for i in range(len(E)):
    ans = ans + S[i] + E[i]
    if i == len(E) - 1:
      ans += str(S[i + 1])
print(ans)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	for i := 0; i < len(S); i++ {
		for j := i; j < len(S); j++ {
			if S[0:i]+S[j:] == "keyence" {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 768
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(m)]
ab.sort()
mid = []
cand = []
for i in range(m):
  if ab[i][0] == 1:
    mid.append(ab[i][1])
  elif ab[i][0] == n:
    cand.append(ab[i][1])
  elif ab[i][1] == n:
    cand.append(ab[i][0])    

if len(set(mid) & set(cand)) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 61108
X = int(input())
ans = 1

for i in range(2,X+1):
    p = 2
    while (X >= i ** p):
        ans = max(ans, i ** p)
        p += 1
        # print('i=',i)
        # print('p=',p)
        # print(i**p)

print(ans)

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

int main(){
  int N, M;
  int highest_score = 0;
  int score = 0;
  
  cin >> M;
  vector <string> blue(M);
  for (int l = 0; l < M; l++){
    cin >> blue.at(l);
  }
  
  cin >> N;
  vector <string> red(N);
  for (int m = 0; m < N; m++){
    cin >> red.at(m);
  }
  
  for (int i = 0; i < M; i++){
    //blueのi番目の要素と同じやつの個数を数える
    for (int j = 0; j < M; j++){
      if (blue.at(j) == blue.at(i)){
        score++;
      }
    }
    for (int k = 0; k < N; k++){
      if (red.at(k) == blue.at(i))
        score--;
    }
  if (highest_score < score)
    highest_score = score;
  score = 0;
  }
  cout << highest_score << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll powLL(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res *= a;
            res %= mod;
        }
        a = a*a;
        a %= mod;
        n >>= 1;
    }
    return res;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> S(N+1, 0);
    REP(i, N) S[i+1] = S[i]^A[i];
    //cerr << S << endl;

    vector<ll> SZ(N+2, 0);
    REP(i, N+1) SZ[i+1] = SZ[i] + (S[i]==0);

    // compress
    set<ll> st;
    REP(i, N+1){
        st.insert(S[i]);
    }
    map<ll, ll> mp;
    ll cnt = 0;
    for(auto x: st){
        mp[x] = cnt;
        cnt++;
    }

    vector<vector<ll>> kan(cnt);
    vector<ll> prev(cnt, -1);

    REP(i, N+1){
        ll val = mp[S[i]];
        kan[val].push_back(SZ[i] - SZ[prev[val]+1]);
        prev[val] = i;
    }

    /*
    REP(i, cnt){
        REP(j, kan[i].size()){
            cerr << kan[i][j] << " ";
        }
        cerr << endl;
    }
    */

    ll res = 0;
    if(S.back()==0){
        REP(i, cnt){
            if(i==0){
                res += powLL(2, (ll)kan[i].size()-2);
                continue;
            }
            ll zz = 1, xx = 1;
            REP(j, kan[i].size()){
                if(j==0)continue;
                zz += (xx*kan[i][j])%mod;
                zz %= mod;
                xx += zz;
                xx %= mod;
            }

            res += xx;
            res %= mod;
        }
    }else{
        REP(i, cnt){
            if(mp[S.back()] != i) continue;
            
            ll zz = 1, xx = 1;
            REP(j, kan[i].size()){
                if(j==0)continue;
                zz += (xx*kan[i][j])%mod;
                zz %= mod;
                xx += zz;
                xx %= mod;
            }

            res += zz;
            res %= mod;
        }
    }
    
    cout << res << endl;
    return 0;
}

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

int main()
{
   ll t;
   cin>>t;
   if(t>=400 && t<=599){
   	cout<<8;
   }
	else if(t>=600 && t<=799){
		cout<<7;
	}
	else if(t>=800 && t<=999){
		cout<<6;
	}
	else if(t>=1000 && t<=1199){
		cout<<5;
	}
	else if(t>=1200 &&t<=1399){
		cout<<4;
	}
	else if(t>=1400 && t<=1599){
		cout<<3;
	}
	else if(t>=1600 && t<=1799){
		cout<<2;
	}
	else{
		cout<<1;
	}
    return 0;
}

Measured memory_bytes: 3632