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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    int res = 0;
    for(int i =n;i>0;i--){
        string s = to_string(i);
        if(s.size() % 2) res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import collections
def inpl(): return list(map(int, input().split()))
n = int(input())
v = inpl()
even,odd=[],[]
for i in range(len(v)):
    if i%2 == 0:
        even.append(v[i])
    else:
        odd.append(v[i])

o = collections.Counter(odd)
e = collections.Counter(even)

omax,emax,ocan,ecan = 0,0,[],[]
for k,v in o.items():
    if v > omax:
        omax = v
        ocan = [k]
    elif v == omax:
        ocan.append(k)
for k,v in e.items():
    if v > emax:
        emax = v
        ecan = [k]
    elif v == emax:
        ecan.append(k)    
end = 0        
for i in ecan:
    for j in ocan:
        if i!=j:
            #print(omax,emax)#
            ans = n-(omax+emax)
            end = 1
            break
    if end == 1:
        break
else:
    esec,osec = 0,0
    for k,v in e.items():
        if v >= emax:
            continue
        esec = max(esec,v)
    for k,v in o.items():
        if v >= omax:
            continue
        osec = max(osec,v)
    ans = min(n-(esec+omax),n-(emax+osec))
print(ans)

Measured memory_bytes: 19040
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define REP(i,e) for (int i = 0; i != int(e); i++)
#define FORIT(i, A) for (auto i : A)
#define ISEQ(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << endl
#define SZ(x) ((int)(x).size())

int main(int argc, char const *argv[])
{
	int d;
	while(scanf("%d", &d) != EOF)
	{
		int sum = 0;
		for (int id = d; id < 600; id += d)
		{
			sum += id * id * d;
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  if((C+B-1)/B <= (A+D-1)/D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
  
}


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

const int mod = 1000000007;

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    map<int,int>mp;
    rep(i,n)mp[a[i]]++;
    bool ok=true;
    rep(i,n){
        if(mp[a[i]]!=1){
            ok=false;
        }
    }
    if(ok){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

lld nCrModp(lld n, lld r, lld p)
{
    if (r > n - r)
        r = n - r;
    lld C[r + 1]={0};
    C[0] = 1;

    for (lld i = 1; i <= n; i++)
    {
      for (lld j = min(i, r); j > 0; j--)
      {
        C[j] = (C[j] + C[j - 1]) % p;

      }
    }
    return C[r];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // lld t;
  // cin>>t;
  // while(t--)
  // {
    // lld x1,x2,x3,x4,x5;
    // cin>>x1>>x2>>x3>>x4>>x5;
    lld x[5];
    lld i;
    for(i=0;i<5;i++)
    {
      cin>>x[i];
    }
    for(i=0;i<5;i++)
    {
      if(x[i]!=i+1)
      {
        cout<<i+1<<'\n';
        exit(0);
      }
    }
  // }

}


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

int main() {
    
    int n; cin >> n;
    int ans = 0;
     for (int i = 0; i < n; i++) {
         int a; cin >> a;
         if (i % 2 == 0 && a % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 50;
int n, m, A[N], B[N], C[N], D[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> A[i] >> B[i];
  FOR(i, 0, m) cin >> C[i] >> D[i];
  FOR(i, 0, n){
    int d = IINF, x=-1;
    FOR(j, 0, m){
      int _d = abs(A[i]-C[j])+abs(B[i]-D[j]);
      if(_d < d){
        x = j;
        d = _d;
      }
    }
    cout << x+1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
char dummy;
struct Elm {
  int month, day, hour, minute;
};
ll operator- (Elm e1, Elm e2) {
  return e1.month * 30 * 24 * 60 + e1.day * 24 * 60 + e1.hour * 60 + e1.minute
      - e2.month * 30 * 24 * 60 - e2.day * 24 * 60 - e2.hour * 60 - e2.minute;
}
void solve(int n) {
  map<string, vector<Elm>> mp;
  for(int i=0;i<n;++i) {
    char m1, m2, d1, d2, h1, h2, m3, m4;
    scanf("%c%c", &m1, &m2);
    scanf("%c", &dummy);
    scanf("%c%c", &d1, &d2);
    scanf("%c", &dummy);
    scanf("%c%c", &h1, &h2);
    scanf("%c", &dummy);
    scanf("%c%c", &m3, &m4);
    scanf("%c", &dummy);
    m1 -= '0';
    m2 -= '0';
    d1 -= '0';
    d2 -= '0';
    h1 -= '0';
    h2 -= '0';
    m3 -= '0';
    m4 -= '0';
    Elm e = {m1 * 10 + m2, d1 * 10 + d2, h1 * 10 + h2, m3 * 10 + m4};
    char tmp, id[3];
    scanf("%c", &tmp);
    scanf("%c", &dummy);
    scanf("%s", id, 3);
    scanf("%c", &dummy);
    mp[id].push_back(e);
  }
  ll ma = 0;
  for(auto &e1: mp) {
    if(e1.first == "000") continue;
    ll now = 0;
    int pos1 = 0, posg = 0;
    while(pos1 < (int)(e1.second.size()) && posg < (int)(mp["000"].size())) {
      if(e1.second[pos1] - mp["000"][posg+1] >= 0) {
        posg += 2;
        continue;
      }
      if(mp["000"][posg] - e1.second[pos1+1] >= 0) {
        pos1 += 2;
        continue;
      }
      now += min({e1.second[pos1+1] - e1.second[pos1],
                  e1.second[pos1+1] - mp["000"][posg],
                  mp["000"][posg+1] - e1.second[pos1],
                  mp["000"][posg+1] - mp["000"][posg]});
      if(mp["000"][posg+1] - e1.second[pos1+1] >= 0) pos1 += 2;
      else posg += 2;
    }
    ma = max(ma, now);
  }
  cout << ma << endl;
}
int main() {
  cout << fixed << setprecision(10);
  while(1) {
    int n; scanf("%d", &n);
    scanf("%c", &dummy);
    if(n == 0) break;
    solve(n);
  }
}



Measured memory_bytes: 3352
n=int(input())
fac=[True]*55556
fac[0]=False
fac[1]=False
for i in range(2,len(fac)):
  if fac[i]:
    nodiv=True
    for j in range(2,fac[i]):
      if fac[i]%j==0:
        nodiv=False
        break
    if not nodiv:
      fac[i]=False
    else:
      for j in range(i*2,len(fac),i):
        fac[j]=False

ans=[0]*n
ind=0
for i in range(len(fac)):
  if fac[i] and i%5==1:
    ans[ind]=i
    ind+=1
    if ind==n:
      break
print(*ans)

Measured memory_bytes: 3444
#include <cstdio>
using namespace std;

int main ()
{
  int N;
  int x, a;
  int sum = 0;

  scanf("%d", &N);

  x = N;
  while (x > 0) {
    a = x % 10;
    x /= 10;
    sum += a;
  }

  if (N % sum == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ANS(ans) cout << ans << endl
#define FLG(flg) if(flg) cout << "Yes" << endl; else cout << "No" << endl;
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
#define COUT(s) cout << s << endl;
#define AN vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i];
#define IN  int n;  cin >> n;
#define VI  vector<int> 
#define SS stringstream ss;
#define SOLVE cout << solve() << endl;
 
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust" << endl;
    else  cout << "win" << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
rs = 0

for i in range(n):
    if A[i] > B[i]:
        rs += B[i]
    else:
        t = min(B[i]-A[i], A[i+1])
        A[i+1] -= t
        rs += t + A[i]
print(rs)

Measured memory_bytes: 18624
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
    char *s;
    int n;
    int i;
    int ans=0;
    s=(char*)malloc(sizeof(char));
    scanf("%s",s);
    //printf("%s\n",s);
    n=strlen(s);
    //printf("%d\n",n);
    for(i=0;i<n-1;i++){
        if(s[i+1]==s[i]){
            if(s[i]=='0'){
                s[i+1]='1';
            }else{
                s[i+1]='0';
            }
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

//in
// 2 2919
//out
// 3719
const main = (inp: string) => {
    // 100 * (10-k)
    const [n, r]: number[] = inp.split(' ').map(Number);
    if (r === 0) {
        console.log(0);
    } else if (n >= 10) {
        console.log(r);
    } else {
        console.log(r + (100 * (10 - n)));
    }
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const int MOD = 1000000009;

int n;
ll a, b, c;
ll x, y;


int main(){
	cin >> a>>b>>c>> x>> y;
	ll ans=0LL;
	ans = a * x + b * y;
	if (a + b > 2 * c) {
		ans -= min(x, y)*(a+b - 2 * c);
		if (a > 2 * c) {
			ans -= (x - min(x, y))*(a - 2 * c);
		}
		if (b > 2 * c) {
			ans -= (y - min(x, y))*(b - 2 * c);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
ary = []
n.times do
    ary << gets.chomp.split
end

sum = 0
ary.each do |i|
    if i[1] == 'JPY'
        sum += i[0].to_i
    else
        sum += i[0].to_f * 380000.0
    end
end
puts sum



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

int main()
{
    int N;
    cin >> N;
    if (N % 1000 != 0)
    {
        cout << 1000 - N % 1000 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3640
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
char l;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	
	bool trois=true;
	
	for(int i=0;i<n;i++){
		cin >> l;
		
		if(l=='Y') trois=false;
	}
	
	if(trois){
		cout << "Three\n";
	}
	else{
		cout << "Four\n";
	}
	
	
}

Measured memory_bytes: 256
//msol2020_a.cpp
//Sun Aug  2 20:38:51 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	int x;
	cin >> x;

	if (x<=599){
		cout << "8" << endl;
	}else if (x <= 799) {
		cout << "7" << endl;
	}else if (x <= 999) {
		cout << "6" << endl;
	}else if (x <= 1199) {
		cout << "5" << endl;
	}else if (x <= 1399) {
		cout << "4" << endl;
	}else if (x <= 1599) {
		cout << "3" << endl;
	}else if (x <= 1799) {
		cout << "2" << endl;
	}else if (x <= 1999) {
		cout << "1" << endl;
	}

}

Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
int p[100], m[100 + 1][100 + 1];

void matrixChainMultiplication(int n) {
	for (int i = 0; i <= n; ++i) {
		m[i][i] = 0;
	}

	for (int l = 2; l <= n; ++l) {
		for (int i = 1; i <= n - l + 1; ++i) {
			int j = i + l - 1;
			m[i][j] = 1 << 21;
			for (int k = i; k <= j - 1; ++k) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
}

int main() {
	int N;
	cin >> N;
	
	for (int i = 1; i <= N; ++i) {
		cin >> p[i - 1] >> p[i]; 
	}

	matrixChainMultiplication(N);
	cout << m[1][N] << endl;
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main(){
    long a1, a2, a3, a4, a5, a6, a7;
    long K = 0;
    cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6 >> a7;
    K +=  a2;
    K += (a1/2)*2;
    K += (a4/2)*2;
    K += (a5/2)*2;
    if(a1%2 == 1 && a4%2 == 1 && a5%2 == 1){
        K+=3;
        cout << K <<  endl;
    }else if(a1%2 == 1 && a4%2 == 1 && a5 != 0){
        K++;
        cout << K <<  endl;
    }else if(a4%2 == 1 && a5%2 == 1 && a1 != 0){
        K++;
        cout << K <<  endl;
    }else if(a5%2 == 1 && a1%2 == 1 && a4 != 0){
        K++;
        cout << K <<  endl;
    }
    else{
        cout << K <<  endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ld EPS=10e-8;
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll dp[57][57][2507];
 
int main() {
    ll N,A,Y[53];cin>>N>>A;
    rep(i,N){
        cin >> Y[i+1];
    }
    dp[0][0][0]=1;
    REP(j,1,N+1){
        REP(k,0,j+1){
            rep(sum,2501){
                if(sum<Y[j]){
                    dp[j][k][sum]=dp[j-1][k][sum];
                }
                else if(k>0){
                    dp[j][k][sum]=dp[j-1][k][sum]+dp[j-1][k-1][sum-Y[j]];
                }
            }
        }
    }
    ll sum = 0;
    REP(i,1,N+1){
        sum += dp[N][i][A*i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 55552
#include <stdio.h>                                                                 
#include <string.h>                                                                
                                                                                   
#define MAX 500                                                                    
                                                                                   
int main() {                                                                       
        char W[MAX];                                                               
        int n, h,i,length;                                                         
                                                                                   
        while(1){                                                                  
          scanf("%s", W);                                                          
          if(W[0] == '-') break;                                                   
                                                                                   
          length = strlen(W);                                                      
                                                                                   
          scanf("%d", &n);                                                         
                                                                                   
          for (i = 0; i < n; i++) {                                                
                scanf("%d",&h);             
                strncpy(&W[length],W,h);                                           
                strncpy(W,&W[h],length);                                           
                W[length] = '\0';                                                  
           }                                                                       
             printf("%s\n", W);                                                    
        }                                                                          
                                                                                   
        return 0;                                                                  
                                                                                   
}                                                                                  



Measured memory_bytes: 2104
#include <stdio.h>
int main(){
	int A, B;
	long long int m, n;
	double d;
	scanf("%d %d", &A, &B);
	if (A>B){
		n=1;
		while (1){
			m=A*n++;
			d=(double)m/B;
			if (d==(int)d){
				printf("%lld\n", m);
				return 0;
			}
		}
	}
	else{
		n=1;
		while (1){
			m=B*n++;
			d=(double)m/A;
			if (d==(int)d){
				printf("%lld\n", m);
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

int func(vector<int>& stones){
	vector<int> dp(stones.size());
	dp[0] = 0;
	dp[1] = abs(stones[1] - stones[0]);
	for(int i = 2;i < (int)stones.size();i++){
		int take1 = dp[i - 2] +abs(stones[i] - stones[i - 2]);
		int take2 = dp[i - 1] + abs(stones[i] - stones[i - 1]);
		dp[i] = min(take1, take2);
	}
	return dp[stones.size() - 1];
}

int main() {
	int n;cin>>n;
	vector<int> stones(n);
	for(auto &x : stones) cin>>x;
	cout<<func(stones)<<endl;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  string s; cin >> s;
  int p = 0;
  rep(i,s.size()){
    if(s[i] == 'p'){
      p++;
    }
  }
  
  cout << s.size()/2 - p << endl;
  
  return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
mod = 10**9 + 7

Ans = 0

for m in range(K,N+2): # m個選ぶ m = K ~ N+1
    # 1刻みで全ての数を作ることができる
    # よって答えは、作れる数の　(最大値) - (最小値) 通りとなる

    # 最大値 = 大きい方からm個選ぶ = N-m+1 ~ N までの和
    maxi = m*(N-m+1 + N)/2

    # 最小値 = 小さい方からm個選ぶ = 0~m-1を選ぶ
    mini = m*(0 + m-1)/2

    Ans += int(maxi - mini + 1)
    Ans %= mod
    
print(Ans)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct Node {
  int freq;
  int start, end;
  Node *left;
  Node *right;
  Node(int s, int e) {
    start = s;
    end = e;
  }
};

Node *build(string &S, int left, int right) {
  auto root = new Node(left, right);
  if (left == right) {
    root->freq = 1 << (S[left] - 'a');
  } else {
    int mid = (left + right) / 2;
    root->left = build(S, left, mid);
    root->right = build(S, mid + 1, right);
    root->freq = root->left->freq | root->right->freq;
  }
  return root;
}

void update(Node *root, int pos, char c) { 
  if (root->start == pos && root->end == pos) {
    root->freq = 1 << (c - 'a');
    return;
  } else {
    int mid = (root->start + root->end) / 2;
    if (pos <= mid) {
      update(root->left, pos, c);
    } else {
      update(root->right, pos, c);
    }
    root->freq = root->left->freq | root->right->freq;
  }
}

int query(Node *root, int l, int r) { 
  if (root->start == l && root->end == r) {
    return root->freq;
  } else {
    int mid = (root->start + root->end) / 2;
    if (l > mid) {
      return query(root->right, l, r);
    } else if (r <= mid) {
      return query(root->left, l, r);
    } else {
      return (query(root->left, l, mid) | query(root->right, mid + 1, r));
    }
  }

}


int main() {
  string S;
  int N, Q;
  cin >> N >> S >> Q;
  auto root = build(S, 0, N - 1);
  for (int i = 0; i < Q; i++) {
    int q;
    cin >> q;
    if (q == 1) {
      int pos;
      char c;
      cin >> pos >> c;
      update(root, pos - 1, c);
    } else {
      int l, r;
      cin >> l >> r;
      int freq = query(root, l - 1, r - 1);
      int cnt = 0;
      for (int i = 0; i < 26; i++) {
        if (((1 << i) & freq)) cnt++;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 47620
#include<bits/stdc++.h>
using namespace std;
int di(int a)
{
	int s=0;
	for(int i=1;i<=a;i++)
	{
		if(a%i==0) s++;
	}
	return s;
}
int main()
{
	int n;
	cin>>n;
	int s=0;
	for(int i=105;i<=n;i+=2)
	{
		if(di(i)==8) s++;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from io import StringIO
import unittest
import os


# 検索用タグ、末尾に続く0の個数、ググる数学問題
# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    n = int(input())

    if n % 2 == 1:
        print(0)
        return

    ans = 0
    val = 2
    # ループ数に意味はない
    for i in range(30):
        val = val * 5
        if val > n:
            break
        ans += n // val

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """12"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """5"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """1000000000000000000"""
        output = """124999999999999995"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 75152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b, c, k, a1, b1, c1;
	cin >> a >> b >> c >> k;
	if(k%2){
		cout << b-a;
	}
	else{
		cout << a-b;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s.at(0)=='R'&&s.at(1)=='R'&&s.at(2)=='R') cout<<"3"<<endl;
    else if(s.at(0)=='R'&&s.at(1)=='R'&&s.at(2)=='S') cout<<"2"<<endl;
    else if(s.at(0)=='S'&&s.at(1)=='R'&&s.at(2)=='R') cout<<"2"<<endl;
    else if(s.at(0)=='S'&&s.at(1)=='S'&&s.at(2)=='S') cout<<"0"<<endl;
    else cout<<"1"<<endl;
}



Measured memory_bytes: 3612
def lunlun(n):
	nums = set([1, 2, 3, 4, 5, 6, 7, 8, 9])
	while len(nums) < n:
		old_nums = list(nums)
		for num in old_nums:
			num = str(num)
			if num[-1] == '0':
				adds = num + '0'
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = num + '1'
				if int(adds) not in nums:
					nums.add(int(adds))
			elif num[-1] == '9':
				adds = num + '9'
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = num + '8'
				if int(adds) not in nums:
					nums.add(int(adds))
			else:
				adds = num + str(int(num[-1]) - 1)
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = num + str(int(num[-1]))
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = num + str(int(num[-1]) + 1)
				if int(adds) not in nums:
					nums.add(int(adds))
			if num[0] == '1':
				adds = '1' + num
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = '2' + num
				if int(adds) not in nums:
					nums.add(int(adds))
			elif num[0] == '9':
				adds = '8' + num
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = '9' + num
				if int(adds) not in nums:
					nums.add(int(adds))
			else:
				adds = str(int(num[0]) - 1) + num
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = str(int(num[0])) + num
				if int(adds) not in nums:
					nums.add(int(adds))
				adds = str(int(num[0]) + 1) + num
				if int(adds) not in nums:
					nums.add(int(adds))

	nums = list(nums)
	nums = sorted(nums)
	return nums[n - 1]

n = int(input())
print(lunlun(n))

Measured memory_bytes: 21640
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loops(i,a,b) for(int i=a;i>=b;i--)
#define fast_ip ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define ump unordered_map
#define ums unordered_set
using namespace std;

void solve(); 

bool prime[10000001];

void sieve(ll n) 
{ 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
long long fast_exp(long long base, long long power) {
    long long result = 1;
    while(power>0) {

        if(power%2==1) { 
            result=(result*base)%MOD;
        }
        base = (base*base) % MOD;
        power = power/2; 
    }
    return result%MOD;
}
void initialize()
{
    for (int i=0; i<=100001; i++) 
    {
          prime[i]=true;
    }
    //sieve();
}

int main() 
{
	// your code goes here
    fast_ip;
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("error.txt", "w", stderr);
    freopen("output.txt", "w", stdout); 
    #endif 
    */
    int t=1;
   // cin>>t;
	while(t--)
	{
	    solve(); 
        cout<<"\n";
	}
   // cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}


void solve() 
{ 
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n){
    	cin>>a[i];
    }
    int dp[n];
    dp[n-1]=0;
    if(n-2>=0)
    {
    	dp[n-2]=abs(a[n-1]-a[n-2]);
       // cout<<dp[n-2]<<" ";
    }
    loops(i,n-3,0){
        //cout<<i<<" ";

        dp[i]=min(abs(a[i]-a[i+1])+dp[i+1],abs(a[i]-a[i+2])+dp[i+2]);
    }
    cout<<dp[0];
} 


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 5000
 
int v[MAX][MAX];
 
main(){
  int a,b,ten,k,i,j,p,q;
 
  scanf("%d",&ten);
  for(i = 0;i < ten;i++){
    scanf("%d%d",&q,&p);
    for(j = 0;j < p;j++){
    scanf("%d",&b);
    v[q-1][b-1] = 1;
    }
    }
  for(i = 0;i < ten;i++){
    for(j = 0;j <ten-1; j++){
      printf("%d ",v[i][j]);
    }
    printf("%d\n",v[i][j]);
  }
  return 0;
}

Measured memory_bytes: 1000
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
     
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

const int maxn=20005;
int p[maxn];
int rk[maxn];

int main() {
    int n;
    read(n);
    REP(i,1,n) read(p[i]);
    REP(i,1,n) rk[p[i]]=i;
    int now=1;
    REP(i,1,n) printf("%d ",now+rk[i]-1),now+=n;putchar('\n');
    REP(i,1,n) printf("%d ",now),now-=n;putchar('\n');
    return 0;
}

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

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

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

int dp[41][401][401]; // dp[N][a][b] := min cost

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, ma, mb;
	cin >> n >> ma >> mb;
	REP(i, n + 1){
		REP(j, 401){
			REP(k, 401){
				dp[i][j][k] = INF;
			}
		}
	}
	vector<piii> chs(n + 1);
	REP1(i, n){
		int a, b, c;
		cin >> a >> b >> c;
		chs[i] = MP(MP(a, b), c);
	}
	dp[0][0][0] = 0;
	REP1(i, n){
		REP(j, 401){
			REP(k, 401){
				dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
				if(j - chs[i].X.X >= 0 && k - chs[i].X.Y >= 0){
					dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - chs[i].X.X][k - chs[i].X.Y] + chs[i].Y);
				}
			}
		}
	}
	int ans = INF;
	for(int i = 1; ma * i <= 400 && mb * i <= 400; ++i){
		ans = min(ans, dp[n][ma * i][mb * i]);
	}
	if(ans == INF) ans = -1;
	cout << ans << "\n";
	return 0;
}



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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int &i: a) scanf("%d", &i);
    vector<int> mxh(n, 0);
    // mxh[n-1] = 0;
    for (int i=n-2; i>=0; i--) {
        if (a[i]>=a[i+1]) mxh[i] = mxh[i+1]+1;
        // else mxh[i] = 1;
    }

    printf("%d\n", *max_element(mxh.begin(), mxh.end()));
}

Measured memory_bytes: 1024
use std::io::stdin;

fn main() {
    let mut nm = String::new();
    stdin().read_line(&mut nm).unwrap();
    let (n, m) = {
        let mut nm = nm.split_whitespace().map(|x| x.parse::<i64>().unwrap());
        (nm.next().unwrap(), nm.next().unwrap())
    };
    let mut a = String::new();
    stdin().read_line(&mut a).unwrap();
    let mut a: Vec<_> = a.split_whitespace().map(|x| x.parse::<i64>().unwrap()).collect();
    let q_a: i64 = a.iter().sum();
    a.sort();
    let p = (n-m) as usize;
    if a[p] > (q_a-1) / (m*4) {
        println!("Yes", );
    } else {
        println!("No", );
    };
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,s[3];
  cin >> n;
  sort(s,s+n);
  for(int i=0;i<n;i++) cin >> s[i];
  for(int i=1;i<=s[0];i++){
    if(n==2&&s[0]%i==0&&s[1]%i==0) cout << i << endl;
    else if(n==3&&s[0]%i==0&&s[1]%i==0&&s[2]%i==0) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 1180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] p = new int[3][n];
        for(int i = 0; i < n; i++) {
        	p[0][i] = sc.nextInt();
        	p[1][i] = sc.nextInt();
        	p[2][i] = sc.nextInt();
        }

        System.out.println(solve(n, p));

    }



	private static int solve(int n, int[][] p) {
		int[][] dp = new int[3][n];

		for(int i = 0; i < 3; i++)
			dp[i][0] = p[i][0];

		for(int i = 1; i < n; i++) {
			for(int j = 0; j < 3; j++) {
				dp[j][i] = Math.max(dp[(j+1) % 3][i-1], dp[(j+2)%3][i-1]) + p[j][i];
			}
		}


		int mostHappy = Math.max(Math.max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]);
		return mostHappy;

	}
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b)
        cout << "Draw" << endl;
    else if (a == 1 || (a > b && b != 1))
        cout << "Alice" << endl;
    else if (b == 1 || (a < b && a != 1))
        cout << "Bob" << endl;
    return 0;
}

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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
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; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// Let's get AC!

typedef long long ll;
const int arm = 31;
const int MAX_N = 1000;
const char dir[] = { 'L', 'D', 'U', 'R' };

int N;
bool isodd;
int ans[MAX_N][arm + 1];
ll X[MAX_N], Y[MAX_N];

int main(){

    cin >> N;
    rep(i, N){
        ll x, y;
        cin >> x >> y;
        if(i == 0)isodd = (x + y) & 1;
        else if(isodd != ((x + y) & 1)){
            cout << "-1\n";
            return 0;
        }
        X[i] = (x - y + (1ll << arm)) >> 1;
        Y[i] = (x + y + (1ll << arm)) >> 1;
    }

    rep(i, N){
        rep(j, arm)if(X[i] & (1ll << j))ans[i][j] |= 1;
        rep(j, arm)if(Y[i] & (1ll << j))ans[i][j] |= 2;
    }

    if(isodd){
        cout << arm << '\n';
        rep(i, arm)cout << (1ll << i) << (i == arm - 1 ? '\n' : ' ');
        rep(i, N){
            rep(j, arm)cout << dir[ans[i][j]];
            cout << '\n';
        }
    } else {
        cout << arm + 1 << '\n';
        rep(i, arm)cout << (1ll << i) << ' ';
        cout << "1\n";
        rep(i, N){
            rep(j, arm + 1)cout << dir[ans[i][j]];
            cout << '\n';
        }
    }

}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
    int flg=1 ,flg2=0 ;
    int n=0 ;
    int i=0 ;
    int mem=0 ;

    scanf("%d",&n);
    int num[n] ;

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

    while (flg){

        flg=0;

        for (i=n-1 ;i>=1 ;i--){

            if (num[i-1] > num[i]){
                mem=num[i];
                num[i]=num[i-1];
                num[i-1]=mem;

                flg++;
                flg2++;
            }
        }

    }

    for (i=0 ;i<n-1 ;i++){
        printf("%d ",num[i]);
    }
    printf("%d\n",num[n-1]);
    printf("%d\n",flg2);

    return 0;
}

Measured memory_bytes: 600
def f(num, base):
    # calc max Pth Power
    ret = 1
    while ret <= num:
        ret *= base
    return ret // base


def main():
    N = {int(input())}
    ans = 0
    while (all(N)):
        N = {x - f(x, 6) for x in N} | {x - f(x, 9) for x in N}
        ans += 1
    print(ans)
    return


main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << "\n"
#define endwith return
constexpr int mod = 1000000007;
using namespace std;
int input() { int t; cin >> t; return t; }
signed main() {
	int a[123456], n, k;
	cin >> n >> k;
	for0(i, n)cin >> a[i]; sort(a, a + n);
	int ans = 0; for0(i, k)ans += a[i]; puts(ans);
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int N, x, y, z;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> N;
  for (int i = 1; i <= N; i ++) {
    int n = i, cnt = 0;
    for (int x = 1; x * x <= n; x ++)
      for (int y = 1; x * x + y * y <= n; y ++)
        for (int z = 1; x * x + y * y + z * z + x * y + y * z + x * z <= n; z ++)
          if (x * x + y * y + z * z + x * y + y * z + x * z == n)
            cnt ++;
    cout << cnt << '\n';
  }
  return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Sum(int n)
        {
            int sum = 0;
            while (n > 0)
            {
                sum += n % 10;
                n /= 10;
            }
            return sum;
        }
        static int Solve(int N)
        {
            int min = int.MaxValue;
            for (int A = 1; true; ++A)
            {
                int B = N - A;
                if (B < A) { break; }
                min = Math.Min(Sum(A) + Sum(B), min);
            }
            return min;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            Console.WriteLine(Solve(N));
        }
    }
}


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

namespace ConsoleApp11
{
    class Class69
    {
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NM[0], M = NM[1];
            var X = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(X);
            int ans = 0;
            if (M > 1)
            {
                if (N > M) N = M;
                var dif = new int[M - 1];
                for (int i = 0; i < M - 1; i++)
                    dif[i] = X[i + 1] - X[i];
                Array.Sort(dif);
                ans = dif.Sum();
                for (int i = 0; i < N - 1; i++)
                    ans -= dif[M - 2 - i];
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 19808
#pragma GCC optimize (3)
#include<bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ff(v,a,b) for(int v=a;v<=b;v++)
#define clr(a) memset(a,0,sizeof(a))
#define ll long long
using namespace std;
const int N=1e5+10;
int n;
int a[N];
int x;
int main() {
    boost;
	cin>>n;
	cin>>x;
	ff(i,2,n)cin>>a[i],x^=a[i];
	if(!x)cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 640
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ans = sum(s)
x = 0
for v in s:
    if v % 10 == 0:
        pass
    else:
        x = v
        break
if ans % 10 == 0:
    if x == 0:
        print(0)
    else:
        print(ans-x)
else:
    print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;
int main(){
    int a, b;
    string s;
    stack<int> x;
    while(cin >> s){
        if(s == "+"){
            a = x.top(); x.pop();
            b = x.top(); x.pop();
            x.push(a+b);
        }
        else if(s == "-"){
            a = x.top(); x.pop();
            b = x.top(); x.pop();
            x.push(b-a);
        }
        else if(s == "*"){
            a = x.top(); x.pop();
            b = x.top(); x.pop();
            x.push(a*b);
        }else{
            x.push(atoi(s.c_str()));
        }
    }
    cout << x.top() << endl;
}

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

using namespace std;

int a[6];

void genInput() {
	for (int i = 1; i <= 5; ++i)
		a[i] = rand() % 50 + 3;
}

int bruteForce() {
	int res = 1e9 + 7;
	sort(a + 1, a + 6);
	do {
		int tmp = 0;
		for (int i = 1; i <= 5; ++i) {
			if (tmp % 10) tmp = (tmp / 10 + 1) * 10;
			tmp += a[i];
		}
		res = min(res, tmp);
	}
	while (next_permutation(a + 1, a + 6));
	return res;
}

int Greedy() {
	int res = 1e9 + 7, mm = 0;
	for (int i = 1; i <= 5; ++i) {
		int tmp = 0;
		for (int j = 1; j <= 5; ++j)
			if (i != j) {
				if (tmp % 10) tmp = (tmp / 10 + 1) * 10;
				tmp += a[j];
			}
		if (tmp % 10) tmp = (tmp / 10 + 1) * 10;
		res = min(res, tmp + a[i]);
	}
	return res;
}

int calcMax(int x) { return (x % 10 != 0) ? (x / 10 + 1) * 10 : x; }

int Greedy1() {
	int res = 0, mm = 0;
	for (int i = 1; i <= 5; ++i) {
		res += calcMax(a[i]);
		mm = max(mm, (10 - a[i] % 10) % 10);
	}
	return res - mm;
}

int main() {
	for (int i = 1; i <= 5; ++i)
		cin >> a[i];
	cout << Greedy1();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d


int main() {
    int N, M; cin >> N >> M;
    P ab[M];
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab, ab+M);

    int ans = 0;
    int now = 0;
    REP(i, M) {
        P f = ab[i];
        int l = f.second;
        int r = f.first;
        if (l >= now) {
            ans++;
            now = r;
        }
    }

    cout << ans << "\n";



    return 0;
}

Measured memory_bytes: 1024
a,b=input().split()
a=int(a)
b=int(b)
if ((a+b)%3)==0:
  print("Possible")
else:
  if (a%3)==0:
    print("Possible")
  else:
    if (b%3)==0:
      print("Possible")
    else:
      print("Impossible")

Measured memory_bytes: 9176