akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;

	while(cin >> n, n) {
		vector<int> v1, v2;
		int count = 0;

		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			v1.push_back(tmp);
		}

		while(1) {
			count++;
			for(int i = 0; i < n; i++) {
				int tmp = 0;
				for(int j = 0; j < n; j++) {
					if(v1[i] == v1[j])
						tmp++;
				}
				v2.push_back(tmp);
			}

			if(v1 == v2)
				break;
			v1 = v2;
			v2.clear();
		}

		cout << count - 1 << endl;
		cout << v1[0];
		for(int i = 1; i < n; i++)
			cout << " " << v1[i];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<vector<ll>> count(27, vector<ll>(n, 0));
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        for(char c : s){
            count.at(c - 'a').at(i)++;
        }
    }

    vector<ll> mincount(27);
    for(int j = 0; j < 27; ++j){
        mincount.at(j) = *min_element(count.at(j).begin(), count.at(j).end());
    }

    string ans;
    for(int i = 0; i < 27; ++i){
        for(int j = 0; j < mincount.at(i); ++j){
            ans.push_back('a' + (char)i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception{
		// TODO ?????????????????????????????????????????????
			String a1,a2;
			int al;
			Scanner sc = new Scanner(System.in);
			String a = sc.next();
			int b = sc.nextInt();
			al = a.length();
			
			for(int c=0;c<b;++c){
				String d = sc.next();
				if(d.equals("replace")){
					int e = sc.nextInt();
					int f = sc.nextInt();
					String g = sc.next();
					a1 = a.substring(0, e);
					a2 = a.substring(f+1, al);
					a = a1 + g + a2;
				}
				if(d.equals("reverse")){
					int e = sc.nextInt();
					int f = sc.nextInt();
					a1 = a.substring(0, e);
					a2 = a.substring(f+1, al);
					for(f=f;f>=e;f-=1){
						a1 = a1 + a.substring(f,f+1);
					}
					a = a1+a2;
				}
				if(d.equals("print")){
					int e = sc.nextInt();
					int f = sc.nextInt();
					a1 = a.substring(e,f+1);
					System.out.println(a1);
				}
			}
	}

}

Measured memory_bytes: 61920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// int N = 3;
		// int[] A = { 24, 16, 24 };

		Scanner scan = new Scanner(System.in);

		int N = Integer.parseInt(scan.next());

		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(scan.next());
		}

		scan.close();

		int i = 0;
		boolean volid = true;
		while (true) {
			for (int j = 0; j < A.length; j++) {
				if (A[j] % 2 != 0) {
					volid = false;
					break;
				}
				A[j] = A[j] / 2;
			}
			if (!volid) {
				break;
			}
			i += 1;
		}
		System.out.println(i);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    int n, m;
    cin >> n >> m;
    if (n == m){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 256
import sys

def main():
  n, k, *h = map(int, sys.stdin.read().split())
  dp = [float("inf")] * n
  dp[0] = 0
  for i in range(1, n):
    if i < k:
      dp[i] = min([ dpj+abs(hj-h[i]) for dpj, hj in zip(dp[:i], h[:i]) ])
    else:
      dp[i] = min( [ dpj+abs(hj-h[i]) for dpj, hj in zip(dp[i-k:i], h[i-k:i]) ] )
  print(dp[n-1])
  
if __name__ == "__main__":
  main()

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

int	main()
{
	int		N, A, B;
	int		count, ret, sum, lim, i = 0;
	char	*S;

	scanf("%d %d %d\n", &N, &A, &B);
	lim = A + B;
	count = 0;
	sum = 0;
	S = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s\n", S);
	while (i < N)
	{
		ret = 0;
		if (S[i] == 'a')
		{
			if (sum < lim)
				ret = 1;
		}
		else if (S[i] == 'b')
		{
			if (sum < lim)
			{
				if (count < B)
				{
					ret = 1;
					count++;
				}
			}
		}
		if (ret && ++sum)
			printf("Yes\n");
		else
			printf("No\n");
		i++;
	}
	return (0);
}

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

using namespace std;

const int MoneyTable[] = { 0,6000,4000,3000,2000 };

int main() {
	int t, n;

	for (int i = 0; i < 4; ++i) {
		cin >> t >> n;
		cout << (n*MoneyTable[t]) << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3096
function Main(input){
    input = input.split("");
	var n = (input.length-1)/2;
	var mini = input.slice(0,n);
	var flag = true;
	for(var i=0;i<input.length;i++){
		if(input[i]!=input[input.length-i-1]) flag = false;
	}
	for(i=0;i<Math.ceil(mini.length/2);i++){
		if(mini[i]!=mini[mini.length-i-1]) flag = false;
	}
	mini = input.slice(n+1,input.length)
		for(i=0;i<Math.ceil(mini.length/2);i++){
		if(mini[i]!=mini[mini.length-i-1]) flag = false;
	}
	if(flag){
		console.log("Yes");
	}else{
		console.log("No")
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    ans = [0] * N
    con = [deque() for _ in range(N)]

    for _ in range(N - 1):
        p, c = map(int, input().split())
        con[p-1].append(c-1)
        con[c-1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1] += v

    stacks = deque()
    stacks.append((0, -1))

    while stacks:
        stack = stacks.pop()
        node, parent = stack[0], stack[1]

        children = con[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stacks.append((child, node))

    print(*ans)


if __name__ == '__main__':
    main()


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

#define MOD 1000000007LL

long long b[222222],w[222222];

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

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<222222;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;
}

long long MODpow(long long a,int b){
	if(b==0)return 1;
	if(b%2==0){
		long long t=MODpow(a,b/2);
		return (t*t)%MOD;
	}
	return (a*MODpow(a,b-1))%MOD;
}

int main(){
	int B,W;
	cin >> B >> W;
	
	COMinit();
	
	for(int i=0;i<B+W;i++){
		if(i>0){
			b[i]=(b[i-1]+COM(i-1,B-1)*MODpow(inv[2],i))%MOD;
			w[i]=(w[i-1]+COM(i-1,W-1)*MODpow(inv[2],i))%MOD;
		}
		printf("%lld\n",(((1LL-b[i]+w[i]+MOD)%MOD)*inv[2])%MOD);
	}
	
	return 0;
}

Measured memory_bytes: 10752
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N;
	while (N--) {
		string st; cin >> st;
		string aa; cin >> aa;
		for (int i = 0; i < st.size(); ++i) {
			char c = st[st.size() - 1 - i];
			if (c == 'A') {
				reverse(aa.begin(), aa.end());
			}
			else if (c == 'C') {
				rotate(aa.begin(), aa.begin() + 1, aa.end());
			}
			else if (c == 'M') {
				for (auto& ac : aa) {
					if (isdigit(ac))ac = (ac - '0' + 1) % 10 + '0';
				}
			}
			else if (c == 'P') {
				for (auto& ac : aa) {
					if (isdigit(ac))ac = (ac - '0' + 9) % 10 + '0';
				}
			}
			else if (c == 'E') {
				string from = aa.substr(0,aa.size() / 2);
				string to = aa.substr(aa.size()-aa.size() / 2,aa.size() / 2);
				if (aa.size() % 2)aa = to + aa[aa.size() / 2] + from;
				else aa = to + from;
			}
			else if (c == 'J') {

				rotate(aa.begin(), aa.begin() + aa.size()-1, aa.end());
			}
		}
		cout << aa << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint A(N);
    rep(i, N) cin >> A[i];

    map<int, int> cnt;
    rep(i, N) {
        cnt[A[i]]++;
    }
    ll sum = 0;
    for (auto& c : cnt) {
        sum += ll(c.second) * ll(c.second - 1) / 2;
    }

    rep(i, N) {
        ll ans = sum;
        ll c = cnt[A[i]];
        ans -= c * (c - 1) / 2;
        ans += (c - 1) * (c - 2) / 2;
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 9088
_n = int(input())

_map_list = []

for i in range(2):
  _input_row = list(map(int, input().split(" ")))
  _map_list.append(_input_row)

sum_list = []

for index_go_down in range(_n):
  buf_sum = sum(_map_list[0][:index_go_down+1]) + sum(_map_list[1][index_go_down:])
  sum_list.append(buf_sum)

print(max(sum_list))


Measured memory_bytes: 3060
from fractions import gcd


def solve(n, m, s, t):
    g = gcd(n, m)
    ng = n // g
    mg = m // g

    for h in range(g):
        if s[ng * h] != t[mg * h]:
            return -1
    return ng * mg * g


n, m = list(map(int, input().split()))
s = input()
t = input()
print(solve(n, m, s, t))


Measured memory_bytes: 5432
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.ns();
            int n = s.length();
            int done = 0;
            long ans = 0;
            for (int dist = 0; dist < n; dist++) {
                if (s.charAt(n - dist - 1) == 'B') {
                    ans += dist - done;
                    done++;
                }
            }
            out.println(ans);

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 25812
#include<bits/stdc++.h>
#define ll long long int
#define ipair pair<ll, ll>
#define debug(a, st, en){for(ll i = st; i <= en; i++){cout << a[i] << " "; } cout << endl;}
#define debuga(a) cout << #a << " = " << a << endl;
#define mp make_pair
#define pb push_back
#define is insert
#define endl "\n"
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define FORD(i, a, b) for(ll i = a; i >= b; i--)
#define EACH(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define cins(_x, a, b) {for(ll $i = a; $i <= b; $i++) cin >> _x[$i];}
#define EPS 0.0000000001
#define fl float
#define db double
#define MOD 1000000007
#define MAX 1000007

using namespace std;

ll n;

struct m {
    ll a, b;
};
bool comp(m a, m b) {
    return a.a + a.b > b.a + b.b;
}

vector<m> a;

int main() {
    cin >> n;
    ll s1 = 0, s2 = 0;
    FOR(i, 0, n-1) {
        m t;
        cin >> t.a >> t.b;
        a.pb(t);
    }

    sort(a.begin(), a.end(), comp);
    bool b = true;
    FOR(i, 0, n-1) {
        if(b) {
            s1 += a[i].a;
        } else {
            s2 += a[i].b;
        }
        b = !b;
    }
    cout << s1 - s2 << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n, k;
  cin >> n >> k;
  vector<string> v(k, "@");
  for(int i = 0; i < k; i++)
  {
    cin >> v[i];
  }

  while(true)
  {
    bool flag = true;
    for(string i : v)
    {
      if(to_string(n).find(i) != string::npos) flag = false;
    }
    if(flag)
    {
      cout << n << endl;
      return 0;
    }
    n++;
  }

}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	ans := 0
	for i := 0; i < n; i++ {
		x := iScan()
		ans += smaller(x, k-x) * 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    r = int(input())
    if r < 1200:
        print("ABC")
        exit()
    if r < 2800:
        print("ARC")
        exit()
    print("AGC")
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10292
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

ll a, b;

ll number(ll divide) {
  return b / divide - (a - 1) / divide;
}

int main()
{
  ll c, d, lcm;
  cin >> a >> b >> c >> d;

  lcm = (c / __gcd(c, d)) * d;
  cout << b - a + 1 - number(c) - number(d) + number(lcm) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out ="";
    int n = scanner.nextInt();
    for (int ii = 0; ii < n; ii++) {
      String a = scanner.next();
      String b = scanner.next();
      if (a.length() > 80 || b.length() > 80) {
        out += "overflow\n";
        continue;
      }
      BigInteger aa = new BigInteger(a);
      BigInteger bb = new BigInteger(b);
      BigInteger cc = aa.add(bb);
      if (cc.toString().length() > 80) {
        out += "overflow\n";
        continue;
      }
      out += cc + "\n";
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 17264
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces1197
gi = lambda : list(map(int,input().strip().split()))
a, b = gi()
if a == b:
	print(a + b)
else:
	print(max(a, b) * 2 - 1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
ll inf=1e+9+3;
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<pair<int,int>>> t(n);
    rep(i,m){
        int l,r,d;cin>>l>>r>>d;l--;r--;
        t[l].push_back({r,d});
        t[r].push_back({l,-d});
    }
    vector<ll> mp(n,-inf);
    rep(i,n){
        if(mp[i]!=-inf)continue;
        if(t[i].size()==0)continue;
        mp[i]=0;
        queue<ll> que;
        que.push(i);
        while(que.size()){
            ll l=que.front();que.pop();
            ll x=mp[l];
            rep(j,t[l].size()){
                ll r=t[l][j].first,d=t[l][j].second;
                if(mp[r]==-inf){
                    que.push(r);
                    mp[r]=x+d;
                }else{
                    ll rx=mp[r];
                    if(rx!=x+d){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  int count = 0;
  int max_count = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      count++;
      max_count = max(count, max_count);
    } else {
      count = 0;
    }
  }
  if (max_count >= 3) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main()
{
	int k,s;
	cin >> k >> s;

	int count=0;
	for (int i=0;i<=k;++i)
	{
		for (int j=0;j<=k;++j)
		{
			if ((s-i-j>=0)&&(s-i-j<=k))
			{
				++count;
			}
		}
	}
	cout << count << endl;


}



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

namespace ABC
{
    class ABC096A
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int TargetMonth = int.Parse(str[0]);//月
            int TargetDay = int.Parse(str[1]);//日

            int ans = CountTakahashi(TargetMonth, TargetDay);

            Console.WriteLine("{0}",ans);
        }

        static int CountTakahashi(int TargetMonth, int TargetDay)
        {
            int cnt = 0;
            for(int m = 1; m <= TargetMonth; ++m)
            {
                int maxDate = 31;
                if(m == TargetMonth) { maxDate = TargetDay; }
                for (int d = 1; d <= maxDate; ++d)
                {

                    if(m == 2 && d >= 29) { continue; }
                    if(m == 4 && d >= 31) { continue; }
                    if(m == 6 && d >= 31) { continue; }
                    if(m == 9 && d >= 31) { continue; }
                    if(m == 11 && d >= 31) { continue; }
                    if(m == d)
                    {
                        cnt++;
                        break;//一度見つかったらその月にはそれ以降高橋はない
                    }

                }
            }
            return cnt;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

bool dfs(vector<vector<int>> &gr, vector<pair<int, int>> &ans, int &t, int now, vector<bool> &chk){
  static int chkc = 0;
  chk.at(now) = true;
  chkc++;
  ans.at(now).first = t;
  for(auto i : gr.at(now)){
    if(chk.at(i) == true) continue;
    t++;
    dfs(gr, ans, t, i, chk);
  }
  t++;
  ans.at(now).second = t;
  // cerr << now << " " << chkc << endl;
  if(chkc == ans.size()) return true;
  else return false;
}

int main(){
  int n;
  cin >> n;
  vector<vector<int>> gr(n, vector<int>());
  // vector<bool> stc(n, false);
  vector<pair<int, int>> ans(n);
  rep(i, n){
    int aa, deg;
    cin >> aa >> deg;
    rep(j, deg){
      int a;
      cin >> a;
      a--;
      // stc.at(a) = true;
      gr.at(i).push_back(a);
    }
  }
  int t = 0;
  vector<bool> chk(n, false);
  while(1){
    int st = -1;
    rep(i, n){
      if(chk.at(i) == false){
        st = i;
        break;
      }
    }
    if(st == -1){
      cerr << "f" << endl;
      exit(1);
    }
    t++;
    bool end = dfs(gr, ans, t, st, chk);
    if(end == true) break;
  }
  rep(i, n){
    cout << i+1 << " " << ans.at(i).first << " " << ans.at(i).second << endl;
  }
  return 0;
}


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

int main(){
    string s;
    bool flag1, flag2;
    
    flag1 = flag2 = 0;
    cin >> s;
    int y = stoi(s);
    if(y % 100 <= 12 && y % 100 >= 1) flag2 = 1;
    if(y / 100 <= 12 && y / 100 >= 1) flag1 = 1;
    
    if(flag1 == 1 && flag2 == 1) cout << "AMBIGUOUS" << endl;
    else if(flag1 == 0 && flag2 == 1) cout << "YYMM" << endl;
    else if(flag1 == 1 && flag2 == 0) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int MOD=1000000007;
#define IOS() ios_base::sync_with_stdio(0); cin.tie(0);
typedef long long ll;

int main()
{
  IOS();
  string s;
  string t;
  cin>>s>>t;
  int ans=0;
  for (int i = 0; i < s.length(); ++i)
  {
       if(s[i]!=t[i])
          ans++;
  }
  cout<<ans<<endl;
return 0;
}

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

int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  int ans = 0;
  rep(i,N){
    if(s[i] == s[i+1]) continue;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    while(1){
        string s;
        cin >> s;
        if(s == "-"){ break; }
        ll m;
        cin >> m;
        REP(i, m){
            ll h;
            cin >> h;
            s = s.substr(h, s.size() - h) + s.substr(0, h);
        }
        cout << s << endl;
    }
    return 0;
}



Measured memory_bytes: 3216
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    long[] a = new long[k];
    for(int i=0;i<k;i++)a[i]=sc.nextLong();
    long[] l = new long[k+1];
    long[] r = new long[k+1];
    l[k]=2;
    r[k]=2;
    for(int i=k;i>0;i--){
      if(r[i]%a[i-1]==0||l[i]%a[i-1]==0||l[i]/a[i-1]<r[i]/a[i-1]){
        l[i-1]=(long)Math.ceil((double)l[i]/a[i-1])*a[i-1];
        r[i-1]=(long)Math.floor((double)r[i]/a[i-1])*a[i-1]+a[i-1]-1;
      }else{
        System.out.println(-1);
        return;
      }
    }
    System.out.println(l[0]+" "+r[0]);
  }
}


Measured memory_bytes: 60980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<string, ll> mstrll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, n, m, x, y, z, w, h, ans, cnt, mx, mn;
string s, t;
vll dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
//vll dx = {-1, 0, 1, -1, 1, -1, 0, 1}, dy = {-1, -1, -1, 0, 0, 1, 1, 1};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n){
        ll c[n], s[n], f[n];
        rep(i, 1, n){
            cin >> c[i] >> s[i] >> f[i];
        }
        rep(i, 1, n + 1){
            ll time = 0;
            rep(j, i, n){
                if(time < s[j]){
                    time = s[j];
                }else if(time % f[j]){
                    time += f[j] - ((time - s[j]) % f[j]);
                }
                time += c[j];
            }
            print(time);
        }
    }
}

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

const ll MAX=2000010;
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;
}

int main() {
  ll r1,r2,c1,c2;
  cin>>r1>>c1>>r2>>c2;
  ll ans=0;
  COMinit();
  ans+=COM(r1+c1,r1);
  for(int i=r1+1;i<=r2;i++){
      ans+=COM(i+c2,i);
      ans%=MOD;
  }
  for(int i=c1+1;i<=c2;i++){
      ans+=COM(i+r2,i);
      ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 47104
package main

import (
	"fmt"
)

var N int
var S []string

func main() {
	fmt.Scanf("%d", &N)

	S = make([]string, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S[i])
	}

	m := make(map[string]bool)
	for i := 0; i < len(S); i++ {
		m[S[i]] = true
	}

	ans := 0
	for _, v := range m {
		if v {
			ans++
		}
	}

	if ans == 4 {
		fmt.Println("Four")
	} else if ans == 3 {
		fmt.Println("Three")
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int w[10], k[10];
	
	for (int i = 0; i < 10; i++){
		scanf("%d", &w[i]);
	}
	for (int i = 0; i < 10 ; i++){
		scanf("%d", &k[i]);
	}
	sort(w, w + 10);
	reverse(w, w + 10);
	
	sort(k, k + 10);
	reverse(k, k + 10);
	
	printf("%d %d\n", w[0] + w[1] + w[2], k[0] + k[1] + k[2]);
	
	return (0);
}

Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int m=1;
    int s;
    cin >> s;
    
    int exist[1000001]={};
    
    exist[s]=1;
    while(true){
        m++;
        if(s%2==0){
            s=s/2;
        }else{
            s=3*s+1;
        }
        
        if(exist[s]==1){
            cout<<m<<endl;
            return 0;
        }else{
            exist[s]=1;
        }
    }
    return 0;
}


Measured memory_bytes: 4224
/*
                    author         : TAPAN SAVANI 
                    codeforces     : savanitapan2001
                    codechef       : savanitapan17
*/

/*
------------------------------------------------------------------------

░██╗░░░░░░░██╗░█████╗░██████╗░██╗░░██╗  ██╗░░██╗░█████╗░██████╗░██████╗░
░██║░░██╗░░██║██╔══██╗██╔══██╗██║░██╔╝  ██║░░██║██╔══██╗██╔══██╗██╔══██╗
░╚██╗████╗██╔╝██║░░██║██████╔╝█████═╝░  ███████║███████║██████╔╝██║░░██║
░░████╔═████║░██║░░██║██╔══██╗██╔═██╗░  ██╔══██║██╔══██║██╔══██╗██║░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝██║░░██║██║░╚██╗  ██║░░██║██║░░██║██║░░██║██████╔╝
░░░╚═╝░░░╚═╝░░░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝  ╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░
 
------------------------------------------------------------------------
*/

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

#define HAPPY_CODING              \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())
#define mod 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define ull unsigned long long
#define be begin()
#define en end()
#define FOR(i, a, b) for (long long int i = a; i < b; i++)
#define FORI(i, a, b) for (int i = a; i >= b; i--)

typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef vector<PI> VPI;

int main()
{
    HAPPY_CODING;

    int x;
    cin >> x;

    if(x)
    cout << "0\n";
    else 
    cout << "1\n";

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int,int>> vp;
int main() {
    cin >> n;
    for(int i=0;i<n;i++){
        int a, b; cin>>a>>b;
        vp.push_back(make_pair(a,b));
    }
    sort(vp.begin(), vp.end(),[](const pair<int,int>& a, const pair<int,int>& b){
        if(a.second!=b.second) return a.second < b.second;
        else return a.first < b.first;
    });
    int cur = 0, count = 0;
    for(auto& i :vp) {
        if (cur + i.first <= i.second) {
            count++;
            cur += i.first;
        }
    }
    cout << (count == n ? "Yes" : "No") << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[100010],t[100010];
signed main()
{
	int n,q,i,b,c,sum=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		t[a[i]]++;
		sum+=a[i];
	}
	cin>>q;
	while(q--)
	{
		cin>>b>>c;
		sum+=(c-b)*t[b];
		t[c]+=t[b];
		t[b]=0;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int dp[110][110][11000];

signed main()
{       
    int N,A; cin>>N>>A;
    vint a(N);
    REP(i,N) cin>>a[i];

    dp[0][0][0]=1;
    REP(i,N){
        REP(j,i+1){
            REP(k,10000){
                dp[i+1][j][k]+=dp[i][j][k];
                dp[i+1][j+1][k+a[i]]+=dp[i][j][k];
            }
        }
    }
    int ans=0;
    for(int j=1;j<=N;j++) ans+=dp[N][j][j*A];
    cout<<ans<<endl;
}


Measured memory_bytes: 213248
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

void readint(int N, vector<int> &a);
void readdouble(int N, vector<double> &a);
void readindex(int N, vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> A(N);
    readint(N, A);

    vector<int> A2(N + 2);
    A2[0] = 0;
    A2[N + 1] = 0;
    REP(i, N){
        A2[i + 1] = A[i];
    }

    int total = 0;
    REP(i, N + 1){
        total += llabs(A2[i + 1] - A2[i]);
    }

    FOR(i, 1, N + 1){
        cout << total - (llabs(A2[i] - A2[i - 1]) + llabs(A2[i + 1] - A2[i])) + llabs(A2[i + 1] - A2[i - 1]);
        if(i != N) cout << endl;
    }

    return 0;
}








void readint(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readdouble(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

Measured memory_bytes: 2816
macro_rules! extract {
    (String, $iter:expr) => {
        $iter.next().unwrap().trim().to_owned()
    };
    ($t:tt, $iter:expr) => {
        $iter.next().unwrap().trim().parse::<$t>().unwrap()
    };
}

macro_rules! read_split_impl {
    ( $e:expr, $( $t:tt ),* ) => {{
        let mut s = String::new();
        $e.read_line(&mut s).unwrap();
        let s = s.trim_right();
        let mut iter = s.split_whitespace();
        ( $(extract!($t, iter)),* )
    }};
}

macro_rules! read_split {
    ( $( $t:tt ),* ) => {
        read_split_impl!(std::io::stdin(), $($t),* )
    };
}

fn gcd(a: u64, b: u64) -> u64 {
    if a > b {
        gcd_impl(b, a)
    } else {
        gcd_impl(a, b)
    }
}

fn gcd_impl(a: u64, b: u64) -> u64 {
    if a == 0 {
        b
    } else {
        gcd_impl(b % a, a)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    (a / gcd(a, b)) * b
}

fn main() {
    let (a, b) = read_split!(u64, u64);

    print!("{}", lcm(a, b));
}

Measured memory_bytes: 4352
monthday = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ['Wednesday', 'Thursday', 'Friday', 'Saturday',
		'Sunday', 'Monday', 'Tuesday']

def nthday(m, d):
	cnt = d
	for i in range(0, m):
		cnt += monthday[i]
	return cnt

while True:
	inpt = map(int, raw_input().split())
	if inpt[0] == 0:
		break
	else:
		print days[nthday(inpt[0], inpt[1]) % 7]

Measured memory_bytes: 6248
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


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

typedef struct{
  int x,y,c;
}state;

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    int kabe[w][2*h-1];
    rep(i,2*h-1){
      rep(j,w+i%2-1){
	cin>>kabe[j][i];
      }
    }

    bool heya[w][h];
    memset(heya,0,sizeof(heya));

    queue<state> Q;
    Q.push((state){0,0,1});
    int ans=INT_MAX/2;

    while(!Q.empty()){
      int cx=Q.front().x,cy=Q.front().y,cc=Q.front().c;
      Q.pop();
      if(heya[cx][cy])continue;
      heya[cx][cy]=1;

      if(cx==w-1 && cy==h-1){
	ans=cc;
	break;
      }

      rep(i,4){
	int nx=cx+dx[i],ny=cy+dy[i];
	if(nx<0 || w<=nx || ny<0 || h<=ny)continue;

	if(nx==cx && kabe[nx][cy*2+dy[i]]==0){
	  Q.push((state){nx,ny,cc+1});
	}else if(ny==cy && kabe[(cx+nx)/2][ny*2]==0){
	  Q.push((state){nx,ny,cc+1});
	}
      }
    }
    if(ans==INT_MAX/2)cout<<0<<endl;
    else cout<<ans<<endl;
  }
}

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


int main() {
    long long int N;
    std::cin >> N;

    std::vector<long long int> prices(N);
    for (int i = 0; i < N; i++) {
        std::cin >> prices[i];
    }

    long long int money = 1000;
    long long int stock = 0;
    for (int i = 0; i < N - 1; i++) {
        int diff = prices[i + 1] - prices[i];
        if (diff >= 0 && stock == 0) {
            stock = money / prices[i];
            money -= stock * prices[i];
        }
        if (diff <= 0 && stock > 0) {
            money += prices[i] * stock;
            stock = 0;
        }
    }
    if (stock > 0) {
        money += prices[N - 1] * stock;
    }
    std::cout << money << std::endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    map<string,set<pll>> S;
    REP(i,0,N) {
        string s;
        ll p;
        cin >> s >> p;
        S[s].insert({-p,i+1});
    }

    FORR(s,S) {
        FORR(p,s.second) {
            PR(p.second);
        }
    }

    return 0;
}

/*



*/

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

namespace ABC100
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                while (A[i] % 2 == 0)
                {
                    A[i] /= 2;
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int k,x; cin >> k >> x;

  if(500*k>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
    
  return 0;
}


Measured memory_bytes: 3596
s = input()

flag = 0

while flag==0 and len(s)!=0 :
    if s.endswith('hi'):
        s = s[0:len(s)-2]
    else:
        flag = 1
#    print(s)
#    print(len(s))

if flag == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 2940
n,m=map(int,input().split())
a=[]
for _ in range(n):
    a.append(input())
b=[]
for _ in range(m):
    b.append(input())
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if a[i+k][j:j+m]!=b[k]:
                break
            elif k==m-1:
                print('Yes')
                exit()
print('No')

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

const int N = 100;

int main (){
    int n,p[N+1],m[N+1][N+1];
    cin >> n;
    for (int i = 1; i <= n ; ++i)cin >> p[i-1] >> p[i];
    for (int i = 1; i <= n ; ++i) m[i][i] = 0;
    for (int l = 2; l <= n ; ++l) {
        for (int i = 1; i <= n - l + 1 ; ++i) {
            int j = i + l - 1 ;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j -1  ; ++k) {
                m[i][j] = min (m[i][j],m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  ll n,m; cin >> n >> m;
  UnionFind uf(n);   
  ll num = (ll) n*(n-1)/2;
  vector<ll> ans;
  vi A(m), B(m);
  rep(i,m) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  rep(i,m) {
    ll a = A[i], b=B[i];
    ans.push_back(num);
    if (!uf.same(a,b)) {
      num -= (ll) uf.size(a) * uf.size(b);
    }
    uf.unite(a, b);
  }
  reverse(ans.begin(), ans.end());
  rep(i,m) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 5440
class Test:
    def __init__(self):
        pass

class CustomUtils:
    def __init__(self):
        pass
    def to_int(self, inputs, sp=' '):
        if sp == '':
            return [int(d) for d in list(inputs)]
        else:
            return [int(d) for d in inputs.split(sp)]
    def debug_print(self, inputs, debug=False):
        if debug:
            print(inputs)

# 引用　python する man,「Pythonでの再帰関数とメモ化」, PSM, ２０１７、７/４
# http://muromura.hatenablog.com/entry/2017/07/04/204908#%E3%83%A1%E3%83%A2%E5%8C%96
def memorize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func
debug = False


u = CustomUtils()
iarray = list(input())

@memorize
def acgt(i):
    if i < 0:
        return 0
    elif iarray[i] in ['A', 'C', 'G', 'T']:
        return acgt(i -1) + 1
    else:
        return 0
result = max(acgt(i) for i in range(len(iarray)))
print("{}".format(result))

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <deque>

using namespace std;

class TaskB {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n, x;
		in >> n >> x;

		if (x == 1 || x == 2 * n - 1) {
			out << "No";
		} else {
			if (n == 2 && x == 2) {
				out << "Yes\n1\n2\n3";
				return;
			}
			deque<int> q;
			if (x >= 3) {
				q.push_back(x);
				q.push_back(1);
				q.push_front(2 * n - 1);
				q.push_front(2);
				bool last = true;
				for (int i = 3; i <= 2 * n - 2; ++i) {
					if (i == x) {
						continue;
					}
					if (last) {
						q.push_back(i);
					} else {
						q.push_front(i);
					}
					last = !last;
				}
			} else {
				q.push_back(2);
				q.push_back(4);
				q.push_front(1);
				q.push_front(3);
				for (int i = 5; i <= 2 * n - 1; ++i) {
					if (i % 2) {
						q.push_back(i);
					} else {
						q.push_front(i);
					}
				}
			}
			out << "Yes\n";
			for (int xx: q) {
				out << xx << "\n";
			}
		}
	}
};


int main() {
	std::ios_base::sync_with_stdio(false);


	TaskB solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0);
	out << std::fixed;
	out.precision(20);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int P[N],Q[N];
    for(int i=0; i<N; i++){
        cin >> P[i];
    }
    for(int i=0; i<N; i++){
        cin >> Q[i];
    }    

    vector <int> x(N);
    iota(x.begin(),x.end(),1);

    long long iter=0, piter, qiter;
    bool pflag=false; bool qflag=false;

    do{
        iter++;

        //cout << "iter= " << iter << endl;

        /*cout << "x= ";
        for(int i=0; i<N; i++){
            cout << x[i] << " ";
        }
        cout << endl; */

        for(int i=0; i<N; i++){
            if( x[i] == P[i] ){
                if(i==N-1){
                    pflag=true;
                }
                continue;
            }else{
                pflag=false;
                break;
            }
        }

        if(pflag){
            piter = iter;
            //cout << "piter = " << piter << endl;
        }

        for(int i=0; i<N; i++){
            if( x[i] == Q[i] ){
                if(i==N-1){
                    qflag=true;
                }
                continue;
            }else{
                qflag=false;
                break;
            }
        }
        if(qflag){
            qiter = iter;
            //cout << "qiter = " << qiter << endl;
        }
 

    }while( next_permutation(x.begin(), x.end()) );

    cout << abs(qiter-piter) << endl;

    return 0;
}

Measured memory_bytes: 256