akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    ll res = 180 * (n - 2);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 200005
const int INF=1000000;
int n,m,w[maxn],pre[maxn],other[maxn],last[maxn],o,l[maxn],r[maxn];
bool flag[maxn];

void connect(int x,int y)
{
    o++;
    pre[o]=last[x];
    last[x]=o;
    other[o]=y;
}

void dfs(int u,int fa)
{
    l[u]=-INF;r[u]=INF;
    if (flag[u]) l[u]=r[u]=w[u];
    for (int p=last[u];p;p=pre[p]) 
    {
        int v=other[p];
        if (v==fa) continue;
        dfs(v,u);
        l[u]=max(l[u],l[v]-1);
        r[u]=min(r[u],r[v]+1);
    }
    if (l[u]>r[u]) {puts("No");exit(0);}
}

void solve(int u,int fa)
{
    if (u==1) w[u]=l[u];
    else if (w[fa]+1>=l[u]&&w[fa]+1<=r[u]) w[u]=w[fa]+1;
    else if (w[fa]-1>=l[u]&&w[fa]-1<=r[u]) w[u]=w[fa]-1;
    else {puts("No");exit(0);}
    for (int p=last[u];p;p=pre[p]) 
    {
        int v=other[p];
        if (v==fa) continue;
        solve(v,u);    
    }
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<n;i++) 
    {
        int x,y;
        scanf("%d%d",&x,&y);
        connect(x,y);
        connect(y,x);
    }
    scanf("%d",&m);
    for (int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        w[x]=y;
        flag[x]=1;       
    }
    dfs(1,-1);
    solve(1,-1);
    puts("Yes");
    for (int i=1;i<=n;i++) printf("%d\n",w[i]);
    return 0;
}

Measured memory_bytes: 9216
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,MOD = map(int,read().split())

def cumprod(A, MOD = MOD):
    L = len(A); Lsq = int(L**.5+1)
    A = np.resize(A, Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        A[:,n] *= A[:,n-1]; A[:,n] %= MOD
    for n in range(1,Lsq):
        A[n] *= A[n-1,-1]; A[n] %= MOD
    return A.ravel()[:L]
def make_fact(U, MOD = MOD):
    x = np.arange(U, dtype = np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact,fact_inv

U = 10 ** 5
fact, fact_inv = make_fact(U)
inv = np.zeros(U,np.int64)
inv[1:] = fact[:-1] * fact_inv[1:] % MOD

def fft_convolve(f, g, MOD = MOD):
    """
    数列 (多項式) f, g の畳み込みの計算．上下 15 bitずつ分けて計算することで，
    30 bit以下の整数，長さ 250000 程度の数列での計算が正確に行える．
    """
    fft = np.fft.rfft; ifft = np.fft.irfft
    Lf = len(f); Lg = len(g); L = Lf + Lg - 1
    fft_len = 1 << L.bit_length()
    fl = f & (1 << 15) - 1; fh = f >> 15
    gl = g & (1 << 15) - 1; gh = g >> 15
    conv = lambda f,g: ifft(fft(f,fft_len) * fft(g,fft_len))[:L]
    x = conv(fl, gl) % MOD
    y = conv(fl+fh, gl+gh) % MOD
    z = conv(fh, gh) % MOD
    a, b, c = map(lambda x: (x + .5).astype(np.int64), [x,y,z])
    return (a + ((b - a - c) << 15) + (c << 30)) % MOD

def fps_exp(h,MOD=MOD):
    # 面倒なので2べきに
    L = len(h)
    i = (L-1).bit_length()
    N = (1 << i)
    h = np.resize(h,N)
    dh = np.empty_like(h)
    dh[0:N-1] = h[1:N] * np.arange(1,N,dtype=np.int64) % MOD
    f = np.zeros_like(h); g = np.zeros_like(h)
    f[:2] = np.array([1,h[1]],np.int64); g[0] = 1; m = 2
    while m <= N//2:
        fg = fft_convolve(f[:m],g[:m],MOD)[:m]
        fgg = fft_convolve(fg,g[:m],MOD)[:m]
        g[:m] *= 2; g[:m] -= fgg; g %= MOD
        q = dh[:m-1]
        s = np.zeros(m+m,np.int64); s[1:m] = f[1:m] * np.arange(1,m,dtype=np.int64) % MOD
        r = fft_convolve(f[:m],q,MOD)
        s[1:1+len(r)] -= r
        s[0:m] += s[m:m+m]
        s = s[:m] % MOD
        t = fft_convolve(g[:m],s,MOD)[:m]
        t *= inv[m:m+m]; t %= MOD
        u = h[m:m+m] - t; u %= MOD
        v = fft_convolve(f,u,MOD)[:m]
        f[m:m+m] += v
        m *= 2
    return f[:L]

f = np.zeros((N+N+10),np.int64)
for x in range(1,N//2+1):
    f[x::x] += 2 * inv[1:(len(f)-1) // x + 1]
if N & 1:
    x = (N+1)//2
    f[x::x] += inv[1:(len(f)-1) // x + 1]

g = fps_exp(f)
answer = g[:N].sum() % MOD
print(answer)

Measured memory_bytes: 21612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);	
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		String str = sc.next();
		
		StringBuffer sb = new StringBuffer(str);
		
		sb.replace(k-1, k, String.valueOf(sb.charAt(k-1)).toLowerCase());
		
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21584
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,c,k,*t=map(int,open(0).read().split())\n"
"t.sort(reverse=1)\n"
"a=0\n"
"while t:\n"
"  h=t.pop()\n"
"  i=h\n"
"  j=1\n"
"  while t and j<c and i-h<k:\n"
"    i=t.pop()\n"
"    j+=1\n"
"  if i-h>k:\n"
"    t.append(i)\n"
"  a+=1\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

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

bool field1[6][6], field2[6][6], field3[6][6];
int bnum, h, w;

void reverseR(int r) {
  rep(i, w) {
    if (field2[r][i]) {
      field2[r][i] = false;
      bnum--;
    }
  }
}

void reverseC(int c) {
  rep(i, h) {
    if (field3[i][c]) {
      field3[i][c] = false;
      bnum--;
    }
  }
}

int main() {
  int k;
  cin >> h >> w >> k;
  int ball = 0;
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      if (s[j] == '.') field1[i][j] = false;
      else { field1[i][j] = true; ball++; }
    }
  }

  int ans = 0;
  rep(i, 1 << h) {
    bnum = ball;
    rep(j, h) rep(k, w) field2[j][k] = field1[j][k];
    rep(j, h) {
      if (i >> j & 1) reverseR(j);
    }
    if (bnum < k) continue;
    int bsub = bnum;

    rep(j, 1 << w) {
      bnum = bsub;
      rep(k, h) rep(l, w) field3[k][l] = field2[k][l];
      rep(k, w) {
        if (j >> k & 1) reverseC(k);
      }
      if (bnum == k) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
/*
*/


Measured memory_bytes: 3628
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B=MI_()
    H,W=100,100
    print(H,W)
    ans = [[""]*W for _ in range(H)]
    for i in range(H):
        if i<H//2:
            ans[i] = ["#"]*W
        else:
            ans[i] = ["."]*W

    for i in range(H):
        for j in range(W):
            if i&1 or j&1:
                continue
            if i<H//2:
                if A:
                    ans[i][j] = "."
                    A-=1
            else:
                if B:
                    ans[H+49-i][j] = "#"
                    B-=1
    for a in ans:
        print(*a,sep="")

if __name__ == '__main__':
    main()

Measured memory_bytes: 7820
import collections

N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7

c = collections.Counter(A)

for value in c.values():
    if(value == c[0]):
        continue
    if(value%2 != 0):
        print(0)
        quit()

if(N%2 != 0):
    if(c[0] == 1):
        ans = (2**(len(c)-1))%mod    
        print(ans)
    else:
        print(0)
else:
    if(c[0]):
        print(0)
    else:
        ans = (2**len(c))%mod
        print(ans)

Measured memory_bytes: 14820
#include <stdio.h>

int main(void) {
    int r, c, table[101][101];
    int i, j, sum;

    sum=0;
    scanf("%d %d", &r, &c);
    for (i=0; i<r; i++) {
        for (j=0; j<c; j++) {
	    if (i==0) table[r][j]=0;
	    if (j==0) table[i][c]=0;
	    scanf("%d", &table[i][j]);
	    table[i][c]+=table[i][j];
	    table[r][j]+=table[i][j];
	    sum+=table[i][j];
	}
    }
    table[r][c]=sum;
    for (i=0; i<=r; i++) {
        for (j=0; j<=c; j++) {
	    printf("%d", table[i][j]);
	    if (j!=c) printf(" ");
	}
	printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<stdio.h>
using namespace std;
const int maxn = 1e5 + 1;
int pre(int a[],int n,int k)
{
	int i = 0;
	a[n] = k;
	while (a[i] != k)i++;
	//printf("i=%d\n", i);
	return i != n;
}
int main()
{
	int n;
	int sum = 0;
	int x;
	int q;
	int a[maxn];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &x);
		if (pre(a, n, x))
			sum++;
	}
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 3240
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        String S = in.next();
        int i = 1;
        for (char c : S.toCharArray()) {
            if (i % 2 == 0) {
                if (c == 'L' || c == 'U' || c == 'D') {}
                else {
                    System.out.println("No");
                    return;
                }
            } else {
                if (c == 'R' || c == 'U' || c == 'D') {}
                else {
                    System.out.println("No");
                    return;
                }
            }
            i++;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21844
n,m=map(int,input().split())
r=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
ans=False
for i in range(1,n-1):
    if 0 in r[i]and (n-1) in r[i]:
        ans=True

print("POSSIBLE" if ans else "IMPOSSIBLE")

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

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

struct Kadomatsu {
  int a;
  int b;
  int c;
  int mp;
};
const int INF = 1e9;

int calc_cost(const Kadomatsu& k, int A, int B, int C) {
  if(k.a == 0 || k.b == 0 || k.c == 0) {
    return INF;
  }
  int mp = k.mp;
  mp += abs(k.a - A);
  mp += abs(k.b - B);
  mp += abs(k.c - C);
  return mp;
}

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> ls(N);
  for(int i = 0; i < N; ++i) {
    cin >> ls[i];
  }
  queue<Kadomatsu> ks;
  ks.push({0, 0, 0, 0});
  for(int i = 0; i < N; ++i) {
    int ksize = ks.size();
    int l = ls[i];
    while(ksize > 0) {
      auto k = ks.front();
      ks.pop();
      ks.push({k.a + l, k.b, k.c, k.mp + (k.a == 0 ? 0 : 10)});
      ks.push({k.a, k.b + l, k.c, k.mp + (k.b == 0 ? 0 : 10)});
      ks.push({k.a, k.b, k.c + l, k.mp + (k.c == 0 ? 0 : 10)});
      ks.push({k.a, k.b, k.c, k.mp});
      ksize--;
    }
  }
  int ans = INF;
  while(!ks.empty()) {
    auto k = ks.front();
    ks.pop();
    chmin(ans, calc_cost(k, A, B, C));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

#define REP(i, a, b) for(int i = int(a); i < int(b); i++)

using namespace std;
typedef pair<int,int> pii;

int main() {
    int h, w, s;
    while (cin >> h >> w >> s, h + w + s) {
	vector<vector<int>> U(h, vector<int>(w));
	int sum = 0;
	REP (i, 0, h) {
	    REP (j, 0, w) {
		cin >> U[i][j];
		sum += U[i][j];
	    }
	}
	vector<vector<int>> vsum(h + 1, vector<int>(w + 1, 0));
	REP (i, 0, h) {
	    REP (j, 0, w) {
		vsum[i + 1][j + 1] += vsum[i + 1][j] + U[i][j];
	    }
	}
	REP (j, 0, w + 1) {
	    REP (i, 0, h) {
		vsum[i + 1][j] += vsum[i][j];
	    }
	}
	//const int inf = 1 << 29;
	
	vector<vector<vector<vector<pii>>>> dp(h, vector<vector<vector<pii>>>(w, vector<vector<pii>>(h, vector<pii>(w, {-1, -1}))));
	vector<vector<vector<vector<bool>>>> memo(h, vector<vector<vector<bool>>>(w, vector<vector<bool>>(h, vector<bool>(w, false))));

	function<bool(int,int,int,int)> rec = [&](int h1, int w1, int h2, int w2) -> bool{
	    if (h1 == h2 && w1 == w2) {
		dp[h1][w1][h2][w2] = make_pair(1, s - (sum - U[h1][w1]));
		return (sum - U[h1][w1] <= s);
	    }
	    if (dp[h1][w1][h2][w2].first != -1) return memo[h1][w1][h2][w2];
	    int tmp = vsum[h2 + 1][w2 + 1] - vsum[h2 + 1][w1] - vsum[h1][w2 + 1] + vsum[h1][w1];
	    bool ok = (sum - tmp <= s);
	    pii ans(1, s - (sum - tmp));
	    REP (i, h1, h2){
		bool res1 = rec(h1, w1, i, w2);
		bool res2 = rec(i + 1, w1, h2, w2);
		if (res1 && res2){
		    ok = true;
		    pii div1 = dp[h1][w1][i][w2];
		    pii div2 = dp[i + 1][w1][h2][w2];
		    if (ans.first < div1.first + div2.first) {
			ans.first = div1.first + div2.first;
			ans.second = min(div1.second, div2.second);
		    } else if (ans.first == div1.first + div2.first) {
			ans.second = max(ans.second, min(div1.second, div2.second));
		    }
		}
	    }
	    REP (i, w1, w2) {
		bool res1 = rec(h1, w1, h2, i);
		bool res2 = rec(h1, i + 1, h2, w2);
		if (res1 && res2){
		    ok = true;
		    pii div1 = dp[h1][w1][h2][i];
		    pii div2 = dp[h1][i + 1][h2][w2];
		    if (ans.first < div1.first + div2.first) {
			ans.first = div1.first + div2.first;
			ans.second = min(div1.second, div2.second);
		    }else if (ans.first == div1.first + div2.first) {
			ans.second = max(ans.second, min(div1.second, div2.second));  
		    }
		}
	    }
	    memo[h1][w1][h2][w2] = ok;
	    dp[h1][w1][h2][w2] = ans;
	    return ok;
	};
	
	rec(0, 0, h - 1, w - 1);
	pii ans = dp[0][0][h - 1][w - 1];
	cout << ans.first << " " << ans.second << endl;
    }
    return 0;
}



Measured memory_bytes: 14828
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<double,double> P;

bool isCross(P p1, P p2, P p3, P p4){
  double c = ((p1.first - p2.first) * (p3.second - p1.second) + (p1.second - p2.second) * (p1.first - p3.first)) * 
    ((p1.first - p2.first) * (p4.second - p1.second) + (p1.second - p2.second) * (p1.first - p4.first));
  if(c<=0.0)
    return true;
  return false;
}

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(3);

  int INF = 1000000;

  double x1,y1,x2,y2,x3,y3,xp,yp;
  while( cin >>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
    P p1(x1,y1),p2(x2,y2),p3(x3,y3),px(xp,yp);
    if( isCross(p1,p2,p3,px) || isCross(p1,p3,p2,px) || isCross(p2,p3,p1,px) )
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  


  return 0;
}

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

using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vp;
#define all(q) q.begin(), q.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define X first
#define Y second
#define endl '\n'
const int maxn = 2e6;
int a[maxn];
bool mark[maxn];
main(){
    IOS;
    int n, x;
    cin >> n >> x;
    n = n * 2 - 1;
    if(x == 1 || x == n){
        if(n == 1){
            cout << "Yes" << endl;
            cout << 1 << endl;
            return 0;
        }
        cout << "No" << endl;
        return 0;
    }
    if(n == 3){
        cout << "Yes" << endl;
        for(int i=1; i<=n; i++)
            cout << i << endl;
        return 0;
    }
    int pos = n/2;
    memset(a, -1, sizeof a);
    if(x != n - 1){
        a[pos] = x;
        a[pos + 1] = x + 1;
        a[pos - 2] = x + 2;
        a[pos - 1] = x - 1;
    }
    else{
        a[pos] = x;
        a[pos + 1] = x - 1;
        a[pos - 2] = x - 2;
        a[pos - 1] = x + 1;
    }
    for(int i=0; i<n; i++)
        if(a[i] != -1) mark[a[i]] = true;
    vi v;
    for(int i=1; i<=n; i++)
        if(!mark[i]) v.push_back(i);
    for(int i=0; i<n; i++)
    if(a[i] == -1){
            a[i] = v.back();
            v.pop_back();
    }
    cout << "Yes" << endl;
    for(int i=0; i<n; i++)
        cout << a[i] << endl;
}


Measured memory_bytes: 10228
def solve():
    num_one, num_zero, num_minus_one, num_select = map(int, input().split())
    if num_one == num_select:
        print(num_one)
        return
    if num_select < num_one:
        print(num_select)
        return

    if num_one + num_zero == num_select:
        print(num_one)
        return
    if num_select < num_one + num_zero:
        print(num_one)
        return

    if num_one + num_zero + num_minus_one < num_select:
        print(num_one - num_minus_one)
        return

    max_minus_one = num_select - (num_one + num_zero)
    if num_minus_one < max_minus_one:
        print(num_one - num_minus_one)
    else:
        print(num_one - max_minus_one)

solve()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t; cin>>s>>t;
	int cnt=0;
	while(s!=t){
		cnt++;
		if(cnt==200){
			printf("No\n");
			return 0;
		}
		string cp;
		cp.push_back(s[(int)s.length()-1]);
		for(int i=0;i<(int)s.length()-1;i++) cp.push_back(s[i]);
		s=cp;
	}
	printf("Yes\n");
	return 0;
}

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

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

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

using namespace std;


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

	long long x;
	cin >> x;

	long long q = x / 11;
	long long r = x % 11;

	long long ans = 0;
	ans = q * 2;
	if(r > 0 && r <= 6){
		ans = ans + 1;
	}
	else if(r > 6){
		ans = ans + 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  string s;
  int q;
  cin >> s >> q;
  int front =1;
  int back=2;
  string sfront="";
  string sback="";
  rep(i,q){
    int t;
    cin >> t;
    if(t==1){
      front=3-front;
      back=3-back;
    }
    else if(t==2){
        int f;
        cin >> f;
        char c;
        cin >> c;
        if(f==1){
            if(front==1)sfront+=c;
            else if(front==2)sback+=c;
        }
        else if(f==2){
            if(back==2)sback+=c;
            else if(back==1)sfront+=c;
        }
    }
  }
  if(front==1){
      reverse(sfront.begin(),sfront.end());
      cout << sfront << s << sback << endl;
  }
  else if(front==2){
    reverse(sback.begin(),sback.end());
    reverse(s.begin(),s.end());
    cout << sback << s << sfront << endl;

  }
}

Measured memory_bytes: 3924
package main

import (
	"bufio"
	"fmt"
	basicIO "io"
	"math"
	"os"
	"strconv"
)

func main() {
	protagonist(os.Stdin, os.Stdout)
}

func protagonist(r basicIO.Reader, w basicIO.Writer) {
	io := NewIO(r, w)
	N := io.nextInt()
	A := make([]int, N)

	nega := 0
	absMin := math.MaxInt64
	maxIfAllPosi := 0
	for i := 0; i < N; i++ {
		A[i] = io.nextInt()
		absA := int(math.Abs(float64(A[i])))
		if absA < absMin {
			absMin = absA
		}
		maxIfAllPosi += absA

		if A[i] == 0 {
			continue
		}
		if A[i] < 0 {
			nega++
		}
	}

	var sol int
	if nega%2 == 0 {
		sol = maxIfAllPosi
	} else {
		sol = maxIfAllPosi - 2*absMin
	}

	io.PutInt(sol)
}

type IO struct {
	Scanner *bufio.Scanner
	Writer  basicIO.Writer
}

func NewIO(r basicIO.Reader, w basicIO.Writer) *IO {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	return &IO{
		Scanner: s,
		Writer:  w,
	}
}

func (io *IO) nextString() string {
	io.Scanner.Scan()
	return io.Scanner.Text()
}

func (io *IO) nextInt() int {
	io.Scanner.Scan()
	i, _ := strconv.Atoi(io.Scanner.Text())
	return i
}

func (io *IO) PutInt(v int) {
	fmt.Fprintf(io.Writer, "%d\n", v)
}

func (io *IO) PutString(s string) {
	fmt.Fprintf(io.Writer, "%s\n", s)
}


Measured memory_bytes: 3072
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());

    ll ans = a[0];
    ll now = 2;
    for(ll i = 1; i < n; i++){
        if(abs(now - n) == 1){
            ans += a[i];
            break;
        } else if(abs(now - n) == 0){
            break;
        }
        ans += a[i] * 2;
        now += 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4772
# -*-*-*- coding: utf-8 -*-*-*-
member = int(input())
days, choco = map(int, input().split())
ans = choco
 
for i in range(member):
    num = int(input())
    ans += (days - 1) // num + 1
#    print(i, 'day : eat = {} // {} = {:2}, ans = {:2}'.format(days, num, (days // num + 1), ans))
 
print(ans)

Measured memory_bytes: 2940
#include "iostream"
#include "string"


int main()
{
	std::string ring, word;
	std::cin >> ring;
	std::cin >> word;
	ring += ring;

	for (int i = 0; i < ring.length(); i++) {
		if (ring[i] == word[0]) {
			for (int j = 0; j < word.length(); j++) {
				if (i + j + 1 >= ring.length())
					break;
				if (ring[i + j] == word[j] && j + 1 == word.length()) {
					std::cout << "Yes" << std::endl;
					return 0;
				}
				else if (ring[i + j] != word[j])
					break;
			}
		}
		if (i + 1 == ring.length())
			std::cout << "No" << std::endl;
	}
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int h,w; scanf("%d%d",&h,&w);
   vector<string> b(h,string(w,'.')),r(h,string(w,'.'));
   rep(i,0,h){
      if(i%2)b[i]=string(w,'#'); else r[i]=string(w,'#');
      b[i][0]=r[i][w-1]='.'; b[i][w-1]=r[i][0]='#';
   }
   rep(i,0,h)rep(j,0,w){
      char c; cin>>c;
      if(c=='#')b[i][j]=r[i][j]='#';
   }
   rep(i,0,h)cout<<b[i]<<endl; puts("");
   rep(i,0,h)cout<<r[i]<<endl;
   return 0;
}

Measured memory_bytes: 1280
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
int nxt[200005][26];
int dp[200005], trc[200005];
vi ans;
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	string s; cin>>s; int n = s.length();
	s = '$'+s;
	fill(dp, dp+n+3, INT_MAX/10);
	for(int i=n+1; i>=0; i--)
	{
		for(int j=0; j<26; j++)
		{
			if(i==n+1) nxt[i][j] = i;
			else if(s[i+1]-'a'==j) nxt[i][j] = i+1;
			else nxt[i][j] = nxt[i+1][j];
		}
	}
	for(int i=n+1; i>=0; i--)
	{
		if(i==n+1) dp[i]=1;
		else
		for(int j=0; j<26; j++)
		{
			if(dp[i]>dp[nxt[i][j]]+1) 
			{
				dp[i]=dp[nxt[i][j]]+1;
				trc[i]=j;
			}
		}
	}
	int cur=0;
	while(cur<n+1)
	{
		int temp = trc[cur];
		ans.eb(temp);
		cur = nxt[cur][temp];
	}
	for(auto c: ans) cout<<char(c+'a');
}




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

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


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main() {
	int N = 0;
	int data[120];
	int sum = 0;
	int all = 0;
	int T = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> data[i];
		sum = sum + data[i];
	}
	for (int i = 0; i < N-1; i++) {
		all = all + data[i];
		if (i == 0) {
			T = sum - all;
		}
		T = min(T, abs(sum-2 * all));
	}
	cout << T;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cstdlib>
typedef long long int ll;
using namespace std;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}



int main() {
    int N;
    cin >> N;
    ll result = 0;

    for (int i = 0; i < N; i++) {
        ll temp;
        cin >> temp;
        while (temp % 2 == 0) {
            temp /= 2;
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

typedef long long ll;
const int mod=1e9+7;
const int INF=1<<30;

ll pow(ll a,ll b){
  // aのb乗を求める
  ll res = 1;
  while(b){
    if(b%2) res=(res*a)%mod;
    a=(a*a)%mod;
    b>>=1;
  }
  return res;
}

ll imod(ll n){
  // nのmodの逆元を求める
  ll P=mod;
  return pow(n,P-2);
}

ll comb_mod(ll n,ll k,ll fact[]){
  //nまで埋めた階乗テーブルを渡す
  return (fact[n] * imod(fact[k]) % mod) * imod(fact[n-k]) % mod ;
  //nCk % mod を返す
}

int main(){
  int H,W,A,B;
  cin >> H >> W >> A >> B ;
  ll fact[H+W+1];
  fact[0]=1;
  rep(i,H+W)  fact[i+1]=((i+1)*fact[i])%mod;
  
  ll ans=0;
  for(ll x=0; x<W-B; x++){
    ans=(ans+(comb_mod(H-A+B-1+x,H-A-1,fact) * comb_mod(W+A-B-2-x,A-1,fact) % mod))%mod;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
import bisect
n=int(input())
a=list(int(i) for i in input().split())
b=list(int(i) for i in input().split())
c=list(int(i) for i in input().split())
A=sorted(a)
B=sorted(b)
C=sorted(c)
ans=0

for i in range(n):
    ans+=(bisect.bisect_left(A,B[i]))*(n-bisect.bisect_right(C,B[i]))
print(ans)

Measured memory_bytes: 106212
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
ll bans[52];
ll all[52];

ll solve(ll n, ll x){
    if (n == 0){
        if(x <= 0){
            return 0;
        }
        else{
            return 1;
        }
    }
    else if(x <= 1 + all[n-1]){
        return solve(n-1,x-1);
    }
    else {
        return bans[n-1]+1+solve(n-1,x-2-all[n-1]);
    }


}


int main(){
    ll n,x;
    cin >> n >> x;
    bans[0] = 1;
    all[0] = 1;
    for(int i = 1;i < 51;i++){
        bans[i] = 2 * bans[i-1] + 1;
        all[i] = 2 * all[i-1] + 3;
    }
    ll ans;
    ans = solve(n,x);
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    double d,t,s;
    cin>>d>>t>>s;
    double var=(d/s);
    if(var<=t)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;

    
}

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

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

    int ans=0,cnt=0;
    for(int i=0;i<n;i++){
        if(cnt>=h[i]) cnt=h[i];
        else{
            ans+=h[i]-cnt;
            cnt=h[i];
        }
    }
    cout<<ans<<endl;
}

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

int N, A, B;
string S;

int main()
{
  cin >> N >> A >> B >> S;

  int a = 0;
  int b = 0;

  for (int n; n < N; n++) {
    if (S[n] == 'a' && a + b < A + B) {
      a++;
      cout << "Yes" << endl;
    }
    else if (S[n] == 'b' && a + b < A + B && b < B) {
      b++;
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    int max = 0, sum = 0;
    REP (i, n) {
        sum += (s[i] == 'I' ? 1 : (-1));
        if (sum > max) max = sum;
    }
    cout << max << endl;
    return 0;
}

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

string s;

int main()
{
	cin>>s;
	if ((s[0]=='Y')&&(s[1]=='A')&&(s[2]=='K')&&(s[3]=='I'))
		puts("Yes");
	else  puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int n,k;
cin>>n>>k;
ld a[n],v=0,ans=0;
FOR(i,n)
{
	cin>>a[i];
}

FOR(j,k)
{	
	v+=a[j];
}
ans=v;
FORA(i,k,n-1)
{
	v=v-a[i-k]+a[i];
	ans=max(ans,v);
}
 cout << fixed << setprecision(12) <<(ans+k)/2<<endl; 
return  0;
}




Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  ll n;
  string s;
  cin >> n;
  cin >> s;
  char a = s.at(0);
  vector<char> p;
  p.push_back(a);
  for (ll i = 1; i < n; i++) {
    p.push_back(s.at(i));
    if (s.at(i) == s.at(i - 1)) {
      p.pop_back();
    }
  }
  cout << p.size() << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;

    ll P = N%K;
    cout << min(P,K-P) << ln;
}


Measured memory_bytes: 256
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n = int(input())
res = {}
ans = []
for _ in range(n):
    s, p = input().split()
    ans.append(int(p))
    if s in res:
        res[s].append(int(p))
    else:
        res[s] = [int(p)]
stdRes = sorted(res.keys())
for x in stdRes:
    for m in sorted(res[x], reverse=True):
        print(ans.index(m) + 1)

Measured memory_bytes: 5304
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	if (n == 0) return 1;
	if (n % 2) return x * modpow(x * x % mod, n / 2) % mod;
	return  modpow(x * x % mod, n / 2) % mod;
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= (i + 1);
		ans %= mod;
	}
	return ans;
}

int comb(int n, int r) {
	if (n < r) swap(n, r);
	if (n - r < r) r = n - r;
	return fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) % mod;
}

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

string s;
int k;
signed main() {
	cin >> s >> k;
	int n = s.size();
	if(k == 1) {
		cout << s[0] << endl;
	}
	else {
		rep(i, n) {
			if(s[i] != '1') {
				if(k <= i) {
					cout << s[0] << endl;
				}
				else {
					cout << s[i] << endl;
				}
				return 0;
			}
		}
		cout << s[0] << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, m, cnt = 0;
int f[N];

int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int l, r;
		cin >> l >> r;
		f[l]++;
		f[r + 1]--;
	}
	for(int i = 1; i <= n; i++)
	{
		f[i] += f[i - 1];
		if(f[i] == m)
			cnt++;
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 4412
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	ll a,b;
	cin>>a>>b;
	ll dc = __gcd(a,b);
	int cnt = 1;
	for(ll i=2;i*i<=dc;i++) {
		if(dc%i==0) {
			cnt++;
			while(dc%i==0)dc/=i;
		}
	}
	if(dc!=1)cnt++;
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

void put_lower(const char c[],int p){
    for(int i=0;c[i];i++){
        if(i!=p){
            cout << c[i];
        } else {
            cout << static_cast<char>(tolower(c[p]));
        }
    }
}


int main(void){
    int n,k;
    cin >> n >> k;
    char s[n];
    cin >> s;
    
    put_lower(s,k-1);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
{
int n;
scanf ("%d",&n);
if(n<105) {printf("0");
	}else if(n<135) {printf("1");
		}else if(n<165) {printf("2");
			}else if(n<189) {printf("3");
				}else if(n<195) {printf("4");
					}else {printf("5");}
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

// http://arc082.contest.atcoder.jp/tasks/arc082_b

size_t run()
{
  size_t n;
  cin >> n;
  vector<size_t> a(n);
  cin >> a;
  --a;

  size_t out = 0;
  for(size_t i = 0; i + 1 < n; )
    if(a[i] != i)
      ++i;
    else
    {
      ++ out;
      swap(a[i], a[i + 1]);
      i += 2;
    }

  return out + (a.back() == n - 1);
}

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << run();

  return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 1000000007

ll n,c;
ll a[410],b[410];
ll dp[410][410];//dp[i][j]=i人目までにj個配ったときの答え
ll cum[410][410];//cum[i][j]=1^i+...+j^i
int main(){
	scanf("%lld%lld",&n,&c);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)scanf("%lld",b+i);
	
	rep(i,0,405)rep(j,1,405)cum[i][j]=(cum[i][j-1]+pom(j,i,MOD))%MOD;

	dp[0][0]=1;
	rep(i,1,n+1)rep(j,0,c+1)rep(k,0,j+1)dp[i][j]=(dp[i][j]+dp[i-1][j-k]*(cum[k][b[i-1]]-cum[k][a[i-1]-1]))%MOD;
	printf("%lld",(dp[n][c]+MOD)%MOD);
}

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

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
typedef long long LL;

const int maxn = 1500010;

int main()
{
    int n, x; double sum = 0;
    scanf("%d", &n);
    REP(i, 1, n) { scanf("%d", &x); sum += 1.0 / x; }
    printf("%0.6lf\n", 1.0 / sum);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define MOD 1000000007
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
const long long INF = 1LL << 60;
typedef vector<ll> Array;

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

	ll n, k;
	cin >> n >> k;
	Array a(n);
	REP(i, n)cin >> a[i];
	sort(all(a));
	auto find = [&](ll tar,ll u) {
		ll l = -1, r = n;
		while (r - l > 1) {
			ll mid = (r + l) / 2;
			if (u * a[mid] <= tar) {
				if (u >= 0)l = mid;
				else r = mid;
			}
			else {
				if (u >= 0)r = mid;
				else l = mid;
			}
		}
		if (u >= 0)return l + 1;
		else return n - r;
	};
    ll l = -INF, r = INF;
	while (r - l > 1) {
		ll mid = (r + l) / 2;
		ll cnt = 0;
		REP(i, n) {
			cnt += find(mid, a[i]);
			if (a[i] * a[i] <= mid)cnt--;
		}
		if (cnt / 2 >= k)r = mid;
		else l = mid;
	}
	cout << r << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

int main(void){
	int n=in(),K=in(),i,j,k,l,m;
	long long ans=INF,x[50],y[50],xa[50],ya[50],x1,y1,x2,y2;
	rep(i,n){
		x[i]=llin();
		y[i]=llin();
		xa[i]=x[i];
		ya[i]=y[i];
	}
	sort(xa,n);
	sort(ya,n);
	rep(i,n){
		for(j=i+1;j<n;j++){
			rep(k,n){
				for(l=k+1;l<n;l++){
					x1=xa[i];
					y1=ya[k];
					x2=xa[j];
					y2=ya[l];
					int c=0;
					rep(m,n)
						if(x1<=x[m]&&x[m]<=x2&&y1<=y[m]&&y[m]<=y2)c++;
					if(c>=K)ans=min(ans,(x2-x1)*(y2-y1));
				}
			}
		}
	}
	llprint(ans);					
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 99999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll m = 1000007;

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

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll dist[201][201];
int N, M, R;
int r[9];


int main() {
	cin >> N >> M >> R;
	REP(i, N) {
		REP(j, N) {
			dist[i][j] = INF;
		}
	}
	REP(i, R) {
		int k;
		cin >> k;
		r[i] = k - 1;
	}
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		dist[a-1][b-1] = c;
		dist[b-1][a-1] = c;
	}
	REP(k, N) {	//kが中継点
		REP(i, N) {
			REP(j, N) {
				dist[i][j] = min(dist[i][j], (dist[i][k] + dist[k][j]));
			}
		}
	}
	vector<int> v(R);
	REP(i, R) {
		v[i] = r[i];
	}
	VSORT(v);
	ll ans = INF;
	do {
		ll cnt = 0;
		REP(i, R - 1) {
			cnt += dist[v[i]][v[i+1]];
		}
		ans = min(ans, cnt);
	} while (next_permutation(v.begin(), v.end()));     // 次の順列を生成
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
  char s[100001];
  cin >> s;
  int l = strlen(s), a = 0;
  while(l) a += s[--l] == 'g' ? 1 : -1;
  cout << a / 2 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a - b) > c)
    {
        cout << 0 << endl;
    } else
    {
        cout << (c - (a - b)) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def gcd(A, B):
    x = max(A, B)
    y = min(A, B)
    if x % y == 0:
        return y
    else : 
        while x % y != 0:
            z = x % y
            x = y
            y = z
        
        return y

print(A*B // gcd(A, B))




Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
 
  // 配列
  vector<int> vec; // int型の配列変数vecを宣言
 
  vec = { 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 << vec.at(K-1) << endl; // 
 
}



Measured memory_bytes: 256