akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   string s;
   cin >> s;
   map<char, int> m;
   rep(i, 4) m[s[i]]++;
   int cnt = 0;
   for (char c = 'A'; c <= 'Z'; c++) {
      if (m[c] == 2)
         cnt++;
   }
   if (cnt == 2)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;

   return 0;
}

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

int N, M, Q;
int a[50], b[50], c[50], d[50];
int ans = 0;
int C[20];
void recursive_comb(int s, int rest) {
  if (rest == 0) {
    int A[N];
    for(int i = 0;i<N;i++){
    	A[i] = C[i] - i + 1;
    	//cout << A[i] << ":";
    }
    //cout << endl;
    int tmp = 0;
    for(int i=0;i<Q;i++){
		if(A[b[i] - 1] - A[a[i] - 1] == c[i])tmp += d[i];
	}
	ans = max(tmp, ans);
    return;
  } 
  else {
    if (s < 0) return;
    recursive_comb(s - 1, rest);
    C[rest - 1] = s;
    recursive_comb(s - 1, rest - 1);
  }
}

int main(){
	cin >> N >> M >> Q;
	for(int i=0;i<Q;i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	recursive_comb(N + M - 2, N);
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
// #include <vector>
// #include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

int main(){
    int N, L;
    cin >> N >> L;
    string SA[N];
    for (int i=0; i<N; i++) cin >> SA[i];
    sort(SA, SA + N);
    string sum = "";
    for (int i=0; i<N; i++) sum += SA[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s;
  string t;

  int w=0;
  cin >> s >> t;
    for (int i=0;i<=3;i++)
    {
        if (s[i]==t[i])
        {
            w++;
        }
    }
    cout << w-1;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
ll a[1000000+9];
using namespace std;
int main()
{
    ll n,i,j;
    cin>>n;
    set<ll>s;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    j=s.size();
    cout<<j<<endl;
}


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

int main()
{
    string s,t;
    cin>>s>>t;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No"<<endl;
            return 0;

        }

    }

   cout << "Yes" << endl;
       return 0;
}














Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
#define LOOP while(true)
const long long MOD = 10e9 + 7;
typedef long long ll;

int main(){
	int A, B, C;
	cin >> A >> B >> C;
	bool JD = false;
	rep(i, B){
		if(A * i % B == C){
			JD = true;
			break;
		}
	}
	cout << ((JD) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(B / A > C) cout << C<< endl;
    else cout << B / A << endl;   
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))

ll a[60];
ll s[60];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",a+i);

	ll ans=INF;
	rep(x,0,n+1){
		//操作回数の合計をS=k(n+1)+xと決め打ち
		//a[i]は操作後に(a[i]+S)%(n+1)になっている
		//a[i]に対する操作回数をs[i]とすると
		//a[i]+S-(n+1)*s[i]=(a[i]+x)%(n+1)より
		//s[i]=(a[i]+x)/(n+1)+k
		//これの総和を取って
		//S=kn+Σ(a[i]+x)/(n+1)より
		//k=-x+Σ(a[i]+x)/(n+1)
		//S>=0かつs[i]>=0かつ(a[i]+S)%(n+1)!=nかどうかチェック
		
		ll k=-x;
		rep(i,0,n)k+=s[i]=(a[i]+x)/(n+1);
		ll S=k*(n+1)+x;
		int f=1;
		rep(i,0,n)f&=s[i]+k>=0&&(a[i]+S)%(n+1)!=n;
		if(S>=0&&f)ans=min(ans,S);
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n)cin>>a[i];
    ll min = INF;
    ll max = -INF;
    ll mini = 0;
    ll maxi = 0;
    rep(i,n){
        if(chmin(min,a[i])){
            mini = i;
        }
        if(chmax(max,a[i])){
            maxi = i;
        }
    }
    VP res;
//    dbg(min)
//    dbg(max)
    if(abs(min)>max){
        rep(i,n){
            if(i!=mini){
                res.emplace_back(mini,i);
            }
        }
    }else{
        rep(i,n){
            if(i!=maxi){
                res.emplace_back(maxi,i);
            }
        }
    }
    if(abs(min)>max){
        PER(i,n-1,1){
            res.emplace_back(i,i-1);
        }
    } else{
        REP(i,1,n){
            res.emplace_back(i-1,i);
        }
    }
    bool debug = false;
    cout<<res.size()<<endl;
    rep(i,res.size()){
        cout<<res[i].fi+1<<" "<<res[i].se+1<<endl;
        if(debug){
            a[res[i].se] += a[res[i].fi];
        }
    }
    if(debug){
        dbg(a);
    }
    return  0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		String S = "",T="";
		String result ="";
		S=sc.next();
		T=sc.next();
		for(int i=0;i<N;i++) {
			result+=S.charAt(i);
			result+=T.charAt(i);
		}


		out.println(result);

		out.flush();
	}


}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}



Measured memory_bytes: 21204
import math
numOfStation = int(input())
array = [0] * (numOfStation - 1)

for i in range(numOfStation - 1):
    array[i] = input().split()

for i in range(numOfStation - 1):
    time = 0
    for j in range(i, numOfStation - 1):
        nextTrain = int(array[j][1])
        # check the next train
        if time > nextTrain:
            # Additional time to catch the next one
            nextTrain += math.ceil((time - nextTrain)/int(array[j][2]))*int(array[j][2])

        time += (nextTrain - time) + int(array[j][0])  # Time arrived at the next station

    print(time)

print(0)

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	ll money = 1000, stock = 0;
	for(int i = 0; i < N; i++) {
		if(i != N - 1) {
			if(A[i] < A[i + 1]) {
				ll n = money / A[i];
				money -= n * A[i];
				stock += n;
			}
			if(A[i] > A[i + 1]) {
				money += stock * A[i];
				stock = 0;
			}
		}
		else {
			money += stock * A[i];
		}
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 3620
s=input()
l=len(s)

a="keyence"
cnt=0
i=0
j=0
ans=""
if l<7:
  ans="NO"
elif s==a:
  ans="YES"
else:
  while(i<l):
    if s[i]==a[j]:
      cnt+=1
      i+=1
      j+=1
      
    else:
      i+=l-7
  if cnt==7:
    ans="YES"
  else:
    ans="NO"
print(ans)

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

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
	int n;
	cin>>n;
	int A[n+1];
	for(int i=1;i<=n;i++) cin>>A[i];
	
	for(int i=1;i<=n;i++){
		cout<<"node "<<i<<": key = "<<A[i]<<", ";
		if(parent(i)>=1) cout<<"parent key = "<<A[parent(i)]<<", ";
		if(left(i)<=n) cout<<"left key = "<<A[left(i)]<<", ";
		if(right(i)<=n) cout<<"right key = "<<A[right(i)]<<", ";
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3108
import java.util.Scanner;
    
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String labelStr = scanner.nextLine();
        String orderStr = scanner.nextLine();
        
        String[] labelArr = labelStr.split(" ");
        int dice[] = new int[6];
        
        for (int i=0; i<6; i++) {
            dice[i] = Integer.parseInt(labelArr[i]);
        }
        
        DiceUtil diceUtil = new DiceUtil();
        diceUtil.setDice(dice[0],dice[1],dice[2],dice[3],dice[4],dice[5]);

        char[] orderArr = orderStr.toCharArray();
        for(char order : orderArr){
            diceUtil.orderDice(order);
        }
        
        System.out.println(diceUtil.getDiceTop());
    }
}

class DiceUtil {
    
    int dice[];
    
    DiceUtil() {
        dice = new int[6];
    }
    
    public void setDice(int num1, int num2, int num3, int num4, int num5, int num6){
        dice[0] = num1;
        dice[1] = num2;
        dice[2] = num3;
        dice[3] = num4;
        dice[4] = num5;
        dice[5] = num6;
    }
    
    public void orderDice(char order){
        int tmp = 0;
        switch(order){
            case 'N':
                tmp = dice[0];
                dice[0] = dice[1];
                dice[1] = dice[5];
                dice[5] = dice[4];
                dice[4] = tmp;
                break;
            case 'S':
                tmp = dice[0];
                dice[0] = dice[4];
                dice[4] = dice[5];
                dice[5] = dice[1];
                dice[1] = tmp;
                break;
            case 'E':
                tmp = dice[0];
                dice[0] = dice[3];
                dice[3] = dice[5];
                dice[5] = dice[2];
                dice[2] = tmp;
                break;
            case 'W':
                tmp = dice[0];
                dice[0] = dice[2];
                dice[2] = dice[5];
                dice[5] = dice[3];
                dice[3] = tmp;
                break;
        }
    }
    
    public int getDiceTop(){
        return dice[0];
    }
};


Measured memory_bytes: 26212
#include<iostream>
using namespace std;
int main(){
    int ans=0,c,p;
    int n,d,x[10][10];
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            c=0;
            for(int k=0;k<d;k++){
                p=x[i][k]-x[j][k];
                c+=p*p;
            }
            for(int k=0;k<130;k++){
                if(k*k==c){
                    ans++;
                    break;
                }
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#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 n0, n1, n2;
//	string s;
	cin >> n0 >> n1 >> n2;
	if(n0 == n1){
		cout << n2 << endl;
	}else if(n1 == n2){
		cout << n0 << endl;
	}else{
		cout << n1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;

int main(){
	long r, D, x;
	cin >> r >>  D >> x;
	for(int i=1;i<=10;i++){
		x *= r;
		x -= D;
		cout << x << endl;
	}
}

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

int main() {
  int h, w;
  cin >> h >> w;

  string G[h];
  for (int i = 0; i < h; i++) cin >> G[i];

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

  bool can = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (G[i][j] == '#') {
        bool sharp = false;
        for (int d = 0; d < 4; d++) {
          if (i + dy[d] < 0 || h <= i + dy[d]) continue;
          if (j + dx[d] < 0 || w <= j + dx[d]) continue;
          if (G[i + dy[d]][j + dx[d]] == '#') sharp = true;
        }
        if (sharp == false) can = false;
      }
    }
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    ve <char> ans;
    rep (i,0,n)
    {
        ans.pb(s1[i]);
        ans.pb(s2[i]);
    }
    for (auto x: ans)
    {
        cout<<x;
    }

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int len,i,cnt;
	char s[11],ss[11];
	scanf("%s",s);
	len=strlen(s);
	cnt=0;
	for(i=0;i<len;i++){
		if(s[i]!='B'){
			ss[cnt]=s[i];
			cnt++;
		}
		else if(cnt>0){
			cnt--;
		}
	}
	ss[cnt]='\0';
	printf("%s\n",ss);
	return 0;
}

Measured memory_bytes: 128
X, N = input().split()
X = int(X)
N = int(N)
p = list(map(int, input().split()))

tmp = [i for i in range(-101, 200)]
for i in p:
  tmp.remove(i)
for i in range(len(tmp)):
  tmp[i] = abs(tmp[i] - X)

ans = 0
for i in p:
  if X-min(tmp)==i:
    ans = 1

if ans==0:
  print(X-min(tmp))
else:
  print(X+min(tmp))

Measured memory_bytes: 9212
#include <stdio.h>
int main(void)
{
  int n,m,l;
  int i,j,k;
  int a[100][100]={0};
  int b[100][100]={0};
  double c[100][100]={0};
 
  scanf("%d",&n);
  scanf("%d",&m);
  scanf("%d",&l);
 
  for (i=0; i<n; i++) 
  {
    for (j=0; j<m; j++) 
	{
      scanf("%d",&a[i][j]);
    }
  }
  
  for (i=0; i<m; i++) 
  {
    for (j=0; j<l; j++) 
	{
      scanf("%d",&b[i][j]);
    }
  }
 
  for (i=0; i<n; i++) 
  {
    for (j=0; j<l; j++) 
	{
      for (k=0; k<m; k++) 
	  {
        c[i][j]+=a[i][k]*b[k][j];
      }
    }
  }
 
  for (i=0; i<n; i++) 
  {
    for (j=0; j<l; j++) 
	{
      if (j!=l-1) printf("%.lf ",c[i][j]);
      else printf("%.lf\n",c[i][j]);
    }
  }
  
  return 0;
}

Measured memory_bytes: 796
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;

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

int H, W;
int field[410][410];
ll numb{0}, numw{0};

bool seen[410][410];
void DFS(int h, int w)
{
	seen[h][w] = true;
	if (field[h][w] == 1) ++numb;
	else ++numw;
	
	for (int i = 0; i < 4; ++i)
	{
		int hh = h + dy[i];
		int ww = w + dx[i];
		if (hh < 0 || hh >= H || ww < 0 || ww >= W) continue;
		if (seen[hh][ww]) continue;
		if (field[h][w] == field[hh][ww]) continue;
		DFS(hh, ww);
	}
}

int main(int argc, char **argv)
{
	cin >> H >> W;

	vector<pint> target;
	for (int h = 0; h < H; ++h)
	{
		for (int w = 0; w < W; ++w)
		{
			char c; cin >> c;
			if (c == '#')
				field[h][w] = 1;
			else field[h][w] = 0;
		}
	}

	memset(seen, 0, sizeof(seen));
	ll res{0};
	for (int h = 0; h < H; ++h)
	{
		for (int w = 0; w < W; ++w)
		{
			if (field[h][w] == 0) continue;
			if (seen[h][w]) continue;
			numb = numw = 0;
			DFS(h, w);
			res += numb * numw;
		}
	}

	std::cout << res << std::endl;

}


Measured memory_bytes: 8576
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    int k;
    String s;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        k = sc.nextInt();
        s = sc.next();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        if (s.length() <= k) {
            System.out.println(s);            
        } else {
            System.out.println(s.substring(0, k)+"...");            
        }
    }
}

Measured memory_bytes: 38620
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n;
  cin>>n;
  string s;
  string t;
cin>>s;
  cin>>t;
  
  char P[2*n+1];
 for(int i=0;i<=n-1;i++){
   P[2*i+1]=s[i];
   P[2*i+2]=t[i];
 
 }
  
  for(int i=1;i<=2*n;i++){
    cout<<P[i];}
  
  cout<<endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

int solve() {
    ll L, R;
    cin >> L >> R;
    ll dif = R - L;
    if(dif >= 2019) return 0;
    L %= 2019;
    R %= 2019;
    int ans = 2018;
    rep(i, L, R) rep(j, i+1, R+1) {
        int m = i * j % 2019;
        ans = min(ans, m);
    }
    return ans;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define FOR(i,x,y) for(int (i)=(x); (i)<(y);(i++))
#define INT long long
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
using namespace std;

INT n, a, b, c, d, C, D, gap, dif;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>a>>b>>c>>d;
    for(int i = 0 ; i < n ; i++ )
    {
        if( c*i-d*(n-i-1) <= b-a and b-a <= d*i-c*(n-i-1) )
            return cout<<"YES"<<endl, 0;
    }
    cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll Mod = 1e9 + 7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    int n , k;
    cin >> n >> k;
    int A[n+1];
    for(int i = 1; i<= n ;i++)
        cin >> A[i];
    
    ll dp[k+1] , pref[k+1];

    for(int i = 0 ;i <= k ; i++)
        pref[i] = 1; 
   
    for(int i = 1 ;i <= n ;i++){
        
        for(int no = 0 ; no <= k ; no++){
            
            dp[no] = pref[no];
            if(no > A[i])
                dp[no] -= pref[no-A[i]-1]; 
            if(dp[no] >= Mod)
                dp[no] -= Mod;
            if(dp[no] < 0)
                dp[no] += Mod;
        }
        pref[0] = dp[0];
        for(int j = 1 ; j <= k ; j++){
            pref[j] = pref[j-1] +  dp[j];
            if(pref[j] >= Mod)
                pref[j] -= Mod;
        }
    }
    cout << dp[k] << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	double EPS=1e-6;

	int n, m;
	// n:black
	// m:white
	int[] xs, ys;

	void run(){
		for(;;){
			n=sc.nextInt();
			m=sc.nextInt();
			if((n|m)==0){
				break;
			}
			xs=new int[n+m];
			ys=new int[n+m];
			for(int i=0; i<n+m; i++){
				xs[i]=sc.nextInt();
				ys[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int[] s=new int[n+m];
		for(int b=0; b<n; b++){
			for(int w=n; w<n+m; w++){
				double xw=xs[w];
				double yw=ys[w];
				double xb=xs[b];
				double yb=ys[b];

				double a=xb==xw?0:(double)(yb-yw)/(xb-xw);
				double y1=yw;
				double x1=xw;

				boolean f=true;
				for(int i=0; i<n+m; i++){
					double x=xs[i];
					double y=ys[i];
					boolean on=false;
					if(xb!=xw){
						double y2=a*(x-x1)+y1;
						if(y+EPS<y2){
							// º
							s[i]=-1;
						}else if(y2+EPS<y){
							// ã
							s[i]=1;
						}else{
							on=true;
						}
					}else{
						// c
						if(x+EPS<x1){
							// ¶
							s[i]=-1;
						}else if(x1+EPS<x){
							// E
							s[i]=1;
						}else{
							on=true;
						}
					}
					if(on){
						// ¼üó
						boolean fx=false;
						boolean fy=false;
						if(i<n){
							// black
							fx|=c(xw, xb, x);
							fx|=c(x, xb, xw);
							fy|=c(yw, yb, y);
							fy|=c(y, yb, yw);
						}else{
							// white
							fx|=c(xb, xw, x);
							fx|=c(x, xw, xb);
							fy|=c(yb, yw, y);
							fy|=c(y, yw, yb);
						}
						if(fx&&fy){
							s[i]=0;
						}else{
/*
  							println("black:"+xb+","+yb);
							println("white:"+xw+","+yw);
							println("coor:"+x+","+y);
							println("NO");
							return;*/
							f=false;
						}
						// s[i]=(fx&&fy)?0:2;
					}
				}

				// check

				// ã\ÆÈé(Ìóâ)
				int s1=0, s2=0;
				for(int i=0; i<n; i++){
					if(Math.abs(s[i])==1){
						s1=s[i];
					}
				}
				for(int i=n; i<n+m; i++){
					if(Math.abs(s[i])==1){
						s2=s[i];
					}
				}

				// 0©¯ê©Ì¸
				for(int i=0; i<n; i++){
					if(s1*s[i]==-1){
						f=false;
					}
				}
				for(int i=n; i<n+m-1; i++){
					if(s2*s[i]==-1){
						f=false;
					}
				}

				// Ý¢Éá¤
				// Ðûª¼üó
				// 0,1
				// 0,-1
				// 1,-1
				// 1,1
				// -1,-1
				f&=s1*s2!=1;
				if(s1*s2!=1){
					// ok
				}

				if(f){
/*					println("s1:"+s1);
					println("s2:"+s2);
					println("black:"+xb+","+yb);
					println("white:"+xw+","+yw);
					println(Arrays.toString(s));*/
					println("YES");
					return;
				}
			}
		}
		println("NO");
	}

	// a<=b<=c
	boolean c(double a, double b, double c){
		return a<b+EPS&&b<c+EPS;
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

	}
}

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

using namespace std;

int main()
{
//    cout << "Hello world!" << endl;
    long long int l,r,d,i,result=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++){
        if(i%d==0)
            result+=1;
    }
    cout<<result;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;


signed main(){
	string s;
	cin>>s;
	int cnt = 0;
	REP(i,s.size()/2){
		if(s[i]!=s[s.size()-i-1])cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let solve a b c d =
  if a < b || b > d then "No"
  else if b <= c then "Yes"
  else let v = gcd b d in if b - v + (a mod v) <= c then "Yes" else "No"
let () =
  Scanf.scanf "%d" @@ fun t ->
  Array.init t (fun _ -> Scanf.scanf " %d %d %d %d" solve)
  |> Array.iter print_endline

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	ll a,b,c,k;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if(k%2LL==0){
		printf("%lld\n",a-b);
	}else{
		printf("%lld\n",b-a);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main(){
  string S;
  cin >> S;
  int chg = 0;
  REP(i, 1, S.size()) {
    if (S[i - 1] != S[i]) chg++;
  }
  cout << chg << endl;
  return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,a,b;

    std::cin >> n>>a>>b;
    std::cout <<(n/(a+b))*a+min(a,n%(a+b))  << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int ma=0,cur=0;
  string s;
  cin>>s;
  int n=s.size();
  veci v(s.size(),0);
  rep(i,n)if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')v[i]=1;
  rep(j,n){
    
    ma=max(ma,cur);
    if(v[j]==1){cur=1;ma=max(ma,cur);
    rep(k,n-j-1){
      if(v[j+k+1]==1){cur++;ma=max(ma,cur);}
      else{ma=max(ma,cur);break;}
      
             }}
             }
  ma=max(ma,cur);
      cout<<ma<<endl;
}


Measured memory_bytes: 256
let mod = 1000000007

func readIntPair() -> (Int, Int) {
    let line = readLine()!.split(separator: " ").map({Int($0)!})
    return (line[0], line[1])
}

func readIntArray() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let (N, M) = readIntPair()
let S = readIntArray(), T = readIntArray()

var dp: [[Int]] = Array.init(repeating: Array.init(repeating: 0, count: M + 1), count: N + 1)
var sum: [[Int]] = Array.init(repeating: Array.init(repeating: 0, count: M + 1), count: N + 1)

(1...N).forEach({ i in
    (1...M).forEach({ j in
        if S[i - 1] == T[j - 1] {
            dp[i][j] = (1 + sum[i - 1][j - 1]) % mod
        } else {
            dp[i][j] = 0
        }
        sum[i][j] = (dp[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + mod) % mod
    })
})

print((sum[N][M] + 1) % mod)


Measured memory_bytes: 70772
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 301002

int n;
int m;

vector<long long int> x;
vector<long long int> y;

long long int pre(long long int pos) {
	int id = lower_bound(y.begin(), y.end(), pos) - y.begin();
	id--;
	if (id >= 0) {
		return pos-y[id];
	}
	return -1;
}
long long int nex(long long int pos) {
	int id = lower_bound(y.begin(), y.end(), pos) - y.begin();
	if (id<y.size()) {
		return y[id] - pos;
	}
	return -1;
}
vector<long long int> dif;

vector<pair<long long int, long long int> > v;

bool cmp(pair<long long int, long long int> a, pair<long long int, long long int> b) {
	if (a.first != b.first) {
		return a.first > b.first;
	}
	return a.second < b.second;
}

long long int dp[MAX];
#define MOD 1000000007
long long int bit[MAX];
void add(int i, long long int x) {
	i = MAX - 10 - i;
	while (i < MAX) {
		bit[i] += x;
		if (bit[i] >= MOD)bit[i] %= MOD;
		i += i & -i;
	}
}
long long int sum(int i) {
	long long int r = 0;
	i = MAX - 10 - i;
	while (i) {
		r += bit[i];
		r %= MOD;
		i -= i & -i;
	}
	return r;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		x.push_back(a);
	}
	for (int i = 0; i < m; i++) {
		int a;
		scanf("%d", &a);
		y.push_back(a);
	}
	for (int i = 0; i < x.size(); i++) {
		long long int d1 = pre(x[i]);
		long long int d2 = nex(x[i]);
		if (d1 == -1 || d2 == -1)continue;
		v.push_back(make_pair(d1, d2));
		dif.push_back(d1);
		dif.push_back(d2);
	}
	sort(dif.begin(), dif.end());
	dif.erase(unique(dif.begin(), dif.end()), dif.end());
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for (int i = 0; i < v.size(); i++) {
		v[i].first = lower_bound(dif.begin(), dif.end(), v[i].first) - dif.begin();
		v[i].second = lower_bound(dif.begin(), dif.end(), v[i].second) - dif.begin();
	}
	sort(v.begin(), v.end(),cmp);
	long long int cur = 1;
	add(dif.size(), 1);
	for (int i = 0; i < v.size(); i++) {
		//choose X
		//int burn = v[i].second-1;  //(burn ~ )
		//leave(0, v[i].second-1);

		//choose O
		int burn = v[i].second;
		long long int z = sum(v[i].second+1);
		add(burn, z);
		//add(burn, sum(0,v[i].second));
		//leave(v[i].second + 1, inf);
	}
	long long int ans = sum(-3);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9072
/* Akshat Sharma @akshat98 */
#include <iostream>
#include <bits/stdc++.h>
#define IOS  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp   make_pair
#define pb   push_back
#define F    first
#define S    second
#define ll   long long
#define MOD  1000000007
#define MAX  1000000001
#define vi   vector<int>
#define vl   vector<ll>
#define vpi  vector<pair<int,int> >
#define vpl  vector<pair<ll,ll> >
#define rep(i,a,b) for(i=a;i<b;i++)
#define reqp(i,a,b) for(i=a;i<=b;i++)
#define ren for(i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;


int main()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input_file.txt", "r", stdin);
	//freopen("output_file.txt", "w", stdout);
	//#endif
	int i,j,k,l,n,test_case,m,r;
	test_case=1;
	//cin>>test_case;
	while(test_case--){
		cin>>n;
		ll sum=0;
		rep(i,1,n+1){
			if(i%3 && i%5)sum+=i;
		}
		cout<<sum;


	}
	
	return 0;
}

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

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

    int count = 0;
    for (int i = 0; i < s.length() / 2; ++i)
    {
        if (s[i] != s[s.length() - 1 - i])
        {
            ++count;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    result = 5000 * 10 ** 5 * 2 + 1
    for i in range(0, 10 ** 5 + 1):
        cost = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B

        result = min(result, cost)
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define INFINITE 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define INF (1e18+5)
	#define inf (1e9+5)
	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };

	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	ll fun(string a)
	{
		ll sum=0;
		ll n=sz(a);
		forn(i,n)
		{
			sum+=a[i]-'0';
		}
		return sum;
	}
	void solve()
	{
		string n;
		cin>>n;
		ll er=fun(n);
		if(er%9==0)
		{
			cout<<"Yes"<<endl;
		}
		else 
			cout<<"No"<<endl;

	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,v;
  cin>>s>>v;
  int a,b;
  cin>>a>>b;
  string f;
  cin>>f;
  if(f==s)
    cout<<a-1<<' '<<b;
  else
    cout<<a<<' '<<b-1;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

//--------------------------

int main() {

  deque<char> dq;

  string s;
  cin >> s;
  int q, t, f, r = 0;
  cin >> q;
  char c;

  rep(i, s.length()) {
    dq.push_back(s[i]);
  }

  rep(i, q) {
    cin >> t;
    if(t==1) ++r;
    else {
      cin >> f >> c;
      if(r%2==0) {
        if(f==1) dq.push_front(c);
        else dq.push_back(c);
      }else {
        if(f==1) dq.push_back(c);
        else dq.push_front(c);
      }
    }
  }

  if(r%2==0) {
    while(!dq.empty()) {
      cout << dq.front();
      dq.pop_front();
    }
  }else {
    while(!dq.empty()) {
      cout << dq.back();
      dq.pop_back();
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 896
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] += 1
    else:
        d[S] = 1
max_val = max(d.values())
key_list = [kv[0] for kv in d.items() if kv[1] == max_val]
for k in sorted(key_list):
    print(k)


Measured memory_bytes: 35464
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b = sc.nextInt
  val res = (a - b) match {
      case x if x < 0 => "a < b"
      case x if x > 0 => "a > b"
      case x => "a == b"
  }
  
  println(res)

}


Measured memory_bytes: 45128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100000), 100000000)
}

func main() {
	n := scanInt()
	xm := make(map[string]int)
	for i := 0; i < n; i++ {
		s := scanString()
		xm[s]++
	}

	fmt.Println("AC x", xm["AC"])
	fmt.Println("WA x", xm["WA"])
	fmt.Println("TLE x", xm["TLE"])
	fmt.Println("RE x", xm["RE"])
}


Measured memory_bytes: 2188
import math
K = int(input())

gl = [[0]*K for _ in range(K)]
for i in range(K):
    for j in range(K):
        gl[i][j] = math.gcd(i+1, j+1)

res = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            tmp = gl[i][j]
            res += gl[tmp-1][k]

print(res)


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

signed main() {
  string S;
  cin >> S;
  int N = (int)S.size()+1;
  
  vector<int> A(N, 0);
  int count = 0;
  for( int i = 0; i < S.size(); i++ ){
    if( S.at(i) == '<' ){
      count++;
      A.at(i+1) = count;
    }else{
      count = 0;
      A.at(i+1) = count;
    }
  }
 
  for( int i = S.size()-1; i >= 0; i-- ){
    if( S.at(i) == '>' ){
      count++;
      A.at(i) = max(A.at(i), count);
    }else{
      count = 0;
      A.at(i) = max(count, A.at(i));
    }
  }
  
  int total = 0;
  for( int i = 0; i < N; i++ ) total += A.at(i);
  cout << total << endl;
      
}



Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
 
typedef long long lld;
const int NN = 1e5 + 5;
lld aa[NN], dp[NN];
int nn;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
        cin >> nn;
        for (int ii = 1; ii <= nn; ++ii)
            cin >> aa[ii];
        dp[1] = 0;
        dp[2] = abs(aa[2] - aa[1]);
        for (int ii = 3; ii <= nn; ++ii)
            dp[ii] = min(dp[ii-1] + abs(aa[ii] - aa[ii - 1]), dp[ii-2] + abs(aa[ii] - aa[ii - 2]));
        cout << dp[nn];
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
const int inf=1e9;
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int in[11][11];
    rep(i,11)rep(j,11)in[i][j]=inf;
    int maax=0;
    rep(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      in[a][b]=c;
      in[b][a]=c;
      maax=max(maax,a);
      maax=max(maax,b);
    }
    n=maax+1;
    int mini=inf;
    rep(k,n)rep(a,n)rep(b,n)in[a][b]=min(in[a][b],in[a][k]+in[k][b]);
    int out;
    rep(i,n){
      int sum=0;
      rep(j,n){
	if(i==j)continue;
	sum+=in[i][j];
	//vector<vector<int> >tmp(n,vector<int>(n));
	//rep(a,n)rep(b,n)tmp[a][b]=in[a][b];
	//rep(k,n)rep(a,n)rep(b,n)tmp[a][b]=min(tmp[a][b],tmp[a][k]+tmp[k][b]);
	//sum+=tmp[i][j];
	//cout<<" "<<i<<" "<<j<<" "<<sum<<endl;
      }
      if(mini>sum){
	mini=sum;
	out=i;
      }
      //cout<<i<<" ! "<<sum<<endl;
    }
    cout<<out<<" "<<mini<<endl;
  }
}

Measured memory_bytes: 1156
#include <stdio.h>
int main(void){
char s[100005];
  int count;
  scanf("%s",s);
  for(count=0;;){
  printf("%c",s[count]);
    if(s[count+1]=='\0'||s[count+2]=='\0'){break;}
    count=count+2;
  }
  
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int s = 0;
    int t = 0;

    for(int i=0; i<4; ++i){
        int a;
        cin >> a;
        s += a;
    }
    for(int i=0; i<4; ++i){
        int a;
        cin >> a;
        t += a;
    }

    cout << max(s, t) << endl;
    return 0;
}

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

#define H 15
#define W 20

int main(){
    int n;
    cin >> n;
    int b, f, r, v;
    int t[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if((i + 1) % 4 == 0) continue;
            if((j + 1) % 2 == 0) t[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> b >> f >> r >> v;
        t[4 * (b - 1) + (f - 1)][(r * 2) - 1] += v;
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if((i + 1) % 4 == 0) cout << "#";
            else if((j + 1) % 2 == 0) cout << t[i][j];
            else cout << " ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200003;
int n,m;
int f[MaxN];

int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) {
		int a,b;
		scanf("%d%d",&a,&b);
		f[a]++,f[b]++;
	}
	bool flag=true;
	for (int i=1;i<=n;++i) 
		if (f[i]%2) {
			flag=false;
			break;
		}
	if (flag) puts("YES");else puts("NO");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int cntl=0;
    int cntr=0;
    int n, m, x;
    cin >> n >> m >> x;
    int A[m];
    for(int i=0; i<m; i++){
        cin >> A[i];
    }
    int j=0;
    for(j=0; A[j]<x; j++){
        cntl++;
    }
    cntr=m-cntl;

    if(cntl<cntr){
        cout << cntl << endl;
    }
    else{
        cout << cntr << endl;
    }

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	ll x, k, d;
	cin >> x >> k >> d;
	ll tar1 = x % d;
	ll tar2;
	if (x < 0) tar2 = tar1 + d;
	else tar2 = tar1 - d;
	ll mn = abs(x/d);
	if (mn > k) {
		if (x < 0) cout << abs(x + k*d) << '\n';
		else cout << abs(x - k*d) << '\n';
		return 0;
	}
	ll diff = k - mn;
	cout << abs(((diff&1) ? tar2 : tar1)) << '\n';
}

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

using namespace std;

int main() {
    vector<int> rgb(3);
    int n;
    for (int i=0; i<3; i++) cin >> rgb[i];
    cin >> n;

    vector<int> dp(n+1, 0);
    dp[0] = 1;
    for (int i=0; i<3; i++) {
        for (int j=0; j<=n-rgb[i]; j++) {
            dp[j + rgb[i]] += dp[j];
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 256