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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int M, N;
int t[128];
int dp[32][128];

int dfs(int m, int n){
  //  printf("%d %d\n", m, n);
  if(m == M && n == N) return 0;
  if(m == M) return INF;
  if(n == N) return 0;
  if(dp[m][n] >= 0) return dp[m][n];

  int res = INF;
  for(int i = n+1; i < N+1; i++){
    res = min(res, max(dfs(m+1, i), t[i] - t[n]));
  }

  return dp[m][n] = res;
}

int main(){
  while(scanf("%d%d", &M, &N) && M + N){
    memset(dp, -1, sizeof(dp));
    t[0] = 0;
    rep(i, N) scanf("%d", t+i+1);
    rep(i, N) t[i+1] += t[i];

    printf("%d\n", dfs(0, 0));
  }
}

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

class Program
{
  public static void Main(string[] args)
  {
    int[] s = Console.ReadLine().Split('/').Select(int.Parse).ToArray();
    if (s[0] > 2019) Console.WriteLine("TBD");
    else {
      if (s[1] > 4) Console.WriteLine("TBD");
      else {
        Console.WriteLine("Heisei");
      }
    }
  }
}


Measured memory_bytes: 13268
#include<stdio.h>

int main(void){
  int n;
  int a[200000];
  int sum[200000];
  for(int i=0;i<200000;i++){
    sum[i]=0;
  }

  scanf("%d", &n);
  for(int i=0;i<n-1;i++){
    scanf("%d", &a[i]);
    sum[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    printf("%d\n", sum[i]);
  }

  return 0;
}


Measured memory_bytes: 3292
s = input()
l = (len(s))
t = ''
u = ['dream', 'dreamer', 'erase', 'eraser'] 

while s != '':
    if s[-1]  == 'r':
        now = s[-7:]
        #print(now)
        if now == 'dreamer':
            #print(now)
            s = s[:len(s)-7]
        elif now[-6:] == 'eraser':
            #print(now)
            s = s[:len(s)-6]
        else:
            print('NO')
            exit()
    else:
        now = s[-5:]
        #print(now)
        if now in u:
            #print(now)
            s = s[:len(s)-5]
        else:
            print('NO')
            exit()

print('YES')

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

using namespace std;

int main()
{
    string str = "";
    long long num, rem;
    bool flag = true;

    cin >> num;

    while(num > 0)
    {
        rem = num % 26;
        num /= 26;
        if(rem == 0)
        {
            rem = 26;
            num--;
        }
        str += (char)(rem + 96);
    }
    for(int i = str.length() - 1; i >= 0; i--)
        cout << str[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int x,y; cin >> x >> y;
	if(y>=2*x&&(y-2*x)%2==0&&4*x>=y){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d",&N);
	long long int A[N],B[N];
	int i,j,k,r;
	long int e = 0;
	long long int c;
	c = 0;
	for(i = 0; i < N; i++)
	{
		scanf("%lld %lld",&A[i],&B[i]);
	}
	for(i = N-1; i >= 0; i--)
	{
		A[i] += c;
		e = A[i]/B[i];
		if(A[i]%B[i] != 0){
			c += B[i]*(e+1)-A[i];
		}
	}
	printf("%lld",c);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;
 
ll powmod(ll a, ll b, ll mod = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (mod - 1ll), a %= mod;
	while(b){
		if(b%2 == 1)	res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}

 
int main(){	

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);
 
	int n;
	cin >> n;
	pair<ll, ll> arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i].first >> arr[i].second;
		arr[i].first += arr[i].second;
	}	

	sort(arr, arr + n, greater<pair<ll, ll>> ());
	ll a = 0, b = 0;
	for(int i = 0; i < n; i++){	
		arr[i].first -= arr[i].second;	
		if(i&1)	b += arr[i].second;
		else	a += arr[i].first;
	}

	cout << a - b << "\n";
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
	vector<int>l;
	int t;
	cin >> t;
	for (int i = 0; i < t; i++){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x2 += x1;
		y2 += y1;
		int n;
		cin >> n;
		int sum = 0;
		for (int i = 0; i < n; i++){
			int x, y;
			cin >> x >> y;
			if (x1 <= x&&x <= x2){
				if (y1 <= y&&y <= y2){
					sum++;
				}
			}
		}
		l.push_back(sum);
	}
	for (int i = 0; i < t; i++){
		cout << l[i] << endl;
	}
	char cc;
	cin >> cc;
	return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

#define int long long
#define ll long long
#define double long double
#define pii pair<int, int>
#define vec vector
#define u_map unordered_map
#define u_set unordered_set
#define str string
#define all(el) el.begin(), el.end()
#define allr(el) el.rbegin(), el.rend()
#define sz(el) (int)el.size()
#define f first
#define s second
#define pb push_back
#define in insert
#define mp make_pair
#define endl "\n"
#define forn(i, n) for (int i = 0; i < n; ++i)

inline int maxi(int &a, int b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(int &a, int b) { if (b < a) { a = b; return 1; } return 0; }

inline int maxi(double &a, double b) { if (b > a) { a = b; return 1; } return 0; }

inline int mini(double &a, double b) { if (b < a) { a = b; return 1; } return 0; }

int bin_pow(int x, int p) {
    if (p < 0) {
        return 0;
    }
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int ans = bin_pow(x, p / 2);
        return ans * ans;
    }
    return x * bin_pow(x, p - 1);
}

int gcd(int a, int b) {
    if (!b) {
        return a;
    }
    return gcd(b, a % b);
}

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vec<int> hv_a(a), hv_b(b), hv_c(c);
    for (int i = 0; i < a; i++) {
        cin >> hv_a[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> hv_b[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> hv_c[i];
    }
    sort(allr(hv_a));
    sort(allr(hv_b));
    sort(allr(hv_c));

    int ans = 0;
    vec<int> hv;
    for (int i = 0; i < x; i++) {
        ans += hv_a[i];
        hv.pb(hv_a[i]);
    }
    for (int i = 0; i < y; i++) {
        ans += hv_b[i];
        hv.pb(hv_b[i]);
    }

    sort(all(hv));

    int pos = 0;
    for (int i = 0; i < sz(hv); i++) {
        if (hv[i] < hv_c[pos]) {
            ans -= hv[i];
            ans += hv_c[pos];
            pos++;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 7676
N,M = map(int,input().split())
stores = [ [int(x) for x in input().split()] for i in range(N)]
stores = sorted(stores,key= lambda x:x[0])

minCost = 0
for (cost,q) in stores:
    if(q > M):
        minCost += M*cost
        break
    else:
        M -=q
        minCost += q*cost
print(minCost)


Measured memory_bytes: 23524
#include<iostream>
using namespace std;
int add(int n, int s, int x, int t);
int main(){
	for(;;){
		int n,s,t=0;
		cin >>n>>s;
		if(n == 0 && s == 0){break;}
		for(int i=0; i<10; i++){
			if(s>=i){t+=add(n-1,s-i,i,0);}
		}
		cout <<t<<endl;
	}
	return 0;
}
int add(int n, int s, int x, int t){
	int k = t;
	if(n == 0 && s == 0){return 1;}
	else if(n == 0 && s != 0){return 0;}
	else{
		for(int i=x+1; i<10; i++){
			if(s>=i){t+=add(n-1,s-i,i,k);}
		}
	}
	return t;
}

Measured memory_bytes: 0
N = int(input())
if (1 <= N < 105):
    print(0)
if (105 <= N < 135):
    print(1)
if (135 <= N < 165):
    print(2)
if (165 <= N < 189):
    print(3)
if (189 <= N < 195):
    print(4)
if (195 <= N <= 200):
    print(5)

Measured memory_bytes: 9108
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string str;
	int i;
	cin>>str;
	for (i=0;i<str.size();i++)
	{
		if (str[i]<'D'){
			str[i]=str[i]+23;
		}else{
			str[i]=str[i]-3;
		}
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int a[3],k;
int main()
{
    cin>>a[0]>>a[1]>>a[2]>>k;
    sort (a,a+3);
    while (k!=0)
    {
        a[2]=a[2]*2;
        k--;
    }
    cout<<(a[2]+a[1]+a[0]);
    return 0;
}


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

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


Measured memory_bytes: 3636
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
string s;

using ll = long long;

ll quick_pow(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}


int mod = 1e9+7;
struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> s;
    int len = s.length();
    
    vector< vector<modular> > dp(len, vector<modular>(13, 0));
    
    int remain = 1;
    for (int i = 0; i < len; i++){
        int digit_pos = len - 1 -i;
        if(digit_pos == len - 1){
            if(s[digit_pos] == '?'){
                for (int j = 0; j <= 9; j++){
                    dp[digit_pos][j] = 1;
                }
            }else{
                dp[digit_pos][s[digit_pos] - '0'] = 1;
            }
        }else{
            if(s[digit_pos] == '?'){
                for (int j = 0; j <= 9; j++){
                    for (int k = 0; k <= 12; k++){
                        dp[digit_pos][(k + j * remain %13)%13] += dp[digit_pos+1][k];
                    }
                }
            }else{
                for (int k = 0; k <= 12; k++){
                    dp[digit_pos][(k + (s[digit_pos] - '0')* remain %13)%13] += dp[digit_pos+1][k];
                }
            }
        }
        remain *= 10;
        remain %= 13;
    }
    
    cout << dp[0][5] << "\n";
    return 0;
}


Measured memory_bytes: 8912
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)998244353;
const double eps=1e-9;
long long seen[100005],v[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,x,m,sum=0;
    cin>>n>>x>>m;
    if(n<=100000){
        sum=v[1]=x;
        for(int i=2;i<=n;i++)
            v[i]=(v[i-1]*v[i-1])%m,
            sum+=v[i];
        return cout<<sum,0;
    }
    int ctr=1,cycleBegin,cycleEnd;
    sum=v[1]=x;
    for(int i=2;;i++)
    {
        v[i]=(v[i-1]*v[i-1])%m;
        cycleBegin=seen[v[i]];
        cycleEnd=i-1;
        if(seen[v[i]])
            break;
        seen[v[i]]=i;
        sum+=v[i];
        ctr++;
    }
    long long cycleSum=0;
    for(int i=cycleBegin;i<=cycleEnd;i++)
        cycleSum+=v[i];
    long long rem=n-ctr;
    sum+=rem/(cycleEnd-cycleBegin+1)*cycleSum;
    rem%=cycleEnd-cycleBegin+1;
    for(int i=cycleBegin;i<cycleBegin+rem;i++)
        sum+=v[i];
    cout<<sum;
    return 0;
}


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

using ll = long long;
using vll = vector<ll>;
using pl4 = pair<ll,ll>;
using str = string;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;

signed main(){
    stin(s);
    ll m=1000;
    ll k;
    FOR(i,0,s.sz-3){
        k=abs(753-((int(s[i])-48)*100+(int(s[i+1])-48)*10+(int(s[i+2])-48)));
        m=((m>k)?k:m);
    }
    sal(m);
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

vector<pair<int, int>> e;
int parent[N], Size[N];

int findParent(int x) {
  if (parent[x] == x) return x;
  return parent[x] = findParent(parent[x]);
}

long long unionize(int a, int b) {
  a = findParent(a);
  b = findParent(b);
  long long ret = 0;
  if (a != b) {
    if (Size[a] < Size[b]) swap(a, b);
    parent[b] = parent[a];
    ret = 1LL * Size[a] * Size[b];
    Size[a] += Size[b];
  }
  return ret;
}

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    parent[i] = i;
    Size[i] = 1;
  }
  for (int u, v, i = 0; i < m; ++i) {
    scanf("%d %d", &u, &v);
    e.emplace_back(u-1, v-1);
  }
  long long ma = 1LL*n*(n-1)/2;
  vector<long long> ans;
  for (int i = m-1; i >= 0; --i) {
    ans.push_back(ma);
    ma -= unionize(e[i].first, e[i].second);
  }
  for (int i = ans.size()-1; i >= 0; --i) {
    printf("%lld\n", ans[i]);
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 6420
#include <iostream>

using namespace std;

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int cnt=0;
		int length=0;
		for(int i=n/2+1;i>=0;i--){
			int sum=0;
			length=0;
			for(int j=i;j>0;j--){
				sum+=j;
				length++;
				if(sum==n&&length>=2){
					cnt++;
				}
				else if(sum>n){
					break;
				}
			}
		}

		cout<<cnt<<endl;
	}
	return 0;
}

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

int main(){
  char str;
  int bitf=0;
  for(int i=0;i<3;i++){
      cin >> str;bitf |= 1<<(str-'a');
  }
  if(bitf == (1<<3)-1)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200;
const int MAX_M = 200;
const int MAX_K = 20;

/* typedef */

/* global variables */

int ks[MAX_N], sis[MAX_N][MAX_K], his[MAX_N][MAX_K];
int maxms[MAX_N];
double hs[MAX_N][MAX_M + 1], dp[MAX_N + 1][MAX_M + 1];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    cin >> ks[i];
    for (int j = 0; j < ks[i]; j++) cin >> sis[i][j] >> his[i][j];
  }
  
  for (int i = 0; i < n; i++) {
    hs[i][0] = 0.0;
    int m0 = 0;
    for (int j = 0; j < ks[i]; j++) {
      int m1 = m0 + sis[i][j] * his[i][j];
      int maxl = min(m1 - 1, m);
      for (int l = m0 + 1; l <= maxl; l++)
	hs[i][l] = hs[i][m0] + (double)(l - m0) / sis[i][j];
      if (m1 <= m) hs[i][m1] = hs[i][m0] + his[i][j];
      m0 = m1;
      if (m0 >= m) break;
    }
    maxms[i] = min(m0, m);
    continue;
    printf("maxms[%d]=%d:", i, maxms[i]);
    for (int j = 0; j <= maxms[i]; j++) printf(" %lf", hs[i][j]); putchar('\n');
  }

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) dp[i][j] = -1.0;
  dp[0][0] = 0.0;

  for (int i = 0; i < n; i++) {
    memcpy(dp[i + 1], dp[i], sizeof(dp[i]));
    for (int j = 0; j <= m; j++)
      if (dp[i][j] >= 0.0) {
	for (int k = 1; k <= maxms[i] && j + k <= m; k++) {
	  double ndp = dp[i][j] + hs[i][k];
	  if (dp[i + 1][j + k] < ndp) dp[i + 1][j + k] = ndp;
	}
      }
    continue;
    printf("%d:", i + 1);
    for (int j = 0; j <= m; j++) printf(" %lf", dp[i + 1][j]); putchar('\n');
  }

  printf("%.8lf\n", dp[n][m]);
  return 0;
}

Measured memory_bytes: 1848
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z=0;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    string s;cin>>s;
    int ans=mod;
    rep(i,0,s.size()-2){
        string str=s.substr(i,3);
        //cout<<str<<" ";
        int sum=abs(753-(stoi(str)));
        //cout<<sum<<endl;
        ans=min(ans,sum);
    }cout<<ans<<endl;return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)


int main() {
	string str;
	cin >> str;
	if (str == "SUN") cout << 7 << endl;
	if (str == "MON") cout << 6 << endl;
	if (str == "TUE") cout << 5 << endl;
	if (str == "WED") cout << 4 << endl;
	if (str == "THU") cout << 3 << endl;
	if (str == "FRI") cout << 2 << endl;
	if (str == "SAT") cout << 1 << endl;


}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int N;
    cin >> N;
    printf("%lld\n", 180 * (N - 2));
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int n,a,b;
int main() {
	cin >> n >> a >> b;
	ll ans = 0;
	if(b>=a)ans=(ll)(n-2) * (b-a)+1;
	cout << max(0ll,ans) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, ans = 0, check = 0;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for (int i = 0; i < M; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  for ( ; ans <= 999; ans++) {
    int ac = ans;
    for (int i = 0; i < N - 1; i++) {
      ac /= 10;
    }
    if (ans == 0) {
      if (N != 1) {
        continue;
      }
    }
    else if (ac < 1 || ac > 9) {
      continue;
    }
    int checker = 1;
    for (int i = 0; i < M; i++) {
      ac = ans;
      for (int j = 0; j < N - s.at(i); j++) {
        ac /= 10;
      }
      if (ac % 10 != c.at(i)) {
        checker = 0;
      }
    }
    if (checker == 1) {
      cout << ans << endl;
      check = 1;
      break;
    }
  }
  if (check == 0) {
    cout << -1 << endl;
  }
}

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

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n , p ;
    cin >> n >> p ;

    string s; 
    cin >>  s ; 
    
    if (p == 2 ){   
        ll ans = 0 ; 

        for(int i = 0 ; i < n ; ++i){
            if ((s[i] - '0' ) % 2 ==0){
                ans += i + 1; 
            }
        }

        cout << ans << "\n";
        return 0 ;
    }
    else if (p == 5){

        ll ans = 0 ;
        for(int i = 0 ; i < n ; ++i){
            if (((s[i] - '0')  == 0 ) || ((s[i] - '0') == 5) ){
                ans += i + 1 ;
            }
        }

        cout << ans << "\n";

        return 0 ;
    }

    ll P = 1 ;
    ll suf = 0  ;
    map<ll,ll> m ; 
    m[0] = 1 ;
    ll ans = 0 ;
    for(int i = n - 1 ; i >=0  ;--i){
        suf = (suf + (s[i] - '0')*P) % p;
        ans = ans + m[suf];
        m[suf]++; 

        P = (10*P)% p ;
    }
    cout << ans << "\n";

    
  
    return 0;
}



Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  long long min=9223372036854775806;
  int P=1; //集会の座標
  vector<int>X(N);
  for (int i=0; i<N; i++) cin >> X[i];
  for (int P=1; P<=100; P++){
    long long HP = 0;
    for (int i=0; i<N; i++){
      HP += (X[i]-P)*(X[i]-P);
    }
    if (min > HP) min = HP;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <vector>
#include <iomanip>
using namespace std;


int main(){
    // input
    int n; cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++){
        cin >> p.at(i);
    }

    // compute
    int ans = 0;
    for (int i = 1; i < n - 1; ++i){
        if (p.at(i-1) <= p.at(i) && p.at(i) < p.at(i+1)) ans++;
        if (p.at(i-1) > p.at(i) && p.at(i) >= p.at(i+1)) ans++;
    }
    
    // output
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int si=s.size();
  int min=INF;
  rep(i,si-2){
    int count=0;
    REP(j,i,i+3){
      if(j==i){
        count+=(s[j]-'0')*100;
      }
      else if(j==i+1){
        count+=(s[j]-'0')*10;
      }
      else{
        count+=(s[j]-'0');
      }
    }
    chmin(min,abs(count-753));
  }
  cout<<min<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define x real()
#define y imag()
using namespace std;
typedef complex <double> point;
typedef pair <int,int> P;
int n,m,w,h,S;
point L[30001][2];
point A[30001];
long long arm[30001];
 
bool ccw(point a,point b,point c){
  b-=a,c-=a;
  c*=conj(b);
  return (c.y>0);
}
 
void mk_arm(){
  memset(arm,0,sizeof(arm));
  for(int i=0;i<n;i++){
    int low=0,mid,up=m+1;
    while(low<up){
      mid=(low+up)/2;
      if(!ccw(L[mid][0],L[mid][1],A[i]))up=mid;
      else low=mid+1;
    }
    arm[low]++;
  }
   
  for(int i=1;i<=m;i++)arm[i]+=arm[i-1];
  arm[m+1]=n;
}
 
int solve(){
  long long res=0;
  for(int i=0;i<m;i++){
    int low=i,mid,up=m+1;
    while(low<up){
      mid=(low+up)/2;
      double sss=(L[mid][0].y-L[i][0].y+L[mid][1].y-L[i][1].y)*w/2.0;
      if(w*h-(sss)<S) up=mid;
      else low=mid+1; 
    }
    res=max(res,(arm[low-1]-arm[i]));
  }
  assert(n-res>=0);
  return n-res;
}
 
int main(){
   
  while(1){
    cin>>n>>m>>w>>h>>S;
    if(!n&&!m&&!w&&!h&&!S)break;
     
    L[0][0]=point(0,0),L[0][1]=point(w,0);
    for(int i=1,a,b;i<=m;i++){
      cin>>a>>b;
      L[i][0]=point(0,a);
      L[i][1]=point(w,b);
    }
 
    double a,b;
    for(int i=0;i<n;i++)cin>>a>>b,A[i]=point(a,b);
    mk_arm();
    cout << solve()<<endl;
  }
   
  return 0;
}

Measured memory_bytes: 2888
A, B, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

mincost = 10**12
for _ in range(M):
	x, y, c = [int(i) for i in input().split()]
	cost = a[x-1] + b[y-1] - c
	if cost < mincost:
		mincost = cost
nodiscount_cost = min(a) + min(b)
if nodiscount_cost < mincost:
	print(nodiscount_cost)
else:
	print(mincost)

Measured memory_bytes: 66540
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

const int MAX = 10;

int main(void) {
	int a[MAX];
	
	for(int i=0; i<MAX; i++) {
		cin >> a[i];
	}
	
	sort(a, a+MAX, greater<int>());
	
	for(int i=0; i<3; i++) {
		cout << a[i] << endl;
	}
	
	return 0;
}

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

int a,b;

int main()
{
  cin >> a >> b;
  cout << 6-a-b << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


ll ten[20];

ll val = 0;
void f(int L, int R, ll D, ll cur) {
  if (L > R) {
    if (D == 0) val += cur;
    return;
  }

  if (abs(D) > ten[R+1]) return;
  // cout << L << " " << R << " " << D << endl;

  if (L == R) {
    f(L+1, R-1, D, cur * 10);
  } else {

    for (int d = -9; d <= 9; d++) {
      ll D2 = D - (ten[R] - ten[L]) * d;
      ll ways = 10 - abs(d);
      if (L == 0) ways = 9 - abs(d);
      f(L+1, R-1, D2, cur * ways);
    }
  }

}

int main2() {
  ll D = nextLong();

  ten[0] = 1;
  REP(i, 19) ten[i+1] = ten[i] * 10;

  ll ans = 0;
  for (int k = 1; k <= 18; k++) {
    val = 0;
    f(0, k-1, D, 1);
    ans += val;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3768
let inputString;

process.stdin.on('data', (input) => { inputString += input; });

process.stdin.on('end', () => {
  proc(inputString);
});

const proc = (input) => {
  const arr = toMappedArr(input);
  const origin = collectWithNum(arr);

  quickSort(arr, 0, arr.length - 1);

  const sorted = collectWithNum(arr);
  const stable = Object
    .keys(origin)
    .every((key) => {
      return origin[key]
        .every((mark, index) => {
          return mark === sorted[key][index];
        });
    });
  console.log(stable ? 'Stable' : 'Not stable');
  console.log(arr.map((obj) => `${obj.mark} ${obj.num}`).join('\n'));
};

const toMappedArr = (input) => {
  const arr = input
    .replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));
  arr.shift();
  return arr
    .map((str) => {
      const arr = str.split(' ');
      return {
        mark: arr[0],
        num: Number(arr[1]),
      };
    });
};

const collectWithNum = (arr) => {
  const obj = {};
  arr.forEach((value) => {
    if (!!obj[value.num]) {
      obj[value.num].push(value.mark);
    } else {
      obj[value.num] = [value.mark];
    }
  });
  return obj;
};

const quickSort = (arr, p, r) => {
  if (p < r) {
    const q = partition(arr, p, r);
    quickSort(arr, p, q - 1);
    quickSort(arr, q + 1, r);
  }
};

const partition = (arr, p, r) => {
  const x = arr[r].num;
  let i = p - 1;
  for (let j=p; j<r; j++) {
    if (arr[j].num <= x) {
      i = i + 1;
      const needToBeInLeft = arr[j];
      const needToBeInRight = arr[i];
      arr[i] = needToBeInLeft;
      arr[j] = needToBeInRight;
    }
  }
  const needToBeInRight = arr[r];
  const needToBeInLeft = arr[i + 1];
  arr[i+1] = needToBeInRight;
  arr[r] = needToBeInLeft;
  return i + 1;
};


Measured memory_bytes: 77232
import sys
if sys.subversion[0] == "PyPy":
    import io, atexit
    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
    
    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()

n, a, b, c = map(int, raw_input().split())
cmds = []

def getidx(c):
    return 'ABC'.index(c)

g = [ [], [], [] ]
for i in xrange(n):
    s = raw_input()
    cmds.append(s)
    g[getidx(s[0])].append(i)
    g[getidx(s[1])].append(i)

def getnext(c, idx):
    v = g[getidx(c)]
    l, r = 0, len(v) - 1
    while l <= r:
        m = (l + r) / 2
        if v[m] <= idx:
            l = m + 1
        else:
            r = m - 1
    if l >= len(v):
        return n
    return v[l]

cnt = [a, b, c]
res = []


for i in xrange(n):
    cmd = cmds[i]
    p1 = ord(cmd[0]) - ord('A')
    p2 = ord(cmd[1]) - ord('A')

    if cnt[p1] > 1 or cnt[p2] > 1 or cnt[p1] == 0 or cnt[p2] == 0:
        if cnt[p1] > cnt[p2]:
            res.append(cmd[1])
            cnt[p1] -= 1
            cnt[p2] += 1
        else:
            res.append(cmd[0])
            cnt[p1] += 1
            cnt[p2] -= 1
        if min(cnt) < 0:
            res = []
            break
    elif i == n - 1:
        res.append(cmd[0])
        cnt[p1] += 1
        cnt[p2] -= 1
    else:
        # print cnt, p1, p2
        assert cnt[p1] == 1 and cnt[p2] == 1
        assert i + 1 < n

        nxt = cmds[i + 1]
        idx1 = getnext(cmd[0], i)
        idx2 = getnext(cmd[1], i)
        assert min(idx1, idx2) > i

        if idx1 < idx2:
            res.append(cmd[0])
            cnt[p1] += 1
            cnt[p2] -= 1
        else:
            res.append(cmd[1])
            cnt[p1] -= 1
            cnt[p2] += 1
    assert min(cnt) >= 0

if not res:
    print 'No'
else:
    print 'Yes'
    print '\n'.join(res)



Measured memory_bytes: 91308
import java.util.Scanner;

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

		int p1,p2;
		p1 = n*a;
		p2 = b;
		if(p1<p2){
			System.out.println(p1);
		}else{
			System.out.println(p2);
		}
	}
}


Measured memory_bytes: 23764
f :: [String] ->[(Int,Int,Int)]
f []=[]
f (x:xs)=let (t1:x1:y1:[])=map read (words x)::[Int]
         in (t1,x1,y1):f xs

f2 ::(Int,Int,Int)->[(Int,Int,Int)]->String
f2 _ [] = "Yes"
f2 (t0,x0,y0) ((t1,x1,y1):xs) = let d = abs(x0-x1)+abs(y0-y1)
                                in if t1-t0>=d && (t1-t0-d) `mod` 2==0 then f2 (t1,x1,y1) xs else "No"

main = do
      e<-getLine
      xs<-getContents
      let ys=f (lines xs)
      putStrLn $ f2 (0,0,0) ys

Measured memory_bytes: 2300
#include <stdio.h>

int main() {
    int N,R,Hrate,Nrate;
    scanf("%d%d",&N,&R);
    if(N>=10){
        printf("%d",R);
    }
    else{
        Hrate=100*(10-N);
        Nrate=R+Hrate;
        printf("%d",Nrate);
    }
    return 0;
}


Measured memory_bytes: 128
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 2e6+10;
LL fac[SIZE],inv[SIZE];
LL mypow(LL x,LL y){
    LL res=1;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
LL C(int x,int y){
    if(y<0||y>x)return 0;
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
void build(){
    assert(MOD>=SIZE);
    fac[0]=1;
    REPP(i,1,SIZE)fac[i]=fac[i-1]*i%MOD;
    inv[SIZE-1]=mypow(fac[SIZE-1],MOD-2);
    for(int i=SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%MOD;
}
int main(){
    build();
    int r1,r2,c1,c2;
    R(r1,c1,r2,c2);
    LL an=0;
    FOR(i,r1,r2)ADD(an,C(i+c2+1,i+1)-C(i+c1,i+1));
    W(an);
    return 0;
}


Measured memory_bytes: 31488
# vim: fileencoding=utf-8

import math


def main():
    n, c, k = map(int, input().split())
    t = []
    for x in range(n):
        t.append(int(input()))
    t.sort()
    ans = 0
    bucket = []
    for i in t:
        while len(bucket) >= c:
            ans += 1
            bucket = bucket[c:]
        while len(bucket) > 0 and bucket[0] + k < i:
            ans += 1
            bucket = bucket[c:]
        bucket.append(i)
    ans += math.ceil(len(bucket) / c)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 81080
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
string a="CODEFESTIVAL2016",b; 
int ans;
int main()
{
  cin>>b;
  for(int i=0;i<16;i++)if(a[i]!=b[i])ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())


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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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


uf = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))
print(ans)

Measured memory_bytes: 76372
#include <stdio.h>
#include <string.h>
 
int main(void){
  int i,j,k,n,s;
  char ca[200],can[200];
 
  while(1){
    scanf("%s\n%d", ca, &n);
    if(!strcmp(ca, "-")) break;
    
    for(i=0;i<n;i++){
      scanf("%d", &s);
      for(j=s;ca[j]!='\0';j++)
        can[j-s] = ca[j];
      for(k=0;k<s;k++)
        can[j-s+k] = ca[k];
      
      for(j=0;ca[j]!='\0';j++)
        ca[j] = can[j];
    }
 
    printf("%s\n", ca);
  }
 
  return 0;
}



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

int main() {
	int N, a[100] = { 0 },mini=1000000000,maxi=0,sum=0,ans=0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] > maxi)maxi = a[i];
	}
	
	for (int i = -100; i <= 100; i++) {
		for (int j = 0; j < N; j++) {
			sum += (i - a[j])*(i - a[j]);
		}
		if (sum < mini) { mini = sum; ans = i; }
		sum = 0;
	}
	cout << mini<< "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
using lint=int64_t;
using namespace std;

int main()
{
	string S;

	cin >> S;

	sort(S.begin(),S.end());
	if(S[0]==S[1] && S[2]==S[3] && S[0]!=S[2])
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define f(i,x,n) for(ll int i=x;i<n;i++) 
#define re(j,x,n) for(ll int j=x;j>=n;j--)
#define f1(k,x,n) for(ll int k=x;k<=n;k++)
#define mp make_pair
#define pb push_back
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int count=0,c[n],v[n];
    f(i,0,n)
    cin>>v[i];
    f(i,0,n)
    cin>>c[i];
    f(i,0,n)
    {
      if(v[i]>c[i])
      count+=v[i]-c[i];
    }
    cout<<count;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int N = in.nextInt();
        int A = in.nextInt();
        if(N%500 <= A)
        {
            System.out.println("Yes");
        }
        else
            {
                System.out.println("No");
            }

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 22996
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int a[110],b[110];
int dp[3][3][110];

int main() {
	int n,k;
	cin>>n>>k;
	rep(i,k){
		cin>>a[i]>>b[i];
		--a[i];
		--b[i];
	}
	memset(dp,0,sizeof(dp));
	rep(i,n)rep(p,3)rep(j,3){
		int t;
		rep0(t,k)if(a[t]==i&&b[t]!=j)break;
		if(t<k)continue;
		if(i==0)dp[0][j][i]=1;
		else if(i==1){
			rep(s,3){
				dp[p][j][i]+=dp[s][p][i-1];
				dp[p][j][i]%=10000;
			}
		}else{
			rep(s,3)if(p!=j||s!=p){
				dp[p][j][i]+=dp[s][p][i-1];
				dp[p][j][i]%=10000;
			}
		}
	}
//rep(i,n)rep(j,3)rep(t,3)cout<<i<<" "<<j<<" "<<t<<" "<<dp[j][t][i]<<endl;
	int res=0;
	rep(i,3)rep(j,3)res+=dp[i][j][n-1];
	cout<<res%10000<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#define int long long
#define MOD 10000
using namespace std;

int m;
int dp[510][500][10][4][2] = {};//keta,mod,prevnum,UorDorNoorZero,limit

int calc(string s){
	for(int i = 0;i <= s.length();i++){
		for(int j = 0;j < m;j++){
			for(int k = 0;k < 10;k++){
				for(int l = 0;l < 4;l++){
					for(int o = 0;o < 2;o++) dp[i][j][k][l][o] = 0;
				}
			}
		}
	}
	dp[0][0][0][3][1] = 1;
	for(int i = 0;i < s.length();i++){
		for(int j = 0;j < m;j++){
			for(int k = 0;k < 10;k++){
				for(int l = 0;l < 10;l++){
					if(k < l){
						(dp[i + 1][(j * 10 + l) % m][l][0][0] += dp[i][j][k][1][0] + dp[i][j][k][2][0]) %= MOD;
						if(l < s[i] - '0') (dp[i + 1][(j * 10 + l) % m][l][0][0] += dp[i][j][k][1][1] + dp[i][j][k][2][1]) %= MOD;
						else if(l == s[i] - '0') (dp[i + 1][(j * 10 + l) % m][l][0][1] += dp[i][j][k][1][1] + dp[i][j][k][2][1]) %= MOD;
					}
					else if(k > l){
						(dp[i + 1][(j * 10 + l) % m][l][1][0] += dp[i][j][k][0][0] + dp[i][j][k][2][0]) %= MOD;
						if(l < s[i] - '0') (dp[i + 1][(j * 10 + l) % m][l][1][0] += dp[i][j][k][0][1] + dp[i][j][k][2][1]) %= MOD;
						else if(l == s[i] - '0') (dp[i + 1][(j * 10 + l) % m][l][1][1] += dp[i][j][k][0][1] + dp[i][j][k][2][1]) %= MOD;
					}
					if(!k){
						if(!l) (dp[i + 1][j][0][3][0] += dp[i][j][k][3][0] + dp[i][j][k][3][1]) %= MOD;
						else{
							(dp[i + 1][(j * 10 + l) % m][l][2][0] += dp[i][j][k][3][0]) %= MOD;
							if(l < s[i] - '0') (dp[i + 1][(j * 10 + l) % m][l][2][0] += dp[i][j][k][3][1]) %= MOD;
							else if(l == s[i] - '0') (dp[i + 1][(j * 10 + l) % m][l][2][1] += dp[i][j][k][3][1]) %= MOD;
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0;i < 10;i++){
		for(int j = 0;j < 3;j++){
			for(int k = 0;k < 2;k++){
				ans = (ans + dp[s.length()][0][i][j][k]) % MOD;
			}
		}
	}
	return ans;
}

signed main(){
	string a,b;
	cin >> a >> b >> m;
	for(int i = a.length() - 1;i >= 0;i--){
		if(a[i] != '0'){
			a[i]--;
			if(!i && a[i] == '0') a = a.substr(1,a.length() - 1);
			break;
		}
		a[i] = '9';
	}
	//cout << calc(b) << endl;
	cout << (calc(b) - calc(a) + MOD) % MOD << endl;
	return 0;
}

Measured memory_bytes: 159716
#include<iostream>
using namespace std;
int main(){
    int p[3] = {0};
    int pmin = 9999;
    int j[2] = {0};
    int jmin = 9999;
    for(int i = 0;i < 3;i++){
        cin >> p[i];
        if(p[i] <= pmin){
            pmin = p[i];
        }
    }
    for(int i = 0;i < 2;i++){
        cin >> j[i];
        if(j[i] <= jmin){
            jmin =j[i];
        }
    }
    cout << pmin+jmin-50 << endl;
}

Measured memory_bytes: 3044