akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
#define deb(x) cerr << "\n" << (#x) << " is " << (x) << endl
int mod=998244353;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}
auto random_add = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_add() | 1);
mt19937_64 rng(SEED);


const int N=1e6+5;
int bit[N]={0};


void add(int node,int x)
{
  x%=mod;
  for(;node<N;node+=(node&(-node))){
    bit[node]+=x;
    if(bit[node]>=mod)
      bit[node]-=mod;
  }
}

int get(int node)
{
  int x=0;
  for(;node>0;node-=(node&(-node))){
    x+=bit[node];
    if(x>=mod)
      x-=mod;
  }
  return x;
}


void solve()
{
  int n,k;
  cin>>n>>k;
  int a[k+1][2];
  for(int i=1;i<=k;i++)
  {
    cin>>a[i][0]>>a[i][1];
  }
  int dp[n+1]={0};
  dp[n]=1;
  add(n,1);

  for(int i=n-1;i>=1;i--)
  {
    for(int j=1;j<=k;j++)
    {
      int l=i+a[j][0];
      int r=i+a[j][1];
      if(r<i)
        continue;
      r=min(r,n);
      int x=get(r)-get(l-1);
      if(x<0)
        x+=mod;
      dp[i]+=x;
      if(dp[i]>=mod)
        dp[i]-=mod;
    }
 //   cout<<dp[i]<<endl;
    add(i,dp[i]);
  }
  cout<<dp[1]<<endl;

}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
// cin>>t;
 for(int i=1;i<=t;i++)
 {
   solve();
 }
}


Measured memory_bytes: 6752
#include <stdio.h>

int main(){
	int a, b, s1, s2, s3;
	scanf("%i %i", &a, &b);
	s1=a+b;
	s2=a-b;
	s3=a*b;
	if(s1>=s2 && s1>=s3)
		printf("%i\n", s1);
	else if(s2>=s1 && s2>=s3)
		printf("%i\n", s2);
	else
		printf("%i\n", s3);	
}


Measured memory_bytes: 128
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

int main() {
  using std::string;
  int ans;
  char op = '\0';
  string s;
  while (1) {
    if (s[0] == '=') break;
    std::cin >> s;
    if (std::all_of(s.cbegin(), s.cend(), isdigit)) {
      if (op == '\0')
        ans = stoi(s);
      else
        switch (op) {
          case '+':
            ans += stoi(s);
            continue;
          case '-':
            ans -= stoi(s);
            continue;
          case '*':
            ans *= stoi(s);
            continue;
          case '/':
            ans /= stoi(s);
            continue;
          defalut:
            break;
        }
    } else
      op = s[0];
  }
  std::cout << ans << std::endl;

  return 0;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    string s, t;
    cin >> N;
    cin >> s >> t;

    ll cnt, m = 0;
    REP(i,0,N) {
        cnt = 0;
        REP(j,0,N-i) {
            if(s[i+j] == t[j]) {
                ++cnt;      
            }
            else break;
        }
        m = MAX(m,cnt);
    }
    PR(N*2-m);

    return 0;
}

/*



*/

Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int dist(pair<int, int> a, pair<int, int> b){
    return abs(a.first - b.first) + abs(a.second - b.second);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    map<int, pair<int, int>> M;
    rep(h, H) rep(w, W) {
        cin >> A[h][w];
        M[A[h][w]] = mp(h, w);
    }
    vector<int> S(H * W + 1, 0);
    rep(i, D + 1, H * W + 1) {
        S[i] = S[i - D] + dist(M[i], M[i - D]);
    }
    int Q;
    cin >> Q;
    rep(i, Q){
        int l, r;
        cin >> l >> r;
        output(S[r] - S[l]);
    }
    
    return 0;
}


Measured memory_bytes: 7424
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char s[100001];
	int i,al[26],x,len;
	scanf("%s",s);
	len=strlen(s);
	for(i=0;i<26;i++)	al[i]=0;
	for(i=0;i<len;i++)	{
		x=s[i]-'a';
//		printf("x=%d\n",x);
		al[x]=1;
	}
	for(i=0;i<26;i++)	{
		if(al[i]==0)	{
			printf("%c\n",i+'a');
			break;
		}
	}
	if(i==26)	printf("None\n");
    return 0;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto e: v) os << e << ",";
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

ll H, N;
ll a[100010];

void solve()
{
    ll s = 0;
    REP (i, N) s += a[i];
    cout << (s >= H ? "Yes" : "No") << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> N;
    REP (i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

int main() {
  int N;
  cin >> N;
  vector<pair<string, int>> ST(N);
  for (int i = 0; i < N; i++) {
    string s;
    int t;
    cin >> s >> t;
    ST.at(i).first = s;
    ST.at(i).second = t;
  }
  string X;
  cin >> X;
  int x;
  for (int i = 0; i < N; i++) {
    if (ST.at(i).first == X) x = i;
  }
  int ans = 0;
  for (int i = x; i < N; i++) {
    ans += ST.at(i).second;
  }
  cout << ans - ST.at(x).second << "\n";
}

Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq

MOD = 1000000007


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    N = get_input(int)
    Ss = set()
    for i in range(N):
        S = get_input()
        Ss.add(S)
    print(len(Ss))


if __name__ == '__main__':
    main()


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

typedef long long ll;
const int N = 3005;
const ll mod = (ll)1e9 + 7;

int n, a, b, c, d;
ll fac[N], facinv[N];
ll inv[N];
ll dp[N][N];

ll fp(ll x, ll k){
    if(k == 0) return 1;
    ll hf = fp(x, k/2);
    return k % 2 ? hf * hf % mod * x % mod: hf * hf % mod;
}

ll comb(int n, int k){
    return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll get(int i, int rem) {
    if(i < a) return rem == 0;
    if(dp[i][rem] != -1) return dp[i][rem];
    dp[i][rem] = 0;
    for(int j = c; j <= min(d, rem / i); j++) {
        dp[i][rem] += get(i - 1, rem - j * i) *
                comb(rem, j * i) % mod * fac[j * i] % mod * fp(facinv[i], j) % mod * facinv[j] % mod;
    }
    dp[i][rem] += get(i - 1, rem);
    dp[i][rem] %= mod;
    return dp[i][rem];
}


int main(){
    inv[1] = 1;
    for(int i = 2; i < N; i++) inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
    fac[0] = 1;
    for(int i = 1; i <= N-1; i++) fac[i] = fac[i-1] * i % mod;
    facinv[N-1] = fp(fac[N-1], mod - 2);
    for(int i = N-1 - 1; i >= 0; i--) facinv[i] = facinv[i+1] * (i+1) % mod;

    memset(dp, -1, sizeof(dp));
    cin >> n >> a >> b >> c >> d;
    cout << get(b, n) << endl;

}


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

int h,w,c;

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

int change(int maps[9][9],int color,int x,int y)
{
  int tmp=maps[x][y];
  maps[x][y]=color;
  int sum=1;
  for(int i=0;i<4;i++)
    {
      if(x+dx[i]>=0 && y+dy[i]>=0 &&
         x+dx[i]<h && y+dy[i]<w &&
         tmp==maps[x+dx[i]][y+dy[i]])
        {
          sum+=change(maps,color,x+dx[i],y+dy[i]);
        }
    }
  return sum;
}


int check(int maps[9][9],int cnt)
{
  /*
  if(cnt==0&& maps[0][0]==c)
    {
  cerr<<"------"<<endl<<"cnt  "<<cnt<<endl;
  for(int i=0;i<h;i++,cerr<<endl)
        for(int j=0;j<w;j++)
          {
            cerr<<maps[i][j]<<" ";
          }
  cerr<<"------"<<endl;
    }
  */
  if(cnt<=0)
    {
      if(maps[0][0]!=c)
        return 0;
      else
        return change(maps,9,0,0);
    }
  int ans=0;
  for(int cc=1;cc<=6;cc++)
    {
      if(maps[0][0]!=cc)
        {
          int tmp[9][9];
          for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
              tmp[i][j]=maps[i][j];
          change(tmp,cc,0,0);
          ans=max(ans,check(tmp,cnt-1));
        }
    }
  return ans;

}


int main()
{

  for(;cin>>h>>w>>c,h;)
    {
      int maps[9][9];
      memset(maps,-1,sizeof(maps));
      for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
          {
            cin>>maps[i][j];
          }
      cout<<check(maps,5)<<endl;

    }

}

Measured memory_bytes: 1164
#include <cstdio>
#include <iostream>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll;
//const int maxn = 2e5 + 10;

int main(){
	int n;cin>>n;
	if(n%2==0) cout<<n/2-1<<endl;
	else cout<<n/2<<endl;
}

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

int main() {
  	int N, K;
  	cin >> N >> K;
  
  	if ((N - 1) % (K - 1) == 0) cout << (N - 1) / (K - 1) << endl;
  	else cout << (N - 1) / (K - 1) + 1<< endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define array(N,t) (t*)calloc(N,sizeof(t))
typedef long long LL;
const int sz=1<<22;
inline char CH(void)
{
  static char buf[sz],*s1=buf,*s2=buf;
  return s1==s2&&(s2=(s1=buf)+fread(buf,1,sz,stdin),s1==s2)?EOF:*s1++;
}
inline LL IN(void)
{
  LL x=0;short f=0,c=CH();
  while(c<'0'||c>'9')f^=c=='-',c=CH();
  while(c>='0'&&c<='9')x=x*10+c-48,c=CH();
  return f?-x:x;
}
signed main(void)
{
  int N,i,j,p;LL K;
  N=IN(),K=IN();
  int *A=array(N,int),*town=array(N,int);
  for(i=0;i<N;i++)A[i]=IN(),town[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(town[i]<0)town[i]=j;else break;
  for(p=0;K>0;p=A[p]-1,K--)if(i==p){K%=town[i]-j;if(!K)break;}
  free(A),free(town);
  return printf("%d\n",p+1),0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<long long int> A(N + 1);
  vector<long long int> B(N);
  rep(i, N + 1)
  {
    cin >> A[i];
  }
  rep(i, N)
  {
    cin >> B[i];
  }

  //Aそれぞれが10^9までなので
  //これのsumはintに収まらないことに注意！
  long ans = 0;
  for (int i = 0; i < N; i++)
  {
    //まずは左を全力で倒す
    int left = min(A[i], B[i]);
    ans += left;
    A[i] -= left;
    B[i] -= left;

    //残った戦力で右を全力で倒す
    int right = min(A[i + 1], B[i]);
    ans += right;
    A[i + 1] -= right;
    B[i] -= right;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[2][N] = {{}};
    int B[N] = {};
    int C[N] = {};
    rep(i, N) cin >> A[0][i];
    rep(i, N) cin >> A[1][i];
    B[0] = A[0][0];
    C[0] = A[1][N-1];
    rep(i, N-1) B[i+1] = B[i] + A[0][i+1];
    rep(i, N-1) C[i+1] = C[i] + A[1][N-i-2];
    int ans = 0;
    rep(i, N) {
        ans = max(ans, B[N-i-1] + C[i]);
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())

alis=list(map(int,input().split()))

a=0
b=0
for i in range(n-1):
    for j in range(n-1-i):
        if alis[i]>alis[i+1+j]:
            a+=1
        elif alis[i]<alis[i+j+1]:
            b+=1

aa=(a*k*(k+1)//2)%(10**9+7)
bb=(b*k*(k-1)//2)%(10**9+7)

ans=(aa+bb)%(10**9+7)
print(int(ans))


Measured memory_bytes: 3188
#include<stdio.h>
int main(void)
{
  int i,j,k;
  int n;
  int b,f,r,v;
  int data[4][3][10];
  for(i=0;i<4;i++)
    for(j=0;j<3;j++)
      for(k=0;k<10;k++)
        data[i][j][k]=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d%d%d",&b,&f,&r,&v);
      data[b-1][f-1][r-1]+=v;
    }
  for(i=0;i<4;i++)
    {
      if(i>0) printf("####################\n");
      for(j=0;j<3;j++)
        {
          for(k=0;k<10;k++) printf(" %d",data[i][j][k]);
          printf("\n");
        }
    }
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
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; }

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int m;
    cin >> m;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    int t = min(n, m);
    rep(i, t){
        if(a[i] < b[i]){
            cout << 1 << endl;
            return 0;
        }else if (a[i] > b[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    if(n < m) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3092
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	long double r;
 	cin>>r;
 	long double a=2.00*r*acos(-1LL);
 	cout<<fixed<<setprecision(12)<<a<<endl;
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

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

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		string s;
		cin>>s;
		int c = 0;
		if(s[0] == 'R') {
			c++;
		}
		if(s[1] == 'R') {
			c++;
		}
		if(s[2] == 'R') {
			c++;
		}
		if(c==2) {
			if(s[1] == 'S') {
				c = 1;
			}
		}
		cout<<c<<"\n";
 	}
 	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<long long> l(n+1,0);

  l[0]=2;
  l[1]=1;
  
  for(int i=2; i<n+1; i++){
    l[i]=l[i-1]+l[i-2];
  }
  
  cout << l[n] << endl;
}

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



int main() {
  int a,b;
  cin >> a>>b;
  cout << a*b-a-b+1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 
 #include <ctype.h> 
 
 
 int main(){ 
     char ch; 
     while(1){ 
         scanf("%c", &ch); 
         if(ch=='\n'){ 
             printf("\n"); 
             break; 
         }else if(islower(ch)){ 
             printf("%c", toupper(ch)); 
         }else if(isupper(ch)){ 
             printf("%c", tolower(ch)); 
         }else{ 
             printf("%c", ch); 
         } 
     } 
 
 
     return 0; 
 } 



Measured memory_bytes: 2100
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 100011
#define inf 1000000000000000
#define ll long long
#define endl '\n'
ll dp[2][MAX],w;
int v[MAX],c[MAX];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n>>w;
	for(int i =0 ; i < n  ;i ++)cin>>c[i]>>v[i];
	
	for(int i = 0 ; i < MAX; i++)dp[0][i] = inf,dp[1][i] = inf;
	dp[0][v[0]] = c[0];

	for(int i = 1; i < n ; i++){
		dp[1][v[i]] = c[i];
		for(int j = 1 ; j + v[i] < MAX ; j++){
			if(dp[0][j] != inf)
				dp[1][j + v[i]] = min(dp[0][j] + c[i] , dp[0][j + v[i]]);
		}
		for(int j = 1; j < MAX; j ++)dp[0][j] = min(dp[0][j],dp[1][j]);
	}
	int ans = 0;
	for(int j = 1; j < MAX; j++)if(dp[0][j] <= w)ans = max(ans,j);
	if(ans != MAX)cout<<ans;
	else cout<<0;
	return 0; 
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
int main() { 
    fastIO;
     int t=1  ;
     //cin>>t;
     while(t--){
 int n;
 cin >>n;
 int a[n],b[n],c[n];
 for(int i=0;i<n;i++)
 cin>>a[i]>>b[i]>>c[i];
 vector<vector<int>> dp(n+1,vector<int>(3,0));
 for(int i=n-1;i>=0;i--)
 { for(int j=0;j<3;j++)
 { for(int j1=0;j1<3;j1++)
{ if(j!=j1)
   {if(j==0)
   dp[i][j]=max(dp[i][j],a[i]+dp[i+1][j1]);
   else if(j==1)
   dp[i][j]=max(dp[i][j],b[i]+dp[i+1][j1]);
   else
   dp[i][j]=max(dp[i][j],c[i]+dp[i+1][j1]);
   }
}}
 }
int ans=max({ dp[0][0],dp[0][1],dp[0][2]});
cout<<ans<<endl;
          }
	return 0;
}


Measured memory_bytes: 9780
// problem: "https://atcoder.jp/contests/abc155/tasks/abc155_a"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    if(a == b && a != c)
        cout<<"Yes";

    else if(a == c && a != b)
        cout<<"Yes";

    else if(b == c && b != a)
        cout<<"Yes";

    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 256
a, b, c, = map(int,input().split())
if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
elif c <= b <= a:
    print(c, b, a)


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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	str st,s;
	cin >> k >> st;
	if(st.size()<=k)
		s=st;
	else
	{
		for(i=0;i<k;i++)
		{
			s+=st[i];
		}
		s+='.';
		s+='.';
		s+='.';
	}
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();

        int x = n % 1000;

        if (x==0) {
            System.out.println(0);
        } else {
            System.out.println(1000 - x);
        }
    }


}

Measured memory_bytes: 35520
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    pair<int,int>p[x];
    for (int i=0;i<x;i++){
        cin>>p[i].first;
        p[i].second=i+1;
    }
    sort(p,p+x);
    for (int i=0;i<x;i++){
        cout<<p[i].second<<" ";
    }
    return 0;
}


Measured memory_bytes: 1664
s = input()
lst = [0]

for i in range(len(s)):

    if s[i] in 'ACGT':
        tmp = 0
        for j in range(len(s)-i):
            if s[i+j] in 'ACGT':
                tmp += 1
            else:
                break

            lst.append(tmp)


print(max(lst))

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    Map<Integer, Integer> map = new HashMap<>();

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        char[] arr = sc.next().toCharArray();

        if ((arr[0]==arr[1] && arr[1]==arr[2]) || (arr[1]==arr[2] && arr[2]==arr[3])) System.out.println("Yes\n");
        else System.out.println("No");
    }

}


Measured memory_bytes: 25172
#include <iostream>
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define all(collection) (collection).begin(), (collection).end()
#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)

int mp = 0;


int main()
{
	int n; cin >> n;
	vector<pair<string, string>> s(n);
	
	loop(i, n)
	{
		cin >> get<0>(s[i]);
		cin >> get<1>(s[i]);
	}

	double sum = 0;
	for (const auto & e : s)
	{
		if (get<1>(e) == "JPY")
		{
			sum += stod(get<0>(e));
		}
		else {
			sum += (stod(get<0>(e)) * 380000.0);
		}
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
a,b,c,d=map(int,input().split())
E=b//c-(a-1)//c
F=b//d-(a-1)//d
LCM=c*d//gcd(c,d)
G=b//LCM-(a-1)//LCM
print((b-a+1)-(E+F-G))


Measured memory_bytes: 5048
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N, K = MI()
    S = []
    mod = 998244353
    for i in range(K):
        l, r = MI()
        S.append((l, r))
    dp = [0] * (N+1)
    dp[1] = 1
    C = [0] * (N+1)
    C[1] = 1
    for i in range(2, N+1):
        for s in S:
            l = max(1, i - s[1])
            r = i - s[0]
            if r < 1:
                continue
            dp[i] += (C[r] - C[l-1]) % mod
        C[i] += (dp[i] + C[i-1]) % mod
    print(dp[N] % mod)
            
if __name__ == '__main__':
    solve()



Measured memory_bytes: 26980
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
N=int(input())
L=[int(input()) for _ in range(N)]
print(lcm_list(L))

Measured memory_bytes: 5076
#include<stdio.h>
#include<stdlib.h>

int main(){
	int n;
	int i;
	int j;
	int *A;
	scanf("%d", &n);
	A = (int*) malloc(sizeof(int) * n);
	for(i=0;i<n;++i)scanf("%d", &A[i]);
	for(j=0;j<n;++j){
		int d = A[j];
		i = j - 1;
		while(i>=0&&A[i]>d){
			A[i+1] = A[i];
			--i;
		}
		A[i+1] = d;
		for(i=0;i<n;++i){
			if(i)printf(" ");
			printf("%d", A[i]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int N,M;
	cin>>N>>M;
	DBG("","","","");
	cout<<(N*(N-1)/2+M*(M-1)/2)<<endl;
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<pair<int,int>> E[101010];
int num[101010];
ll ret;
int C[101010];

pair<int,int> dfs_center(int cur,int pre) {
	pair<int,int> res=make_pair(1<<30,-1);
	int ma=0;
	num[cur]=1;
	
	FORR(r,E[cur]) if(r.first!=pre) {
		res=min(res,dfs_center(r.first,cur));
		ma=max(ma,num[r.first]);
		num[cur]+=num[r.first];
	}
	return min(res,make_pair(max(ma,N-num[cur]),cur));
}

int dfs(int cur,int pre,ll dep) {
	ret+=dep*2;
	C[cur]=1;
	FORR(e,E[cur]) if(e.first!=pre) C[cur]+=dfs(e.first,cur,dep+e.second);
	return C[cur];
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y>>r;
		E[x-1].push_back({y-1,r});
		E[y-1].push_back({x-1,r});
	}
	
	int center=dfs_center(0,-1).second;
	dfs(center,center,0);
	int mi=1LL<<30;
	FORR(e,E[center]) {
		if(C[e.first]*2==N) {
			cout<<ret-e.second<<endl;
			return;
		}
		mi=min(mi,e.second);
	}
	cout<<ret-mi<<endl;
	
	

}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 15872
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from collections import Counter
N = int(input())
As = list(mapint())
Q = int(input())

S = sum(As)
C = Counter(As)
for _ in range(Q):
    b, c = mapint()
    cnt = C[b]
    S += (c-b)*cnt
    C[b] = 0
    C[c] += cnt
    print(S)

Measured memory_bytes: 24008
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n; cin >> n;
	vector<int> v(n), c(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >>c[i];
	}
	for (int i = 0; i < n; i++) {
		//cin >> v[i] >> c[i];
		if (v[i] - c[i] > 0) sum+= v[i] - c[i];
	}
	cout << sum;
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll h1, m1, h2, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	ll t1 = h1*60 + m1;
	ll t2 = h2*60 + m2 -k;
	cout<<t2-t1<<endl;
	return 0;
}


Measured memory_bytes: 27040
import java.util.Scanner;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=1,x=1;
        while(n != 0 || x != 0){
            n = sc.nextInt();
            x = sc.nextInt();
            if(n == 0 && x == 0) break;
            int cnt = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    for(int k=j+1;k<=n;k++){
                        if(i+k+j == x){
                            cnt++;
                        }
                    }
                }
            }
            System.out.printf("%d%n",cnt);
        }
        
        sc.close();
    }
}



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

int main() {
  int n, m, x;
  cin >> n >> m >> x ;
  int a[m-1], i;
  i = 0;
  while (i < m) {
    cin >> a[i];
    i = i+1;}

  int j = 0 ;
  int count = 0;
  while (j < m) {
    if (a[j] < x) {count = count + 1;} 
    j = j+1;
  }
  int co = m-count;
  cout << std::min(count, co) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	string str;
	cin >> str;
	vector<char> v;
	ll num[27] = {};
	ll ln;
	ln = str.length();

	for (ll i =0 ; i < ln; i++) {
		v.push_back(str[i]);
	}

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

	char old = ' ';
	ll times = 0;
	int pos = 0;
	for (ll i = 0; i < ln; i++) {
		if (old == v[i]) {
			times++;
			num[pos] = times;
		}
		else {
			pos++;
			times = 1;
			num[pos] = times;
			old = v[i];
		}
	}

	ll answer = 1;
	ll add = ln*(ln-1)/2;
	for(int i=0;i<27;i++){
		add -= (num[i] * (num[i] - 1) / 2);
	}
	answer += add;

	cout << answer;

	return 0;
}

Measured memory_bytes: 772
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

void main() {
    auto s = readln.chomp;

    if (s.length == 2) {
        writeln(s);
    }
    else {
        writeln(s.retro());
    }
}















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int gcd(int a, int b) {
	return a % b ? gcd(b, a % b) : b;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (auto& e : a) {
		cin >> e;
	}
	int d = a.front();
	for (auto e : a) {
		d = gcd(d, e);
	}
	bool r = false;
	for (auto e : a) {
		r |= k <= e && (e - k) % d == 0;
	}
	cout << (r ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}


Measured memory_bytes: 640
/**
 *      AGC 2 A
 *      author  : kyomukyomupurin
 *      created : 2018-10-11 06:08:13
**/

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define int64 long long
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b; cin >> a >> b;

    if (a > 0) cout << "Positive" << endl; 
    else if (a <= 0 && b >= 0) cout << "Zero" << endl;
    else if (b < 0){
        if ((abs(a) - abs(b)) % 2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import Data.List

solve :: (Int, Int, Int) -> Int
solve (a,b,c) 
    | c - b == 1 = 1 + solve (a+1,c,c)
    | c - b > 0 && even (c-b) = (c-b) `quot` 2 + solve (a,c,c) 
    | c - b >= 3 = 1 + solve (a+1,b+1,c)
    | c == b && even (b-a) = (b-a) `quot` 2
    | c == b && odd (b-a) = 1 + solve (a,b+1,c+1)

main = do
    [a,b,c] <- sort . map read . words <$> getLine
    print $ solve (a,b,c)

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

int main()
{
    long long int n;
            
    cin >> n;
    string s = "";
            
    while(n > 0)
    {
        n -= 1;   
        int alpha = n % 26;
        n = n/26;
        
        string new_s(1, char(alpha + 97));
        s = new_s + s;
        
    }
    
    cout << s;
    
}   
       

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

using namespace std;
using ll = long long;

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main(int argc, char const *argv[])
{
    int x;
    cin >> x;
    while (true)
    {
        if (IsPrime(x))
        {
            cout << x << endl;
            return 0;
        }
        x++;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int X;
  while(scanf("%d",&X)!=0)
  {
    for(long long A=0;A<120;A++)for(long long B=-120;B<A;B++)if(A*A*A*A*A-B*B*B*B*B==X)return printf("%lld %lld\n",A,B),0;
  }
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;
    int n;
    scn(n);
    int mx = 1<<n;
    int val[n],cost[n];
    for(int i=0;i<n; i++)scn(val[i]);
    for(int i=0;i<n; i++)scn(cost[i]);
    int ans=  0;
    for(int mask=0; mask<mx; mask++){
        int now = 0;
        for(int i=0; i<n; i++){

            if(check(mask,i)) now += val[i]-cost[i];
        }
        ans = max(ans,now);
    }
    cout<<ans;

    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 256
dataset = []
while True:
    x, y = map(int, input().split())
    if (x < 0 and x > 10000) and (y < 0 and y > 10000):
        break
    elif (x is 0) and (y is 0): 
        break

    listed = []
    listed.append(x)
    listed.append(y)
    dataset.append(listed)
    if len(dataset) >= 3000:
        break

for i in dataset:
    if i[0] > i[1]:
        print("{0} {1}".format(str(i[1]), str(i[0])))
    elif i[0] < i[1]:
        print("{0} {1}".format(str(i[0]), str(i[1])))
    else:
        print("{0} {1}".format(str(i[0]), str(i[1])))

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

int main(){
    ll N, x; cin >> N >> x;
    ll ans = 0;
    ll prev; cin >> prev;
    for (int i = 1; i < N; i++){
        ll num; cin >> num;
        ll sum = prev + num;
        if(sum<=x){
            prev = num;
            continue;
        }

        ans += sum-x;
        if(sum-x > num) num = 0;
        else num = num - (sum - x);

        prev = num;
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
cd = Counter(D)
ct = Counter(T)
flag = True
for k, v in ct.items():
    if v > cd[k]:
        flag = False
print('YES' if flag else 'NO')

Measured memory_bytes: 57056
import java.util.*;

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

        int N = sc.nextInt();

        if(N%2==0){
            System.out.println(N/2);
        }
        else{
            System.out.println((N+1)/2);
        }
    }
}

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

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

int main()
{
  cout << fixed << setprecision(10);
  int A,B,C;
  cin >> A >> B >> C;
  bool ans = false;
  if(A==7&&B==5&&C==5)
  {
    ans = true;
  }
  if(B==7&&C==5&&A==5)
  {
    ans = true;
  }
  if(C==7&&B==5&&A==5)
  {
    ans = true;
  }
  if(ans==true)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    flg=0
    for i in range(1,10):
        if n%i==0:
            if 1<=n//i<=9:
                flg=1
    if flg==1:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;
 
#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7
 
typedef long long ll;
typedef long long int lli;
 
int main() {
	string res = "Yay!";
    int n = 5;
    int k;
    vector<int> nums;
	for (int i = 0; i < n; i++) {
        int num;
        cin >> num;
        nums.push_back(num);
    }
    cin >> k;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i+1; j <= n; j++) {
            if (nums[j] - nums[i] > k) {
                res = ":(";
                break;
            }
        }
    }
	cout << res << endl;
	return 0;
}

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

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    if(A == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll k = N / (A + B);

    ll r = N % (A + B);
    // cout << A * k + r << endl;
    cout << A * k + min(r, A) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int N, i;
  char List[256];
  char S[128];
  char T[128];
  
  scanf("%d", &N);
  scanf("%s %s", S, T);
  
  for(i=0; i<=N; i++) {
    List[2 * i] = S[i];
    List[2 * i + 1] = T[i];
  }
  
  printf("%s", List);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define mod 838627288460106
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll n,i,j;
    string s,t;
    cin>>s;
    t=s.substr(4,s.length()-1);


    cout<<"2018"<<t<<endl;

    return 0;
}





Measured memory_bytes: 3568
import sys
from collections import Counter

# sys.stdin = open('d1.in')
# sys.stdout = open('out.txt', 'w')

M = 10 ** 9 + 7


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    inv = [0] * (n + 2)
    inv[1] = 1
    for i in range(2, n + 2):
        inv[i] = (M - M // i) * inv[M % i] % M
    a = read_int_list()
    c = Counter(a)
    j = -1
    for i in range(1, n + 1):
        if c[i] == 2:
            j = i
            break
    p = [i for i in range(n + 1) if a[i] == j]
    d = p[1] - p[0]
    r = [0] * (n + 1)
    c = 1
    cc = 1
    for k in range(1, n + 2):
        c *= n + 1 - k + 1
        c *= inv[k]
        c %= M
        r[k - 1] = (c - cc) % M

        cc *= n - d - k + 1
        cc *= inv[k]
        cc %= M

    res = '\n'.join(map(str, r))
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23828
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 2e5;
typedef long long LL;
LL a[MaxN + 5], b[MaxN + 5];
int n;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) 
	{
		scanf("%lld", &a[i]);
		b[i] = a[i];
	}
	sort(a + 1, a + 1 + n);
	int x = a[n/2];
	int y = a[n/2+1];
	for(int i = 1; i <= n; i++)
	{
		if(b[i] <= x) printf("%d\n", y);
		else if(b[i] >= y) printf("%d\n", x);
	}
	return 0;
}

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

namespace ABC155
{
    class A
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = input[0];
            int B = input[1];
            int C = input[2];

            int count = 0;
            if (A == B) count++;
            if (B == C) count++;
            if (C == A) count++;

            if (count == 1) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
program kadai
implicit none

integer  ::  n,i,j,ans
character(len=10),allocatable  ::  s(:)
!character(len=10)  ::  a
integer,allocatable  ::  p(:)

read(*,*) n

allocate(s(n))
allocate(p(n))

do i=1,n
read(*,*) s(i),p(i)
end do

do i=1,n
    ans=min_ch(s)
    do j=1,n
        if (s(ans)==s(j) .and. p(ans)<p(j)) then
            ans=j
        end if
    end do
    write(*,*) ans
    s(ans)="zzzzzzzzzz"
    p(ans)=-1
end do

contains

function min_ch(s) result(ret)
    implicit none
    character(len=10)  ::  s(:)
    integer  ::  ret,n,i
    n=size(s)
    ret=1
    do i=2,n
        if (s(ret)>s(i)) then
            ret=i
        end if
    end do

    return
end function min_ch


end program kadai

Measured memory_bytes: 768
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

import numpy as np

score = np.array([0, R, S, P], dtype=int)
M = (1 + (N-1)//K)
addi = M * K - N
t = np.array([{'n':0, 's':1, 'p':2, 'r':3}[i] for i in T+'n'*addi], dtype=int)

t = t.reshape(M,K).T

for i in range(K):
    for j in range(M):
        if j!=0 and t[i,j] == t[i,j-1]:
            t[i,j] = 0

print(score[t].sum())

Measured memory_bytes: 23848