akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i * fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    init();

    ll rui[101010];
    rui[1] = 1;
    rep(i, n) {
        rui[i+2] = (rui[i+1] + inv[i+2])%mod;
    }

    ll ans = 0;
    rep(i, n) {
        ans += a[i]*(rui[i+1] + rui[n-i] - 1)%mod;
        ans %= mod;
    }
    ans *= fact[n];
    ans %= mod;

    out(ans);
    re0;
};

Measured memory_bytes: 4224
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest081-B
#  https://beta.atcoder.jp/contests/abc081/tasks/abc081_b


def devide2(s):

	strList = s.split(' ')
	listLength = len(strList)
	intList = []
	for i in range(listLength-1):
		intList.append(int(strList[i]))
	sunukeCheckGoing = True
	sunukeCheckCounter = 0
	while sunukeCheckGoing:
		for j in range(listLength-1):
			oddCheck = intList[j]%2
			if oddCheck == 1 :
				sunukeCheckGoing = False
			else :
				intList[j]=intList[j]//2
		if sunukeCheckGoing == True:
			sunukeCheckCounter = sunukeCheckCounter +1

	answer = sunukeCheckCounter
	return answer


if __name__ == '__main__':
	_ = input()
	intAsStr=input()
	count=devide2(intAsStr)
	print(count)


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i32 k;
    cin >> k, k--;
    vector<i32> v { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    cout << v[k] << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
j = K-1
l = i
r = N - l - 1
ans, e = divmod(l, j)
if e:
    ans += 1
    r -= K - e - 1
ans += (r+j-1)//j
print(ans)

Measured memory_bytes: 52652
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	int gesture[5];
	while(~scanf("%d",&gesture)){
		if(gesture[0]==0) break;
		for(int i=0;i<4;i++){
			scanf("%d",gesture+i+1);
		}

		for(int i=0;i<5;i++){
			int bit,player;
			bit = player = (1 << (gesture[i]-1));

			for(int j=0;j<5;j++){
				if(i==j) continue;
				bit |= (1 << (gesture[j]-1));
			}

			if(bit == ((1<<3)-1)){
				printf("3\n");
			}

			else if(bit == 1 
				|| bit == (1<<1)
				|| bit == (1<<2)){
					printf("3\n");
			}

			else{
				bit &= ~player;
				if(player == 1 && bit == (1<<1)){
					printf("1\n");
				}
				else if(player == 1 && bit == (1<<2)){
					printf("2\n");
				}

				else if(player == (1<<1) && bit == 1){
					printf("2\n");
				}
				else if(player == (1<<1) && bit == (1<<2)){
					printf("1\n");
				}

				else if(player == (1<<2) && bit == 1){
					printf("1\n");
				}
				else if(player == (1<<2) && bit == (1<<1)){
					printf("2\n");
				}
			}
		}
		
	}

}

Measured memory_bytes: 3080
N = int(input())
X = list(map(int, input().split()))
X_ = sum(X) // N
HP1 = 0
HP2 = 0
for i in range(N):
  HP1 += (X[i] - X_)**2
  HP2 += (X[i] - X_ -1 )**2
if HP1>=HP2:
  print(HP2)
else:
  print(HP1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  1000005;
const ll mod = 1e9 + 7;

using namespace std;

void solve()
{
// string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>k>>n;

  for (ll i = 1;; ++i)
  { 
      x = i;
      y = 0;
      while(x%100==0)
      {
        x/=100;
        y++;
      }
      if(y==k)
        c++;

      if(c==n)
      {
        c(i);
        return;
      }        
  }

}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


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

int main() {
  int N, D;
  cin >> N >> D;
  
  int A = 0;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    A += D * 2 + 1;
    count++;
    if (A >= N) {
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main()
{
	int k, n;
	scanf("%d %d", &k, &n);
	int i;
	int a[200005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int max = 0;
	for (i = 0; i < n; i++)
		if (max < (a[(i + 1) % n] - a[i] + k) % k)
			max = (a[(i + 1) % n] - a[i] + k) % k;
	printf("%d\n", k - max);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int li[3][31], t[31][31];

int main(){
	int n, c, a[510][510]; cin >> n >> c;
	for(int i = 0; i < c; i++) {
		for(int j = 0; j < c; j++) {
			cin >> t[i][j];
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
			
			li[(i + j) % 3][a[i][j] - 1]++;
		}
	}
	
	long mi = 1e9;
	for(int i = 0; i < c; i++) {
		for(int j = 0; j < c; j++) {
			for(int k = 0; k < c; k++) {
				if(i == j or j == k or k == i) continue;
				long cost = 0;
				
				for(int l = 0; l < 30; l++) {
					cost += t[l][i] * li[0][l];
					cost += t[l][j] * li[1][l];
					cost += t[l][k] * li[2][l];
				}
				
				mi = std::min(mi, cost);
			}
		}
	}
	
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 1280
#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>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

int N;
vector<long long> V, W;
long long Wmax;
vector<vector<vector<long long>>> DP;

int main() {
	cin >> N >> Wmax;
	V.resize(N + 1);
	W.resize(N + 1);
	for (int n = 1; n <= N; n++) {
		cin >> W[n] >> V[n];
	}
	DP.resize(N + 1, vector<vector<long long>>(N + 1, vector<long long>(301, -1)));
	DP[0][0][0] = 0;
	for (int n = 1; n <= N; n++) {
		DP[n][0][0] = 0;
		for(int k = 1;k <= n;k++)
		for (int w = 0; w <= 300; w++) {
			DP[n][k][w] = DP[n - 1][k][w];
			if (w - W[n] + W[1] >= 0) {
				DP[n][k][w] = max(DP[n][k][w], DP[n - 1][k - 1][w - W[n] + W[1]] + V[n]);
			}
		}
	}
	long long ans = 0;
	for (int k = 0; k <= N; k++) {
		for (int w = 0; w <= min((long long)300,Wmax - k * W[1]); w++) {
			ans = max(ans, DP[N][k][w]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    if((a + b) % 2 == 0){
        cout << (a+b) / 2 << endl;
    }else{
        cout << ((a+b) / 2) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s=int(input())
l=[s]
i=0
ans="False"
while ans=="False":
	if l[i]%2==0:
		l.append(l[i]//2)
		i+=1
		if l[i] in l[:i-1]:
			ans="True"
	else:
		l.append(l[i]*3+1)
		i+=1
		if l[i] in l[:i-1]:
			ans="True"
print(len(l))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const int MX = 3010;
ll dp[MX][MX][4];
ll items[MX][MX]; // // [行][列][行で拾ったitemの個数]

void solver(
  int R, int C, int K,
  vector<int> r, vector<int> c, vector<int> v
) {

  REP(i,K) items[ r[i]-1 ][ c[i]-1 ] = v[i];

  REP(i,R+1) REP(j,C+1) REP(k,4) dp[i][j][k] = -LINF;
  dp[0][0][0] = 0;

  REP(i,R) REP(j,C) {
    for (int k = 2; k >= 0; k--) {
      if (dp[i][j][k] < 0) continue;

      dp[i][j][k+1] = max(dp[i][j][k+1], dp[i][j][k] + items[i][j]);
    }

    REP(k,4) {
      if (dp[i][j][k] < 0) continue;

      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
      dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
    }
  }

  ll ans = -LINF;
  REP(k,4) chmax(ans, dp[R-1][C-1][k]);
  COUT(ans);
  return;
}

int main() {
  IOS;

  int R,C,K;
  cin >> R >> C >> K;
  vector<int> r(K),c(K),v(K);
  REP(i,K) cin >> r[i] >> c[i] >> v[i];

  solver(R,C,K,r,c,v);

  return 0;
}

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

typedef long long TI;
typedef std::vector<TI> VI;
typedef std::vector<VI> VVI;

TI ks(TI n, VI as, VI bs) {
  auto dp = VVI(as.size()+1);
  dp[0] = VI(n+1, 0);
  for(int i=1; i<=3; ++i) {
    //std::cerr << "--------" << std::endl;
    dp[i] = VI(n+1, 0);
    auto a = as[i-1];
    auto b = bs[i-1];
    for(TI m=1; m<=n; ++m) {
      //std::cerr << dp[i-1][m];
      dp[i][m] = dp[i-1][m] > dp[i][m] ? dp[i-1][m] : dp[i][m];
      if (m - a >= 0) {
        auto v = dp[i][m - a] + b;
        //std::cerr << " " << v;
        dp[i][m] = v > dp[i][m] ? v : dp[i][m];
      }
      //std::cerr << " " << dp[i][m] << std::endl;
    }
  }
  TI ans = 0;
  for(TI m=0; m<=n; ++m) {
    auto v = n-m+dp[3][m];
    ans = v > ans ? v : ans;
  }
  return ans;
}

int main() {
  TI N;
  auto gsb0 = VI(3);
  auto gsb1 = VI(3);
  std::cin >> N;
  for(int i=0; i<3; ++i) std::cin >> gsb0[i];
  for(int i=0; i<3; ++i) std::cin >> gsb1[i];

  auto M = ks(N, gsb0, gsb1);
  std::cerr << "*" << M << "*" << std::endl;
  auto V = ks(M, gsb1, gsb0);
  std::cout << V << std::endl;
}


Measured memory_bytes: 781668
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;


int main() {
    long double a, b, c;
    cin >> a >> b >> c;
    if (2 * pow(a * b, 0.5) < c - a - b){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

namespace ABC0603
{
	class Program
	{
		static void Main(string[] args)
		{

			var ps = Console.ReadLine().Split(' ').Select(i => Convert.ToInt32(i)).ToList();

			ps.Sort();

			Console.WriteLine(ps[0] + ps[1]);

		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define endl '\n'
#define inf 9223372036854775807
#define maxn 3000001
#define mod (ll)(1e9+7)
#define int ll
 
using namespace std;
 
void io(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int t,l,r;

int32_t main(){
io();
IOS;    
		int x;
		cin>>x;
		if(x>=30){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}


       



        

        


        
    
        
        
                


 
        
 
 
 
        
 
 
 
 
        
        
 
        
        
 
    
    
    
    
 
 
       
 
 
 
 
      
   
 
 
 
 
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    string s = in<string>();
    VB odd(26);
    rep(i, 26) odd[i] = count(ALL(s), 'a' + i) % 2;
    cout << (count(ALL(odd), true) ? "No" : "Yes") << endl;

    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    A, V = map(int, input().strip().split())
    B, W = map(int, input().strip().split())
    T = int(input().strip())
    return A, V, B, W, T


def solve(A, V, B, W, T):
    if A < B:
        a = A + V * T
        b = B + W * T
        return "YES" if a >= b else "NO"
    else:
        a = A - V * T
        b = B - W * T
        return "YES" if a <= b else "NO"


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 9196
n = int(input())
up = list(map(int, input().split()))
down = list(map(int, input().split()))

cum_down = [0]
total = 0
for num in down:
    total += num
    cum_down.append(total)

up_total = 0
ans = 0
for idx, num in enumerate(up):
    up_total += num
    candidate = up_total + total - cum_down[idx]
    ans = max(ans, candidate)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define true 1
#define false 0
#define N 100

int G[N + 1][N + 1];
int d[N + 1], f[N + 1];
int t = 0;

void dfs(int u) {
  int i;

  if(d[u])
    return;

  d[u] = ++t;

  for(i = 0;i < N + 1;i++)
    if(G[u][i] == 1)
      dfs(i);

  f[u] = ++t;
  return;
}

int main() {
  int i, j, k;
  int u, v, w;
  int n;

  for(i = 0;i < N + 1;i++) {
    d[i] = 0;
    f[i] = 0;
    for(j = 0;j < N + 1;j++)
      G[i][j] = 0;
  }

  scanf("%d", &n);
  for(i = 0;i < n;i++) {
    scanf("%d %d", &u, &k);
    for(j = 0;j < k;j++) {
      scanf("%d", &w);
      G[u][w] = 1;
    }
  }

  for(i = 1;i < n + 1;i++)
    dfs(i);

  for(i = 1;i < n + 1;i++)
    printf("%d %d %d\n", i, d[i], f[i]);
}



Measured memory_bytes: 2052
package main

import "fmt"

var list [][]int
var memo [][]int

type color int

const (
	red = color(iota)
	white
	black
)

const mod = 1e9 + 7

func f(curr, prev int, c color) int {
	if memo[curr][c] != -1 {
		return memo[curr][c]
	}
	bpi := 0
	wpi := 1
	cnt := 0
	for _, next := range list[curr] {
		if next == prev {
			continue
		}
		cnt++
		wpi = wpi * f(next, curr, white) % mod
		if c != black {
			if bpi == 0 {
				bpi = 1
			}
			bpi = bpi * f(next, curr, black) % mod
		}
	}
	if cnt == 0 {
		switch c {
		case black:
			return 1
		default:
			return 2
		}
	}
	memo[curr][c] = (wpi + bpi) % mod
	return memo[curr][c]
}

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

	list = make([][]int, n+1)
	var x, y int
	for i := 0; i < n-1; i++ {
		fmt.Scan(&x, &y)
		list[x] = append(list[x], y)
		list[y] = append(list[y], x)
	}

	memo = make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		memo[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			memo[i][j] = -1
		}
	}

	fmt.Println(f(1, -1, red) % mod)
}

Measured memory_bytes: 38528
#include <bits/stdc++.h>
using namespace std;
#define tag "spoj"
#define maxn 100007
#define oo 1000000007
#define mid ((l+r)>>1)
#define meset(a,x) memset(a,x,sizeof(a))
#define loop(x) for(int LoOpEr=1;LoOpEr<=x;LoOpEr++)
///>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool dd(const int &n,const vector<int> &a)
{
    for(int i=1;i<n;i++)
        if(a[i-1]>a[i])
            return 0;
    return 1;
}
int main()
{
    #ifdef dmdd
    freopen(tag".inp","r",stdin); freopen(tag".out","w",stdout);
    #endif //dmdd
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;cin>>n;
    vector<int> a(n);
    for(int &x: a) cin>>x;

    for(int i=0;i<n;i++)
        for(int j=i;j<n;j++)
        {
            swap(a[i],a[j]);

            if(dd(n,a))
            {
                cout<<"YES";
                return 0;
            }
            swap(a[i],a[j]);
        }

    cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.nextLine();
		in.close();
		List<Integer> values = new ArrayList<>();
		for (int i = 0; i + 3 <= S.length(); ++i) {
			int val = Integer.parseInt(S.substring(i, i + 3));
			values.add(val);
		}

		int diff = Integer.MAX_VALUE;
		for (Integer val : values) {
			if (diff > Math.abs(val - 753)) {
				diff = Math.abs(val - 753);
			}
		}
		System.out.println(diff);
	}
}


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

#define NIL -1

int main(){

  int n,i;

  scanf("%d",&n);

  int m[500];

  for( i = 1; i <= n; i++)scanf("%d", &m[i]);

  for( i = 1; i <= n; i++){

    printf("node %d: key = %d, ", i,m[i]);

    if( i/2 <= n && i/2 > 0)
      printf("parent key = %d, ", m[ i / 2]);

    if( 2*i <= n)
      printf("left key = %d, ", m[ i * 2]);   

    if( 2 * i + 1 <= n)
      printf("right key = %d, ", m[ i * 2 +1]); 

 printf("\n");

  }

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 998244353;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    vector<int> d(n);
    map<int, ll> mp;
    int maxd = 0;
    rep(i, n) { cin >> d[i]; ++mp[d[i]]; chmax(maxd, d[i]); }

    if(d[0] != 0 || mp[0] > 1){ cout << 0 << endl; return 0; }
    bool ng = false;
    rep(i, maxd+1) if(mp[i] == 0) { ng = true; break; }
    if(ng) { cout << 0 << endl; return 0; }

    ll ans = 1;
    repr(i, 1, maxd+1){
        ans *= modpow(mp[i-1], mp[i]);
        chmod(ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6912
import java.util.Scanner;

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

				while(i <= n) {
					x = i;
					if(x % 3 == 0) {
						System.out.print(" " + i);
					}
					else {
						do {
							if(x % 10 == 3) {
								System.out.print(" " + i);
								break;
							}
						} while((x /= 10) != 0);
					}

					i++;
				}
				
				System.out.println("");
		}
}

Measured memory_bytes: 28720
//Exception Handling

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
struct edge{int to;ll cost;};
const int inf = 2147483647;

int main (){
    int n;cin>>n;
    vector<int> a(n),aa;
    rep(i,0,n){
        cin>>a[i];
    }
    aa=a;stable_sort(range(aa),greater<int>());
    rep(i,0,n){
        cout << (a[i]==aa[0] ? aa[1] : aa[0]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3192
N = int(input())
tmp = 10
i = 0
ans = 0
while tmp <= N:
  if i%2 ==0:
    ans += 9*(10**i)
  i += 1
  tmp = 10**(i+1)
if i%2 == 0:
  ans += N-10**i+1
print(ans)  

Measured memory_bytes: 3060
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

class DisjointSet {
public:
	int size;
	vector<int> rank;
	vector<int> parent;

	DisjointSet() {}

	// 0, 1, ... size-1 をそれぞれ唯一の要素とする
	// size個の互いに素な集合を作成
	DisjointSet(int size) {
		this->size = size;
		rank.resize(size, 0);
		parent.resize(size, 0);
		for (int i=0; i<size; i++) {
			makeSet(i);
		}
	}

	// 要素がXただ一つである新しい集合を作る
	void makeSet(int x) {
		parent[x] = x;
		rank[x] = 0;
	}

	// xとyが同じ集合に属しているかを判定する
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	// 指定された2つの要素x, yを合併する
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	// 低い方の木を高い方の木に合併
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			parent[y] = x;
		} else {
			parent[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	// 要素xが属する集合の代表の要素を求める
	int findSet(int x) {
		if (x != parent[x]) {
			parent[x] = findSet(parent[x]);
		}
		return parent[x];
	}

	// 集合の個数を求める
	int countSet() {
		int cnt = 0;
		for (int x=0; x<size; x++) {
			if (x == parent[x]) cnt++;
		}
		return cnt;
	}
};

int main() {
	int N, M;
	cin >> N >> M;

	DisjointSet ds = DisjointSet(N);

	for (int i=0; i<M; i++) {
		int A, B;
		cin >> A >> B;
		A--;
		B--;
		ds.unite(A, B);
	}

	unordered_map<int, int> cnt;
	for (int i=0; i<N; i++) {
		cnt[ds.findSet(i)]++;
	}

	int ans = -1;
	for (auto itr : cnt) {
		ans = max(ans, itr.second);
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12756
MOD = 10**9 + 7


def main():
    import sys
    input = sys.stdin.buffer.readline
    _ = int(input())
    A = [int(i) for i in input().split()]

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    def lcm(x, y):
        return x*y//gcd(x, y)

    n = 1
    for a in A:
        n = lcm(n, a)
    n %= MOD

    ans = 0
    for i, a in enumerate(A):
        ans += n*pow(a, MOD-2, MOD)
    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41948
#include <bits/stdc++.h>
/*    #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;       */
using namespace std;

#define ll long long
#define ull unsigned long long
#define f(a, b) for (ll i = a; i < b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define ld long double
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
#define print(x) cerr << #x << " is " << x << endl;
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "rt", stdin);
//     freopen("output.txt", "wt", stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    ll a[n];
    f(0, n) cin >> a[i];
    ll mx1 = 0, mx2 = 0, cm = 0;
    f(0, n)
    {
        if (mx1 == 0)
            mx1 = a[i], cm = 1;
        else if (a[i] > mx1)
            mx2 = mx1, mx1 = a[i], cm = 1;
        else if (a[i] == mx1)
            cm++;
        else if (a[i] > mx2)
            mx2 = a[i];
    }
    // cout << mx1 << " " << mx2 << " " << cm << "\n";
    f(0, n)
    {
        if (a[i] == mx1 && cm == 1)
            cout << mx2 << "\n";
        else
            cout << mx1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;

signed main() {
    int n, m;
    cin >> n >> m;
    int a[n];
    int s[n + 1] = {};
    rep (i, 0, n) {
        cin >> a[i];
        s[i + 1] = (s[i] + a[i]) % m;
    }
    map<int, int> mp;
    rep (i, 0, n + 1) { mp[s[i]]++; }
    int ans = 0;
    for (auto p : mp) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 8908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  for (int i = 0; i < N-1; i++) {
    if (A.at(i) == A.at(i+1)){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
    
  
  

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n, 0);
    a[0] = 0;
    int t;
    for (int i = 1; i < n; i++) {
        cin >> t;
        a[t - 1]++;
    }

    for (auto& item: a) {
        cout << item << "\n";
    }

}


Measured memory_bytes: 3952
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

#define __ { \
	freopen("input.txt","r",stdin); \
	freopen("output.txt","w",stdout); \
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // __;
   int nn;cin>>nn;
   vector<ll> p,n;
   for(int i=0;i<nn;i++){
   	ll a;cin>>a;
   	if(a<0)n.push_back(a);
   	else p.push_back(a);
   }
   int x=n.size();
   sort(n.rbegin(),n.rend());
        	ll yay=1e9+1;
   ll ans=accumulate(p.begin(),p.end(),0ll)-accumulate(n.begin(),n.end(),0ll);
   if(x&1){
   	for(int i=0;i<p.size();i++)yay=min(yay,abs(p[i]));
   	for(int i=0;i<x;i++)yay=min(yay,abs(n[i]));
   		   cout<<ans-yay*2;
   }
else cout<<ans;
  
}

Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+=(i*(i+1))/2;
	}
	for(ll i=0;i<n-1;i++){
		ll u, v;
		cin>>u>>v;
		if(u>v){
			swap(u, v);
		}
		ans-=(u*(n-v+1));
	}
	cout<<ans;

    return 0;
}


Measured memory_bytes: 3656
s=input()
t=input()

lens=len(s)
lent=len(t)

imin=lent
for i in range(lens-lent+1):
    icnt=0
    for j in range(lent):
        if s[i+j]!=t[j]:
            icnt+=1
    imin=min(imin,icnt)   
print(imin)

Measured memory_bytes: 67536
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
	int d;
	scanf("%d",&d);
	int a[100005],b[100005];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	int t;
	int maxa=0,maxb=0;
	int sea=0,seb=0;
	for(int i=0;i<d;i++)
	{
		if(i%2==0)
		{
			scanf("%d",&t);
			a[t]++;
			if(a[t]>=a[maxa])
			{
				if(t!=maxa)
				{
				sea=maxa;
				maxa=t;
				}
			}
		}
		else
		{
			scanf("%d",&t);
			b[t]++;
			if(b[t]>=b[maxb])
			{
				if(t!=maxb)
				{
				seb=maxb;
				maxb=t;
				}
			}
		}
	}
	if(maxa==maxb)
	{
		if(a[sea]>=b[seb])maxa=sea;
		else maxb=seb;
	}
	printf("%d",d-a[maxa]-b[maxb]);
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    int ans = 0;
    int k = 1;
    while(k <= n){
        string hoge = s.substr(s.size()-k);
        string fuga = t.substr(0,hoge.size());
        if(hoge == fuga){
            ans = k;
        }
        k++;
    }
    cout << 2 * n - ans << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
static class Program
{
    static void Main()
    {

        var s = long.Parse(Console.ReadLine());

        var a = (long)Math.Sqrt(s);
        var b = a + 1;

        if (b > 1000000000) b = 1000000000;


        var lest = a * b - s;
        if(lest < 0)
        {
            a++;
            lest = a * b - s;
        }

        Console.WriteLine($"0 0 1 {a} {b} {lest}");

    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <utility>
using namespace std;
static const int NMAX = 100;
static const int VMAX = 100;

void show_vec(int n, int* vec) {
	for (int i = 0; i < n; i++) {
		if (i != 0) cout << " ";
		cout << vec[i];
	}
	cout << endl;
}

int bubbleSort(int n, int* vec) {
	bool flag = 1;
	int i = 0, num_sw = 0;
	while (flag) {
		flag = 0;
		for (int j = n - 1; j > i; j--) {
			if (vec[j - 1] > vec[j]) {
				swap(vec[j - 1], vec[j]);
				flag = 1;
				num_sw++;
			}
		}
		i++;
	}
	show_vec(n, vec);

	return num_sw;
}

int main() {
	int argc, argv[100], num_sw;

	cin >> argc;
	for (int i = 0; i < argc; i++) cin >> argv[i];

	//show_vec(argc, argv);
	num_sw = bubbleSort(argc, argv);

	cout << num_sw << endl;

	return 0;
}

Measured memory_bytes: 3072
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp;
fn main() {
    input! {
        N: usize,
        T: i32,
        CT: [(i32, i32); N],
    }
    let mut values: Vec<i32> = Vec::new();
    let mut result: i32 = 114514;
    for (c, t) in CT {
        if t <= T {
            result = cmp::min(result, c);
        }
    }
    if result == 114514 {
        println!("TLE");
    } else {
        println!("{}", result);
    }
}


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

int maxcal (int max,int i){
  if(max < i){
    max = i;
  }
  return max;
}

int  mincal (int min,int i){
  if(min > i){
    min = i;
  }
  return min;
}

int main(){
  int n = 0;
  int max = 0;
  int min = 21;
  int count = 0;
  char *end1, *end2;
  scanf("%d",&n);
  int a[n+1];
  char b[3*n + 1];
  scanf("%*c%[^\n]%*c", b);
  //printf("%c\n", b[0]);
  //printf("%c\n", b[1]);
  //printf("%c\n", b[2]);
  // for(int i = 0; i < n; i++){
  a[0] = strtol(b, &end1, 10);
  for(int i = 1; i < n; i++){
    a[i] = strtol(end1, &end2, 10);
    end1 = end2;
  }
  for(int j = 0; j < n - 2; j++){
    //printf("%d\n",a[j]);
    max = a[j];
    min = a[j];
    max = maxcal(max, a[j + 1]);
    min = mincal(min, a[j + 1]);
    max = maxcal(max, a[j + 2]);
    min = mincal(min, a[j + 2]);
    //printf("%d %d\n", max, min);
    if(a[j + 1] != max && a[j + 1] != min){
      count++;
    }
}
printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
using P = pair<int, int>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

int main(void) {

    ios::sync_with_stdio(false); cin.tie(0);

    bool same = true;

    deque<char> Q;
    string s;
    cin >> s;
    int q;
    cin >> q;

    rep (i, s.size()) {
        Q.push_back(s[i]);
    }

    rep (i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            if (same) same = false;
            else same = true;
        }
        else {
            int f; char c;
            cin >> f >> c;
            bool b;
            if (f == 1) b = true;
            else b = false;
            if (same && b) {
                Q.push_front(c);
            }
            else if (same && !b) {
                Q.push_back(c);
            }
            else if (!same && b) {
                Q.push_back(c);
            }
            else Q.push_front(c);
        }
    }

    string ans = "";
    for (auto it = Q.begin(); it != Q.end(); it++) {
        ans += *it;
    }
    if (!same) reverse(rng(ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1368
#include<iostream>
#include<math.h>
int main(void) {
	int a ,b ,c = 1;
	std::cin >> a;
	std::cin >> b;
	int l1;
	for (l1 = 0; l1 < a; l1++) {
		if (c * 2 >= c + b)
			break;
		c = 2 * c;
	}
	for (l1; l1 < a; l1++) {
		c += b;
	}
	std::cout << c;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long double dp[3009][3009],a[3009];
int n;
long double bt(int id,int q)
{
    long double &ret=dp[id][q];
    if(ret!=-1.0)return ret;
    if(id==n)
    {
        if(q>n-q)return 1.0;
        else return 0.0;
    }
    ret=bt(id+1,q+1)*a[id]+bt(id+1,q)*(1.0-a[id]);
    return ret;
}
int main()
{
    for(int i=0;i<3009;i++)
        for(int j=0;j<3009;j++)dp[i][j]=-1.0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    cout<<setprecision(10)<<fixed<<bt(0,0)<<"\n";
}


Measured memory_bytes: 141952
S = $stdin.gets.chomp
M = 1000000007
abc = [1,0,0,0]
S.chars { |t|
  isWild = t == "?"
  isA = isWild || t == "A"
  isB = isWild || t == "B"
  isC = isWild || t == "C"
  abc = [ 
    abc[0] * (isWild ? 3 : 1),
    abc[1] * (isWild ? 3 : 1) + (isA ? 1 : 0) * abc[0],
    abc[2] * (isWild ? 3 : 1) + (isB ? 1 : 0) * abc[1],
    abc[3] * (isWild ? 3 : 1) + (isC ? 1 : 0) * abc[2],
   ]
  abc.map!{ |x| x %= M }
}
puts abc[-1]



Measured memory_bytes: 2044
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

const int N = 200001;
int i, j, k, m, n;
string s;
int a[N];

void solve() {
    if (n >= 2 * k - 1) cout << "YES"; else cout << "NO";
    cout << endl;
}

int main() {
    //freopen("x.in", "r", stdin);
    while (cin >> n >> k) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, K;
int V[50];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> K;
    REP (i, N) cin >> V[i];
    int ans = 0;
    REP (i, N + 1) REP (j, N + 1) {
        if (i + j > min(N, K)) continue;
        vector<int> v;
        int sum = 0;
        REP (k, i) v.push_back(V[k]), sum += V[k];
        REP (k, j) v.push_back(V[N - 1 - k]), sum += V[N - 1 - k];
        sort(v.begin(), v.end());
        int rem = K - v.size();
        REP (k, min((int)v.size(), rem)) if (v[k] < 0) sum -= v[k];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define eps 1e-9
using namespace std;
int main() {
    int n;
    cin >> n;
    ll x;
    cin >> x;
    vector<ll> vec;
    vec.push_back(x);
    for (int i = 0; i < n; i++) {
        ll in;
        cin >> in;
        vec.push_back(in);
    }
    sort(vec.begin(), vec.end());
    ll g = vec[1] - vec[0];
    for (int i = 2; i < vec.size(); i++)
        g = __gcd(g, vec[i] - vec[i - 1]);
    cout << g << '\n';
    return 0;
}


Measured memory_bytes: 1400
#include <cstdio>
#include <algorithm>
using namespace std;
#define x 10001
int dp[x][2],num[x];
int main()
{
  int n;
  scanf("%d",&n);
  for(int i=1;i<n;i++)
    {
      scanf("%d",&num[i]);
    }
  for(int i=0;i<x;i++)
    {
      dp[i][0]=x*x;
      dp[i][1]=x*x;
    }
  dp[1][0]=0;
  for(int i=1;i<n;i++)
    {
      for(int j=1+i;j>=1;j--)
    {
      dp[j][1]=min(dp[j][1],dp[j][0]+num[i]);
      dp[j][0]=min(dp[j-1][0],dp[j-1][1]+num[i]);
    }
    }
  printf("%d\n",min(dp[n/2][0],dp[n/2][1]));
  return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
int main(){
    int64_t N, K;
    cin >> N >> K;
    int64_t ans = 0;
    for (int64_t i = K; i <= N+1; i++){
        int64_t start = (i - 1) * i / 2;
        int64_t goal = (N * (N + 1) / 2) - ((N - i) * (N - i + 1) / 2);
        //cout << start << " " << goal << endl;
        ans += (goal - start + 1);
        ans %= 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
n,y=(int(i) for i in input().split())
must_one=int((y%5000)/1000)
max_five=int(y/5000)
 
a,b,c = 0,max_five,must_one

while True:
    z = n - a - b - c 
    if z == 0:
        break
    elif z > 0 :
        if z >=9 and a>=1:
            a,b,c = a - 1 , b  , c + 10
        else:
            a,b,c = a , b - 1 , c + 5
    elif z  < 0 :
        if z <= -9 and c >=10 + must_one:
            a,b,c = a + 1 , b , c - 10
        else:
            a,b,c = a + 1, b -2 , c 

    if b < 0:
        a,b,c= -1,-1,-1
        break

print("%d %d %d"%(a,b,c))

Measured memory_bytes: 3064
$n,$m,$q = gets.split.map(&:to_i)
$pro = readlines.map{|line| line.split.map(&:to_i)}
$ans = []

def rec(a = [])
  if a.size == $n
    res = 0
    $pro.each do |j|
      res += j[3] if a[j[1]-1] - a[j[0]-1] == j[2]
    end
    $ans << res
    return
  end

  for i in (a[-1]||1)..$m
    ac = a.clone
    ac << i
    rec(ac)
  end
end

rec()
puts $ans.max

Measured memory_bytes: 16128
open Batteries
(* 文字列を逆にする *)
let reverse s = let len = String.length s in
  String.init len (fun i -> s.[len - 1 - i])

let c1 = read_line () |> reverse
let c2 = read_line ()
let _ = (if c1 = c2 then "YES" else "NO") |> print_endline

Measured memory_bytes: 1152
#include<stdio.h>
#include<cmath>

int main(){
    int n;
    double x = 0, m, z = 0, S, s;
    double box[1000] = {};
    while(1){
        scanf("%d", &n);
        if ( n == 0 ) break;
        for ( int i = 0; i < n; i++ ){
            scanf("%lf", &box[i]);
            x += box[i];
        }
        m = x / n;
        for ( int j = 0; j < n; j++ ){
            z += pow( box[j]-m, 2);
        }
        S = z / n;
        s = sqrt(S);
        printf("%lf\n", fabs(s));
        x = 0;
        z = 0;
    }
    return 0;
}



Measured memory_bytes: 2732
// --------------
// Tejas Pandey  |
// 12 - 01 - 20  |
// ABC #151      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		ll ac =0,wa = 0,k;
		ll n,m;
		cin >> n >> m;
		ll a[n + 1],w[n + 1];
		memset(a,0,sizeof(a));
		memset(w,0,sizeof(w));
		for(int i = 0;i < m;i++){
			cin >> k;
			string s;
			cin >> s;
			if(s == "AC"){
				if(!a[k]){
					a[k] = 1;
					ac++;
					wa += w[k];
				}
			}
			else{
				if(!a[k])
					w[k]++;
			}
		}
		cout << ac << " " << wa << "\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
int main() {
  ll a,b,c,n,m,x,y;
  cin>>a>>b;
  rep(i,1000000){
    if((i*8/100==a)&&(i/10==b)){
      cout<<i<<endl;return 0;
    }
  }
   cout<<-1<<endl;
}

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

using namespace std;

int main() {
  int n, team[100], rank[100];

  for (int i=0; i<100; i++) {
    team[i]=0;
    rank[i]=1;
  }
  
  cin >> n;
  for (int i=0; i<n*(n-1)/2; i++) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--;b--;
    if (c<d) {
      team[a]+=0;team[b]+=3;
    } else if (c==d) {
      team[a]+=1;team[b]+=1;
    } else {
      team[a]+=3;team[b]+=0;
    }
  }

  for (int i=1; i<n; i++) {
    for (int j=0; j<i; j++) {
      if (team[i] < team[j]) {
	rank[i]++;
      } else if (team[i] > team[j]) {
	rank[j]++;
      }
    }
  }

  for (int i=0; i<n; i++)
    printf("%d\n", rank[i]);

  return 0;
}

Measured memory_bytes: 1144
#include<iostream>
typedef long long ll;
using namespace std;
ll ans[100005] = {};
int main() {
	ll n;
	cin >> n;
	
	ll a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		ans[a] += 1;
		if (a != 0) {
			ans[a - 1] += 1;
		}
		ans[a + 1] += 1;
	}
	int max = -1e8;
	for (int i = 0; i < 100005; i++) {
		if (max < ans[i]) {
			max = ans[i];
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1024