akhauriyash/Code-Regression huggingface dataset:
/*
AOJ 0121 Seven Puzzle

?¢???????7??°???????¢??????¨2??4????£????????????????7????£??????????????£?????????????1???7???????????°?????????????£???????????????°???????????????
?£??????????????????????????????¨0??¨??????????????????????????????????????????????£?????????\?§???°??????????????\?£???????????????????????????????
????????????????§???¶?????????????????\??¬?§???°????????¶???????????????????§????????§???¶?????¬????????????????????¶???????§???¨?£??????\??°????°?????§???¨??\??????

?????\??????????????\?????????8?????°?????¨???????§???¶??????????????°????¬¬??????????????°?????????????????°????¬¬??????????????°??????

?????????????°???????????°???\?????\????????\??¶?????°???????????¶??????0 1 2 3 4 5 6 7???
 */
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }

const int N = 8;
int f[N+1], v[N];
int *dp;

int encode(void) {
  int val[N], loc[N];
  REP(i, N) val[i] = v[i], loc[v[i]] = i;
  int ans = 0;
  REP(i, N) {
    int j = loc[i];
    ans += (j - i) * f[N - 1 - i];
    swap(val[i], val[j]);
    loc[i] = i;
    loc[val[j]] = j;
  }
  return ans;
}

int decode(int idx) {
  REP(i, N) v[i] = i;
  FOR(i, 1, N) {
    int loc = idx % i + (N - i);
    idx /= i;
    swap(v[loc], v[N-i]);
  }
  REP(i, N) if (v[i] == 0) return i;
  return -1;
}

int change[3][8] = {
  {-1, 0, 1, 2, -1, 4, 5, 6},
  {1, 2, 3, -1, 5, 6, 7, -1},
  {4, 5, 6, 7, 0, 1, 2, 3}};

void init(void) {
  f[0] = 1;
  FOR(i, 1, N) f[i] = f[i-1] * i;
  dp = new int[f[N]];
  memset(dp, -1, sizeof(dp[0]) * f[N]);
  dp[0] = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int idx = q.front();
    int z = decode(idx);
    q.pop();
    REP(i, 3) {
      int j = change[i][z];
      if (j == -1) continue;
      swap(v[z], v[j]);
      int next = encode();
      if (dp[next] == -1) {
        dp[next] = dp[idx] + 1;
        q.push(next);
      }
      swap(v[z], v[j]);
    }
  }
}

bool readline(void) {
  REP(i, 8) if (scanf("%d", &v[i]) != 1) return false;
  return true;
}

int main(int argc, char *argv[]) {
  init();
  while (readline()) printf("%d\n", dp[encode()]);
  delete[] dp;
  dp = NULL;
}

Measured memory_bytes: 1268
/+ AOJ 0014 +/
import std.stdio;
import std.conv;
import std.string;
import std.array;
void main()
{
	string input;
	while(true){
		input = readln();
		if(chomp(input).length == 0) break;
		int d = to!int(chomp(input));
		int s;
		for(int i = 0; i * d < 600; i++) {
			s += i * d * i * d * d;
		}
		writefln("%d", s);
	}
}

Measured memory_bytes: 984
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll a[MAX];


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


  cin >> n;
  rep(i, n) cin >> a[i];
  ll pre = inf, idx;
  rep(i, n) {
    if (mi > a[i]) {
      idx = i;
      mi = a[i];
    }
  }
  while (pre != mi) {
    rep(i, n) {
      if (idx == i) continue;
      a[i] %= mi;
    }

    pre = mi;
    rep(i, n) {
      if (!a[i]) continue;
      if (mi > a[i]) {
        idx = i;
        mi = a[i];
      }
    }
  }
  cout << mi << endl;

  return 0;
}

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

int main()
{
    int N, W;
    cin >> N >> W;
 
    int v[N],w[N];
    
    for(int i=0; i<N; i++){
        cin >> v[i] >> w[i];
    }
 
    int dp[N+1][W+1];

    for(int j=0; j<=W; j++)
        dp[N][j] = 0;
 
    for(int i=N-1; i>=0; i--){
        for(int j=0; j<=W; j++){
            if(j<w[i])
                dp[i][j] = dp[i+1][j];
            else{
                if(dp[i+1][j]>dp[i+1][j-w[i]]+v[i])
                    dp[i][j] = dp[i+1][j];
                else    
                    dp[i][j]=dp[i+1][j-w[i]]+v[i];         
             }
        }
   } 
    cout << dp[0][W] << endl;
 
    return 0;
}

Measured memory_bytes: 7000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
int main(){
  int n,i;cin>>n;double g,h;
  for(i=0;i<n;i++){cin>>h;g+=(1.0000000/h);}
  double ans=1.000000;ans/=g;
  cout<<ans<<endl;
}

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

def prepare(n):
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]

    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

    return fact, factinv

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    return f[n] * v[r] * v[n - r] % p

f,v = prepare(n)

ans = 0
for i in range(k + 1):
    a = cmb(n-1,i,p) * m * pow(m-1,n-i-1,p) % p
    ans += a
    ans %= p

print(ans)


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int nax = 2e5 + 100;

vector<int> g[nax];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
	#endif
	int n;
	cin>>n;
	vector<vector<int>> a(2,vector<int>(n)),dp(2,vector<int>(n));
	for(int x=0;x<2;x++)
		for(int i=0;i<n;i++)
			cin>>a[x][i];

	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			if(i)dp[i][j] = max(dp[i][j] , a[i][j] + dp[i-1][j]);
			else dp[i][j] = max(dp[i][j],a[i][j]);
			if(j)dp[i][j] = max(dp[i][j] , a[i][j] + dp[i][j-1]);
			else dp[i][j] = max(dp[i][j],a[i][j]);
		}
	}
	cout << dp[1][n-1] << endl;;
}

Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

typedef vector<ll> t;
typedef vector<t> T;

int n,A;
vi a;
T dp;

int main(){
	cin>>n>>A;
	a=vi(n);
	int M=0,m=0;
	for(vi::iterator i=a.begin();i!=a.end();i++){
		cin>>*i;
		*i-=A;
		if(*i>0) M+=*i;
		else m-=*i;
	}
	int W=M+m+1;
	dp=T(n+1,t(W));
	dp[0][m]=1;
	for(int i=1;i<=n;i++) for(int j=0;j<W;j++){
		dp[i][j]=dp[i-1][j];
		int cj=j-a[i-1];
		if(0<=cj&&cj<W) dp[i][j]+=dp[i-1][cj];
	}
	cout<<dp[n][m]-1<<endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();

        int contest = 0;

        for (int i = 1; i <= 9; ++i)
        {
            contest = i * 100 + i * 10 + i;
            if (n <= contest) { break; }
        }

        Console.WriteLine(contest);
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mii map<int,int>
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b)  (x/gcd(x,y))*y
#define inf (long long) 1e18
#define neg_inf (long long) (-1*1e18)
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n)  for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define deb(x) cout << #x << "=" << x <<"\n";
const int N = 1e9 + 7;

int pow(int x, int y) { int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int pow(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }



void solve()
{
    int h,w;
    cin>>h>>w;
    vector<vector<char>> v(h+1,vector<char>(w+1,'.'));


    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>v[i][j];
        }
    }
    vector<vector<int>> dp(h+1,vector<int> (w+1,0));

    dp[1][1]=1;

    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(v[i][j]=='.')
            {
                dp[i][j]=dp[i-1][j]+dp[i][j-1]+dp[i][j];
                dp[i][j]%=N;
            }
        }
    }
    cout<<dp[h][w];
} 



int32_t main()
{
  // #ifndef ONLINE_JUDGE
 //    freopen("gymnastics.in", "r", stdin);
 //    freopen("gymnastics.out", "w", stdout);
  // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t=1;
    // cin>>t;

   while(t--)
   {
      solve();
   }
}






//code by-Roshan











//unnecessary
// bool cmp(pair<int,int> &a,pair<int,int> &b)
// {
//  if(a.F==b.F)
//    return (a.S<b.S);
//  else 
//    return (a.F<b.F);
//  //< =chota wala pehle
//  //> =chota wala baad me
// }


//better use this structure
// struct s{
//  int a;
//  bool operator <(const s &x) const
//  {
//    return (a>x.a);
//  }
// };



//  priority_queue<int,vector<int>,greater<>> p;(priority queue as min heap)



Measured memory_bytes: 12164
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
#define ll long long
//#define local

using namespace std;

const int MOD = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 5005;

set <string> s;

int main() {
#ifdef local
    if(freopen("/Users/Andrew/Desktop/data.txt", "r", stdin) == NULL) printf("can't open this file!\n");
#endif
    int a;
    scanf("%d", &a);
    bool flag = 1;
    string str[105];
    cin >> str[1];
    s.insert(str[1]);
    for (int i = 2; i <= a; ++i) {
        cin >> str[i];
        int len = int(str[i-1].size());
        if (s.count(str[i]) || (str[i][0] != str[i-1][len-1]))
            flag = 0;
        else s.insert(str[i]);
    }
    if (flag == 1) printf("Yes\n");
    else printf("No\n");
#ifdef local
    fclose(stdin);
#endif
    return 0;
}











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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main()
{
	int n;
	cin >> n;
	int a[n+1], b[n+1], c[n+1];
	for(int i=1;i<=n;i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	int dp[n+1][3];
	dp[0][1] = 0;
	dp[0][0] = 0;
	dp[0][2] = 0;
	for(int i=1;i<=n;i++)
	{
		dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i];
		dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";
	return 0;
}

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

int main(void){
    int N,ans = 1;
    int imax = 0;

    cin >> N;

    rep(i,N){

        int count = 0;
        int curv = i;
        while (curv%2 == 0 && curv > 0)
        {
            curv /=2;
            count++;
        }
        if(imax < count){
            imax = count;
            ans = i;
        }
            
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    lis=[[0]*9 for _ in range(9)]
    for i in range(1,n+1):
        si=str(i)
        if int(si[-1])>0:
            lis[int(si[0])-1][int(si[-1])-1]+=1
    cunt=0
    for i in range(9):
        for j in range(9):
            cunt+=lis[i][j]*lis[j][i]
    print(cunt)
    
    

if __name__=='__main__':
    main()

Measured memory_bytes: 40940
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let mut ans  = true;
    for i in (b'a'..=b'z').map(|c| c as char).filter(|c| c.is_alphabetic()).collect::<Vec<_>>() {
        if !s.contains(i) {
            println!("{}", i);
            ans = false;
            break;
        }
    }
    if ans {
        println!("None");
    }
}


Measured memory_bytes: 2240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();
            int iX = int.Parse(sS);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            iOut += (iX / 500) * 1000;
            iOut += ((iX % 500) / 5) * 5;

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll ans = 0;
    if (s[0] != s[s.size() - 1]) {
        for (int i = 0; i < s.size() - 1; ++i) {
            if (s[i] == s[i + 1]) {
                ans++;
                i++;
            }
        }
        cout << ans * k;
    } else {
        bool flag = true;
        for (int i = 0; i < s.size() - 1; ++i) {
            if (s[i] != s[i + 1]) {
                flag = false;
            }
        }
        if (flag) {
            cout << (s.size() * k) / 2;
        } else {
            int i = 1;
            while (s[i] == s[i - 1]) {
                i++;
            }
            int j = s.size() - 2;
            while (s[j] == s[j + 1]) {
                j--;
            }
            for (int k = i; k <= j; ++k) {
                if (s[k] == s[k + 1]) {
                    ans++;
                    k++;
                }
            }
            cout << ans * k + i / 2 + (s.size() - 1 - j) / 2 + ((i + s.size() - 1 - j) / 2) * (k - 1);
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
const int MAX_N = 105;

int N, len[MAX_N];

int isOK(int now, int d){
  int i;
  int tmp[MAX_N], tmp_i = 0;
  for(i = 0; i < N; ++i){
    if(i == now) continue;
    tmp[tmp_i] = len[i];
    ++tmp_i;
  }

  for(i = 0; i < tmp_i - 1; ++i){
    if(tmp[i + 1] - tmp[i] != d)
      return 0;
  }
  return 1;
}

//int main(void) {
//  int i;
//  scanf("%d", &N);
//  ++N;
//  for(i = 0; i < N; ++i)
//    scanf("%d", &len[i]);
//
//  int ans = -1;
//  for(i = 0; i < N; ++i){
//    int d = (i != 0 && i != 1 ? len[1] - len[0] : len[3] - len[2]);
//    if(isOK(i, d))
//      ans = i;
//  }
//  printf("%d\n", len[ans]);
//  return 0;
//}
//
int main(void) {
  int i;
  while(1){
    scanf("%d", &N);
    if(!N) break;
    ++N;
    for(i = 0; i < N; ++i)
      scanf("%d", &len[i]);

    int ans = -1;
    for(i = 0; i < N; ++i){
      int d = (i != 0 && i != 1 ? len[1] - len[0] : len[3] - len[2]);
      if(isOK(i, d))
        ans = i;
    }
    printf("%d\n", len[ans]);
  }
  return 0;
}

Measured memory_bytes: 1032
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    a = list(mi())
    d = [0]*9
    for i in range(N):
        if a[i] < 400:
            d[0] = 1
        elif a[i] < 800:
            d[1] = 1
        elif a[i] < 1200:
            d[2] = 1
        elif a[i] < 1600:
            d[3] = 1
        elif a[i] < 2000:
            d[4] = 1
        elif a[i] < 2400:
            d[5] = 1
        elif a[i] < 2800:
            d[6] = 1
        elif a[i] < 3200:
            d[7] = 1
        else:
            d[8] += 1

    print(max(1, sum(d[:-1])), sum(d))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62136
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    int map[26] = {0};

    int n;
    scanf("%d", &n);
    char **str_list = malloc(n * sizeof(char *));

    for (int i = 0; i < n; i++)
    {
        str_list[i] = malloc(51 * sizeof(char));
        scanf("%s", str_list[i]);
    }

    for (int i = 0; i < 26; i++)
    {
        char letter = 'a' + i;
        int min = 50;
        for (int j = 0; j < n; j++)
        {
            int letter_count = 0;
            for (int k = 0; k < strlen(str_list[j]); k++)
            {
                if (str_list[j][k] == letter) letter_count++;
            }
            if (letter_count < min) min = letter_count;
        }
        map[i] = min;
    }

    for (int i = 0; i < 26; i++)
    {
        char letter = 'a' + i;
        for (int j = 0; j < map[i]; j++)
        {
            printf("%c", letter);
        }
    }

    return 0;
}


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

using ll = long long int;


int main(){
    ll n, L;
    cin >> n >> L;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int idx = -1;
    for(int i=0;i<n-1;i++){
        if(a[i]+a[i+1] >= L){
            idx = i;
            break;
        }
    }
    if(idx != -1){
        cout << "Possible" << endl;
        for(int i=0;i<idx;i++){
            cout << i+1 << endl;
        }
        for(int i=n-2;i>=idx;i--){
            cout << i+1 << endl;
        }
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(b%a==0){
            System.out.println(a+b);
        }else{
            System.out.println(b-a);
        }
        sc.close();
    }
}

Measured memory_bytes: 23252
def setM():
    k = K2 // 2
    while k:
        m = int(("1" * (K2 - k) + "0" * (K2 + k)) * 3001, 2)
        M.append((k, m, ~m, (1 << K2 + k) % P))
        k //= 2
        break

def modp(n):
    for k, m, tm, a in M:
        n = (n & tm) + ((n & m) >> K2 + k) * a
    return n

K = 64
K2 = K // 2
P = 998244353
mm = (1 << K * 3001) - 1
mmm = (1 << K) - 1
M = []
setM()
N, S = map(int, input().split())
A = [int(a) for a in input().split()]
s = 0
ans = 0
for a in A:
    s += 1
    s += s << a * K
    s &= mm
    s = modp(s)
    ans += (s >> S * K) & mmm

print(ans % P)

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main(){
  int a,b;
  cin>>a>>b;
  int c=b-a+1;
  c/=2;
  c%=2;
  int res;
  if(a%2==0){
    if(b%2==0)res=b^c;
    else res=c;
  }
  else {
    if(b%2==0)res=a^b^(c^1);
    else res=a^c;
  }
  cout<<(res)<<endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}

int modpow(int x, int n, int m){
    int a = 1;
    IREP(i, 64){
        a = (a * a) % m;
        if(((n >> i) & 1) == 1) a = (a * x) % m;
    }
    return a;
}

signed main(){

    int N; cin >> N;
    vec h(N + 1, 1); REP(i, N) cin >> h[i + 1];
    int mod = 1000000007;

    set<int> s;
    REP(i, N + 1) s.insert(h[i]);
    map<int, int> m;
    vec v(0);
    for(int i: s) v.push_back(i);
    int n = v.size();
    //REP(i, n) cout << v[i] << endl;

    mat dp(N + 1, vec(n + 1, 0));
    dp[0][n] = 1;
    REP(i, N){
        int j0 = Lower_bound(v, h[i]);
        int j1 = Lower_bound(v, h[i + 1]);
        if(j1 <= j0){
            REP(j, j1 + 1){
                dp[i + 1][j] = dp[i][j];
            }
            FOR(j, j1 + 1, n + 1){
                dp[i + 1][n] += 2 * dp[i][j];
                dp[i + 1][n] %= mod;
            }
        }else{
            REP(j, j0 + 1){
                dp[i + 1][j] = (dp[i][j] * modpow(2, h[i + 1] - h[i], mod)) % mod;
            }
            FOR(j, j0 + 1, j1 + 1){
                int tmp = ((modpow(2, v[j] - v[j - 1], mod) + mod - 1) * modpow(2, h[i + 1] - v[j], mod)) % mod;
                dp[i + 1][j] = (2 * dp[i][n] * tmp) % mod;
            }
            dp[i + 1][n] = (2 * dp[i][n]) % mod;
        }
    }

    //debug(dp);

    int ans = 0;
    REP(i, n + 1) ans = (ans + dp[N][i]) % mod;
    cout << ans;
    
    return 0;
}

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

using namespace std;

typedef long long int ll;

const ll MOD = 1e9+7;

ll mod(ll x) {
	x = x % MOD;

	if (x < 0) {
		x += MOD;
	}

	return x;
}

int main() {
	int n;

	cin >> n;

	vector <ll> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll ans = 0;

	for (int j = 0; j < 60; j++) {
		ll ones = 0;
		ll zeros = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] & (1LL << j)) {
				ones++;
			} else {
				zeros++;
			}
		}

		ans = ans + mod(mod(1LL << j) * mod(ones * zeros));
		ans = mod(ans);
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 5572
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int a[100001];
map<int,int> tb;
vector<int> v2,v1;
int main(){
    int n,ai;
    cin>>n;
    rep(i,n){
        cin>>ai;
        ++tb[ai];
    }
    int cnt=0;
    for(auto it:tb){
        if(it.second>1){
            rep(i,it.second-1) v2.pb(it.first);
        }
        else v1.pb(it.first);
    }
    int ans=0;
    sort(v2.begin(),v2.end());
    int sz=tb.size();
    if(sz%2==0) --ans;
    v2.erase(unique(v2.begin(),v2.end()),v2.end());
    ans+=v1.size()+v2.size();
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
	string s;
	if (n == 25)s = "Christmas";
	if (n == 24) s = "Christmas Eve";
	if (n == 23) s = "Christmas Eve Eve"; 
	if (n == 22) s = "Christmas Eve Eve Eve";
	cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

class Dice2{
public:
	Dice2(){
		number = new int[6];
		relative = new int[55];
		relative[31] = relative[43] = relative[24] = relative[12] = 0;
		relative[3] = relative[20] = relative[52] = relative[35] = 1;
		relative[1] = relative[40] = relative[54] = relative[15] = 2;
		relative[4] = relative[10] = relative[51] = relative[45] = 3;
		relative[2] = relative[30] = relative[53] = relative[25] = 4;
		relative[21] = relative[42] = relative[34] = relative[13] = 5;
 	};
	~Dice2(){
		delete[] number;
		delete[] relative;
	};

	void setNumber(int index,int num){
		number[index] = num;
	};

	int returnRight(int top,int front){
		int top_index,front_index;
		for(int i = 0; i < 6; i++){
			if(number[i] == top)
				top_index = i;
			if(number[i] == front)
				front_index = i;
		}
		return number[relative[10*top_index+front_index]];
	}
private:
	int* number;
	int* relative;
};

int main(){
	Dice2 dice2;
	int x,q,top,front;
	for(int i = 0; i < 6; i++){
		scanf("%d",&x);
		dice2.setNumber(i,x);
	}
	scanf("%d",&q);
	for(int i = 0; i < q; i++){
		scanf("%d %d",&top,&front);
		printf("%d\n",dice2.returnRight(top,front));
	}
}


Measured memory_bytes: 2684
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	int count=0;
	rep(i,n) {
		if(i%2==0 && a[i]%2==1) count++;
	}
	print(count);
}


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

int main(){
	string s;
  	cin >> s;
  	deque<char> q;
  	for(char c : s) q.push_back(c);
  	bool flip = false;
  	int n;
  	cin >> n;
  
  	rep(i, n){
    	int t;
      	cin >> t;
      	if(t == 1){
        	flip = !flip;
        } else {
        	int f; char c;
          	cin >> f >> c;
          	if(flip) f = 3 - f;
          	if(f == 1){
            	q.push_front(c);
            } else {
            	q.push_back(c);
            }
        }
    }
  
  	if(flip) reverse(q.begin(), q.end());
  	string ans;
  	for(char c : q) ans += c;
  	cout << ans << endl;
}

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

int main(){
  int x,y,r = 1;

  scanf("%d%d",&x,&y);
  if(x<1 || 10*10*10*10*10*10*10*10*10<x)exit(0);
  if(y<1 || 10*10*10*10*10*10*10*10*10<y)exit(1);

  if(x>=y){
    while(r!=0){
      r = x % y;
      x = y;
      y = r;
    }
    printf("%d\n",x);
  }

  else{
    while(r!=0){
      r = y % x;
      y = x;
      x = r;
    }
    printf("%d\n",y);
  }
  
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <vector>

#define rep(i, n) for(int i = 0; i < n; i++)
#define ll long long int
#define ull unsigned ll
using namespace std;

int main(){
	int n;
	while(cin >> n && n){
		vector<int> numset;
		numset.clear();
		rep(i, n){
			int num;
			cin >> num;
			numset.push_back(num);
		}

		ull dp[128][21];
		rep(i, n)rep(j, 21) dp[i][j]= 0;
		
		dp[1][numset[0]] = 1;

		for(int i = 1; i < n - 1; i++){
			rep(j, 21){
				if(dp[i][j] == 0) continue;
				int plus = j + numset[i];
				int minus = j - numset[i];
				
				if(plus <= 20){
					dp[i+1][plus] += dp[i][j];
				}
				
				if(minus >= 0){
					dp[i+1][minus] += dp[i][j];
				}
			}
		}
		cout << dp[n-1][numset.back()] << endl;
	}
	
	return 0;
}


	

Measured memory_bytes: 1224
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 22 18:54:37 2018
ABC086
@author: maezawa
"""

n = int(input())
tarr = []
xarr = []
yarr = []
for _ in range(n):
    t, x, y = list(map(int, input().split()))
    tarr.append(t)
    xarr.append(x)
    yarr.append(y)

is_ok = True
x0 = 0
y0 = 0
t0 = 0
for i in range(n):
    xi = xarr[i]
    yi = yarr[i]
    ti = tarr[i] - t0
    d = abs(xi-x0) + abs(yi-y0)
    if d > ti:
        is_ok = False
        break
    if ti % 2 == 1 and d % 2 == 0:
        is_ok = False
        break
    if ti % 2 == 0 and d % 2 == 1:
        is_ok = False
        break
    x0 = xi
    y0 = yi
    t0 = tarr[i]
    
if is_ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 11836
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	ss := make([]bool, n)
	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)
		var a int
		for j := 0; j < d; j++ {
			fmt.Scan(&a)
			a--
			ss[a] = true
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if !ss[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int ans = 0;
  if(s[0] == t[0]) ans++;
  if(s[1] == t[1]) ans++;
  if(s[2] == t[2]) ans++;
  cout << ans <<endl;
	
  return 0;
}


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

using namespace std;

void Main() {
    int x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC" << endl;
    }
    else {
        cout << "ARC" << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int INF = 1000100000;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  int n;
  ll k;
  cin >>n >> k;
  int a[n];
  int b;
  ll bucket[100010]={};
  rep(i,n){
    cin >> a[i];
    cin>>b;
    bucket[a[i]]+=b;
  }
  ll counter=0;
  int ans;
  rep(i,100005){
    counter+=bucket[i];
    if(counter>=k){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}


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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>

using namespace std;
vector<long long int>global(100001, -1);

long long int compute(long long int arr[], long long int start, long long int n, long long int k)
{
	if (global[start] != -1)
		return global[start];

	if (start >= n - 1) {
		return 0;
	}
	long long int p = INT_MAX;
	for (int i = 1; i <= k; i++) {
		if (start + i < n) {
			p = min(p, abs(arr[start] - arr[start + i]) + compute(arr, start + i, n, k));
		}
	}
	global[start] = p;
	return global[start];
}


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int n;
	cin >> n;
	long long int k;
	cin >> k;
	long long int arr[n];
	for (long long int i = 0; i < n; i++)
		cin >> arr[i];

	cout << compute(arr, 0, n, k) << endl;







	return 0;


}


Measured memory_bytes: 12592
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i64>();
    let b=read::<i64>();
    println!("{}",if (a-b).abs()<2{"Brown"}else{"Alice"})
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)

int main(){
  int n,m,ttl=0;cin>>n>>m;
  vector<int> x(n,0);
  REP(i,n){
    cin>>x.at(i);
    ttl+=x.at(i);
  }
  int ans=0;
  REP(i,n){
    if(x.at(i)>=(ttl+4*m-1)/(4*m)) ans++;
  }
  
  cout<<(ans>=m?"Yes":"No");
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    string str;
    while(cin >> str && str != "0"){
        int sum = 0;
        for(int i = 0; i < str.size(); i++){
            sum += str[i] - '0';
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int n, m;
vector<int> ve[100005];
int cnt;
bool v[100005];

void dfs(int p)
{
    if(v[p]) return;
    v[p] = true;
    for(int i = 0; i < ve[p].size(); i++)
    {
        dfs(ve[p][i]);
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    while(m--)
    {
        int t1, t2;
        scanf("%d%d%*d", &t1, &t2);
        ve[t1].push_back(t2);
        ve[t2].push_back(t1);
    }
    for(int i = 1; i <= n; i++)
    {
        if(!v[i]) dfs(i), cnt++;
    }
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 8960
from collections import deque


BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


LIST = deque()

num_command = int(input())

for loop in range(num_command):

    input_command = input()

    if input_command == 'deleteFirst':
        LIST.popleft()
    elif input_command == 'deleteLast':
        LIST.pop();
    else:
        com,num = input_command.split()

        if com == 'insert':
            LIST.appendleft(num)
        elif com == 'delete':
            try:
                LIST.remove(num)
            except:
                pass

print(' '.join(LIST))




Measured memory_bytes: 69752
import os

n,y = (int(x) for x in input().split())

for i in range(n+1):
    for j in range(n-i+1):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                print(" ".join([str(i),str(j),str(n-i-j)]))
                exit()
print(" ".join([str(-1),str(-1),str(-1)]))


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


int main()
{
    ll t,x;
     t=1;
    while(t--){
        cin>>x;
        ll y=x/1000;
        if(x%1000==0){
            cout<<"0\n";
            continue;
        }
        cout<<1000*(y+1)-x<<endl;
    }
}


Measured memory_bytes: 3636
def q2():
    A, B, C, K = (int(i) for i in input().split())
    ans = 0

    if K <= A:
        ans += K
        return ans
    else:
        K -= A
        ans += A

    #print(K, ans)
    if K <= B:
        return ans
    else:
        K -= B

    #print(K, ans)
    if K <= C:
        ans -= K
        return ans
    else:
        ans -= C
        return ans


if __name__ == '__main__':
    print(q2())


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	constexpr int n_max=50;

	for(ll k;cin>>k&&k!=-1;){
		vl res(n_max,n_max-1);
		rep(i,n_max)
			res[i]+=k/n_max;
		k%=n_max;
		rep(i,k) rep(j,n_max)
			if(j==i)
				res[j]+=n_max;
			else
				res[j]--;

		cout<<n_max<<endl;
		rep(i,n_max) cout<<res[i]<<"\n "[i+1<n_max];
	}
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

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

  int k = (a+b)/2;

  if (abs(a-k) != abs(b-k))
    cout << "IMPOSSIBLE\n";
  else
    cout << k << "\n";

  return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}


/*{
  }*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1<<30;

signed main(){
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  rep(i, 0, 1000){
    char pw[4];
    sprintf(pw, "%03lld", i);

    int cnt = 0;
    rep(j, 0, n){
      if(s[j] == pw[cnt]){
        cnt++;
        if(cnt == 3){
          ans++;
          break;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int isPrime(LL p){
        if(p<=1) return 0;
        if(p==2 || p==3 || p==5 || p==7) return 1;
        if(p==4 || p==6 || p==8 || p==9) return 0;

        LL i;
        int ret = 1;
        for(i=2; i*i<=p; i++){
                if(p%i==0 && i!=p){
                        ret = 0;
                        break;
                }
        }
        return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	long long n;
	
	cin >> N ;

	if(isPrime(N) == 1){
		printf("%lld\n", N - 1);
		return 0;
	}

	n = (int)sqrt(N) + 1;
	long long ans = N * 2;
	for(long long i = 2; i <= n; i++){
		if((N % i) != 0){
			continue;
		}
		long long j = N / i;
		long long u = i - 1 + j - 1;
		if(u < ans){
			ans = u;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m;
  cin>>n;
  vector<string> blue(n);
  rep(i,n){
    cin>>blue[i];
  }
  cin>>m;
  vector<string> red(m);
  rep(i,m){
    cin>>red[i];
  }
  int ans=0;
  rep(i,n){
    int count=0;
    rep(j,n){
      if(blue[i]==blue[j]){count++;}
    }
    rep(l,m){
      if(blue[i]==red[l]){count--;}
    }
    ans=max(ans,count);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
map<lli,int>prime_factor(lli n){
  map<lli,int>res;
  for(lli i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  auto P=prime_factor(N);
  for(auto v:P){
    rep(i,0,50){
      if(i*(i+1)/2>v.second){
        sum+=i-1;
        break;
      }
    }
  }
  Out(sum);
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main(){
	long n,t,a;
	cin>>n>>t;
	if(n>t){
	a=n-t;
	cout<<a<<endl;
	return 0;
	}
	if(n<=t){
		a=0;
		cout<<a<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()

	if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	} else {
		fmt.Println("a == b")
	}
}



Measured memory_bytes: 1092
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
using namespace std;
const double eps = 1e-8;
typedef long long LL;
const int M=105;
int n;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    cout<<a+b/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100
#define INF (1<<21)
#define B 2
#define G 1
#define W 0
 
int n,M[MAX][MAX];
 
void dijkstra(){
  int i,u,v,min,d[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INF;
    color[i]=W;
  }
  d[0]=0;
  color[0]=G;
  while(1){
    min=INF;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i]&&color[i]!=B){
        u=i;
        min=d[i];
      }
    }
    if(u==-1) break;
    color[u]=B;
    for(v=0;v<n;v++){
      if(color[v]!=B&&M[u][v]!=INF){
        if(d[v]>d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=G;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i]==INF ? -1 : d[i]));
  }
}
 
int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INF;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}

Measured memory_bytes: 636