akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    ll N, E, T;
    cin >> N >> E >> T;
    ll X[100010], Y[100010];
    X[0] = 0;
    for (int i = 1;i <= N;i++) cin >> X[i];
    Y[0] = 0;
    int idx = 0;
    ll sum = 0;
    ll total, tmp;
    multiset<ll> S;
    S.insert(T);
    ll now = 1E18;
    multiset<ll>::iterator it;
    for (int i = 1;i <= N;i++) {
    	now += 3 * (X[i] - X[i - 1]);
    	sum += X[i] - X[i - 1];
    	while (X[i] - X[idx] > T / 2) {
    		// Eject X[idx].
    		if (idx != 0) total = T + X[i] - X[idx - 1] + Y[idx - 1];
    		else total = T + X[i];
    		total -= sum;
    		it = S.find(total);
    		S.erase(it);
    		if (idx > 0) tmp = (X[i] - X[idx]) * 3 + Y[idx - 1] + X[idx] - X[idx - 1];
    		else tmp = (X[i] - X[idx]) * 3 + X[1] - X[0];
    		now = min(now, tmp);
    		idx++;
    	}
        S.insert(T + Y[i - 1] + X[i] - X[i - 1] - sum);
        it = S.begin();
        Y[i] = min(now, *it + sum);
    }
    cout << Y[N] + E - X[N] << endl;
    return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>

int main(void){

  int a,b,i;
  char op;
  while(1){
  scanf("%d %c %d",&a,&op,&b);

  if(op=='+'){
    i=a+b;
  }
  else if(op=='-'){
    i=a-b;
  }
  else if(op=='*'){
    i=a*b;
  }
  else if(op=='/'){
    i=a/b;
  }
  else if(op=='?'){
    break;
  }

    printf("%d\n",i);

  }

    return 0;
}
    

  



Measured memory_bytes: 2080
#include <iostream>
using namespace std;
int w,h;
int mp[20][20];
int memo[20][20];
int ans;
int count;

int saiki(int x,int y) {
  count++;
  // cout << x <<" "<<y <<endl;
  int dx[3] = {-1,0,1};
  int dy[3] = {1,1,1};
  
  if(y >= h-1) ans++,memo[y][x]++;
  
  else if(mp[y][x] != 1) {
    for(int i=0;i<3;i++) {
      int nx = dx[i]+x;
      int ny = dy[i]+y;
      if(nx <0|| nx >= w || memo[ny][nx] == -1||mp[ny][nx] == 1) continue;
      
      if(memo[ny][nx] > 0 && mp[ny][nx] == 0) {
	ans += memo[ny][nx];
	memo[y][x] += memo[ny][nx];
      }  
      else if(mp[ny][nx] == 0){
	saiki(nx,ny);
	if(memo[ny][nx] > 0) memo[y][x] += memo[ny][nx];
      } 
      else if(nx==x && mp[ny][nx] == 2){
	int ty = ny;
	while(mp[ty][nx] == 2) ty+=2;
	if(mp[ty][nx] == 0 && memo[ty][nx] == 0){
	  saiki(nx,ty);
	  if(memo[ty][nx] > 0) memo[y][x] += memo[ty][nx];
	}
	else if(mp[ty][nx] == 0 && memo[ty][nx] > 0){
	  memo[y][x] += memo[ty][nx];
	  ans+= memo[ty][nx];
	}
      }
    }
    if(memo[y][x] == 0) memo[y][x] = -1;
  }
}


int main() {

  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;

    for(int i=0;i<=19;i++) 
      for(int j=0;j<=19;j++){ 
	memo[i][j] = 0;
	mp[i][j] = 0;
      }
    
    for(int i=0;i<h;i++) 
      for(int j=0;j<w;j++) 
	cin >> mp[i][j];


    ans = 0;
    count = 0;
    for(int i=0;i<w;i++) {
      if(mp[0][i] !=1) saiki(i,0);
    }
    
    /*
    for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) 
      cout << memo[i][j]<<" ";
    cout << endl;
    } 
    */
  
    int ans2 = 0;
    for(int i=0;i<w;i++) 
      if(memo[0][i] > 0) ans2+=memo[0][i];
    
    cout << ans << endl;
    //   cout << ans2 << endl;
    //cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 1168
#include<stdio.h>
int main()
{
	int S,h,a,m,s;
	scanf("%d", &S);
	h = S / 3600;
	a = S % 3600;
	m = a / 60;
	s = a % 60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 2732
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws java.lang.Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int a = Integer.parseInt(br.readLine());
        String s = br.readLine();

        System.out.println(a >= 3200 ? s : "red");
    }
}

Measured memory_bytes: 21076
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=sorted([s+t for s in a for t in b])[-1:-k-1:-1]
abc=sorted([s+t for s in ab for t in c])[-1:-k-1:-1]
for i in range(k):
    print(abc[i])

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int K, N;
	cin >> K >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = a[N - 1] - a[0];
	for (int i = 0; i < N - 1; i++) {
		ans = min(a[i] + K - a[i + 1], ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 123456;
char T[MAXN];

int main() {
    int N, K, R, S, P;
    scanf("%d %d", &N, &K);
    scanf("%d %d %d", &R, &S, &P);
    scanf("%s", T);
    int ans = 0;
    for (int rd = 0; rd < K; rd++) {
        int r = 0, s = 0, p = 0;
        for (int i = rd; i < N; i += K) {
            int np, ns, nr;
            if (T[i] == 'r') {
                np = max(r, s) + P;
                ns = max(p, r);
                nr = max(p, s);
            } else if (T[i] == 's') {
                nr = max(p, s) + R;
                np = max(r, s);
                ns = max(p, s);
            } else {
                ns = max(r, p) + S;
                np = max(s, r);
                nr = max(p, s);
            }
            r = nr, p = np, s = ns;
        }
        ans += max({r, s, p});
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

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

    
    for (int i=0;i<S.size();i++) {
        if (S[i] + N > 'Z') {
            cout << (char)(S[i] - (26-N)); 
        } else {
            cout << (char)(S[i] + N);
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> a(N);
  for (auto& ai: a) scanf("%d", &ai);

  int res = 1e9;
  for (int t = -100; t <= 100; ++t) {
    int cur = 0;
    for (auto ai: a)
      cur += (ai-t) * (ai-t);
    res = std::min(res, cur);
  }
  printf("%d\n", res);
}

Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'

ll arr[20][20];
int n;
ll dp[(1<<17)];
ll dp1[(1<<17)];
ll val(int m){
	ll &s=dp1[m];
	if(~s)return s;
	s=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(m&(1<<i) && m&(1<<j)){
				s+=arr[i][j];
			}
		}
	}return s;
}

ll f(int m){
	if(m==0)return 0;
	ll &ma=dp[m];
	if(~ma)return ma;
	ma=0;
	for (int s=m; s; s=(s-1)&m){
		ma=max(ma,val(s)+f(m^s));
	}return ma;
}
//resub
int main()
{
	fast;
	memset(dp,-1,sizeof dp);
	memset(dp1,-1,sizeof dp1);
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>arr[i][j];
		}
	}cout<<f((1<<n)-1)<<endl;
	return 0;
}

Measured memory_bytes: 5696
x, n = map(int, input().split())
lists = list(input().split())
for i in range(n):
  lists[i] = int(lists[i])
loop = True
number = x
while True:
  if number in lists:
    number = number - 1
  else:
    break
number_2 = x
while True:
  if number_2 in lists:
    number_2 = number_2 + 1
  else:
    break
if abs(number - x) > abs(number_2 - x):
  print(number_2)
elif abs(number - x) == abs(number_2 - x):
  print(number)
else:
  print(number)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main() {
  int N;
  cin>>N; 
  bool ans=true;
  vector<int>t(N);
  vector<int>x(N);
  vector<int>y(N);
  for(int i=0; i<N;i++){
    cin>>t.at(i)>>x.at(i)>>y.at(i);
  }
  rep(i,N){
    if(t.at(i)%2!=(x.at(i)+y.at(i))%2){
      ans=false;
      break;
    }
  }
  int dist=x.at(0)+y.at(0);
  if(ans){
    if(t.at(0)<dist){
      ans=false;
    }
    rep2(i,1,N){
      dist+=abs(x.at(i)-x.at(i-1))+abs(y.at(i)-y.at(i-1));
      if(t.at(i)<dist){
        ans=false;
        break;
      }
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}

Measured memory_bytes: 1408
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	if((a!=b||b!=c||c!=a)&&(a==b||b==c||c==a))printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll h, w; cin >> h >> w;
    vector<vector<ll>> a(h, vector<ll>(w));
    REP(i, h) REP(j, w) {
        cin >> a[i][j];
    }

    vector<tuple<ll, ll, ll, ll>> ops;
    ll iprev = -1, jprev = -1;
    REP(i, h) {
        REP(_j, w) {
            ll j = i % 2 ? w - _j - 1 : _j;
            if (iprev != -1) {
                if (a[iprev][jprev] % 2) {
                    ops.emplace_back(iprev, jprev, i, j);
                    a[iprev][jprev]--;
                    a[i][j]++;
                }
            }
            iprev = i;
            jprev = j;
        }
    }

    cout << ops.size() << endl;
    REP(i, ops.size()) {
        ll y1, x1, y2, x2;
        tie(y1, x1, y2, x2) = ops[i];
        cout << y1+1 << " " << x1+1 << " ";
        cout << y2+1 << " " << x2+1 << endl;
    }

}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 100005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

int main()
{
    int n ;
    scanf("%d",&n) ;

    printf("%d\n" , (n-1)/2 ) ;

    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h[10000];
	int n, m, i, sum=0;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d", &h[i]);
		sum += h[i];
	}
	if (sum > n)
		printf("%d\n", -1);
	else
		printf("%d\n", n - sum);
	return 0;
}

Measured memory_bytes: 1724
//# define FLAG
///delet....................................
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <cstdio>
# include <cmath>
# include <ctime>
# include <set>
# include <map>
# include <queue>
# include <stack>
# include <vector>
# include <fstream>
# include <algorithm>
using namespace std;
# define eps 1e-8
# define pb push_back
# define pi acos(-1.0)
# define bug puts("H")
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false)
# define FO(i,n,a) for(int i=n; i>=a; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define INF 0x3f3f3f3f
# define MOD 1000000007
///           123456789
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef unsigned long long ULL;
typedef long long LL;
inline LL Scan(){
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
///coding...................................

int a[10005],b[105][105];

int main()
{
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif /// FLAG
    int h,w,n,t;
    cin>>h>>w>>n;
    int ans=0;
    FOR(i,1,n) {
        cin>>t;
        FOR(j,1,t)a[++ans]=i;
    }
    //FOR(i,1,ans)cout<<a[i]<<' ';
    ans=0;
    FOR(i,1,h) {
        if(i%2)
            FOR(j,1,w)b[i][j]=a[++ans];
        else
            FO(j,w,1)b[i][j]=a[++ans];
    }
    FOR(i,1,h) {
        FOR(j,1,w) {
            printf(j==1?"%d":" %d",b[i][j]);
        }
        puts("");
    }
    return 0;
}
///delete # define FLAG......................




















Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TEMPAtCoder2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = System.Console.ReadLine();
            string[] s1 = s.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            int A = int.Parse(s1[0]);
            int B = int.Parse(s1[1]);

            int acta = A > B ? A : B;
            int actb = A > B ? B : A;

            int resultint = acta == actb ? acta + actb : acta + acta - 1;

            System.Console.WriteLine(resultint);               
                            

        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int x;
	cin >> x;
	vector<int> items;
	int price = 100;
	rep(i, 6) items.push_back(price + i);
	rep(bit, 1 << 6) {
		int total = 0;
		rep(i, 6) {
			if (bit >> i & 1) {
				total += items[i];
			}
		}
		if (total && ((x % total == 0) || (x % total >= 100 && x % total <= 105))) {
			cout << 1 << endl;
			return;
		}
	}
	cout << 0 << endl;
}

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

	solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int h[101000],nxt[201000],K=0,to[201000];int fa[101000];
bool used[101000];int in[101000];
int q[1010000],H=0,T=0;
void ins(int u,int v){nxt[++K]=h[u];h[u]=K;to[K]=v;}
void dfs(int x,int f)
{
	fa[x]=f;
	for(int i=h[x];i;i=nxt[i])if(to[i]!=f)dfs(to[i],x);
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		ins(u,v);ins(v,u);
	}
	dfs(1,0);used[0]=1;
	for(int i=1;i<=n;i++)in[fa[i]]++;
	for(int i=1;i<=n;i++)
	{
		if(in[i]==0)q[T++]=i;
	}
	bool ok=0;
	while(H<T)
	{
		int u=q[H++];if(used[u])continue;used[u]=1;
		if(used[fa[u]]){ok=1;break;}
		used[fa[u]]=1;in[fa[fa[u]]]--;
		if(!used[fa[fa[u]]]&&in[fa[fa[u]]]==0)q[T++]=fa[fa[u]];
	}
	if(ok)puts("First");else puts("Second");
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
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; }
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if(n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
  ll N,M;
  cin >> N >> M;
  COMinit();
  auto vec = prime_factorize(M);

  ll ans = 1;
  for(auto v: vec){
    int num = v.second;
    ll ret = COM(num+N-1,N-1);
    ans = ans*ret % MOD;
  }

  cout << ans << endl;



  return 0;
}


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

#define int long long
#define vc vector<char>
#define vi vector<int>
#define vs vector<string>
#define si set<int>
#define pii pair<int,int>
#define SORT(c) sort(c.begin(),c.end())
#define SORTC(c, cmp) sort(c.begin(),c.end(),cmp)
#define mapii map<int,int>
#define pb push_back
#define F first
#define S second
#define rep(i, j, k) for (int i=j;i<k;i++)
#define repb(i, j, k) for (int i=j;i>=k;i--)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ar array

using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0)

const int mxN = 1e7;
int n;
int cnt[mxN + 1];

void solve() {
    cin >> n;
    rep(i, 1, n + 1) {
        for (int j = 0; (j += i) <= n;) {
            cnt[j]++;
        }
    }
    int ans = 0;
    rep(i, 1, n + 1) {
        ans += i * cnt[i];
    }
    cout << ans;

}


int32_t main() {
    fast;

    int tt{1};
//    cin >> tt;
    while (tt--) {
        solve();
        cout << endl;
    }
    return 0;

}

Measured memory_bytes: 81764
b=0
for e in iter(input,'0 0'):
 if b:print()
 b=u=1
 s,t=map(int,e.split())
 for y in range(s,t+1):
  if y%4==0 and y%100!=0 or y%400==0:print(y);u=0
 if u:print('NA')


Measured memory_bytes: 5720
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }

  ll upnum = 0, up = 0;
  for (int i = 0; i < n; i++){
    if (a[i] < b[i]){
      up += b[i] - a[i];
      upnum++;
    }
  }
  vector<ll> amari(0);
  for (int i = 0; i < n; i++){
    if (a[i] > b[i]){
      amari.emplace_back(a[i] - b[i]);
    }
  }
  sort(amari.begin(), amari.end());

  
  for (int i = 0; i < amari.size(); i++){
    if (up <= 0)
      break;
    upnum++;
    up -= amari[amari.size()-i-1];
  }

  if (up <= 0)
    cout << upnum << endl;
  else
    cout << -1 << endl;
  
  
  
  
  
  
  

  return 0;
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B;
	cin >> A >> B;

	if (B % A == 0) co(A + B);
	else co(B - A);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <regex>
#include <utility> // pair
#include <algorithm> // swap
#include <numeric> // accumulate
#include <cmath> // pow
#include <iomanip> // setprecision
using namespace std;

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()

int sign(int p, int bit) {
  return ((p>>bit)&1) == 1 ? 1 : -1;
}

signed main() {
  string str;
  cin >> str;
  vector<int> ns;
  for(char s : str) ns.push_back(s - '0');
  int ps = 1 << 3;
  rep(p, ps) {
    if(ns[0] + sign(p,0)*ns[1] + sign(p,1)*ns[2] + sign(p,2)*ns[3] == 7) {
      cout << ns[0] << (sign(p,0)==1?'+':'-') << ns[1] << (sign(p,1)==1?'+':'-') << ns[2] << (sign(p,2)==1?'+':'-') << ns[3] << "=7" << endl;
      exit(0);
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool sob(pair<ll,ll> x1,pair<ll,ll> x2){return x1.second< x2.second;};
int main(){
  ll n;
  cin >>n;
  vector <pair<ll,ll>> q;
  ll x[n],y[n];
  for(ll i=0;i<n;i++) {
    cin >>x[i]>>y[i];
  }
  if(n==1){
    cout <<1<<endl;
    return 0;
  }
     for(ll i=0;i<n;i++){
      for(ll j=0;j<n;j++){
       if(i==j) continue;
       if ((x[i]-x[j])!=0||(y[i]-y[j])!= 0){
       q.push_back(make_pair(x[i]-x[j],y[i]-y[j]));
       }
      }
    }
    ll qs=q.size(),ans=1000;
    for(ll i=0;i<qs;i++){
      ll sum=0;
      for(ll j=0;j<n;j++){
        for(ll k=0;k<n;k++){
          if(x[j]+q[i].first==x[k]&&y[j]+q[i].second==y[k]) sum++;
        }
      }
      ans=min(n-sum,ans);
    }
    cout <<ans<<endl;
}


Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        let y = max!($($z),*);
        if $x > y {
            $x
        } else {
            y
        }
    }}
}
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        let y = min!($($z),*);
        if $x < y {
            $x
        } else {
            y
        }
    }}
}
#[derive(Debug)]
pub struct Test {

}

impl Test {
    pub fn new(param: ()) -> Test {
        Test {
        }
    }

    fn solve(&mut self) -> usize {
        0
    }
}
fn main() {
    input! {
        N: usize,
        M: usize,
        LR: [(usize, usize); M],
    };
    
    let mut left = 1;
    let mut right = N;

    for i in 0..M {
        if left < LR[i].0 {
            left = LR[i].0;
        }
        if LR[i].1 < right {
            right = LR[i].1;
        }
    }
    
    if let Some(res) = right.checked_sub(left) {
        println!("{}", res + 1);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 6396
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a,Collections.reverseOrder());
        int alice = 0;
        int bob = 0;
        for(int i = 0 ;i<n;i++){
            if(i%2==0){
                alice += a[i];
            } else {
                bob += a[i];
            }
        }
        System.out.println(alice-bob);
    }
}

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

using ll = long long;
const int INF = 1e9+7;

void solve(){
	int n,ans=0;cin >> n;
	//vector<int> hash(n);
	for(int i = 1;i<=n;++i){
		int x;cin >> x;
		if(i%2 && x%2)
			ans++;
	}
	cout << ans << '\n';
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int t=1;
//	int t;cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
//#define mod 987654321
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 2000025

int num;

int cal(ll x, ll k){
	if(x < k) return 0;
	if(x % k == 0) return x / k;
	int u = x / k + 1;
	if(u >= k) return cal(x - u, k);
	int A = x % k;
	if(A % u == 0) return cal(x - A, k);
	else return cal(x - (A/u + 1) * u, k);
}

int main() {

//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll res = 0;
	cin >> num;
	Rep(run, num){
		ll x, k;
		cin >> x >> k;
//		cout << cal(x, k) << endl;
		res ^= cal(x, k);
	}

	if(!res) cout << "Aoki" << endl;
	else cout << "Takahashi" << endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[110],sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	if(sum%10==0){
		for(int i=0;i<n;i++){
			if(a[i]%10){
				cout<<sum-a[i]<<endl;
				return 0;
			}
		}
		cout<<0<<endl;
	}else{
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<sstream>
#include<string>
using namespace std;
#define ll long long
#define N 300010

int main()
{
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a>k)printf(":(");
    else
        printf("Yay!");
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	int arr[N];
	for (int i = 0; i < N; i++) {
		cin >> arr[i];
		--arr[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (arr[arr[i]] == i) {
			++ans;
		}
	}
	cout << (ans >> 1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) cin >> a[i];
  vector<vector<mint>> dp(n + 1, vector<mint>(s + 3010, 0));
  rep(i, n + 1) dp[i][0] = 1;
  rep(i, n) rep(j, s + 1) {
    dp[i + 1][j] += dp[i][j];
    dp[i + 1][j + a[i]] += dp[i][j];
  }
  mint ans = 0;
  rep(i, n + 1) ans += dp[i][s];
  cout << ans.x << endl;
}

Measured memory_bytes: 141312
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,n;
    cin >>n;
    ll a,b,c;
    cin >>a>>b;
    for(int i=2;i<n;i++){
        cin >>c;
        if ((a<b&&b<c)||(c<b&&b<a))ans++;
        a=b;
        b=c;
    }


    dbg{
        if(true)cout <<"YES"<<endl;
        else cout <<"NO"<<endl;
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
import math
a, b, x = map(float, input().split())
h = b*math.sin(math.radians(x))
S = a*h/2
L = a + b + math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(x)))

print(S)
print(L)
print(h)



Measured memory_bytes: 5692
import sys
import numpy as np

cin = sys.stdin
# cin = open("in.txt", "r")

N, = map(int, cin.readline().split())
cnt = np.zeros((N, 26), int)
s = []
for i in range(N):
    si = cin.readline().strip()
    for ch in si:
        cnt[i][ord(ch)-ord('a')] += 1

total = np.min(cnt, axis=0)
for i,c in enumerate(total):
    print(chr(ord('a')+i)*c, end='')
print()


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

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> a(n), b(n); rep(i, n) cin >> a[i] >> b[i];

	vector<pair<ll, int>> v(n);
	rep(i, n) v[i] = make_pair(a[i], b[i]);
	sort(v.begin(), v.end());

	ll ans = 0;
	int cnt = m;
	rep(i, n) {
		int num = min(v[i].second, cnt);
		cnt -= num;
		ans += v[i].first * num;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
    int a, b, q, i;
    long int l, *l1, *l2, *l3, *l4;
    cin >> a >> b >> q;
    long int s[a], t[b], x[q];
    for(i=0; i<a; i++){
        cin >> s[i];
    }
    for(i=0; i<b; i++){
        cin >> t[i];
    }
    for(i=0; i<q; i++){
        cin >> x[i];
    }
    for(i=0; i<q; i++){
        l1 = lower_bound(s, s+a, x[i]);
        l2 = lower_bound(t, t+b, x[i]);
        l3 = l1-1;
        l4 = l2-1;
        if(l1 == s+a){
            *l1 = 99999999999;
        }
        if(l2 == t+b){
            *l2 = 99999999999;
        }
        if(l3 + 1 == s){
            *l3 = -999999999999;
        }
        if(l4 + 1 == t){
            *l4 = -999999999999;
        }
        l = min(min(max(*l1,*l2)-x[i],x[i]-min(*l3,*l4)),min(min(*l1-x[i],x[i]-*l4)*2+max(*l1-x[i],x[i]-*l4),min(*l2-x[i],x[i]-*l3)*2+max(*l2-x[i],x[i]-*l3)));
        cout << l << '\n';
    }
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;

int main() {
  int n;
  scanf("%d", &n);

  long long maxx = 1;
  long long const_single = 1;

  for (int i=0;i<18;++i)
    maxx = maxx * 10;

  for (int i=0;i<9;++i)
    const_single = const_single * 10;

  long long a = 0, b = 0, c = 1; 
  
  long long x;

  vector<long long> values(n);

  for (int i=0;i<n;++i) {
    scanf("%lld", &values[i]);

    if (values[i] == 0) {
      printf("0");
      return 0;
    }
  }

  for (int i=0;i<n;++i) {
    x = values[i];

    if (a >= 1) {
      printf("-1");
      return 0;
    }

    long long d = x / const_single;
    long long e = x % const_single;
    
    a = d * b;
    b = c * d + b * e;
    c = c * e;
    
    b += c / const_single;
    c %= const_single;

    a += b / const_single;
    b %= const_single;

    if (a >= 1 && (b != 0 || c != 0)) {
      printf("-1");
      return 0;
    }
  }

  printf("%lld", a * const_single * const_single + b * const_single + c);

  return 0;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    ll a, b, n;
    cin >> a >> b >> n;

    ll x = n < b ? n : b - 1;
    ll u = a * x / b;
    ll v = x / b * a;

    cout << u - v << endl;

}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
	ios_base::sync_with_stdio(false);

	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if(k % 2 == 0) {
		cout << a - b << '\n';
	}
	else {
		cout << b - a << '\n';
	}

	return 0;
}


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

class Vector2{
public:
	Vector2(){}
	Vector2( double aX, double aY ) : x( aX ), y( aY ){}

	double cross( Vector2& a ){
		return ( x * a.y ) - ( y * a.x );
	}

	double x;
	double y;
};

int main(){
	Vector2 p0, p1, p2, q;

	while ( cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> q.x >> q.y ){
		bool isInner = false;
		Vector2 ab( p1.x - p0.x, p1.y - p0.y );
		Vector2 bc( p2.x - p1.x, p2.y - p1.y );
		Vector2 ca( p0.x - p2.x, p0.y - p2.y );
		Vector2 ap( q.x - p0.x, q.y - p0.y );
		Vector2 bp( q.x - p1.x, q.y - p1.y );
		Vector2 cp( q.x - p2.x, q.y - p2.y );

		if( ( (ab.cross( ap ) > 0 ) && (bc.cross( bp ) > 0 ) && (ca.cross( cp ) > 0 ) ) ||
			( (ab.cross( ap ) < 0 ) && (bc.cross( bp ) < 0 ) && (ca.cross( cp ) < 0 ) ) ){
			isInner = true;
		}

		cout << ( isInner ? "YES" : "NO" ) << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <vector>

int main(){
  int i,x;
  std::vector<int>v;
  for(i=0;i<10;i++)scanf("%d",&x),v.push_back(x);
  std::sort(v.begin(),v.end());
  printf("%d\n%d\n%d\n",v[9],v[8],v[7]);
}

Measured memory_bytes: 0
include Math
n=gets.to_i
l=[0]
n.times{|i|l=l.flat_map{|v|[v,v+1,v-1,v]}}
x=y=0.0
puts"0 0"
r=100.0/3**n
l.map{|i|x+=r*cos(i*PI/3)
y+=r*sin(i*PI/3)
puts"%f %f"%[x,y]}

Measured memory_bytes: 6284
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,pair<ll,pair<ll,ll> > > CAKE;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    ll X,Y,Z,K; cin>>X>>Y>>Z>>K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    rep(i,X) cin>>A[i];
    rep(i,Y) cin>>B[i];
    rep(i,Z) cin>>C[i];
    sort(all(A),greater<ll>());
    sort(all(B),greater<ll>());
    sort(all(C),greater<ll>());
    priority_queue<CAKE> que;
    //CAKE: a b.a b.b.a b.b.b
    que.push( mp(A[0]+B[0]+C[0],mp(0,mp(0,0))) );
    set<pair<ll,pair<ll,ll> > > se;
    ll i=0;
    while(i<K){
        ll c=que.top().a; cout<<c<<endl;
        ll AA=que.top().b.a,BB=que.top().b.b.a,CC=que.top().b.b.b;
        que.pop();
        if(AA+1<X && BB<Y && CC<Z && se.find( mp(AA+1,mp(BB,CC)) )==se.ed){
            que.push( mp(A[AA+1]+B[BB]+C[CC],mp(AA+1,mp(BB,CC))) );
            se.insert(mp(AA+1,mp(BB,CC)));
        }
        if(AA<X && BB+1<Y && CC<Z && se.find( mp(AA,mp(BB+1,CC)) )==se.ed){
            que.push( mp(A[AA]+B[BB+1]+C[CC],mp(AA,mp(BB+1,CC))) );
            se.insert(mp(AA,mp(BB+1,CC)));
        }
        if(AA<X && BB<Y && CC+1<Z && se.find( mp(AA,mp(BB,CC+1)) )==se.ed){
            que.push( mp(A[AA]+B[BB]+C[CC+1],mp(AA,mp(BB,CC+1))) );
            se.insert(mp(AA,mp(BB,CC+1)));
        }
        i++;
    }
}



Measured memory_bytes: 4028
N,M = map(int,input().split())
p_s = [tuple(input().split()) for _ in range(M)]

wa_total = [0]*N
wa_count = [0]*N 
ac_flg = [False]*N

for p,s in p_s:
    p = int(p)-1
    if not ac_flg[p]:
        if s == 'AC':
            ac_flg[p] = True
            wa_count[p] = wa_total[p]
        else:
            wa_total[p] += 1

print(ac_flg.count(True),sum(wa_count))

Measured memory_bytes: 23648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int64_t x;
    cin>>x;
    int64_t a=0,b=0;
    for(int i=-1000;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            if(pow(i,5)-pow(j,5)==x){
                a=i;
                b=j;
                break;
            }
        }
    }
    cout<<a<<" "<<b<<endl;
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  string s(a, '0' + b);
  string t(b, '0' + a);
  cout << min(s, t) << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner		scan	=	new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();



		scan.close();

		if((a + b) % 2 == 0) {
			int k = (a + b) / 2;
			System.out.println(k);
		} else {
			System.out.println("IMPOSSIBLE");
		}

		scan.close();

	}


}

Measured memory_bytes: 21844
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Map<String, Integer> map = new HashMap<>();
		
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			if (!map.containsKey(s)) map.put(s, 0);
			map.put(s, map.get(s) + 1);
		}
		
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			String t = sc.next();
			if (!map.containsKey(t)) map.put(t, 0);
			map.put(t, map.get(t) - 1);
		}
		
		int max = 0;
		for (String key : map.keySet())
			max = Math.max(max, map.get(key));
		
		System.out.println(max);
		
		sc.close();
	}
}




Measured memory_bytes: 27156
<?php

    // AtCoder Beginner Contest 163
    // A - Circle Pond

    $r = in_int();
    out(round($r * 2 * pi(), 4));

    // -----------------------------------------------------
    function in() { return trim(fgets(STDIN)); }
    function in_int() { return (int)in(); }
    function in_vals() { return explode(' ', in()); }
    function in_ints() { return array_map('intval', in_vals()); }
    function out($s) { echo $s . PHP_EOL; }
    function yes() { out('Yes'); }
    function no() { out('No'); }


Measured memory_bytes: 16148