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

int main()
{

	int H, W;
	cin >> H >> W;

	for (int j = 0; j < W + 2; j++)
	{
		cout << '#';
	}
	cout << endl;

	for (int i = 0; i < H; i++)
	{
		string s;
		cin >> s;
		cout << '#' + s + '#' << endl;
	}

	for (int j = 0; j < W + 2; j++)
	{
		cout << '#';
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<string,int> v;
  int m=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    v[s]++;
    m=max(m,v[s]);
  }
  vector<string> w;
  for(auto i:v)
    if(i.second==m)
      w.push_back(i.first);
  sort(w.begin(),w.end());
  for(int i=0;i<w.size();i++)
    cout<<w.at(i)<<endl;
}


Measured memory_bytes: 26868
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	


	return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
using namespace std;
static const int MAXN=100;
static const int MAXW=10000;
struct item{
	int v;
	int w;
};
int c[MAXN+1][MAXW+1];
int main(){
	int N,W,i,j;
	item a[MAXN+1];
	scanf("%d %d",&N,&W);
	for(i=1;i<N+1;i++){
		scanf("%d %d",&a[i].v,&a[i].w);
	}
	for(i=0;i<W+1;i++){
		c[0][i]=0;
	}
	for(i=0;i<N+1;i++){
		c[i][0]=0;
	}
	for(i=1;i<N+1;i++){
		for(j=1;j<W+1;j++){
			if(j-a[i].w>=0){
				c[i][j]=c[i-1][j]>c[i-1][j-a[i].w]+a[i].v?c[i-1][j]:c[i-1][j-a[i].w]+a[i].v;
			}
			else{
				c[i][j]=c[i-1][j];
			}
		}
	}
	printf("%d\n",c[N][W]);
	return 0;
}

Measured memory_bytes: 4968
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int main()
{
    int n;
    cin >> n;
    vector<int> mem;
    mem.resize(n);
    rep(i,n) cin >> mem[i];

    int ok = 1;
    rep(i,n){
        if(mem[i]%2 == 0){
            if(!(mem[i]%3==0 || mem[i]%5==0)) ok = 0;
        }
    }
    if(ok) printf("APPROVED\n");
    else printf("DENIED\n");
}

Measured memory_bytes: 256
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	v := 0
	for i := 0; i < len(s); i++ {
		if '+' == s[i] {
			v += 1
		} else if '-' == s[i] {
			v -= 1
		}
	}
	fmt.Println(v)

}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
	cin >> a;
    int ans = 0;
    double n;
    if(a.size()%2 == 0)n = a.size()/2;
    else n = a.size()/2 + 1;
	int j = n;
    for( int i = 0;i < j; i++)
        if(a[i] != a[a.size()-(1+i)])ans++;
	cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)

def combination(n,k)
  k = n-k if k > n/2
  return 1 if k == 0
  ((n-k+1)..n).inject(:*) / (1..k).inject(:*)
end

1.step(k) do |i|
  if n-k-i+1 < 0
    puts 0
  else
    puts combination(n-k+1, i) * combination(k-1, i-1) % (10**9 + 7)
  end
end


Measured memory_bytes: 2752
#include<iostream>
#include<vector>

using namespace std;

int main() {
	string s,tests;
	int i, j;
	vector<char>s1,s2,test1, test2;
	cin>>s;
	for (i = 0;i < (s.length() - 1) / 2;i++)s1.emplace_back(s[i]);
	for (j = 0;j < (s.length()) / 2;j++)s2.emplace_back(s[j]);
	tests = s;
	test1 = s1;
	test2 = s2;
	reverse(s.rbegin(), s.rend());
	reverse(s1.rbegin(),s1.rend());
	reverse(s2.rbegin(),s2.rend());
	if (s1 == test1 && test2 == s2 && s == tests)puts("Yes");
	else puts("No");
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    int di = 0;
    while( n > 0 ) {
        n /= k;
        ++di;

    }
    cout << di << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int
main(void)
{
	char X, Y;
	scanf("%c %c", &X, &Y);

	char res;
	if (X > Y)
		res = '>';
	else if (X < Y)
		res = '<';
	else
		res = '=';

	printf("%c\n", res);
	return (0);
}


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

#define fast_io() ios_base::sync_with_stdio(false); cin.tie(0);

typedef pair<int, int> ii;
const long long MOD = 1e9 + 7;



int main() {
    fast_io();
    
    int n, t; cin >> n >> t;
    ii arr[n];
    for(int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second;
    }
    sort(arr, arr + n);
    int dp[n][6002];
    memset(dp, 0, sizeof dp);
    
    for(int i = 0; i < n; ++i) {
        if(i) {
            for(int j = 6000; j >= 0; j--) {
                dp[i][j] = dp[i-1][j];
            }
        }
        int xx = arr[i].first;

        for(int j = t - 1 ; j >= 0; --j) {
            dp[i][j + xx] = max(dp[i][j] + arr[i].second , dp[i][j + xx]); 
        }
    }

    int ans = 0;
    for(int i = 0; i < 6001; ++i) {
        ans = max(ans, dp[n - 1][i]);
    }
    cout << ans << "\n";
    
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    double n; cin >> n;
    if (int(n)%2 == 0){
        cout << 0.5 << endl;
    } else {
        cout << (n+1.0)/(n*2.0) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int r;
	cin >> r;
	if(r < 1200)cout << "ABC\n";
	else if(r < 2800)cout << "ARC\n";
	else cout << "AGC\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

int N;
vector<int> A;

int main() {
	cin >> N;
	A.resize(N);
	for (int n = 0; n < N; n++)cin >> A[n];
	//Aは一種類か?
	sort(A.begin(), A.end());
	int kind = 1;
	for (int n = 1; n < N; n++) {
		if (A[n] != A[n - 1])kind++;
	}
	if (kind == 1) {
		int n = A[0];
		if (n + 1 == N)goto YES;
		else if (2 * n <= N)goto YES;
		else goto NO;
	}
	else if (kind == 2) {
		if (A[0] != A[N - 1] - 1)goto NO;
		//ぼっちの数を数える
		int p = 0;
		for (int n = 0; n < N; n++) {
			if (A[n] == A[0])p++;
		}
		int q = N - p;
		int n = A[0];
		if (p >= n + 1)goto NO;
		if (q < 2 * (n + 1 - p))goto NO;
		goto YES;
	}
	else goto NO;
YES:
	cout << "Yes" << endl;
	return 0;
NO:
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
    ll N,K,sum=0;cin>>N>>K;
    vector<ll> d(N);
    for(int i=0;i<N;i++){
        cin>>d.at(i);
        sum+=d.at(i);
    }

    vector<ll> yaku;
    for(ll i=1;i*i<=sum;i++){
        if(sum%i==0) {
            yaku.push_back(i);
            yaku.push_back(sum/i);
        }
    }
    sort(yaku.begin(),yaku.end());
    reverse(yaku.begin(),yaku.end());

    ll ans;
    for(int i=0;i<yaku.size();i++){
        ll Y=yaku.at(i);
        ll S=0, count=0;
        vector<ll> k;
        for(int j=0;j<N;j++) {
            k.push_back(d.at(j)%Y);
            S+=(d.at(j)%Y);
        }
        sort(k.begin(),k.end());
        reverse(k.begin(),k.end());
        S/=Y;
        for(int j=0;j<S;j++) count+=(Y-k.at(j));
        if(count<=K) {ans=Y; break;}

    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <stack>
#include <queue>
#include <cstring>
#include <iterator>

#define FOR(n) for(int i=0;i<(n);++i)
#define FOR_R(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR_F(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define MODDING(a,b) (a) = AS_MOD(a,b)

using namespace std;
typedef pair<int,int> P;
typedef pair<P, P> PP;
typedef long long ll;
int N;
long long MOD=998244353;
typedef long long POW;
POW powlong(POW x, POW i) {
  POW ret = 1;
  POW temp = x;
  while(i!=0) {
    if (i&1) {
      ret *= temp;
      MODDING(ret,MOD);
    }
    temp *=temp;
    MODDING(temp,MOD);
    i = i>>1;
  }
  return ret;
}
template<class T,int SIZE>struct Vector_{
  T value[SIZE];
  Vector_(){
    for(int i=0;i<SIZE;++i)value[i]=0;
  };
  Vector_(T x,T y){value[0]=x;value[1]=y;};
  Vector_(T x,T y,T z){value[0]=x;value[1]=y;value[2]=z;};
  Vector_ operator-(const Vector_& rhs) {
    Vector_ temp;
    for(int i=0;i<SIZE;++i)temp.value[i]=value[i]-rhs.value[i];
    return temp;
  }
  T dot(const Vector_& rhs) {
    T temp=0;
    for(int i=0;i<SIZE;++i)temp += value[i]*rhs.value[i];
    return temp;
  }
  Vector_ getPerp2D() {
    return Vector_(-value[1],value[0]);
  }
};
typedef Vector_<int,2> Vector;
Vector Points[200];
bool sum[200][200];
int main() {
  scanf("%d", &N);
  for(int i=0;i<N;++i) {
    int x,y;
    scanf("%d%d", &x, &y);
    Points[i] = {x,y};
  }
  long long answer = powlong(2, N);
  answer -= 1;
  answer -= N;
  for(int i=0;i<N;++i) {
    for(int j=i+1;j<N;++j) {
      int num=2;
      for(int k=0;k<N;++k) {
        if (k==j || k==i)continue;
        Vector ang=Points[j]-Points[i];
        Vector perp=ang.getPerp2D();
        Vector to=Points[k]-Points[i];
        if (to.dot(perp)==0) {
          if (k<j) {
            num=0;
            break;
          }
          num++;
        }
      }
      answer -= (powlong(2, num) - num - 1);
      MODDING(answer, MOD);
    }
  }
  printf("%lld\n",answer);

  return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include<time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

int numdigits(ll n){
	int ret=0;
	while(n){
		n/=10;
		ret++;
	}
	return ret;
}

int main(){
	ll n,k;
	while(cin>>n>>k,n|k){
		int a=-1;
		ll pos=0;
		REP(i,9){
			if(pos+pow(10LL,i)*9*(i+1)>n){
				a=i-1;
				break;
			}
			pos+=pow(10LL,i)*9*(i+1);
		}
		ll num=pow(10LL,a+1)-1;
		int b=a+1;
		while(pos<n&&b>=0){
			if(pos+pow(10LL,b)*(a+2)<=n){
				pos+=pow(10LL,b)*(a+2);
				num+=pow(10LL,b);
			}else{
				b--;
			}
		}

		if(pos<n){
			num++;
			pos+=numdigits(num);
		}
	
		//cerr<<numdigits(num)-1-(pos-n)<<"th digit of " <<num<<" "<<endl;

		ostringstream oss;
		REP(i,100){
			oss<<num+i;
		}
		string s=oss.str();
		REP(i,k){
			cout<<s[numdigits(num)-1-(pos-n)+i];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1256
import java.util.Scanner;

import static java.util.Arrays.sort;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[] A=new int[N];
        for(int i=0; i<N; i++){
            A[i]=sc.nextInt();
        }
        sort(A);
        int mannakado = Integer.MAX_VALUE/2;
        for(int i=0; i<N; i++){
            int tm=Math.abs(A[N-1]/2 - A[i]);
            if( tm <= mannakado){
                mannakado=tm;
            }else{
                System.out.println(A[N-1]+" "+A[i-1]);
                System.exit(0);
            }
        }
        System.out.println(A[N-1]+" "+A[N-2]);
    }
}


Measured memory_bytes: 50696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

int sosuu(int a){
  if(a<2)return 0;
  else if(a==2)return 1;
  if(a%2==0)return 0;
  for(int i=3;i<=sqrt(a);i++){
    if(a%i == 0)return 0;
  }
  return 1;
  
}
int main(void){
  int n,a,cnt=0;
  cin>>n;
  for(int i = 0; i < n; i++){
    cin>>a;
    cnt+=sosuu(a);
  }
  cout<<cnt<<endl;


  return 0;
}



Measured memory_bytes: 3044
/*  3_3
    Y_Aizaki    */

#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    // Nが1~9の二つの整数の積かどうかを判定する

    int i = 1;
    while(i < 10){
        if(n % i == 0 && n / i < 10){
            printf("Yes\n");
            break;
        }
        i += 1;
    }

    if(i == 10){
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.math.*;
import java.util.Scanner;
import java.math.BigInteger;

public class Main {
	static final long mod = (int) (1e9 + 7);
	static final int inf = (int) (1e9);
	static final int maxn = (int) (1e5 + 10);

	static int n, m,c;
	static String s;
	static int[][] a=new int [22][22];
	static int [] b=new int[22];
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		n=cin.nextInt();m=cin.nextInt();c=cin.nextInt();
		for(int i=1;i<=m;i++) {
			b[i]=cin.nextInt();
		}
		int sum=0,ans=0;
		for(int i=1;i<=n;i++) {
			sum=c;
			for(int j=1;j<=m;j++) {
				a[i][j]=cin.nextInt();
				sum+=a[i][j]*b[j];
			}
			if(sum>0) ans++;
		}
		System.out.println(ans);
	}
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	FOR(i,1,n){
		int temp;
		cin >> temp;
		a[i - 1] = { temp,i };
	}
	sort(ALL(a));
	FOR(i, 0, n - 1) {
		cout << a[i].second;
		if (i == n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return(0);
}

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

int main()
{
    int n;
    cin >> n;
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    rep(i, n)
    {
        string s;
        cin >> s;
        if (s == "AC")
        {
            ac++;
        }
        if (s == "WA")
        {
            wa++;
        }
        if (s == "TLE")
        {
            tle++;
        }
        if (s == "RE")
        {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 3628
n=int(input())
s=[input() for i in range(n)]
c0=0
c1=0
c2=0
c3=0
for i in s:
  if i == 'AC':
    c0+=1
  elif i == 'WA':
    c1+=1
  elif i == 'TLE':
    c2+=1
  else:
    c3+=1
print('AC x '+str(c0))
print('WA x '+str(c1))
print('TLE x '+str(c2))
print('RE x '+str(c3))

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

using namespace std;

int main() {
    string s;
    int n;
    bool rev = false;
    cin >> s >> n;
    for (int i = 0; i < n; i++) {
        int q;
        cin >> q;
        if (q == 1) {
            rev = 1 - rev;
        } else {
            int f;
            char t;
            cin >> f >> t;
            if (f == 1) {
                if (rev)
                    s += t;
                else
                    s = t + s;
            } else {
                if (rev)
                    s = t + s;
                else
                    s += t;
            }
        }
    }
    s = rev ? string(s.rbegin(), s.rend()) : s;
    cout << s;
}

Measured memory_bytes: 4780
#include <stdio.h>

int main(void)
{
	int n;
	
	while (scanf("%d", &n) != EOF){
		if(n % 39 == 0){
			printf("3C39\n");
		}
		else if (n % 39 < 10){
			printf("3C0%d\n", n % 39);
		}
		else {
			printf("3C%d\n", n % 39);
		}
	}
	return (0);
}

Measured memory_bytes: 608
#include <iostream>

using namespace std;

int main(void)
{
    int n;
    int cnts[100001] = {0};

    cin >> n;

    int cnt = 0;
    for(int x = 1; x * x <= n; x++){
        for(int y = 1; y * y <= n; y++){
            for(int z = 1; z * z <= n; z++){
                int calc = x * x + y * y + z * z + x * y + y * z + z * x;
                if(calc <= 100000){
                    cnts[calc] += 1;
                }
            }
        }
    }

    for(int i = 1; i <= n; i++){
        cout << cnts[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4032
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn main() {
    let n:u64 = read();
    let nums:Vec<u64> = read_vec();

    let mut res:u64 = 1;
    let LIMIT:u64 = 10u64.pow(18u32);
    let mut overLimit: bool = false;
    for i in nums {
        let (tmp, _bool) = res.overflowing_mul(i);
        res = tmp;
        if(i == 0) {
            overLimit = false;
            break;
        }
        if(res > LIMIT || _bool) {
            overLimit = true;
        }
    }
    if(overLimit) {
        println!("-1");
    } else {
        println!("{}", res);
    }
}


Measured memory_bytes: 4824
Point = Struct.new(:x, :y)

def get_circulm_center(a, b, c)
  aa = (b.x - c.x) ** 2 + (b.y - c.y) ** 2
  bb = (a.x - c.x) ** 2 + (a.y - c.y) ** 2
  cc = (b.x - a.x) ** 2 + (b.y - a.y) ** 2

  u1 = aa * (bb + cc - aa)
  u2 = bb * (cc + aa - bb)
  u3 = cc * (aa + bb - cc)
  deno = u1 + u2 + u3

  return false if deno == 0
  
  x = ((u1 * a.x) + (u2 * b.x) + (u3 * c.x)) / deno
  y = ((u1 * a.y) + (u2 * b.y) + (u3 * c.y)) / deno

  Point.new(x, y)
end

def dis(a, b)
  square = (a.x - b.x) ** 2 + (a.y - b.y) ** 2
  Math.sqrt(square)
end

def isAllIncluded(r, c, points)
  flag = true
  points.each do |p|
    d = dis(c, p)
    if d > r
      flag = false
      break
    end
  end

  flag
end

def main
  n = gets.chomp.to_i
  points = []
  min = -1

  n.times do |i|
    input = gets.chomp.split.map(&:to_f)
    points.push(Point.new(input[0], input[1]))
  end

  if n == 2
    puts dis(points[0], points[1]) / 2
    return
  end

  #2点の中点から判定
  n.times do |i|
    n.times do |j|
      next if i == j
      c = Point.new((points[i].x + points[j].x) / 2, (points[i].y + points[j].y ) / 2)
      r = dis(points[i], c)
      next if min != -1 && min < r
      next if !isAllIncluded(r, c, points)
      min = r
    end
  end
  
  #３点の外心から判定
  n.times do |i|
    n.times do |j|
      next if i == j
      n.times do |k|
        next if j == k || i == k
        c = get_circulm_center(points[i], points[j], points[k])
        next if c == false
        r = dis(points[i], c)        

        #rが大きい場合は飛ばす
        next if min != -1 && min < r
        #距離r内に全ての点が含まれているか確認
        next if !isAllIncluded(r, c, points)
        min = r 
      end
    end
  end

  puts min
end

main

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const ll mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int now=1;
    int A,B;cin>>A>>B;
  if(B==1) cout<<0<<endl;
  else{
    for(int i=1;;i++){
        now+=(A-1);
        if(now>=B){
            cout<<i<<endl;
            break;
        }
    }
  }
}


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

using namespace std;

int main()
{
    string s;
    while (cin >> s) {
        int a = 0, b = 0;
        for (int i = 0; i <= (int)s.size()-3; i++) {
            if (s.substr(i, 3) == "JOI") {
                a++;
            } else if (s.substr(i, 3) == "IOI") {
                b++;
            }
        }        
        cout << a << "\n" << b << endl;
    }       
    return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main(void){
 int n,d,x;
 cin>>n>>d>>x;
 vector<int>a(n);
 for(int i=0;i<n;i++){
     cin>>a[i];
 }   
 int ans=0;
 for(int i=0;i<n;i++){
     int cnt=0;
     while(1){
         if(cnt*a[i]+1>d){
             break;
         }
         ans++;
         cnt++;
     }
 }
 cout<<ans+x<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,odd=0;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
        if (a[i]%2==1){
            odd++;
        }
    }
    if (odd%2==0){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
	return 0 ;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  vector<ll> a(n), c, d;
  rep(i, n)
    in(a[i]);
  rep(i, n){
    if(i % 2 == 1)
      c.pb(a[i]);
    else
      d.pb(a[i]);
  }
  if(n % 2 == 0){
    rep(i, c.size()){
      out(c[c.size() - 1 - i]);
      hina;
    }
    rep(i, d.size()){
      out(d[i]);
      hina;
    }
  }
  else{
    rep(i, d.size()){
      out(d[d.size() - 1 - i]);
      hina;
    }
    rep(i, c.size()){
      out(c[i]);
      hina;
    }
  }
  memi;
}


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

constexpr ll mod = 1e9+7;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    ll ans = 0;
    rep(i, 0, 61){
        ll one = 0, zero = 0;
        rep(j, 0, N){
            if(A[j] & (1LL<<i)) one++;
            else zero++;
        }
        ans += (((one * zero) % mod) * ((1LL<<i) % mod)) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  ll onlyb = 0;
  for (int i=0; i<n; i++){
    cin >> a[i] >> b[i];
    onlyb -= b[i];
    c[i] = a[i] + b[i];
  }
  
  sort(c.begin(), c.end(), greater<ll>());
  
  ll ans=onlyb;
  for (int i=0; i<n; i += 2){
    ans += c[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int n,m;
  ll x;
  cin>> n >> m >> x;
  vector<vector<ll>> A;

  rep(i,0,n-1) {
    vector<ll> a;
    ll a_t;
    rep(j,0,m) {
      cin>>a_t;
      a.push_back(a_t);
    }
    A.push_back(a);
  }

  vector<int> res;

  for (int bit = 1; bit < (1<<n); ++bit) {
    vector<ll> indic(m,0);
    ll sum_p = 0;
    for (int i = 0; i < n; ++i) {
        if (bit & (1<<i)) { // i が bit に入るかどうか
          sum_p += A[i][0];
          rep(m_i,1,m) {
            indic[m_i-1]+=A[i][m_i];
          }
        }
    }

    bool mark=true;
    for(auto ind:indic) {
      // cout << ind << " ";
      if(ind<x) mark=false;
    }

    if(mark) {
      res.push_back(sum_p);
    }

    // cout << endl;
  }

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

  if(res.size()==0) {
    pr(-1);
  } else {
    pr(res[0]);
  }

  for(auto r:res) {
  }

  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 3e5 + 10;
const int INF = 0x3f3f3f3f;
int n, m;
char mp[110][110];
int dp[110][110];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)scanf("%s", mp[i]);
	memset(dp, 0x3d, sizeof(dp));
	dp[0][0] = (mp[0][0] == '.' ? 0 : 1);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (!i && !j)continue;
			if (mp[i][j] == '.') {
				if (i > 0)dp[i][j] = min(dp[i][j], dp[i - 1][j]);
				if (j > 0)dp[i][j] = min(dp[i][j], dp[i][j - 1]);
			}
			else {
				if (i > 0) {
					if (mp[i - 1][j] == '#')dp[i][j] = min(dp[i][j], dp[i - 1][j]);
					else dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
				}
				if (j > 0) {
					if (mp[i][j - 1] == '#')dp[i][j] = min(dp[i][j], dp[i][j - 1]);
					else dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
				}
			}
		}
	}
	printf("%d\n", dp[n - 1][m - 1]);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
const int mod = 1000003;
int N, M; vector<vector<int> > G;
unordered_map<unsigned, int> dp;
int solve(int l, int r) {
	if (l == r) return 1;
	if ((r - l) % 2 == 1) return 0;
	if (dp.find(unsigned(l) * N + r) != dp.end()) return dp[unsigned(l) * N + r];
	vector<int> child(G[l].begin(), lower_bound(G[l].begin(), G[l].end(), r));
	int S = child.size();
	vector<int> lmul(S + 1), rmul(S + 1);
	lmul[0] = 1;
	int pl = l + 1;
	for (int i = 0; i < S; ++i) {
		int nxt = (child[i] % 2 == pl % 2 ? child[i] : child[i] + 1);
		lmul[i + 1] = 1LL * lmul[i] * solve(pl, nxt) % mod;
		pl = nxt;
	}
	rmul[S] = 1;
	int pr = r;
	for (int i = S - 1; i >= 0; --i) {
		int nxt = (child[i] % 2 == pr % 2 ? child[i] : child[i] + 1);
		rmul[i] = 1LL * rmul[i + 1] * solve(nxt, pr) % mod;
		pr = nxt;
	}
	int ans = 0;
	for (int i = 0; i < S; ++i) {
		if ((child[i] - (l + 1)) % 2 == 0 && (r - (child[i] + 1)) % 2 == 0) {
			ans = (ans + 1LL * lmul[i + 1] * rmul[i]) % mod;
		}
	}
	dp[unsigned(l) * N + r] = ans;
	return ans;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	while (cin >> N >> M, N) {
		G = vector<vector<int> >(N);
		dp.clear();
		for (int i = 0; i < M; ++i) {
			int a, b;
			cin >> a >> b; --a, --b;
			if (a > b) swap(a, b);
			if ((b - a) % 2 != 0) G[a].push_back(b);
		}
		if (N % 2 == 1) cout << 0 << '\n';
		else {
			for (int i = 0; i < N - 1; ++i) {
				G[i].push_back(i + 1);
			}
			G[0].push_back(N - 1);
			for (int i = 0; i < N; ++i) {
				sort(G[i].begin(), G[i].end());
			}
			int ans = 0;
			for (int i : G[0]) {
				int sl = solve(1, i);
				int sr = solve(i + 1, N);
				ans = (ans + 1LL * sl * sr) % mod;
			}
			cout << ans << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 15132
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int minn, a, b, n;
LL sum;

int main() {
minn = INF;
scanf("%d", &n);
sum = 0;
for (int i=0;i<n;i++) {
	scanf("%d %d", &a, &b);
	if (a > b) minn = min(minn, b);
	sum += b;
}
if (minn == INF) printf("0\n"); else printf("%lld\n", sum - minn);
return 0;
}



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

int main()
{
    char day[5];
    int first,second;
    int flag1,flag2;


    gets(day);

    second=atoi(day)%100;
    first=(atoi(day)-second)/100;


    if(0<first && first<13)
    flag1=0;      //month or year
    else flag1=1;      //year only

   
    if(0<second && second<13)
    flag2=0;      //month or year
    else flag2=1;      //year only

    if(flag1 == 0 && flag2 == 0 )
    printf("AMBIGUOUS");
    else if(flag1 == 1 && flag2 == 1)
    printf("NA");
    else if(flag1 == 0 && flag2==1)
    printf("MMYY");
    else if(flag1 == 1 && flag2 == 0)
    printf("YYMM");

 
  

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <ctgmath>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int* a = new int[N];
    long long int* b = new long long int[N];
    for(int i = 0;i < N;i++){
        cin >> a[i];
        b[i] = a[i]-i-1;
    }
    sort(b,b+N);
    long long int mid = b[(N-1)/2];
    if(N%2 == 0)
        mid = round((b[N/2-1]+b[N/2])/2);
    long long int ans = 0;
    for(int i = 0;i < N;i++)
        ans += abs(a[i]-(mid+1+i));
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define rep(i, n) rep2(i, 0, n)
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
using VVll = vector<Vll>;

char s[1000000];

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

  VVll t(3, Vll(n+1));
  VV pos(3, V());
  char dmc[3] = {'D', 'M', 'C'};

  rep(i, n) rep(j, 3) {
    t[j][i+1] = t[j][i];
    if (s[i] == dmc[j]) {
      ++t[j][i+1];
      pos[j].push_back(i);
    }
  }

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = 0;
    for (auto c : pos[2]) ans += t[1][c] * (t[0][c] - t[0][max(c-k+1, 0)]);
    for (auto a : pos[0]) ans -= t[1][a+1] * (t[2][min(a+k, n)] - t[2][a+1]);
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 32632
#include<stdio.h>
#define MODN 998244353

static inline long modadd(long a,long b){
    return (a+b) % MODN;
}

static inline long modml(long a,long b){
    return (long long)a * b % MODN;
}

static inline long modpow(long n,long ind){
    unsigned long cnt = ind;
    long res = 1;
    while(cnt){
        if(cnt & 1ul)res = modml(res,n);
        n = modml(n,n);
        cnt >>= 1;
    }
    return res;
}

static inline long modinv(long n){
    return modpow(n,MODN - 2);
}

long modfact[200200];

static inline long modnck(long n,long k){
    return modml(modfact[n],modinv(modml(modfact[n-k],modfact[k])));
}

int main(void){
    register int i;
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    modfact[0] = 1;
    for(i = 1;i <= n;i++)modfact[i] = modml(modfact[i-1],i);
    long ans = 0;
    for(i = 0;i <= k;i++)ans = modadd(ans,modml(modml(modpow(m-1,n-i-1),m),modnck(n-1,i)));
    printf("%ld",ans);
}

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

using namespace std;

#define MAX_H 61
#define MAX_W 31
#define INF 1e9
#define Fi first
#define Se second
typedef pair<int,int> pii;

struct State{
  int d,lx,ly,rx,ry;
  bool f;
  State(){}
  State(int d,int lx,int ly,int rx,int ry,bool f) :
    d(d),lx(lx),ly(ly),rx(rx),ry(ry),f(f) {}
  bool operator > (const State &s)const{
    return d > s.d;
  }
};

int W,H;
int ps,pt;
pii S[MAX_W],T[MAX_W];
char field[MAX_H][MAX_W];
int dist[MAX_H][MAX_W][MAX_H][MAX_W][2];

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

bool inField(int x,int y){
  return 0 <= x && x < W && 0 <= y && y < H;
}

int dijkstra(){
  priority_queue<State,vector<State>,greater<State> > Q;
  fill(dist[0][0][0][0],dist[0][0][0][0]+MAX_H*MAX_W*MAX_H*MAX_W*2,INF);
  for(int i = 0 ; i < ps ; i++){
    Q.push(State(0,S[i].Fi,S[i].Se,W,H,0)); 
    Q.push(State(0,W,H,S[i].Fi,S[i].Se,1));
    dist[S[i].Se][S[i].Fi][H][W][0] = 0;
    dist[H][W][S[i].Se][S[i].Fi][1] = 0;
  }

  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int lx = s.lx, ly = s.ly;
    int rx = s.rx, ry = s.ry;

    if(dist[ly][lx][ry][rx][s.f] < s.d) continue;
    for(int i = 0 ; i < pt ; i++){
      if(lx == T[i].Fi && ly == T[i].Se ||
         rx == T[i].Fi && ry == T[i].Se){
        return s.d;
      }
    }
    if(s.f){
      for(int i = 0 ; i < 9 ; i++){
        int nlx = rx - dx[i];
        int nly = ry + dy[i];
        if(!inField(nlx,nly)) continue;
        if(field[nly][nlx] == 'X') continue;
        int t = field[nly][nlx] - '0';
        if(s.d + t < dist[nly][nlx][ry][rx][0]){
          dist[nly][nlx][ry][rx][0] = s.d + t;
          Q.push(State(dist[nly][nlx][ry][rx][0],nlx,nly,rx,ry,0));
        }
      }
    }else{
      for(int i = 0 ; i < 9 ; i++){
        int nrx = lx + dx[i];
        int nry = ly + dy[i];
        if(!inField(nrx,nry)) continue;
        if(field[nry][nrx] == 'X') continue;
        int t = field[nry][nrx] - '0';
        if(s.d + t < dist[ly][lx][nry][nrx][1]){
          dist[ly][lx][nry][nrx][1] = s.d + t;
          Q.push(State(dist[ly][lx][nry][nrx][1],lx,ly,nrx,nry,1));
        }
      }
    }
  }
  return -1;
}

int main(){
  dijkstra();
  while(cin >> W >> H, W){
    ps = pt = 0;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> field[i][j];
        if(field[i][j] == 'S'){
          S[ps++] = pii(j,i);
          field[i][j] = '0';
        }else if(field[i][j] == 'T'){
          T[pt++] = pii(j,i);
          field[i][j] = '0';      
        }
      }
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 29268
#include<stdio.h>
#include<math.h>

int main(){
  int i,j,k=0;
  int N,K;
  scanf("%d",&N);
  scanf("%d",&K);
  
  int A[N];
  
  for(i=0;i<N;i++){
    scanf("%d ",&A[i]);
  }
  
  for(i=0;i<N;i++){
    if(A[i] > abs(A[i]-K)){
      k+=abs(A[i]-K)*2;
    }
    else
      k+=A[i]*2;
  }
  
  printf("%d\n",k);
  return 0;
}
      

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    public static void Main()
    {
        long[] ABCK = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long A = ABCK[0], B = ABCK[1], C = ABCK[2], K = ABCK[3];
        long ans = ( K%2==0 ? A - B : B - A );
        Console.WriteLine(ans);
    }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(c).Select(int.Parse).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
}


Measured memory_bytes: 13268
class Queue:
    def __init__(self):
        self.queue = []
    def push(self, x):
        self.queue.append(x)
    def pop(self):
        return self.queue.pop(0)
    def isEmpty(self):
        return len(self.queue) == 0

n, q = list(map(int, input().split(' ')))
process_queue = Queue()
for i in range(n):
    name, time = list(input().split(' '))
    process_queue.push([name, int(time)])

total_time = 0
while True:
    name, time = process_queue.pop()
    if time <= q:
        print('{} {}'.format(name, time + total_time))
        add_time = time
    else:
        time -= q
        process_queue.push([name, time])
        add_time = q
    total_time += add_time
    if process_queue.isEmpty():
        break



Measured memory_bytes: 13020
#include <iostream>
using namespace std;
bool isYYMM(string s) {
  if ('0' <= s[0] && s[0] <= '9' && '0' <= s[1] && s[1] <= '9') {
    if ((s[2] == '0' && '1' <= s[3] && s[3] <= '9') ||
        (s[2] == '1' && '0' <= s[3] && s[3] <= '2'))
      return true;
  }
  return false;
}
bool isMMYY(string s) {
  if ('0' <= s[2] && s[2] <= '9' && '0' <= s[3] && s[3] <= '9') {
    if ((s[0] == '0' && '1' <= s[1] && s[1] <= '9') ||
        (s[0] == '1' && '0' <= s[1] && s[1] <= '2'))
      return true;
  }
  return false;
}

int main() {
  string s;
  cin >> s;
  bool yymm, mmyy;
  yymm = isYYMM(s);
  mmyy = isMMYY(s);
  if (yymm && mmyy)
    cout << "AMBIGUOUS" << endl;
  else if (yymm)
    cout << "YYMM" << endl;
  else if (mmyy)
    cout << "MMYY" << endl;
  else
    cout << "NA" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))
m = 0
count = 0
for i in range(N):
    eat_num = As[count]
    if count != 0:
        before = As[count-1]
        if before + 1 == eat_num:
            m = m + Cs[before-1]
    m = m + Bs[eat_num-1]
    count += 1
print(m)

Measured memory_bytes: 3064
package main

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

func main() {
	R := nextInt()

	fmt.Printf("%.2f\n", float64(R)*2*3.14)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1784
#include <stdio.h>

int insertionSort(int *a, int *n) {
    int i, v, j, k;

    for (i = 0; i < *n; i++) {
        v = a[i];
        j = i - 1;

        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;

        for (k = 0; k < *n; k++) {
            printf("%d", a[k]);
            if (k < *n - 1) printf(" ");
            else printf("\n");
        }
    }

    return 0;
}

int main(void) {
    int n, f;
    scanf("%d", &n);
    int A[n];

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

    insertionSort(&A, &n);

    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <stdio.h>
using namespace std;


int main(void){
int h=0,r=0;
cin>>h>>r;
if(h+r==0){
cout<<"0"<<endl;
}
else if(h+r>=0){
cout<<"1"<<endl;
}
else {
cout<<"-1"<<endl;
}
return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>

int main(){
  int a[3], min = -1, sum = 0;
  scanf("%d%d%d", &a[0], &a[1], &a[2]);
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      if(i == j) continue;
      sum += a[j];
    }
    if(min == -1) min = sum;
    if(min > sum) min = sum;
    sum = 0;
  }
  printf("%d", min);
}

Measured memory_bytes: 128
import io.StdIn.{readInt, readLine}

object Main extends App {

  val n = readInt
  val numbers = (1 to n by 2)

  def divisor_count(i: Int): Int =
    (1 to i).count(i%_==0)

  val result = numbers.count(divisor_count(_) == 8)
  println(result)

}

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

string kata1, kata2, kata3, acronym;

int main () {
    cin>>kata1>>kata2>>kata3;
    kata1 [0]-=32;
    kata2 [0]-=32;
    kata3 [0]-=32;
    cout<<kata1[0]<<kata2[0]<<kata3[0];
}

Measured memory_bytes: 3596
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a) memset((a),0,sizeof(a))
#define MCLR(a) memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int c[100][100];

int main(){
    int H, W ,N;
    cin >> H >> W >> N;
    VI a;
    REP(i, N){
        int tmp;
        cin >> tmp;
        a.PB(tmp);
    }

    int nowX = 0, nowY = 0;
    REP(i, N){
        while(a[i] != 0){
            c[nowY][nowX] = i+1;
            a[i]--;
            if(nowY % 2 == 0){
                if(nowX + 1 == W){
                    nowY++;
                }else{
                    nowX++;
                }
            }else{
                if(nowX == 0){
                    nowY++;
                }else{
                    nowX--;
                }
            }
        }
    }

    REP(i, H){
        cout << c[i][0];
        REP1(j, W){
            cout << " " << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int A, B; cin >> A >> B;
	int cnt = A, ans = 1;
	if (B <= 1)cout << 0 << endl;
	else {
		while (cnt < B) {
			ans++, cnt += A - 1;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3636
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    // for(int i = 1; i <= n; i++){
    //     for(int j = 1; j <= n; j++){
    //         ans += i % j >= k;
    //     }
    // }
    for(int j = 1; j <= n; j++){
        ans += n / j * max(0ll, j - k);
        // if(n % j)
        ans += max(0ll, n % j - max(0ll, k - 1));
        // ans += max(0ll, n % j - k);
        printd(j, ans);
    }
    // for(int i = 1; i <= n; i++){
    //     ans += n - ;
    // }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    fr(i,0,s.length())
    cout<<'x';
}


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

using namespace std;

int n;
int a[410];
long long sum[410];
long long f[410][410];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=2;i<=n;i++)
		for(int j=1;j+i-1<=n;j++){
			f[j][j+i-1]=(long long)(1e9)*(long long)(1e9);
			for(int k=1;k<i;k++){
				f[j][j+i-1]=min(f[j][j+i-1],f[j][j+k-1]+f[j+k][j+i-1]+sum[j+i-1]-sum[j-1]);
			}
		}
	printf("%lld\n",f[1][n]);

	return 0;
}

Measured memory_bytes: 1536