akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

double dp[100010];
int n, k;

int main() {
  while (cin >> n >> k) {
    dp[k] = 1;
    for (int i = k - 1; i >= 0; --i) {
      dp[i] = dp[min(i * 2, k)] * 0.5;
    }
    double ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += 1.0 / n * dp[min(i, k)];
    }
    printf("%.18f\n", ans);
  }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<cstring>    //for memset
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

#define lli                      long long int
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define pdd                      pair<double,double>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define all(v)                   v.begin(),v.end()
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
#define mem(array,value)         memset(array,value,sizeof array)
#define TEST_CASE                int t;scanf("%d",&t);for(int z=1;z<=t;z++)
#define PRINT_CASE               printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define ordered_set              tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sf                       scanf
#define pf                       printf
#define inf                      99999999999
#define mod                      1000000007
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define fastIO                   ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define watch(x)   	            cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define mx 1000005



int main()
{


    int n;
    cin>>n;
    lli a[n+5];
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    int p=n/2;
    cout<<a[p+1]-a[p];
    return 0;
}









Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define MK make_pair
#define PB push_back
#define fi first
#define se second

typedef long long LL;
typedef pair<int, int> PII;
const int N=1e5+10 ;

int n,m ;
char s[N], t[N];
int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	scanf("%d%d", &n, &m);scanf("%s%s", s, t);
	int gc=__gcd(n,m);
	int step1= n/gc, step2= m/gc;
	bool flag= true;
	for (int i=0;i<gc; ++i)
		if ( s[ i*step1] != t[i*step2] )flag= false;
	
	if ( !flag  ) puts("-1");
		else cout<<1ll*n*m/gc<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
//typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

string s;
int p;
int P, Q, R;
int term();

int elem()
{
	int tmp;
	if (s[p] == '(')
	{
		p++;
		tmp = term();
		p++;
		return tmp;
	}
	int cnt = 0;
	if (s[p] == '-')
	{
		while (s[p] == '-')
		{
			cnt++;
			p++;
		}
		return (cnt % 2 ? 2 - elem() : elem());
	}
	if (isdigit(s[p])) tmp = s[p] - '0';
	else if (s[p] == 'P') tmp = P;
	else if (s[p] == 'Q') tmp = Q;
	else if (s[p] == 'R') tmp = R;
	p++;
	return tmp;
}

int term()
{
	int tmp = elem();
	while (s[p] == '+' || s[p] == '*')
	{
		char c = s[p];
		p++;
		int a = elem();
		if (c == '+')
		{
			tmp = max(tmp, a);
		}
		else
		{
			tmp = min(tmp, a);
		}
	}
	return tmp;
}


int main()
{
	while (getline(cin, s))
	{
		if (s == ".") break;
		p = 0;
		int cnt = 0;
		REP(i, 3)REP(j, 3)REP(k, 3)
		{
			p = 0;
			P = i, Q = j, R = k;
			if (term() == 2) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n, d, a; cin >> n >> d >> a;
  vpr X(n);
  rep(i,n) {
    ll x, h; cin >> x >> h;
    X[i] = make_pair(x, h);
  }
  sort(ALL(X));
  vll sum(n+1, 0);
  ll ans = 0;
  rep(i,n) {
    if(i) sum[i] += sum[i-1];
    ll x = X[i].first, h = X[i].second;
    ll remain = h-sum[i];
    if(remain <= 0) continue;
    pr b = make_pair(x+d*2, 1e18);
    int nextX = upper_bound(ALL(X), b) - X.begin();
    ll damage = remain;
    ans += remain/a;
    if(remain%a) {
      ans++;
      damage = a*(1+remain/a);
    }
    sum[i] += damage;
    sum[nextX] -= damage;
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4992
function main(input){
    let a = input.trim();
    a = a.slice( -1 );
    a = parseInt(a);
    if (a == 2 || a == 4 || a == 5 || a== 7 || a== 9) {
        console.log('hon');      
        
    } else if (a == 0 || a == 1 || a == 6 || a == 8){
        console.log('pon');
        
    } else{
        console.log('bon');
        
    }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29628
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N;
    ll ans=0;
    ll X[4];
    string S[4];
int main(){
    cin>>N;
    cout<<N/2+N%2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int fact(int n)
    {
        int i,f=1;
        if(n==0)
        {
            return 1;
        }
        else{
                for(i=1;i<=n;i++)
                {
                    f=f*i;
                }
            return f;
        }
    }
int main()
{
    int f,n,i,j;
    double s=0,k;
    cin>>n;
    int a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    f=(n-1)*fact(n-2)*2;;
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            s=s+sqrt(pow(a[i]-a[j],2)+pow(b[i]-b[j],2));
        }
    }
    k=(s*f)/fact(n);
    printf("%.10lf\n",k);

}


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

int main()
{
    string s,y,m;
    int a,b,c,d,e;
    cin>>s;
    y+=s[0];
    y+=s[1];
    stringstream ss (y);
    ss>>b;
    m+=s[2];
    m+=s[3];
    stringstream rr (m);
    rr>>c;
    int ck=0;

    if(b<=12 && b>0){
        if(c<=12 && c>0)
            cout<<"AMBIGUOUS"<<endl,ck=1;
        else
            cout<<"MMYY"<<endl,ck=1;
    }
    else if (b>12){
        if(c>12)
            cout<<"NA"<<endl,ck=1;
        else if(c>0 && c<=12)
            cout<<"YYMM"<<endl,ck=1;
        else
            cout<<"NA"<<endl;
    }
    else{

        if (c>12||c==0)
            cout<<"NA"<<endl;
        else if(c<=12)
            cout<<"YYMM"<<endl;
    }
//    if(b<=12&&c<=12)
//        cout<<"AMBIGUOUS"<<endl;
//    else{
//        swap(b,c);
//        cout<<b<<endl;
//        if(b<=12&&c>=00)
//        cout<<"MMYY"<<endl;
//        else if(b>=00&&c<=12)
//        cout<<"YYMM"<<endl;
//        else if(b>12&&b==00)
//            cout<<"NA"<<endl;
//    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

bool sude[5000];
vector<int> hen[5000];

int c[5000];
int r[5000];

bool ik[5000];
int m[2][5000];

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i = 0; i < n; i++)
	{
		scanf("%d%d",c + i,r + i);
		sude[i] = false;
	}
	for(int i = 0; i < k; i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		hen[a - 1].push_back(b - 1);
		hen[b - 1].push_back(a - 1);
	}
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;
	pq.push(make_pair(c[0],0));
	while(1)
	{
		int cw = pq.top().first;
		int bw = pq.top().second;
		pq.pop();
		if(bw == n - 1)
		{
			printf("%d\n",cw - c[n - 1]);
			break;
		}
		for(int i = 0; i < n; i++)
		{
			ik[i] = false;
		}
		int now = 0;
		int k = 1;
		m[now][0] = bw;
		ik[bw] = true;
		for(int i = 0; i < r[bw]; i++)
		{
			int nk = 0;
			int nex = (now + 1) % 2;
			for(int j = 0; j < k; j++)
			{
				int s =  hen[m[now][j]].size();
				for(int jj = 0; jj < s; jj++)
				{
					int t = hen[m[now][j]][jj];
					if(!ik[t])
					{
						ik[t] = true;
						m[nex][nk] = t;
						nk++;
						if(!sude[t])
						{
							pq.push(make_pair(cw + c[t],t));
							sude[t] = true;
						}
					}
				}
			}
			now = nex;
			k = nk;
		}
	}
	return 0;
}

Measured memory_bytes: 1712
#include <stdio.h>
#include <string.h>

#define L 10000

int main() {
	static char s[L + 1], t[L + 1];
	int l, n, i;

	scanf("%d%s", &n, s);
	l = strlen(s);
	for (i = 0; i < l; i++)
		t[i] = ((s[i] - 'A') + n) % 26 + 'A';
	printf("%s\n", t);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
ll gcd(ll x,ll y){
    if (y == 0) return x;
    return gcd(y, x%y);
}
ll lcm(ll x,ll y){
    return x/gcd(x,y)*y;
}
int main(void){
    ll n;cin>>n;
    ll res;cin>>res;
    rep(i,n-1){
        ll t;cin>>t;
        res=lcm(res,t);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3612
S = input().rstrip()

n = len(S)
if n % 2 == 1:
    S = S[:n - 1]
else:
    S = S[:n - 2]

n = 0
while True:
    n = len(S)
    mid = int(n / 2)
    if S[:mid] == S[mid:n]:
        break

    S = S[:n - 2]


print(n)



Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long func(long n, long k);
int main(void);

long func(long n, long k){
    long old, new, n_tmp, new_int;
    long i=0;
    n_tmp = n;
    old = n;
    while(1){
        if(i==0){
            new = n%k;
            new_int = new;
        }else{
            old = new;
            new = labs(new_int-k);
            new_int = new_int-k;
        }
        if(new > old)
            break;
        i++;

    }

    return old;
}

int main(void){
    long n, k;
    long min;
    scanf("%ld %ld", &n, &k);
    min = func(n, k);

    printf("%ld\n", min);

    return 0;
}


Measured memory_bytes: 128
n,s = map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353
dp = [[0]*(s+1) for i in range(n+1)]
dp[1][0] = 2
if a[0] <= s:
    dp[1][a[0]] = 1
for i in range(2,n+1):
    for j in range(0,s+1):
        dp[i][j] = dp[i-1][j]*2
        if j-a[i-1] >= 0:
            dp[i][j] += dp[i-1][j-a[i-1]]
        dp[i][j] %= mod
print(dp[n][s])


Measured memory_bytes: 135384
#include <cstdio>
#include <string>
#include <set>
using namespace std;

int M, N;
bool open = false;
char c[16];
set<string> U;

int main(){
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%s", c, 16);
		U.insert((string)c);
	}
	scanf("%d", &M);
	for (int i = 0; i < M; i++) {
		scanf("%s", c, 16);

		if (U.find((string)c) != U.end()) {
			if (open) {
				printf("Closed by %s\n", c);
			}
			else {
				printf("Opened by %s\n", c);
			}
			open = !open;
		}
		else {
			printf("Unknown %s\n", c);
		}
	}

	return 0;
}

Measured memory_bytes: 2960
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	string X, Y;
	set<char> A;
	int ma = 0;
	for (int i = 0; i < N; i++) {
		X = S.substr(0, i+1);
		Y = S.substr(i + 1,N-i-1);
		for (auto x : X) {
			for (auto y : Y) {
				if (x == y)A.insert(x);
			}
		}
		int k = A.size();
		ma = max(k, ma);
		A.clear();
	}
	cout << ma << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int N,M;
string S,T;

signed main(){
  cin>>S>>T;
  T.pop_back();
  if(S==T)print("Yes");
  else print("No");

}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;
int main() {
    int c[3][3];
    for (int i = 0; i < 3;i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    bool f=1;
    for (int i = 0; i < 2; i++) {
        if (c[i][0] - c[i + 1][0] != c[i][1] - c[i + 1][1] || c[i][1] - c[i + 1][1] != c[i][2] - c[i + 1][2]) f = 0;
    }
    for (int i = 0; i < 2;i++) {
        if (c[0][i] - c[0][i+1] != c[1][i] - c[1][i+1] || c[1][i] - c[1][i+1] != c[2][i] - c[2][i+1]) f = 0;
    }
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
 }

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

int main()
{
	int A = 0;
	int B = 0;
	cin >> A >> B;

	int remnant = 0;
	if (A > 2 * B) {
		remnant = A - 2 * B;
	}



	cout << remnant;
}


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

int main(){
    int a, b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if (op == '?') break;
        
        if (op == '+') cout << a + b << endl;
        else if (op == '-') cout << a - b << endl;
        else if (op == '*') cout << a * b << endl;
        else if (op == '/') cout << a / b << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 100005

ll Weight[N],Profit[N],dp[2][N];

int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,w;cin>>n>>w;
   for(int i=1;i<=n;i++){
      cin>>Weight[i]>>Profit[i];
   }
   fill(dp[0],dp[0]+2*N,-INT_MAX*105);
   dp[(n+1)%2][0]=0;
   for(int i=n;i>=1;i--){
      for(int s=0;s<=w;s++){
         ll op1=dp[(i+1)%2][s];
         ll op2=(s-Weight[i]>=0)?Profit[i]+dp[(i+1)%2][s-Weight[i]]:0ll;
         dp[i%2][s]=max(op1,op2);
      }
   }
   ll ans=0;
   for(int i=0;i<=w;i++) ans=max(ans,dp[1][i]);
   cout<<ans<<"\n";
   return 0;
}



Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
vector<PII> e[N];
int n,m,a[N],b[N],deg[N],f[N];

int find(int x) {
	return f[x]==x?x:f[x]=find(f[x]);
}

void dfs(int u,int f) {
	for (auto p:e[u]) if (p.fi!=f) {
		int v=p.fi,id=p.se;
		dfs(v,u);
		if (deg[v]%2==0) {
			deg[u]++;
			a[id]=u; b[id]=v;
		} else {
			deg[v]++;
			a[id]=v; b[id]=u;
		}
	}
}

int main() {
	scanf("%d%d",&n,&m);
	if (m%2!=0) {
		puts("-1");
		return 0;
	}
	rep(i,1,n+1) f[i]=i;
	rep(i,0,m) {
		scanf("%d%d",a+i,b+i);
		if (find(a[i])!=find(b[i])) {
			e[a[i]].pb(mp(b[i],i));
			e[b[i]].pb(mp(a[i],i));
			f[find(a[i])]=find(b[i]);
		} else {
			deg[a[i]]++;
		}
	}
	dfs(1,0);
	rep(i,0,m) printf("%d %d\n",a[i],b[i]);
}


Measured memory_bytes: 15104
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vp,vpp1;
vector<pair<ll,ll> >vdp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    fast;
    cin>>n>>k;
    ll sum=0;
    FOR(i,n)
    {
        cin>>a;
        v.p_b(a);
        sum+=a;
    }
    sort(v.rbegin(),v.rend());
    ll x=(sum/(4*k));
    if(sum%(4*k)!=0) x++;
    ///cout<<sum<<" "<<x<<" "<<v[k-1]<<endl;
    if(v[k-1]<x){cout<<"No"<<endl;return 0;}
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }
const ll MOD = 1000000007;

signed main() {
    SS(int,n,k);
	set<int>ans; 
	rep(i,k){
		SS(int,d)
		rep(j,d){
			SS(int,inc)
			ans.insert(inc);
		}
	}
	p(n-ans.size());
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
vector<pair<ll,ll>> vec[100000];
int main(){
  ll n;
  cin >> n;
  ll a[n];
  ll maximum = 0;
  ll tmp=0;
  rep(i,n){
    cin >> a[i];
    if(maximum < a[i]){
      maximum = a[i];
      tmp=i;
    }
  }
  sort(a,a+n);
  rep(i,n){
    if(tmp == i){
      cout << a[n-2] << endl;
    }else{
      cout << a[n-1] << endl;
    }
  }
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, x, a;
  cin >> N >> K;
  a = 0;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x > K - x) {
      a += (K - x) * 2;
    }
    else {
      a += x * 2;
    }
  }
  cout << a << endl;
}

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

#define PB push_back
#define CL(A,I) (memset(A,I,sizeof(A)))

#define FOR(i, m, n) for (int i=m; i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)

#define D(X) cout<<"  "<<#X": "<<X<<endl;

using ll=long long;
using ii=pair<ll,ll>;
using vi=vector<ll>;
using vii=vector<ii>;

#define aa first
#define bb second

#define EPS (1e-9)
#define EQ(A,B) (A+EPS>B&&A-EPS<B)

int n;
int arr[100007];

int main() {
cin>>n;
int ccnt=0;
F(n)cin>>arr[i],ccnt+=arr[i]%2;
cout<<(ccnt%2?"NO":"YES")<<endl;
    return 0;
}

Measured memory_bytes: 640
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 3e5 + 200;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

string s;
vector<pair<int, int> > v;
vector<int> x;

void rec(int l, int r, int L, int R){
    if((r + l) % 2 == 0){
        if(s[(r + l) / 2] == '1'){
            int tm = (L + R) / 2;
            v.pb({L, tm + 1});
            rec(l, tm - 1, L, tm);
            rec(tm + 1, r, tm + 1, R);
        }else{
            int tm = (L + R) / 2;
            v.pb({L, tm});
            v.pb({tm, tm + 1});
            rec(l, tm - 1, L, tm - 1);
            rec(tm + 1, r, tm + 1, R);
        }
    }
}

int main () {
    ios;
    cin >> s;
    if(s[s.size() - 1] == '1') return cout << -1, 0;
    string t = "#";
    for(int i = 0; i < s.size() - 1; i++){
        t += s[i];
    }
    s = t;
    if(s[1] == '0') return cout << -1, 0;
    for(int i = 1; i < s.size() - 1; i++){
        if(s[i] != s[s.size() - i]){
            return cout << -1, 0;
        }
    }
    for(int i = 1; i < s.size(); i++){
        if(s[i] == '1') x.pb(i);
    }
    for(int i = 1; i < x.size(); i++){
        v.pb({x[i - 1], x[i]});
    }
    int batya = 0;
    for(int i = s.size() - 1; i >= 1; i--){
        if(s[i] == '1'){
            batya = i;
        }else{
            v.pb({batya, i});
        }
    }
    v.pb({s.size(), s.size() - 1});
    for(int i = 0; i < v.size(); i++){
        cout << v[i].F << ' ' << v[i].S << nl;
    }
    return 0;
}


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


int main() {
    string S;
    cin >>S;
    int a =(S[0]-'0')*10+(S[1]-'0');
    int b =(S[2]-'0')*10+(S[3]-'0');
    if((a>=13||a==0) && 0<b&&b<=12)cout <<"YYMM"<<endl;
    else if(0<a&&a<=12 && (b>=13 || b==0))cout<<"MMYY"<<endl;
    else if((a>=13 || a==0)  && (b>=13 || b==0))cout<<"NA"<<endl;
    else cout <<"AMBIGUOUS"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;


const int six_dx[]={1,1,0,-1,-1,0};
const int six_dy[]={1,0,-1,-1,0,1};

int main()
{
    int n,m;
    cin>>n>>m;
    
    vector<double> l(n),a(n),b(n);
    for(int i=0;i<n;i++) cin>>l[i]>>a[i]>>b[i];
    
    double res=0;
    for(int i=0;i<(1<<n);i++){
        vector<int> pos;
        for(int j=0;j<n;j++){
            if(i&(1<<j)) pos.push_back(j);
        }
        if(pos.size()!=m) continue;
        
        double tmp=0;
        for(int j=0;j<m;j++){
            for(int k=j+1;k<m;k++){
                tmp+=(l[pos[j]]-l[pos[k]])*(l[pos[j]]-l[pos[k]]);
                tmp+=(a[pos[j]]-a[pos[k]])*(a[pos[j]]-a[pos[k]]);
                tmp+=(b[pos[j]]-b[pos[k]])*(b[pos[j]]-b[pos[k]]);
            }
            res=max(res,tmp);
        }
        
    }
    printf("%.8f\n", res);
    
    return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[n+1];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  // for(int i=0;i<n;i++)
  //   cout<<dp[i]<<" ";
  cout<<endl;
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()

bool is_ok(vector<ll> a, ll n, ll k, ll x){
  ll sum = 0;
  vector<ll> rem(n);
  REP(i,n){
    rem[i] = a[i]%x;
    sum += rem[i];
  }
  sort(ALL(rem));
  ll bound = n-1-sum/x;
  ll need = 0;
  REP(i,bound+1) need += rem[i]; 
  return need<=k;
}

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> a(N);
  ll sum = 0;
  REP(i,N){
    cin >> a[i];
    sum += a[i];
  }
  set<ll> div;
  for(ll i=1; i*i<=sum; i++){
    if(sum%i==0){
      div.insert(i);
      div.insert(sum/i);
    }
  }
  ll ans = 1;
  FOREACH(d,div) if(is_ok(a,N,K,d)) ans = max(ans,d);
  cout << ans << endl;
}


Measured memory_bytes: 256
def solve():
    A, B, C, D, E, F = map(int, input().split())
    A, B = 100 * A, 100 * B
    waters = set()
    sugars = set()
    for i in range(3001):
        for j in range(3001):
            if A * i + B * j <= F:
                waters.add(A * i + B * j)
            if C * i + D * j <= F:
                sugars.add(C * i + D * j)
    ans_per = 0
    ans_water = 0
    ans_sugar = 0
    for w in waters:
        if w == 0:
            continue
        for s in sugars:
            if w + s <= F and ans_per <= s / w <= E / 100:
                ans_per = s / w
                ans_water = w
                ans_sugar = s
    print(ans_water + ans_sugar, ans_sugar)


if __name__ == '__main__':
    import datetime
    # print(datetime.datetime.now())
    solve()
    # print(datetime.datetime.now())


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

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] arr;
            while((arr = Console.ReadLine().Split(' ').ToArray())[1] != "?")
            {
                Console.WriteLine(Calculate(int.Parse(arr[0]), int.Parse(arr[2]), arr[1]));
            }
        }

        private static int Calculate(int a, int b, string op)
        {
            switch(op)
            {
                case "+": return a + b;
                case "-": return a - b;
                case "*": return a * b;
                case "/": return a / b;
            }
            return 0;
        }
    }
}



Measured memory_bytes: 16124
#include<stdio.h>

int main(void) {
	int N;
	int a[10000];
	int i, j;
	int cnt = 0;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}

	for (i = 0; i < N; i++) {
		for (j = 2; j*j <= a[i]; j++) {
			if (a[i] != j && a[i] % j == 0) {
				cnt++;
				break;
			}
		}
	}
	
	printf("%d\n", N - cnt);

	return 0;
}


Measured memory_bytes: 2016
N=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
sum_a = sum(a)
x_sum = 0
for x in range(0,len(a),2):
    x_sum += a[x]

y_sum = sum_a - x_sum

print(x_sum - y_sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  string S, T, U;
  cin >> S >> T >> A >> B >>U;
  
  if (U == S) A--;
  else B--;
  
  
  

  cout << A << " " << B << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef unsigned long long ull;
const int INF = 1e9;

int main(){
  int match[10] = {0,2,5,5,4,5,6,3,7,6};
  int N, M;
  cin >> N >> M;
  int dp[N+1];
  rep(i, N+1) dp[i] = -INF;
  dp[0] = 0;
  vector<int> vec;
  rep(i, M){
    int a;
    cin >> a;
    vec.push_back(a);
  }
  sort(vec.begin(), vec.end(), greater<int>());
  for(int i = 1; i <= N; i++){
    int m = -INF;
    rep(j, vec.size()){
      if(i - match[vec[j]] >= 0) m = max(m, dp[i-match[vec[j]]] + 1);
    }
    dp[i] = m;
  }
  string ans = "";
  int n = N;
  for(int i = dp[N]; i >= 1; i--){
    rep(j, vec.size()){
      if(n-match[vec[j]] >= 0 && dp[n-match[vec[j]]] == dp[n]-1) {
        ans += '0' + vec[j];
        n -= match[vec[j]];
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int a, b, c, d, e;
    cin>>a>>b>>c>>d>>e;
    int ans = 0;
    if(a < 0)ans=d;
    while(a<b){
        if(a<0){
            a++;
            ans+=c;
        }
        else {
            a++;
            ans+=e;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3100
import sys

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, sys.stdin.readline().rstrip().split())
edges = []
for _ in range(M):
    a, b = map(int, sys.stdin.readline().rstrip().split())
    edges.append((a-1, b-1))

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j, (a, b) in enumerate(edges):
        if i == j:
            continue
        uf.union(a, b)
    if uf.group_count() != 1:
        ans += 1

print(ans)

Measured memory_bytes: 40944
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
#include <iomanip>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	cout << std::fixed << std::setprecision(10);

	for (;;) {
		int N, L;

		cin >> N >> L;
		if (cin.fail()) break;

		int sum = N * (L + L + N - 1) / 2;
		int a = L;
		int b = L + N - 1;
		if (a <= 0 and b >= 0) {
			cout << sum << endl;
		} else {
			if (abs(a) < abs(b)) {
				cout << sum - a << endl;
			} else {
				cout << sum - b << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    if (n%k) cout << "1" << endl;
    else cout << "0" << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
numbers = []
n.times{numbers << gets.to_i}

m = numbers[1 .. n - 1].max
max_profit = m - numbers[0]
for i in (0 .. n - 2)
    profit = m - numbers[i]
    if profit == 0
        m = numbers[i + 1 .. n - 1].max
        profit = m - numbers[i]
    end
    max_profit = profit if profit > max_profit
end
puts max_profit

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

using namespace std;

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

	int n;
	cin >> n;

	vector<vector<int> > G(n);
	for(int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	vector<int> fa(n, -1);
	function<void(int, int)> dfs = [&] (int u, int f) {
		for(int v : G[u]) {
			if(v != f) {
				fa[v] = u;
				dfs(v, u);
			}
		}
	};

	dfs(0, -1);

	long long ans = 0;
	ans += n;
	for(int i = 1; i < n; ++i) {
		long long l = 0;
		long long r = n - 1;
		if(fa[i] < i) {
			l = fa[i] + 1;		
		} else {
			r = fa[i] - 1;
		}

		ans += 1LL * (i - l + 1) * (r - i + 1);
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 30600
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;
using lli = long long int;

lli gcd(lli x, lli y) {
  return (y == 0 ? x : gcd(y, x % y));
}

lli solve(lli p, lli q) {
  const lli NMAX = 100008;
  vector<lli> factor(NMAX, 0);
  for (lli n = 2; n < NMAX; ++n) {
    if (factor[n]) { continue; }
    for (lli k = 2; k * n < NMAX; ++k) {
      factor[k * n] = n;
    }
  }
  lli ans = 1;
  for (lli n = 2; q > 1 && n < NMAX; ++n) {
    if (factor[n] || (q % n != 0)) { continue; }
    while (q % n == 0) { q /= n; }
    ans *= n;
  }
  ans *= q;
  return max<lli>(2, ans);
}

int main() {
  lli P, Q; cin >> P >> Q;
  const lli G = gcd(P, Q);
  P /= G, Q /= G;
  cout << solve(P, Q) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int p = 1e9+7;

ll powmod(int x, int n) {
    if(n==1) return x%p;
    if(n%2 == 1) return (x * powmod(x,n-1))%p;
    else{
        ll y = powmod(x,n/2)%p;
        return (y*y)%p;
    }
}

ll combineMod(int n,int k){
    ll x = 1,y=1;
    for(int i=k+1;i<=n;i++){
        x = (x * i) % p;
    }
    for(int i=1;i<=n-k;i++)
    {
        y = (y * i) % p;
    }
    return (x * powmod(y,p-2)) % p;
}

int main(){
    ll x,y;
    cin >> x >> y;
    ll n,m;
    if((x+y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    n = (2*y-x)/3;
    m = (2*x-y)/3;
    if(n < 0 || m < 0){
        cout << 0 << endl;
        return 0;
    }
    ll res = combineMod(n+m,n);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
object Main {
  import scala.io.StdIn.readLine
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val v = List.fill(n)(sc.nextInt)

    println(new QC(n, v).ans)
  }
}

class QC(n: Int, input: List[Int]) {
  val s1 = n/2+n%2
  val s2 = n/2
  var m1:Map[Int, Int] = Map()
  var m2:Map[Int, Int] = Map()
  def countUp(m: Map[Int, Int], k: Int) = m.getOrElse(k,0)+1
  input.zipWithIndex.foreach{case (v, idx) => {
    if(idx%2==1){ m1 += v -> countUp(m1,v)}
    else { m2 += v -> countUp(m2,v) }
  }}

  def ans():String = {
    val ms1:Seq[(Int, Int)] = m1.toSeq.sortBy(-_._2)
    val ms2:Seq[(Int, Int)] = m2.toSeq.sortBy(-_._2)
    (ms1.head._1 != ms2.head._1) match {
      case true =>
        (s1-ms1.head._2) + (s2-ms2.head._2)
      case false =>
        val k = (s1-ms1.head._2) + (s2-ms2.tail.headOption.getOrElse((0,0))._2)
        val l = (s1-ms1.tail.headOption.getOrElse((0,0))._2) + (s2-ms2.head._2)
        if (k<l){k} else {l}
    }
  }.toString()
}

Measured memory_bytes: 85228
n = int(input())
A = list(map(int, input().split()))

max_a = max(A)
s_set = set()
l_set = set()
for a in A:
    if(a <= max_a//2):
        s_set.add(a)
    else:
        l_set.add(a)

s_max = max(s_set | {0})
l_min = min(l_set | {max_a})

if(s_max >= (max_a - l_min)):
    print(max_a, s_max)
else:
    print(max_a, l_min)

Measured memory_bytes: 16348
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
}


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

int main(int argc, char const *argv[])
{
	int a[1005];
	a[0]=0;
	for (int i = 1; i < 1005; ++i) a[i]=i+a[i-1];
	int n;
	while(cin>>n,n)
	{
		int ans=0;
		for (int i = 0; i <= 1000; ++i)
		{
			for (int j = i+2; j <= 1000; ++j)
			{
				if(a[j]-a[i]==n) ++ans;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, r, c, tp, tot, st[MAXN];
pii e[MAXN];

inline int Get(int x, int y)
{
	if (!x)
		return y;
	if (y == c)
		return x + c;
	if (x == r)
		return r + (c << 1) - y;
	return (r + c << 1) - x;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	r = Read(), c = Read(), n = Read();
	for (int i = 1; i <= n; i ++)
	{
		int x1 = Read(), y1 = Read(), x2 = Read(), y2 = Read(), x, y;
		if ((!x1 || x1 == r || !y1 || y1 == c) && (!x2 || x2 == r || !y2 || y2 == c))
		{
			x = Get(x1, y1), y = Get(x2, y2);
			if (x > y)
				swap(x, y);
			e[++ tot] = mp(x, i), e[++ tot] = mp(y, -i);
		}
	}
	sort(e + 1, e + tot + 1);
	for (int i = 1; i <= tot; i ++)
		if (e[i].yy > 0)
			st[++ tp] = e[i].yy;
		else if (st[tp] ^ -e[i].yy)
			return puts("NO"), 0;
		else
			tp --;
	return puts("YES"), 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<ll,ll> P;
struct edge{ll to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const ll INF=100000000000000;

bool F[10][10][10];
P info[10];
vector<edge> G[10];
ll N,M;
ll ans=0;
ll d[10];

void Dijkstra(int s){
	std::priority_queue<P,vector<P>,std::greater<P>> que;
	std::fill(d,d+N,INF);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p =que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(int i=0;i<(signed)G[v].size();i++){
			edge e =G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

int main(){
	cout<<boolalpha;
	cin>>N>>M;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		info[i]=P(a,b);
	}
	REP(Bit,1<<M){//111
       if(__builtin_popcount(Bit)!=N-1)continue;
		REP(i,10){
			G[i].clear();
		}
		int cost=0;
		for(int i=M-1;0<=i;i--){
			if(Bit&(1<<i)){
				cost++;
				int a=info[i].first;
				int b=info[i].second;
				edge e;
				e.to=b-1,e.cost=1;
				G[a-1].push_back(e);
				e.to=a-1;
				G[b-1].push_back(e);
			}
		}
		Dijkstra(0);
		for(int i=1;i<N;i++){
			if(d[i]==N-1)ans++;
			ARDEB(i,d)END
		}
		DEB("restwe4twtw3t")END
		DEB(G[0].empty())END
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
N=int(input())

sqrt_N = N**0.5

list_D=[]
list_A=[]

i=1
while(i<sqrt_N):
    if N%i == 0:
        list_D.append(i)
    i+=1

for d in list_D:
    list_A.append(N//d-1)
    
if N==1 or N==2:
    print(0)
else:
    if N%list_A[-1] == 0:
        list_A.pop(-1)
    print(sum(list_A))

Measured memory_bytes: 40428