akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll t,n;
string s;
int numr[4005],numb[4005],numg[4005];
int sumr,sumb,sumg;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	cin>>s;
	int sumr=0,sumb=0,sumg=0;
	per(i,1,n-1){
		if(s[i]=='R')sumr++;
		else if(s[i]=='B')sumb++;
		else if(s[i]=='G')sumg++;
		numr[i-1]=sumr,numb[i-1]=sumb,numg[i-1]=sumg;
	}
	ll sum=0;
	rep(i,0,n-2){		
		int j=i;
		while(j<n-1){
			while(s[j]==s[i]&&j<n-1)j++;
			int cnt=j-i;
			if(j+cnt<=n-1&&s[j+cnt]!=s[i]&&s[j+cnt]!=s[j])sum--;
			int op1=0,op2=0,op3=0;
			if(s[j]=='R'||s[i]=='R')op1++;
			if(s[j]=='B'||s[i]=='B')op2++;
			if(s[j]=='G'||s[i]=='G')op3++;
			if(op1==0)sum+=numr[j];
			else if(op2==0)sum+=numb[j];
			else if(op3==0)sum+=numg[j];
			j++;
		}

	
	//	cout<<sum<<endl;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3688
# -*- coding: utf-8 -*-
import random
random.seed(0)

D = int(input())
C = list(map(int, input().split()))
list_S = [list(map(int, input().split())) for _ in range(D)]

answer = []
L = [0 for _ in range(26)]
for S in list_S:
  contest_index = -1
  contest_manzoku = -10**9
  for i in range(26):
    i_manzoku = S[i]+C[i]+L[i]
    if i_manzoku > contest_manzoku:
      contest_index = i
      contest_manzoku = i_manzoku
  answer.append(contest_index)
  for i in range(26):
    if i==contest_index:
      L[i] = 0
    else:
      L[i] += C[i]

def manzoku(A):
  score = 0
  L = [0 for _ in range(26)]
  for i in range(D):
    contest_index = A[i]
    for j in range(26):
      if j==contest_index:
        L[j] = 0
        score += list_S[i][contest_index]
      else:
        L[j] += C[j]
        score -= L[j] 
  return score

manzoku_now = manzoku(answer)
answer_tmp = [answer[i] for i in range(D)]
day = -1
for _ in range(20000):
  day = (day+1)%D
  contest = random.randrange(26)
  answer_tmp[day] = contest
  manzoku_tmp = manzoku(answer_tmp)
  if manzoku_now < manzoku_tmp:
    manzoku_now = manzoku_tmp
    answer[day] = contest
  else:
    answer_tmp[day] = answer[day]

for index in answer:
  print(index+1)

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

using namespace std;

int main() {

  int n = 0;

  cin >> n;

  int nac = 0;
  int nwa = 0;
  int ntle = 0;
  int nre = 0;

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;

    if (!s.compare("AC")) nac++;
    if (!s.compare("WA")) nwa++;
    if (!s.compare("TLE")) ntle++;
    if (!s.compare("RE")) nre++;
  }

  printf("AC x %d\n", nac);
  printf("WA x %d\n", nwa);
  printf("TLE x %d\n", ntle);
  printf("RE x %d\n", nre);

  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    int h, n, A=0;
    cin >> h >> n;
    rep(i, n){
        int a;
        cin >> a;
        A += a;
    }
    if(h <= A){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) (x & -x)
using namespace std;

const int _ = 3e5 + 10;
int N, M, d;
struct node {
	int l, r, len;
} a[_];

struct BIT {
	int c[_];
	void insert(int x, int y) {
		for ( ; x <= M + 1; x += lowbit(x)) c[x] += y;
	}
	int query(int x) {
		int y = 0;
		for ( ; x; x -= lowbit(x)) y += c[x];
		return y;
	}
} tr;

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i) {
		scanf("%d%d", &a[i].l, &a[i].r);
		a[i].len = (a[i].r - a[i].l + 1);
	}
	sort(a + 1, a + N + 1,
			 [](node a, node b) -> bool { return a.len < b.len; });
	for (int d = 1, p = 1; d <= M; ++d) {
		while (p <= N && a[p].len <= d) {
			tr.insert(a[p].l, 1);
			tr.insert(a[p].r + 1, -1);
			++p;
		}
		int ans = N - p + 1;
		for (int i = d; i <= M; i += d)
			ans += tr.query(i);
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4864
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

int main()
{
  int n,k;
  cin >> n >> k;
  if(n%k==0){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }

  return 0;
}

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

using namespace std;

#define ll long long int
const int mod = 1e9 + 7;

const ll INF = 1e18L + 5;


int main() {
    //code
    ll n,w;
    cin>>n>>w;
    vector<ll> weight(n), value(n);
    ll max_value = 0L;

    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
        max_value += value[i];
    }

    vector<ll> dp(max_value+1,INF);
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(ll j = (max_value - value[i]);j>=0;j--){
            dp[j+value[i]] = min(dp[j+value[i]],dp[j]+weight[i]);
        }
    }
    ll answer = 0;
    for(int i=0;i<=max_value;i++){
        if(dp[i]<=w){
            answer = i;
        }
    }

    printf("%lld",answer);
    return 0;
}

Measured memory_bytes: 3980
#include <stdio.h>

void sort( int *);

int main(void)
{
	int			n,w,a,b;
	int			array[30];
	int			i,s;
	
	for(i=0; i<30; i++)		 array[i] = i+1;
	
	scanf("%d",&w);
	scanf("%d",&n);
		
	for(i=0; i<n; i++){
		sort(array);
	}
	for(i=0;i<w;i++){
		printf("%d\r\n", array[i]);
	}
	return 0;
}


void sort(int *array){
	int a,b, i;
	int s;
	
	scanf("%d, %d",&a, &b);	
	--a;
	--b;	
	s = *(array+a);
	*(array+a) = *(array+b);
	*(array+b) = s;

	return;
}

Measured memory_bytes: 596
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N, M = map(int,input().split())
cities = []
for i in range(M):
    p, y = map(int,readline().split())
    temp = [p, y, i]
    cities.append(temp)
id = [1 for i in range(N)] #国i+1の都市に対して次に割り振るべきID
sortedcities = sorted(cities, key=lambda x:x[1])
for i in range(M):
    sortedcities[i].append(id[sortedcities[i][0]-1])
    id[sortedcities[i][0]-1] += 1
originalcities = sorted(sortedcities, key=lambda x:x[2])
for i in range(M):
    write(str(originalcities[i][0]).zfill(6) + str(originalcities[i][3]).zfill(6) + "\n")

Measured memory_bytes: 33392
from collections import deque
H, W = map(int, input().split())
MASUlist = [input() for _ in range(H)]
MASU = [[0 for i in range(W)]for j in range(H)]
white = 0
for i in range(H):
    S = MASUlist[i]
    for j in range(W):
        if S[j] == "#":
            MASU[i][j] = 1
        else:
            MASU[i][j] = 0
            white += 1
MASU[H-1][W-1] = 2
d = deque()
d.append([0, 0])
dx_dy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
looked = [[0 for i in range(W)]for j in range(H)]
looked[0][0] = 1

while d:
    x = d.popleft()
    lookx = x[0]
    looky = x[1]
    for i in dx_dy:
        a = lookx+i[0]
        b = looky+i[1]
        if not(0 <= a < H) or not(0 <= b < W) or MASU[a][b] == 1 or looked[a][b] != 0:
            continue
        d.append([a, b])
        looked[a][b] = looked[lookx][looky]+1

ans = looked[H-1][W-1]
if ans == 0:
    print(-1)
else:
    print(white-ans)


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

int main() {
  string s;  cin>>s;
  bool ans = true;
  rep(i, s.size()) {
    if (i%2 == 0) {
      if (s[i] == 'L') ans = false;
    }
    else {
      if (s[i] == 'R') ans = false;
    }
  }
  cout<<(ans ? "Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  double min,max;
  double differ;
  double height;
  scanf("%lf",&height);
  min = height;
  max = height;
  while(scanf("%lf",&height)!=EOF){
    if(min > height){
      min = height;
    }else if(max < height){
      max = height;
    }
  }
  differ = max - min;
  printf("%lf\n",differ);
  return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
	int N;
	cin >> N;
	map<int, int> D;
	rep(i, N) {
		int d; cin >> d;
		D[d]++;
	}

	int cnt = 0;
	int M;
	cin >> M;
	rep(i, M){
		int t; cin >> t;
		if(D.count(t) == 0) continue;
		if(D[t] > 0){
			D[t]--;
			cnt++;
		}
	}

	Cout(YES(cnt == M));
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <math.h>
#include <chrono>
using namespace std;
#pragma GCC optimize("-O3")
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10) //cin.tie(0); cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define what(x) cerr << #x << " is " << x << endl;

vector<int> org;
vector<int> poczatki;
vector<vector<int>> D;
int n, k, q;

main()
{
    _upgrade;
    cin >> n >> k >> q;
    org.resize(n);
    rep(i, n) cin >> org[i];
    poczatki = org;
    poczatki.pb(-12);
    sort(all(poczatki));

    int ans = 2e9;
    for (int l : poczatki)
    {
        vector<int> X;
        rep(i, n)
        {
            if (org[i] <= l)
            {
                if (X.size() > 0)
                {
                    D.pb(X);
                    X.clear();
                }
            }
            else
                X.pb(org[i]);
        }

        if (X.size() > 0)
        {
            D.pb(X);
            X.clear();
        }

        for (auto &W : D)
        {
            sort(all(W));
            rep(j, k - 1)
            {
                if (W.empty())
                    break;
                W.pop_back();
            }
            for (int a : W)
                X.pb(a);
        }

        sort(all(X));

        if (X.size() >= q)
        {
            ans = min(ans, X[q - 1] - X[0]);
            //cerr << X[q - 1] << " " << X[0] << endl;
        }
        D.clear();
    }
    cout << ans << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;




int32_t main()
{
    
    IOS
    int h,a;
    cin>>h>>a;
    cout<<ceil((1.0*h)/a)<<'\n';


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(a*n<=b) cout<<a*n<<endl;
    else cout<<b<<endl;
}

Measured memory_bytes: 256
H,W,D=map(int,input().split())
A=[map(int,input().split())for _ in range(H)]
Q=int(input())
L=[map(int, input().split())for _ in range(Q)]
d=[None for _ in range(H*W)]
for i,l in enumerate(A):
 for j,v in enumerate(l):d[v-1]=(i, j)
e=[0for _ in range(H*W)]
for i in range(H*W):
 if i>=D:e[i]=sum(abs(p-q)for p,q in zip(d[i-D],d[i]))+e[i-D]
for l,r in L:print(e[r-1]-e[l-1])

Measured memory_bytes: 62024
import math
N, P = map(int,input().split())
A = list(map(int,input().split()))
B = [e%2 for e in A]
ans = pow(2,B.count(0))
def nCr(n,r):
    return (math.factorial(n)//(math.factorial(r)*math.factorial(n-r)))
t = 0
for k in range(B.count(1)+1):
    if k%2 == 0:
        t += nCr(B.count(1),k)
print(ans*t if P == 0 else pow(2,N)-ans*t)


Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
#define FOR(i,a,n) for(int i=a;i<(n);++i)
inline void read(int &x){
	x=0;char ch=getchar();
	while(ch<'0')ch=getchar();
	while(ch>='0'){
		x=x*10+ch-48;
		ch=getchar();
	}
}
const int N=1e5;
int x[N];
int main(){
	int n,a,b;read(n);read(a);read(b);
	long ans=0;
	read(x[0]);
	FOR(i,1,n){
		read(x[i]);
		ans+=((long)a*(x[i]-x[i-1])>b)?b:(long)a*(x[i]-x[i-1]);
	}
	printf("%ld\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = numeric_limits<ll>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

ll K[4100][4100],x[4100][4100];
ll sum[4100];

//i~j??????
ll sum_w(int i,int j){
  return sum[j]-sum[i-1];
}

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

  int n;
  cin >> n;
  ll w[n+1];
  for(int i=1;i<=n;i++){
    cin >> w[i];
  }
  sum[0]=0;
  for(int i=1;i<=n;i++){
    sum[i]=sum[i-1]+w[i];
  }
  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      K[i][j]=0;
    }
  }
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j){
      x[i][j] = 99999999;
      x[i][i] = 0;
      K[i][i] = i;
    }
  }
  for(int k=1;k<n;k++){
    for(int i=1;i+k<=n;i++){
      int j=i+k;
      ll tmp = INF;
      for(ll r=K[i][j-1];r<=K[i+1][j];r++){
        ll c=x[i][r] + x[r+1][j]+sum_w(i,j);
        if(c<=tmp){
          tmp=c;
          K[i][j]=r;
        }
      }
      x[i][j]=tmp;
    }
  }
  cout << x[1][n] << endl;
}

Measured memory_bytes: 259528
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, L;
    cin >> N >> L;
    vector<string> v(N);
    REP(i, N) {
        cin >> v[i];
    }
    SORT(v);
    REP(i, N) {
        cout << v[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class ATwoIntegers {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int64_t x, y;
    cin >> x >> y;
    if (x % y == 0)cout << -1 << endl;
    else cout << x << endl;
  }
};


int main() {
    ATwoIntegers solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for (auto &r : a) {
    for (auto &e : r) {
      cin >> e;
    }
  }

  vector<pair<pair<int, int>, pair<int, int>>> v;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (a[i][j] % 2) {
        v.push_back({{i, j}, {i, j + 1}});
        a[i][j]--;
        a[i][j + 1]++;
      }
    }
  }
  for (int i = 0; i < h - 1; i++) {
    if (a[i][w - 1] % 2) {
      v.push_back({{i, w - 1}, {i + 1, w - 1}});
      a[i][w - 1]--;
      a[i + 1][w - 1]--;
    }
  }

  cout << v.size() << endl;
  for (auto e : v) {
    auto s = e.first, d = e.second;
    cout << s.first + 1 << " " << s.second + 1 << " " << d.first + 1 << " " << d.second + 1 << endl;
  }
}

Measured memory_bytes: 5232
#!/usr/bin/env python3
A, B, K = map(int, input().split())
for i in range(K):
    if i % 2 == 0:
        A = (A - A % 2) // 2
        B += A
    else:
        B = (B - B % 2) // 2
        A += B
print(A, B)


Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

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

#define forn(i, a, n) for (int i = (a); i < (int)n; i++)
#define trav(x, arr) for (auto &x : arr)
#define sz(x) (int)x.size()
#define Matrix(m, h, w) = std::vector<vector<int>> m(h, vector<int> (w)); 
using ll = long long;

#define vi vector<int>
#define vl vector<long>
#define vll vector<ll>

// benq
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;


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


    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    if (a == 0)
    	cout << 1;
    else if (b == 0)
    	cout << 2;
    else if (c == 0)
    	cout << 3;
    else if (d == 0)
    	cout << 4;
    else
    	cout << 5;

    return 0;
}

Measured memory_bytes: 3580
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const x = readMany(5).map(it => parseInt(it))
    for (let i = 0; i < x.length; i += 1) {
        if (x[i] == '0') return console.log(i + 1)
    }
})()


Measured memory_bytes: 29700
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

string replace_all(string s, string &t, string &u){
    int i = 0;
    while((i = s.find(t, i)) != string::npos){
        s.replace(i, t.size(), u);
        i += u.size();
    }
    return s;
}

int n;
pair<string, string> p[15];
string s, t;

int bfs(){
    queue<pair<string, int>> que;
    map<string, int> mp;
    mp[s] = 0;
    que.emplace(s, 0);
    while(!que.empty()){
        string a; int d;
        tie(a, d) = que.front(); que.pop();
        if(a == t) return d;
        if(a.size() >= t.size()) continue;
        rep(i, n){
            string tmp = replace_all(a, p[i].fi, p[i].se);
            if(mp.find(tmp) == mp.end()){
                mp[tmp] = d+1;
                que.emplace(tmp, d+1);
            }
        }
    }
    return -1;
}

int main(){
    while(scanf("%d", &n) && n){
        rep(i, n) cin >> p[i].fi >> p[i].se;
        cin >> s >> t;
        printf("%d\n", bfs());
    }
}


Measured memory_bytes: 3616
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] Args) throws  IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String string = br.readLine();
        boolean es = true;
        if(n % 2 != 0){
            es = false;
        }
        else{
            for(int i = 0; i < n/2; i++){
                if(string.charAt(i) != string.charAt(i+ (n/2))){
                    es = false;
                }
            }
        }

        if(es){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        br.close();
    }
}

Measured memory_bytes: 21204
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    cin >> s[i];
  }
  debug(s);
  vector<vector<int>> dp(H, vector<int>(W));
  int right = 0;
  int down = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i == 0 && j == 0) {
        if (s[0][0] == '#')
          dp[0][0] = 1;
        else
          dp[0][0] = 0;
      } else if (i == 0) {
        if (s[i][j - 1] == '.' && s[i][j] == '#')
          right = dp[i][j - 1] + 1;
        else
          right = dp[i][j - 1];
        dp[i][j] = right;
      } else if (j == 0) {
        if (s[i - 1][j] == '.' && s[i][j] == '#')
          down = dp[i - 1][j] + 1;
        else
          down = dp[i - 1][j];
        dp[i][j] = down;
      } else {
        if (s[i][j - 1] == '.' && s[i][j] == '#')
          right = dp[i][j - 1] + 1;
        else
          right = dp[i][j - 1];
        if (s[i - 1][j] == '.' && s[i][j] == '#')
          down = dp[i - 1][j] + 1;
        else
          down = dp[i - 1][j];
        dp[i][j] = min(right, down);
      }
    }
  }
  debug(dp);
  cout << dp[H - 1][W - 1] << endl;
  return 0;
}

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

int main() {
    int x, n;
    cin >> x >> n;
    int y;
    vector<int>num;
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
      
        cin >> y;
        num.push_back(y);
    }
    auto s = find(num.begin(), num.end(), x);
    if (s == num.end()) {
        cout << x << endl;
        return 0;
    }
    int l = x-1;
    int g = x + 1;
    while (1) {
        auto r = find(num.begin(), num.end(), l);
        auto q = find(num.begin(), num.end(), g);
        if (r == num.end() ) {
            cout << l << endl;
            return 0;
        }
        if (q == num.end()) {
            cout << g << endl;
            return 0;
        }
        l = l - 1;
        g = g + 1;
    }
    return 0;
    
  
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

class Edge {
    unsigned long long counter = 0;
};


int main()
{
    int n;
    std::cin >> n;
    double denom = 0;

    for (size_t i = 0; i < n; i++)
    {
        double a;
        cin >> a;
        denom += 1.0 / a;
    }

    cout << 1.0 / denom << endl;




}




Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {
	def main(args: Array[String]) = {
		val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toLong)
    println( f"${a/b}%d ${a%b}%d ${a.toDouble/b.toDouble}%.5f" )
  }
}

Measured memory_bytes: 44036
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007, MAX = 500000;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n, k; cin >> n >> k;
  ll mn, mx;

  COMinit();

  mn = max(1LL, n - k);
  mx = n;

  modint<MOD> ans(0);
  rep2(i, mn, mx) {
    ans += COM(n, i) * COM(n-1, i-1);
  }

  cout << ans.value() << endl;
  
  return (0);
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
main()
{
	int n;
	cin>>n;
	
	vector<long long> v(n);
	
	for(int i=0;i<n;i++)
	cin>>v[i];
	
	long long dp[n+1][n+1]={0},dp2[n+1][n+1]={0};
	
	for(int i=0;i<n;i++)
	dp[i][i]=v[i];
	
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<n-i+1;j++)
		{
			dp[j][j+i-1]=1e18,dp2[j][j+i-1]=1e18;
			for(int k=j+1;k<=j+i-1;k++)
			{
				dp[j][j+i-1]=min(dp[j][j+i-1],dp[j][k-1]+dp[k][j+i-1]);
				
				/*if(dp[j][j+i-1]>dp[j][k-1]+dp[k][j+i-1])
				{
					dp[j][j+i-1]=dp[j][k-1]+dp[k][j+i-1];
					dp2[j][j+i-1]=dp2[j][k-1]+dp2[k][j+i-1]+dp[j][j+i-1];
				}*/
				
				dp2[j][j+i-1]=min(dp2[j][j+i-1],dp2[j][k-1]+dp2[k][j+i-1]+dp[j][k-1]+dp[k][j+i-1]);
			}
		}
	}
	
	cout<<dp2[0][n-1];
	
	/*long long ans=0;
	
	for(int i=n-1;i>0;i--)
	{
		long long hi=1e15,pos;
		
		for(int j=0;j<i;j++)
		{
			if(v[j]+v[j+1]<hi)
			{
				hi=v[j]+v[j+1];
				pos=j;
			}
		}
		
		v[pos]=hi;
		
		for(int j=pos+1;j<i;j++)
		{
			v[j]=v[j+1];
		}
		
		ans+=hi;
	}*/
}

Measured memory_bytes: 2816
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
ans = 1
num_list = [0] * (N + 1)
for n in range(2, N+1):
    for i in range(2, 10 ** 3 + 1):
        while n % i == 0:
            num_list[i] += 1
            n //= i
for i in num_list:
    ans *= (i+1)
    ans %= MOD
print(ans)



Measured memory_bytes: 5404
#include <iostream>
using namespace std;
#define FAIL { cout << "0\n"; return 0; }
#define active(i,k) ((i)&(1<<(k)))

int main() {
    int N, t, a[24] = {}, i;
    cin >> N;
    a[0] = 1;
    for (i = 0; i < N; i++) {
        cin >> t;
        if (a[t]) {
            t = (24-t)%24;
            if (a[t]) FAIL;
        }
        a[t]++;
    }

    int R = 0;
    for (i = 0; i < 4096; i++) {
        int j = 0, k = 1, r = 24;

        for (int l = 1; l < 12; l++) {
            // if a[l] is inverted and a[24-l] exists
            if (active(i, l) && a[24-l]) r = 0;
        }

        // find next k that is ACTIVATED
        while (k < 24) {
            // k is activated if:
            // + k >= 12: a[k] exists OR inverted is active
            // + k < 12: a[k] exists AND not inverted

            for (;k < 24; k++) {
                if (k >= 12) {
                    if (a[k] || (a[24-k] && active(i, 24-k))) break;
                } else {
                    if (a[k] && !active(i, k)) break;
                }
            }
            if (k == 24) break;

            //printf("j,k: %d, %d\n", j, k);
            r = min(r, k-j);
            j = k++;
        }

        // check end
        r = min(r, 24-j);
        //printf("%d: %d\n", i, r);
        R = max(R, r);
    }
    cout << R << '\n';


}

Measured memory_bytes: 256
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A, B = map(int, input().split())
    print(max(A + B, A - B, A * B))

if __name__ == '__main__':
    main()


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

#define loop(i, a, b) for (long long i = (a); i < (b); ++i)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N) {
    vector<vector<int>> cnt(10001, vector<int>(5));
    loop (a, 1, 10001) {
        loop (b, a, 10001) {
            if (a * a + b * b + 1 * 1 + a * b + b * 1 + a * 1 > N) break;
            loop (c, b, 10001) {
                if (a * a + b * b + c * c + a * b + b * c + a * c > N) break;
                auto n = a * a + b * b + c * c + a * b + b * c + a * c;
                auto idx = (a == b) + (b == c) + (a == c);
                cnt[n][idx]++;
            }
        }
    }

    loop (i, 1, N+1) {
        cout << cnt[i][0] * 6 + cnt[i][1] * 3 + cnt[i][3] << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3992
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <iostream>
#include <algorithm>
#define mt(a) memset(a,0,sizeof(a))
#define ll long long
using namespace std;
int main(void)
{
	int n,c,k;
	int p[200005];
	mt(p);
	cin>>n>>c>>k;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	sort(p+1,p+1+n);
	ll ans = 1;
	int t = 1;
	int sum = 1;
	for(int i=2;i<=n;i++)
	{
		if(p[i]<=p[t]+k&&sum<c)
		{
			sum++;
		}
		else
		{
			sum = 1;
			ans++;
			t = i;
		}		
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;

class Program{
 static void Main(string[] args){
   var str=Console.ReadLine();
   var set=new HashSet<char>();
   var isPri=true;
   for(var i=0;i<str.Length;i++){
     if(set.Contains(str[i])){
      isPri=false;break; 
     }
     set.Add(str[i]);
   }
   Console.WriteLine(isPri?"yes":"no");
 }
}

Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		System.out.println(solve(n));
		in.close();
	}

	private static String solve(int n) {
		for (int a = 1; a < 10; a++)
			if (n % a == 0 && n / a < 10)
				return "Yes";
		return "No";
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int length = S.Length;
            int ans = 1;
            char prev = S[0];
            int prev_length = 1;
            for (var i = 1; i < length; i++)
            {
                if (prev_length > 1)
                {
                    prev = S[i];
                    prev_length = 1;
                    ans++;
                }
                else
                {
                    if (S[i] != prev)
                    {
                        prev = S[i];
                        prev_length = 1;
                        ans++;
                    }
                    else
                    {
                        if (i == length-1)
                        {
                        }
                        else
                        {
                            //prev = S[i];
                            prev_length = 2;
                            i++;
                            ans++;
                        }
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 13664
using System;
using System.Collections.Generic;

namespace Topcoderhenomiti
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) return;
                AOJ201.solve(n);
            }
        }
    }

    class AOJ201
    {
        class item
        {
            public string name;
            public int v;
            public List<item> components;

            private int min_val = 0;

            public item()
            {
                components = new List<item>();
            }
            public int minVal()
            {
                if (min_val > 0)
                {
                    return min_val;
                }

                if (components.Count == 0)
                {
                    min_val = v;
                }
                else
                {
                    int sum = 0;
                    foreach (item i in components)
                    {
                        sum += i.minVal();
                    }
                    min_val = sum < v ? sum : v;
                }

                return min_val;
            }
        }
        public static void solve(int n)
        {
            char[] delimi = { ' ' };

            //item情報取得
            List<item> items = new List<item>(n);
            for (int i = 0; i < n; i++)
            {
                item a = new item();
                string[] str = Console.ReadLine().Split(delimi);
                a.name = str[0];
                a.v = int.Parse(str[1]);
                items.Add(a);
            }

            //レシピ取得
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                string[] str = Console.ReadLine().Split(delimi);
                foreach (item it in items)
                {
                    if (it.name == str[0])
                    {
                        for (int j = 2; j < str.Length; j++)
                        {
                            foreach (item in_it in items)
                            {
                                if (in_it.name == str[j])
                                {
                                    it.components.Add(in_it);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }

            //解答
            string hoge = Console.ReadLine();
            foreach (item it in items)
            {
                if (it.name == hoge)
                {
                    Console.WriteLine(it.minVal());
                }
            }
        }
    }
}

Measured memory_bytes: 5848
H,N = input().split()
A = input().split()
H = int(H)
N = int(N)
Aintlist = [int(s) for s in A]
sumdata = 0
for i in range(0,len(Aintlist)):
    sumdata += Aintlist[i]

if sumdata >= H:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 13788
import java.util.Scanner
object Main {

  def main(args: Array[String]){
    val sc = new Scanner(System.in)

    val t = sc.nextLine().toInt
    val A = sc.nextLine().split(" ").map(_.toInt)

    def two_index(n:Int): Int = {
      var idx = 0
      var num = n
      while (num % 2 == 0){
        num = num / 2
        idx = idx + 1
      }
      return idx
    }
    
    val two_index_obj = two_index _ 
    println(A.map(two_index_obj).min)
  }
}


Measured memory_bytes: 25672
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

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

  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> a(n+1);
  for(ll i = 0; i < m; i++){
    ll A, B;
    cin >> A >> B;
    a[A].pb(B);
  }

  for(ll i = 0; i < a[1].size(); i++){
    for(ll j = 0; j < a[a[1][i]].size(); j++){
      if(a[a[1][i]][j] == n){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

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

using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;


int main()
{
    fio;
    int A, B, C;
    cin >> A >> B >> C;
    swap(A, B);
    swap(A, C);
    cout << A << ' ' << B << ' ' << C << endl;
    cerr << "Time : " << (double) clock() / (double) CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'S'){
            ans = max(ans, cnt);
            cnt = 0;
        }
        else{
            cnt++;
            ans = max(ans, cnt);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
function main(input) {
  const inputs = input.trim().split('\n');
  var input1 = inputs[0].split(' ');
  var A = input1[0].split('').reverse();
  var B = input1[1];

  var B1 = B.split('.')[0] - 0;
  var B2 = B.split('.')[1].split('').reverse();

  var temp = Array(A.length + 2 + 1);
  var tempLength = temp.length;

  for (var i = 0; i < tempLength; i++) {
    temp[i] = 0;
  }

  var multi = '';
  for (var i = 0; i < B2.length; i++) {
    for (var j = 0; j < A.length; j++) {
      multi = ('' + ((B2[i] - 0) * (A[j] - 0))).split('').reverse();
      for (var k = 0; k < multi.length; k++) {
        temp[tempLength - i - j - k - 1] += (multi[k] - 0);
        for (var l = tempLength - 1; l >= 0; l--) {
          if (temp[l] >= 10) {
            temp[l] -= 10;
            temp[l - 1] += 1;
          }
        }
      }
    }
  }

  var multi = '';
  for (var i = 0; i < A.length; i++) {
    multi = ('' + (B1 * (A[i] - 0))).split('').reverse();
    for (var k = 0; k < multi.length; k++) {
      temp[tempLength - 2 - i - k - 1] += (multi[k] - 0);
      for (var l = tempLength - 1; l > 0; l--) {
        if (temp[l] >= 10) {
          temp[l] -= 10;
          temp[l - 1] += 1;
        }
      }
    }
  }

  temp = temp.slice(0, -2);

  var cont = true;
  while (cont) {
    if (temp[0] == 0) {
      temp = temp.slice(1);
    } else {
      cont = false;
    }
  }

  if (temp.length == 0) {
    temp.push(0);
  }

  console.log(temp.join(''));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29648
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let O = read_String_Vec();
    let E = read_String_Vec();

    let mut S = Vec::new();
    let len = E.len();
    for n in 0..len {
        S.push(O[n]);
        S.push(E[n]);
    }
    if O.len() != E.len() {
        S.push(O[len]);
    }
    println!("{}", vecchar_to_String(S));

}


Measured memory_bytes: 4352
using System;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');

		int x = int.Parse(input[0]);
		int y = int.Parse(input[1]);

		Console.WriteLine(GetGCD(x, y));
	}

	static int GetGCD(int x, int y)
	{
		if (x < y)
		{
			int buf = x;
			x = y;
			y = buf;
		}

		return (x % y == 0) ? y : GetGCD(y, x % y);

	}
}


Measured memory_bytes: 17932
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;



int main()
{
    int N;
    int c=0;
    while(cin>>N)
    {
        c++;
        if(N==0) break;
        vector<vector<int> > res(N,vector<int>(N,0));
        int dx = -1;
        int dy = 1;
        int x = 0, y = 0;
        for(int c=1;c<=N*N;c++)
        {
            res[x][y] = c;
            x+=dx;
            y+=dy;
            if(x < 0 || y < 0 || x == N || y == N)
            {
                dx *=-1;
                dy *=-1;
            }
            if(x == N)
            {
                x--;
                y+=2;
            }
            else if(y == N)
            {
                y--;
                x+=2;
            }
            else if(x < 0)
                x++;
            else if(y < 0)
                y++;


        }
        cout<<"Case "<<c<<":"<<endl;
        for(int c=0;c<N;c++,cout<<endl) for(int c2=0;c2<N;c2++) cout<<(res[c][c2]<10?" ":"")<<(res[c][c2]<100?" ":"")<<res[c][c2];
    }
    return 0;
}

Measured memory_bytes: 1224
S = input()
def check(s):
    count=0
    large=True
    for i in s[2:-1]:
        if i == 'C':
            count+=1
        elif i.isupper():
            large=False
    return (count==1) & (large) & (s[1].islower()) & (s[-1].islower())

if (S[0]=='A') & check(S):
    print('AC')
else:
    print('WA')


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

int main() {
  string x, y;
  cin >> x >> y;

  if (x < y) {
    cout << "<" << endl;
  }
  else if (x > y) {
    cout << ">" << endl;
  }
  else {
    cout << "=" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;i++);
using namespace std;

int syc(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int start;
	int i;
	int a[20];
	int b[20];
	int c[20];
	int sum = 0;
	cin  >> start;
	
	syc(start,2,20);
	
	for(i=0;i<start;i++){
		cin >> a[i];
	}
	
	for(i=0;i<start;i++){
		cin >> b[i];
	}
	
	for(i=0;i<start-1;i++){
		cin >> c[i];
	}
	
	for(i=0;i<start;i++){
		sum += b[a[i]-1];
		if(i!=0 && a[i]-a[i-1] == 1){
			sum += c[a[i-1]-1];
		}
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[][] A = new int[2][N];
        int[] sum = new int[N];
        long sum1 = 0;
        for(int i = 0; i < N; i++){
            A[0][i] = sc.nextInt();
            A[1][i] = sc.nextInt();
            sum[i] = A[0][i]+A[1][i];
            sum1 += A[0][i];
        }
        sc.close();
        Arrays.sort(sum);
        for(int i = N-2; i >= 0; i-=2){
            sum1 -= sum[i];
        }
        System.out.println(sum1);
    }
}

Measured memory_bytes: 91088