akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> Z_algorithm(string S) {
  int c = 0, n = S.size();
  vector<int> Z(n, 0);
  FOR(i, 1, n){
    int l = i - c;
    if (i + Z[l] < c + Z[c]) {
      Z[i] = Z[l];
    } else {
      int j = max(0ll, c + Z[c] - i);
      while (i + j < n && S[j] == S[i + j])
        j++;
      Z[i] = j;
      c = i;
    }
  }

  Z[0] = n;
  return Z;
}

signed main() {
  int N;
  cin >> N;

  string s;
  cin >> s;

  int ans = 0;
  REP(i, N){
    auto v = Z_algorithm(s.substr(i));
    REP(j, v.size()){
      chmax(ans, min(v[j], j));
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 384
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N = getN()
divisors = []
def make_divisors(n):
    for i in range(1, int(math.sqrt(n)) + 1):
        a, b = 0, 0
        if n % i == 0:
            a = i
            b = n // i
            divisors.append([a, b])

make_divisors(N)

ans = float('inf')
for i in divisors:
    a, b = i
    ans = min(ans, a + b - 2)
print(ans)

Measured memory_bytes: 83708
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=3010;
const int inf=2147483647;
const int mod=998244353;
int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    return x*f;
}
void upd(int&x,int y){x+=y;if(x>=mod)x-=mod;}
int n,k;
int f[Maxn][Maxn<<1],C[Maxn][Maxn];
int main()
{
	n=read(),k=read();
	C[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
		C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
//	pw[0]=1;for(int i=1;i<=n;i++)pw[i]=pw[i-1]*2%mod;
	f[0][0]=1;
	for(int i=0;i<n;i++)
	for(int j=0;j<=min(i<<1,k-1);j++)
	for(int l=0;l<3;l++)
	upd(f[i+1][j+l],f[i][j]);
	int ans=0;
	for(int i=0;i<k;i++)upd(ans,f[n][i]);
	if(k&1)
	{
		for(int i=n;i;i--)
		{
			if(2*i<=k)break;
			upd(ans,C[n][i]);
		}
	}
//	printf("%d\n",ans);
	for(int i=0;i<=n;i++)
	{
		if((n-i)*2<k)break;
		int t=0;
		for(int j=1;k+j<=n*2;j+=2)//S-k
		{
			int S=k+j,c=(j+1)/2;
			int t1=(n-i-c*2),t2=S-c*4-t1;
			if(t1<=0||t2<0||t1==t2)continue;
//			printf("%d %d %d\n",t1,t2,C[t1][t2]);
			upd(t,C[t1][t2]);
		}
//		printf("%d %d\n",i,t);
		upd(ans,(LL)t*C[n][i]%mod);
	}
	printf("%d",ans);
}

Measured memory_bytes: 104960
#include<stdio.h>
#include<math.h>
int main(){
    int n;
    scanf("%d",&n);
    while(n!=0){
        float a[n];
        int i;
        for(i=0;i<n;i++){
            scanf("%f",&a[i]);
        }
        float sum=0,ave;
        for(i=0;i<n;i++){
            sum+=a[i];
        }
        ave=sum/n;
        float nbunsan=0,bunsan;
        for(i=0;i<n;i++){
            nbunsan+=(a[i]-ave)*(a[i]-ave);
        }
        bunsan=nbunsan/n;
        float hensa;
        hensa=sqrt(bunsan);
        printf("%f\n",hensa);
        scanf("%d",&n);
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N;

    cin>>N;

    vector<int> a;
    set<int> key;

    for(int i=0;i<N;i++)
    {
        int buf;
        cin>>buf;
        a.push_back(buf);
        key.insert(buf);
    }

    map<int,int> cnt;

    for(int i=0;i<N;i++)cnt[a[i]]++;

    int del = 0;

    for(const auto &b : key)
    {
        if(cnt[b] > b)
        {
            del += cnt[b] - b;
        }
        if(cnt[b] < b)
        {
            del += cnt[b];
        }
    }

    std::cout<<del<<std::endl;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef pair<ll, ll> p;
typedef vector<pair<ll, ll>> vpl;


int main(){
    ll n,a,b; cin >> n >> a >> b;
    if(n*a > b) cout << b << "\n";
    else cout << n*a << "\n";
    return 0;
}


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

int n;
int a[100], b[100], c[100], d[100];
int cflag[200];	//r=0, b=1;
int flag[100];	//rで使用済みは1,othersは0　なおx座標に準拠
int rnum=0, bnum=0;	//rの回数
int rmax=0;
int maxnum=-1;
int ans=0;

void change(int *x, int *y);

int main(void){
	for(int i=0;i<100;i++)	flag[i]=0;

	scanf("%d", &n);
	for(int i=0;i<n;i++){
		scanf("%d %d", &a[i], &b[i]);
		cflag[a[i]] = 0;
	}
	for(int i=0;i<n;i++){
		scanf("%d %d", &c[i], &d[i]);
		cflag[c[i]] = 1;
	}

	for(int i=0;i<100;i++){
		for(int j=0;j<n-1;j++){
			if(a[j]>a[j+1]){
				change(&a[j], &a[j+1]);
				change(&b[j], &b[j+1]);
			}
			if(c[j]>c[j+1]){
				change(&c[j], &c[j+1]);
				change(&d[j], &d[j+1]);
			}
		}
	}

	for(int i=0;i<2*n;i++){
		if(cflag[i] == 0)	rnum++;
		else if(cflag[i] == 1){
			bnum++;
			for(int j=0;j<rnum;j++){
				if(b[j]>rmax && b[j]<d[bnum-1] && flag[j]==0){
					rmax = b[j];
					maxnum=j;
				}
			}
			if(maxnum!=-1){
				flag[maxnum] = 1;
				ans++;
			}
		}
		maxnum=-1;rmax=-1;
	}

	printf("%d", ans);

	return 0;
}

void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef struct tree{
  int N,L,R;
}tree;

tree T[10000];

void prewalk(int);
void inwalk(int);
void poswalk(int);

void prewalk(int x)
{
  if(x == -1)
    return;
  printf(" %d",x);
  prewalk(T[x].L);
  prewalk(T[x].R);
}

void inwalk(int y)
{
  if(y == -1)
    return;
  inwalk(T[y].L);
  printf(" %d",y);
  inwalk(T[y].R);
}

void poswalk(int z)
{
  if(z == -1)
    return;
  poswalk(T[z].L);
  poswalk(T[z].R);
  printf(" %d",z);
}
    
    
int main()
{
  int n,num,lef,rig,root;
  int i;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    T[i].N = -1;

  for(i=0;i<n;i++) {
    scanf("%d%d%d",&num,&lef,&rig);
    T[num].L = lef;
    T[num].R = rig;
    if(lef != -1)
      T[lef].N = num;
    if(rig != -1)
      T[rig].N = num;
  }

  for(i=0;i<n;i++)
    if(T[i].N == -1)
      root = i;

  printf("Preorder\n");
  prewalk(root);
  printf("\nInorder\n");
  inwalk(root);
  printf("\nPostorder\n");
  poswalk(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2004
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int H[] = new int[N];
    int C = 0;
    int c = 0;
    H[0] = sc.nextInt();
    
    for(int i=1; i<N; i++) { 
      H[i] = sc.nextInt();
      if(H[i] <= H[i-1]) {
        c++;
      } else {
        c = 0;
      }
      if(C < c) {
        C = c;
      }
    }

    System.out.println(C);
  }
}

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

int main(){
    int n, m;// number of nodes & edges
    cin >> n;
    m = n-1;

    vector<vector<int>> graph(n);
    vector<pair<int,int>> edge;
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        graph[a].push_back(b);
        graph[b].push_back(a);
        edge.push_back({a,b});// equiv: edge.emplace_back(a,b)
    }

    vector<int> depth1(n,0), depthN(n,0);
    queue<int> que;

    // root
    depth1[0] = 1;
    que.push(0);

    while(!que.empty()){
        int current = que.front();
        que.pop();

        for(int adjacent : graph[current]){
            if(depth1[adjacent]!=0) continue;// already visited
            que.push(adjacent);
            depth1[adjacent] = depth1[current] + 1;
        }
    }

    depthN[n-1] = 1;
    que.push(n-1);

    while(!que.empty()){
        int current = que.front();
        que.pop();

        for(int adjacent : graph[current]){
            if(depthN[adjacent]!=0) continue;// already visited
            que.push(adjacent);
            depthN[adjacent] = depthN[current] + 1;
        }
    }
    int count1 = 0, countN = 0;
    for(int i=0; i<n; i++){
        if(depth1[i] <= depthN[i]) count1 += 1;
        if(depth1[i] >  depthN[i]) countN += 1;
    }
    if(count1 >  countN) cout << "Fennec" << endl;
    if(count1 <= countN) cout << "Snuke" << endl;
    return 0;
}

Measured memory_bytes: 7284
#include <iostream>
#include <algorithm>

#define N 1000000

using namespace std;

int main()
{
  bool primes[N];

  fill(primes+2, primes+N, true);

  // eratos
  for(int i = 2; i < N; ++i)
    if(primes[i])
      for(int j = i+i; j < N; j += i)
	primes[j] = false;

  int n, count;
  while(cin>>n){
    count = 0;
    for(int i = 2; i <= n; ++i)
      if(primes[i]) ++count;

    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>

#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int n, y;
    cin >> n >> y;

    REP(i, n + 1) {
        REP(j, n - i + 1) {
            int z = n - i - j;
            if ( z < 0 ) {
                continue;
            }

            if ( 10000 * i + 5000 * j + 1000 * z == y ) {
                cout << i << " " << j << " " << z << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
bool debug = true;

//=============segment_tree============================
const int MAX_N = 1 << 18;//要変更
int nn;
vector<ll> dat(2 * MAX_N - 1, INF);//要変更

void init(ll n_) {
  nn = 1;
  while (nn < n_) {
    nn *= 2;
  }
}

void update(ll k, ll a) {
  k += nn - 1;
  dat.at(k) = a;//要変更
  while (k > 0) {
    k = (k - 1) / 2;
    dat.at(k) = min(dat.at(k * 2 + 1), dat.at(k * 2 + 2));//要変更
  }
}

ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = nn) {
  if (r <= a || b <= l) {
    return INF;//要変更
  }
  if (a <= l && r <= b) {
    return dat.at(k);
  }
  else {
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);//要変更
  }
}
//=================================================

//=============BIT============================
vector<ll> bit(MAX_N + 1, 0);
ll n;
ll sum(ll i) {
  ll s = 0;
  while (i > 0) {
    s += bit.at(i);
    i -= i & -i;
  }
  return s;
}

void add(ll i, ll x) {
  while (i <= n) {
    bit.at(i) += x;
    i += i & -i;
  }
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  ll K;
  cin >> S >> K;
  ll N = S.size();
  n = N;
  init(N);
  vector<queue<ll>> alfa(26);
  for (ll i = 0; i < N; ++i) {
    alfa.at(S.at(i) - 'a').push(i);
    update(i, S.at(i) - 'a');
  }
  string ans;
  vector<bool> used(N, false);
  while ((K > 0)) {
    ll l = 1, r = N + 1;
    while (l + 1 != r) {
      ll m = (l + r) / 2;
      //使える個数 <= スワップでは１個先まで行ける
      if ((m - sum(m)) <= K + 1) {
        l = m;
      }
      else {
        r = m;
      }
    }
    //lが1indexのため [0, l)で良い
    ll m = query(0, l);
    if (m == INF) {
      break;
    }
    // cout << K << "\n";
    ans += (char)('a' + m);
    update(alfa.at(m).front(), INF);
    used.at(alfa.at(m).front()) = true;
    //番号 - 前にある使えない数 - スワップでは１個先まで行ける
    K -= (alfa.at(m).front() + 1) - sum(alfa.at(m).front() + 1) - 1;
    add(alfa.at(m).front() + 1, 1);
    alfa.at(m).pop();
  }
  for (ll i = 0; i < N; ++i) {
    if (!used.at(i)) {
      ans += S.at(i);
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 11476
#include<stdio.h>
#define NIL -1
#define MAX 10010
struct Node{int p, l, r;
};
struct Node T[MAX];
int n,D[MAX], H[MAX];
int wowDep(int);
int wowSib(int);
void print(int);
int main(){
  int i, v, l, r,n,m;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;
  }

  for ( i = 0; i < n; i++ ){
    D[i] = wowDep(i);
    H[i] = 0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) { // is leaf
      H[i] = 0;
      int p = T[i].p;
      int c = 1;
      while(1){
	if ( p == NIL ) break;
	if ( H[p] < c ) H[p] = c;
	c++;
	p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}
int wowDep(int a){
  int depth = 0;
  while(1){
    a = T[a].p;
    if ( a == NIL ) break;
    depth++;
  }
  return depth;
}
int wowSib(int a){
  if ( T[a].p == NIL ) return NIL;
  if ( T[T[a].p].l != a && T[T[a].p].l != NIL ) return T[T[a].p].l;
  if ( T[T[a].p].r != a && T[T[a].p].r != NIL ) return T[T[a].p].r;
  return NIL;
}
void print(int a){
      int d;
    d=0;
    printf("node %d: ", a);
  printf("parent = %d, ", T[a].p);
  printf("sibling = %d, ", wowSib(a));

  if ( T[a].l != NIL ) d++;
  if ( T[a].r != NIL ) d++;
  printf("degree = %d, ", d);
  printf("depth = %d, ", D[a]);
  printf("height = %d, ", H[a]);

  if ( T[a].p == NIL ){
    printf("root\n");
  } else if ( T[a].l == NIL && T[a].r == NIL ){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}



Measured memory_bytes: 2084
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long H[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			H[i] = sc.nextLong();			
		}
		int max = 0;
		int cur = 0;
		int move = 0;
		while(cur < N - 1){
			if(H[cur] >= H[cur + 1]){
				++move;				
			}else{
				max = Math.max(move, max);
				move = 0;
			}
			++cur;
		}
		max = Math.max(move, max);
		System.out.println(max);
	}
}


Measured memory_bytes: 50228
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
typedef long long Int;

int a[20][20];
int dp[20][20];

int main() {
  for (;;) {
      memset(dp, 0, sizeof(dp));
      memset(a, 0, sizeof(a));
      int C, R; cin >> C >> R;
      if ((C | R) == 0) break;
      REP(r, R) REP(c, C) cin >> a[r][c];

      REP(c, C) if (a[0][c] == 0) dp[0][c] = 1;
      REP(r, R - 1) {
          REP(c, C) if (a[r][c] == 0) {
              if (c - 1 >= 0) dp[r + 1][c - 1] += dp[r][c];
              if (c + 1 <  C) dp[r + 1][c + 1] += dp[r][c];

              int d = 1;
              while (a[r + d][c] == 2) d += 2;
              dp[r + d][c] += dp[r][c];
          }
      }

      Int ans = 0;
      REP(c, C) {
          if (a[R - 1][c] == 0) ans += dp[R - 1][c];
          ans += dp[R][c];
          ans += dp[R + 1][c];
      }

      cout << ans << endl;

  }
  return 0;
}

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

int main(){
    int l;
    cin >> l;
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<l; i++){
        if(s[i] != '.') continue;
        int tmpl = 0;
        for(int j=i-1; j>=0; j--){
            if(s[j] == 'B'){
                tmpl++;
            }else if(s[j] == '.'){
                tmpl = 0;
                break;
            }else{
                break;
            }
            if(j == 0) tmpl = 0;
        }
        int tmpr = 0;
        for(int j=i+1; j<l; j++){
            if(s[j] == 'B'){
                tmpr++;
            }else if(s[j] == '.'){
                tmpr = 0;
                break;
            }else{
                break;
            }
            if(j == l-1) tmpr = 0;
        }
        int f = 0;
        for(int j=i-1; j>=0; j--){
            if(s[j] == 'B') f = 1;
            else if(s[j] == '.') break;
        }
        for(int j=i+1; j<l; j++){
            if(f && s[j] == 'B'){
                tmpl = 0;
                tmpr = 0;
                break;
            }
            else if(s[j] == '.') break;
        }
        ans = max(ans, tmpl+tmpr);


    }
    cout << ans << endl;
}

            



Measured memory_bytes: 3200
import java.util.HashSet;
import java.util.Set;

public class Main {

  private static void solve() {
    int[][] c = ntable(3, 3);
    
    for (int i = 0; i < 2; i ++) {
      Set<Integer> set = new HashSet<>();
      for (int  j = 0; j < 3; j ++) {
        set.add(c[i + 1][j] - c[i][j]);
      }
      if (set.size() != 1) {
        System.out.println("No");
        return;
      }
    }
    
    for (int j = 0; j < 2; j ++) {
      Set<Integer> set = new HashSet<>();
      for (int  i = 0; i < 3; i ++) {
        set.add(c[i][j + 1] - c[i][j]);
      }
      if (set.size() != 1) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 21460
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, m;
    cin >> n;
    if(n < 1200) cout << "ABC";
    else if(n < 2800) cout << "ARC";
    else cout << "AGC";
}

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

int main(){
    long long n; cin >> n;
    string st = "";

    while(n > 0){
        n--;
        st += 'a' + n%26;
        n = n/26;
    }

    reverse(st.begin(), st.end());
    cout << st;
    cout << endl;
}

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

int main()
{
	int n;
	cin >> n;
	int ans = 1;
	for(int i =0;i<n;i++)
	{
		if(ans*2<=n)ans*=2;
	}
	cout<<ans<<endl;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int x, y, z, K;
  cin >> x >> y >> z >> K;

  vll a(x), b(y), c(z);
  cin >> a >> b >> c;

  sort(rall(a));
  sort(rall(b));
  sort(rall(c));

  typedef tuple<ll, ll, ll> T;
  typedef tuple<ll, ll, ll, ll> tp;
  typedef pair<long long int, T> P;

  auto cmp = [](tp l, tp r) { return get<0>(l) < get<0>(r); };
  priority_queue<tp, vector<tp>, decltype(cmp)> pq(cmp);
  pq.push(make_tuple(a[0] + b[0] + c[0], 0, 0, 0));

  map<ll, bool> checked;

  REP(i, K) {
    auto t = pq.top();
    pq.pop();

    auto t0 = get<0>(t);
    auto t1 = get<1>(t);
    auto t2 = get<2>(t);
    auto t3 = get<3>(t);
    cout << t0 << endl;
    // cout << t0 << " : " << t1 << " " << t2 << " " << t3 << endl;

    if (t1 + 1 < a.size() and
        !checked[1000 * 1000 * (t1 + 1) + 1000 * t2 + t3]) {
      pq.push(make_tuple(a[t1 + 1] + b[t2] + c[t3], t1 + 1, t2, t3));
      checked[1000 * 1000 * (t1 + 1) + 1000 * t2 + t3] = true;
    }
    if (t2 + 1 < b.size() and
        !checked[1000 * 1000 * t1 + 1000 * (t2 + 1) + t3]) {
      pq.push(make_tuple(a[t1] + b[t2 + 1] + c[t3], t1, t2 + 1, t3));
      checked[1000 * 1000 * t1 + 1000 * (t2 + 1) + t3] = true;
    }
    if (t3 + 1 < c.size() and !checked[1000 * 1000 * t1 + 1000 * t2 + t3 + 1]) {
      pq.push(make_tuple(a[t1] + b[t2] + c[t3 + 1], t1, t2, t3 + 1));
      checked[1000 * 1000 * t1 + 1000 * t2 + t3 + 1] = true;
    }
  }

  return 0;
}


Measured memory_bytes: 896
k,n=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
 
sol=[]
for i in range(n-1):
  sol.append(a[i+1]-a[i])
sol.append(a[0]-a[n-1]+k)
 
sol.sort()
print(sum(sol[:n-1]))

Measured memory_bytes: 26444
import sys
input = sys.stdin.readline
from collections import Counter
N=int(input())
S=Counter([input().strip() for i in range(N)])

print("AC x "+str(S["AC"]))
print("WA x "+str(S["WA"]))
print("TLE x "+str(S["TLE"]))
print("RE x "+str(S["RE"]))


Measured memory_bytes: 16540
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,r,c,i,j,k=0;
    cin>>r>>c;
    int ar[r+5][c+5];
    int cn[r*c+5][4+5];
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            cin>>ar[i][j];
        }
    }
     for(i=0;i<r;i++)
    {
        for(j=0;j<c-1;j++)
        {
            if(ar[i][j]%2!=0)
            {
                k++;
                ar[i][j+1]=ar[i][j+1]+1;
                ar[i][j]=ar[i][j]-1;
             cn[k-1][0]=i;
              cn[k-1][1]=j;
               cn[k-1][2]=i;
                cn[k-1][3]=j+1;


            }
           // cout<<ar[i][j]<<" ";
        }
        //cout<<ar[i][c-1];
        //cout<<endl;
    }
    for(j=c-1;j<c;j++)
    {
        for(i=0;i<r-1;i++)
        {
            if(ar[i][j]%2!=0)
            {
                k++;
                ar[i+1][j]=ar[i+1][j]+1;
                ar[i][j]=ar[i][j]-1;
             cn[k-1][0]=i;
              cn[k-1][1]=j;
               cn[k-1][2]=i+1;
                cn[k-1][3]=j;


            }
        }
    }
//     for(i=0;i<r;i++)
//    {
//        for(j=0;j<c;j++)
//        {
//            cout<<ar[i][j]<<" ";
//        }
//        cout<<endl;
//    }
    cout<<k<<endl;
    for(i=0;i<k;i++)
    {
        for(j=0;j<4;j++)
        {
            if(j!=3)cout<<cn[i][j]+1<<" ";
            else cout<<cn[i][j]+1<<endl;
        }
    }


}

Measured memory_bytes: 9012
package main

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

var arr = [12]int{1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049}

const inf = 1 << 60

func main() {
	n := getInt()

	dp := make([]int, n+1)
	for i := range dp {
		dp[i] = inf
	}
	dp[0] = 0

	for i := 1; i < n+1; i++ {
		for _, v := range arr {
			if i >= v {
				dp[i] = min(dp[i], dp[i-v]+1)
			} else {
				break
			}
		}
	}

	fmt.Println(dp[n])
}

// 6
// 36
// 216
// 1296
// 7776
// 46656
// 279936
// 9
// 81
// 729
// 6561
// 59049
// 531441

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int rest=x-a;
		int n=rest/b;
		int left=rest-n*b;
		System.out.println(left);
	}
}

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

using namespace std;

#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define fff ff
#define sss ss.ff
#define ttt ss.ss
#define INF (1 << 30)
#define LLF (1ll << 60)
#define PRIME (1000000007)
#define FASTIO std::ios::sync_with_stdio(false)
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << x << endl
#else
#define debug(x)
#endif
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

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

#define all(x) x.begin(), x.end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<string> vs;

/*-----------------END TEMPLATE-----------------*/

int main() {
  FASTIO;
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll dir[n * 2];
  if (s[0] == 'W') {
    cout << 0 << endl;
    return 0;
  }
  dir[0] = 0;
  ll r = 0;
  for (int i = 1; i < 2 * n; i++) {
    if (s[i] == s[i - 1]) {
      dir[i] = dir[i - 1] ^ 1;
    } else {
      dir[i] = dir[i - 1];
    }
    r += dir[i] == 1;
  }
  if (r != n) {
    cout << 0 << endl;
    return 0;
  }
  ll l = 0;
  ll ans = 1;
  for (int i = 0; i < 2 * n; i++) {
    if (dir[i] == 0)
      l++;
    else {
      ans = (ans * l) % PRIME;
      l--;
    }
  }

  for (int i = 1; i <= n; i++) {
    ans = (ans * i) % PRIME;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2196
#include <stdio.h>
int main(){
	int a,b;
	int i,j;
	for(;;){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				if((i+j)%2==0) printf("#");
				else printf(".");
			}
			puts("");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main(){
	string n;
	cin>>n;
	int k;
	ll c=0;
	cin>>k;
	ll ans=0;
	ll t;
	t = n.size();
	if (k == 1){
		cout<<(t-1)*9+n[0]-'0'<<endl;
	}
	else if(k==2){
		if (t<2){
			cout<<0<<endl;
			return 0;
		}
		ans+=(t-1)*(t-2)/2*(ll)(9*9);
		ans+=max((ll)0,(ll)(n[0]-'0'-1))*(t-1)*9;
		//cout<<ans<<endl;
		ll c=0;
		c++;
		t--;
		while(n[c]=='0'&& c< n.size()){
			c++;
			t--;
		}
		if (c==n.size()){
			cout<<ans<<endl;
			return 0;
		}
		ans+=(t-1)*9+n[c]-'0';
		cout<<ans<<endl;
	}
	else if(k==3){
		if(t<3){
			cout<<0<<endl;
			return 0;
		}
		ans+=(t-1)*(t-2)*(t-3)/(ll)6*(ll)(9*9*9);
		ans+=max((ll)0,(ll)(n[0]-'0'-1))*(t-1)*(t-2)/2*(ll)(9*9);\
		//cout<<ans<<endl;
		ll c=0;
		c++;
		t--;
		while(n[c]=='0'&&c< n.size()){
			c++;
			t--;
		}
		if(c==n.size()){
			cout<<ans<<endl;
			return 0;
		}
		ans+=(t-1)*(t-2)/2*(ll)(9*9);
		ans+=max((ll)0,(ll)(n[c]-'0'-1))*(t-1)*9;
		//cout<<ans<<endl;
		c++;
		t--;
		while(n[c]=='0'&&c< n.size()){
			c++;
			t--;
		}
		if(c==n.size()){
			cout<<ans<<endl;
			return 0;
		}
		ans+=(t-1)*9+n[c]-'0';
		cout<<ans<<endl;
	} 
	return 0;	
} 
 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long n,a,b,i,ans = 0;cin >> n >> a >> b;
  long long x[n];
  for(i=0;i<n;i++) cin >> x[i];
  for(i=1;i<n;i++) ans += min(a*(x[i]-x[i-1]),b);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  map<string,int> mp;
  mp["SUN"]=7;
  mp["MON"]=6;
  mp["TUE"]=5;
  mp["WED"]=4;
  mp["THU"]=3;
  mp["FRI"]=2;
  mp["SAT"]=1;
  cout<<mp[s]<<endl;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main() {
	int a = 0;
	int b = 0;
	int c = 0;


	cin >> a >> b >> c;
	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}


Measured memory_bytes: 3104
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i){
        cin >> a[i];
        a[i]--;
    }
    vector<bool> isPushed(n, false);
    int itr = 0;
    int ans = 0;
    for (int i=0; i<n; ++i){
        if(itr == 1){
            break;
        }
        else {
            if(isPushed[itr]){
                ans = -1;
                break;
            }
            isPushed[itr] = true;
            itr = a[itr];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env ruby

stack = []

gets.chomp.split.each do |chr|
  case chr
  when '+' then
    stack << stack.pop + stack.pop
  when '-' then
    a = stack.pop
    b = stack.pop
    stack << b - a
  when '*' then
    stack << stack.pop * stack.pop
  else
    stack << chr.to_i
  end
end

puts stack.pop

Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;  
int main() {
  int n,d;
  cin>>n;
  cin>>d;
  int co=0;
  while(n--)
  { 
    double a,b;
    cin>>a;
    cin>>b;
    double res=sqrt(pow(abs(a),2)+pow(abs(b),2));
    if(res<=float(d))
    co++;
  }
  cout<<co;
 return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
#include <unordered_set>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
//ll min(int a, ll b) {return a < b ? a : b;}
//ll min(ll a, int b) {return a < b ? a : b;}
//ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
//ll max(int a, ll b) {return a > b ? a : b;}
//ll max(ll a, int b) {return a > b ? a : b;}
//ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const long long INF = 1e18;
//#define int long long

int L, n;
int a[500000];
long long ans;

long long solve()
{
    long long res = 0;
    vector<long long> pf(n);
    vector<long long> sf(n);
    for (int i = 0; i < n; i++)
    {
        if (i) pf[i] = pf[i - 1];
        pf[i] += 2 * a[i];
    }
    for (int i = n - 1; i >= 0; i--)
    {
        if (n - i - 1) sf[i] = sf[i + 1];
        sf[i] += 2 * (L - a[i]);
    }
    //for (auto e : pf) cout << e << " "; cout << endl;
    //for (auto e : sf) cout << e << " "; cout << endl;
    pair<int, int> kek;
    kek.first = n / 2;
    kek.second = n % 2;
    for (int i = 0; i < n; i++)
    {
        if (kek.second == 0)
        {
            res = max(res, sf[kek.first] + pf[kek.first - 1] - (i ? pf[i - 1] : 0) - (L - a[kek.first]));
            kek.second = 1;
        }
        else
        {
            res = max(res, (kek.first + 1 < n ? sf[kek.first + 1] : 0) + pf[kek.first] - (i ? pf[i - 1] : 0) - a[kek.first]);
            kek.first++;
            kek.second = 0;
        }
    }
    //cout << res << endl << endl;
    return res;
}
signed main()
{
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> L >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ans = solve();
    for (int i = 0; i < n; i++)
    {
        a[i] = L - a[i];
    }
    reverse(a, a + n);
    ans = max(ans, solve());
    cout << ans;
}


Measured memory_bytes: 4224
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
  ($line:expr, $name:ident, $t:tt) => {
    let $name = value!($line, $t);
  };
}

macro_rules! values_def {
  ($lines:expr, $n:expr, $name:ident, $t:tt) => {
    let $name = {
      let mut vec = Vec::new();
      for i in 0..$n {
        let mut next = $lines.next().unwrap().split_whitespace();
        vec.push(value!(next, $t));
      }
      vec
    };
  };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
  let mut input = String::new();
  io::stdin().read_to_string(&mut input).unwrap();
  let output = solve(input.trim().to_string());
  println!("{}", output);
}

fn solve(input: String) -> String {
  input!(input=>(a:i64 b:i64));
  if b % a == 0 { a + b } else { b - a }.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "4 12\n" => "16\n",
    test2: "8 20\n" => "12\n",
    test3: "1 1\n" => "2\n",
}


Measured memory_bytes: 4352
import java.util.*;

class Main{

    String[] a, b;
    String start, goal;

    void solve(){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int n = sc.nextInt();
            if(n==0) break;
            a = new String[n]; b = new String[n];
            for(int i=0; i<n; i++){
                a[i] = sc.next(); b[i] = sc.next();
            }
            start = sc.next(); goal = sc.next();
            System.out.println(bfs());
        }
    }

    class P{
        String s;
        int cnt;
        P(String s, int cnt){
            this.s = s;
            this.cnt = cnt;
        }
    }

    int bfs(){
        LinkedList<P> q = new LinkedList<P>();
        q.add(new P(start, 0));
        HashSet<String> set = new HashSet<String>();

        while(q.size()>0){
            P qq = q.poll();
            String before = qq.s; int cnt = qq.cnt;

            if(before.equals(goal)) return cnt;
            if(before.length()>=30 || !set.add(before)) continue;

            for(int i=0; i<a.length; i++){
                String ns = before.replaceAll(a[i], b[i]);
                if(before.equals(ns)) continue;
                q.add(new P(ns, cnt+1));
            }
        }
        return -1;
    }

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

Measured memory_bytes: 68176
#include<stdio.h>

int main(void)
{
  int a,ans=0;
  char s[10];
  scanf("%d",&a);
  if(a %2!=0)
    {
      ans = a*2;
    }
  else
    {
      ans = a;
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
	int N;
	cin >> N;
	int K;
	cin >> K;
	
	int ans=0;
	for(int i=0; i<N; i++){
		int x;
		cin >> x;
		
		ans+=2*min(x,K-x);
	}
	cout << ans << endl;
	return 0;
}

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

int n;
vector<bool> used(1 << 24, false);

struct rounds{
            int x, y, r, c;
        };

bool color(int x, int y, vector<rounds> &data){
    return data[x].c == data[y].c;
}

void dfs(vector<vector<int>> &check, vector<rounds> &data, int now, int &ans){
    if (!used[now]){
        used[now] = true;
        vector<bool> ok(n, false);
        for (int i = 0; i < n; i++){
            if ((now >> i) & 1) continue;
            bool flag = true;
            for (int j = 0; j < check[i].size(); j++){
                if (((now >> check[i][j]) & 1) == 0) flag = false;
            }
            if (flag) ok[i] = true;
        }
        bool flag = false;
        for (int i = 0; i < n; i++){
            if (!ok[i]) continue;
            for (int j = i + 1; j < n; j++){
                if (!ok[j]) continue;
                if (color(i, j, data)){
                    flag = true;
                    int next = now;
                    next |= (int)pow(2, i);
                    next |= (int)pow(2, j);
                    dfs(check, data, next, ans);
                }
            }
        }
        if (!flag){
            int tmp = 0;
            for (int i = 0; i < n; i++){
                if ((now >> i) & 1) tmp++;
            }
            ans = max(ans, tmp);
        }
    }
}

int main(){
    while (1){
        for (int i = 0; i < (1 << 24); i++) used[i] = false;
        cin >> n;
        if (!n) break;
        
        int ans = 0;
        vector<rounds> data(n);
        for (int i = 0; i < n; i++) cin >> data[i].x >> data[i].y >> data[i].r >> data[i].c;

        vector<vector<int>> check(n);
        for (int i = 0; i < n; i++){
            for (int j = i + 1; j < n; j++){
                int X = data[i].x - data[j].x;
                int Y = data[i].y - data[j].y;
                int R = data[i].r + data[j].r;
                if (X * X + Y * Y < R * R) check[j].push_back(i);
            }
        }

        int now = 0;
        dfs(check, data, now, ans);
        cout << ans << endl;
    }
}


Measured memory_bytes: 4760
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double

using namespace std;

int main()
{
	fio
	ll h;
	cin>>h;
	ll attacks = 0,monsters = 1;
	while(h>0)
	{
		h = h/2;
		attacks+=monsters;
		monsters*=2;
		
	}
	cout<<attacks<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int ans = 0;

        for(int i = 0;i <= a;i++)
            for(int j = 0;j <= b;j++)
                for(int k = 0;k <= c;k++)
                    if(500*i + 100*j + 50*k == x)
                        ans++;

        System.out.println(ans);
    }
}


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

using namespace std;

int H, W, K, ans;
char c[6][6];

int main(){
	cin >> H >> W >> K;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			cin >> c[i][j];
		}
	}

	for(int h = 0; h < (1<<H); ++h){
		for(int w = 0; w < (1<<W); ++w){
			int cnt = 0;
			for(int i = 0; i < H; ++i){
				for(int j = 0; j < W; ++j){
					if(h&(1<<i) && w&(1<<j) && c[i][j] == '#'){
						cnt++;
					}
				}
			}
			if(cnt == K){
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    int n;cin>>n;
    string s;cin>>s;
    int ans=0;
    rep(i,n-2){
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C') ans++;
    }    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n,m = map(int, input().split())
ans = 0
route = [[0]*(n+1) for i in range(n+1)]

for i in range(m):
  f,t = map(int, input().split())
  route[f][t] += 1
  route[t][f] += 1

for i in range(1, n+1):
  print(sum(route[i]))

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


int digit_num(int i)
{
	int d = 0;
  while (i > 0)
  {
   	d++;
    i/=10;
  }
  if (d%2)
    return 1;
  else
    return 0;
}

int main()
{
 int n;
  cin >> n;
  
  int cnt = 0;
  for (int i = 1; i<=n;i++)
    cnt += digit_num(i);
  
  cout << cnt << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int b, r, g, c, s, t;
int main() {
	while(~scanf("%d%d%d%d%d%d", &b, &r, &g, &c, &s, &t)&&t) {
		printf("%d\n", b*95 + r*63 + g*7 + c*2 + s*3 - t*3 + 100);
	}
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N, K);
  for (int i = 0; i < Q; i++) {
    int a;
    cin >> a;
    A[a - 1]++;
  }
  for (int i = 0; i < N; i++) {
    if (A[i] - Q > 0) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 1024