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

int main() {
	int n; cin >> n;
	vector<int>x(n), y; for (auto&& a : x)cin >> a;
	y = x;
	sort(y.begin(), y.end(), greater<int>());

	int left = y[n / 2 - 1];
	int right = y[n / 2];
	for (int i = 0; i < n; i++) {
		if (x[i] >= left)cout << right << endl;
		else cout << left << endl;
	}
	
	return 0;
}

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

char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
int N;
char S[10005];

int main() {
    scanf("%d", &N);
    scanf("%s", S);
    for (int i = 0; i < strlen(S); i++) {
        putchar(s[S[i]-'A'+N]);
    }
    putchar('\n');
    return 0;
}


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

int main(){
	int group1[] = {1,3,5,7,8,10,12};
	int group2[] = {4,6,9,11};
	int x,y;
	int gx=0,gy=0;

	cin >> x >> y;
	for(auto i : group1){
		if(i == x){
			gx = 1;
		}
		if(i == y){
			gy = 1;
		}
	}

	for(auto j : group2){
		if(j == x){
			gx = 2;
		}
		if(j == y){
			gy = 2;
		}
	}

	if(gx == gy){
		cout << "Yes";
	} else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

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

using namespace std;

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


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

	int ret = INT_MAX;

	rep(i, N) {
		int c, t;
		cin >> c >> t;

		if (t > T) continue;
		ret = min(ret, c);
	}

	if (ret == INT_MAX) cout << "TLE" << endl;
	else cout << ret << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int w, h, n, ans ;
	cin >> w >> h >> n;
	int x[n],y[n],a[n];

	int a1=0 , a2=w , a3=0 , a4=h;

	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> a[i];
		if(a[i] ==1)  a1 = max(a1,x[i]);
		else if(a[i]==2)  a2 = min(a2,x[i]);
		else if(a[i]==3)  a3 = max(a3,y[i]);
		else if(a[i]==4)  a4 = min(a4,y[i]);
	}

	if(a2-a1 <= 0 && a4-a3 <= 0 ){
		cout << 0 << endl;
		return 0;
	}

	ans = (a2-a1)*(a4-a3);
	if( ans < 0){
		cout << 0 << endl;
	}
	else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php

$input = trim(fgets(STDIN),"\r\n");

$hour = floor($input/3600);
if($hour < 0) $hour = 0;
$minute = floor(($input%3600)/60);
if($minute < 0) $minute = 0;
$second = ($input%3600)%60;

echo $hour.':'.$minute.':'.$second."\n";

Measured memory_bytes: 6540
import Control.Applicative
import Data.List
import Control.Monad
strToInt s = (read :: String -> Int) s

main :: IO ()
main = do
    -- 文字列の入力
    s1 <- getLine
    s2 <- getLine
    -- 出力
    putStrLn $ if s1 == reverse s2 then "YES" else "NO"


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

signed main() {
    int n;
    bool ans = false;
    cin >> n;
    string w[100];
    cin >> w[0];
    for (int i = 1; i < n; i++) {
        cin >> w[i];
        if (w[i][0] != w[i - 1][w[i - 1].size() - 1]) {
            ans = true;
        }
        rep (j, i) {
            if (w[j] == w[i]) {
                ans = true;
            }
        }
    }
    if (ans == false) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { //USE LONGS TO AVOID OVERFLOW THEN CAST
 
	public static void main(String[] args) { 
		FastScanner input = new FastScanner();
		PrintWriter w = new PrintWriter(System.out);
		String S = input.next();
		int N = S.length();
		long K = input.nextLong();
		long ans = 0;
		for (int i = 0; i < N; i++) {
			if (S.charAt(i)=='1') {
				ans=1;
				K--;
				if (K==0) break;
			}else {
				ans=Long.parseLong(Character.toString(S.charAt(i)));
				break; //2^(5x10^15 is definitely > 10^18)
			}
		} 
		w.println(ans);
		w.flush();
	}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 25452
#include<stdio.h>

// SUB ID: UG02-53-20-001

int main()
{
    int A, B;
    scanf("%d%d",&A,&B);

    if(B%A==0)
    {
        printf("%d",A+B);

    }  else

    {
            printf("%d",B-A);
    }


    return 0;
}

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

typedef long long int lli;
const int N = 1e5 + 5;
int n, q;
lli l;
lli x[N];
int a[N];
int b[N];

int lastJump[N][20]; //Last index reachable by L*2^(second index) jumps

int solve(int a, int b, int ans) {
	if(a >= b) return ans;

	int x = lower_bound(lastJump[a], lastJump[a]+20, b) - lastJump[a];
	if(x != 0) x--;
	return solve(lastJump[a][x], b, ans + (1<<x));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; i++) cin >> x[i];

	cin >> l >> q;

	for(int i = 0; i < q; i++) cin >> a[i] >> b[i];

	for(int j=0; j<20; j++) {
		if(j==0) {
			lli jumpL = ((lli)1<<j)*l;
			int k = 0;
			while(k<n && x[k] - x[0] <= jumpL) k++;
			lastJump[0][j] = k-1;
			for(int i=1; i<n; i++) {
				while(k < n && x[k] - x[i] <= jumpL) k++;
				lastJump[i][j] = k-1;
			}
		} else {
			for(int i=0; i<n; i++) {
				lastJump[i][j] = lastJump[lastJump[i][j-1]][j-1];
			}
		}
	}

	for(int i=0; i<q; i++) {
		if(a[i] > b[i]) {
			int tmp = a[i];
			a[i] = b[i];
			b[i] = tmp;
		}
		cout << solve(a[i]-1, b[i]-1, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 10240
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n -= -1
m -= -1
a.insert(0, 0)
b.insert(0, 0)
for i in range(1, n): a[i] += a[i - 1]
for i in range(1, m): b[i] += b[i - 1]
ans = 0
for i in range(n):
    if a[i] > k: break
    lo, hi = 0, m - 1
    tmp = a[i]
    while hi - lo > 1:
        mid = lo + (hi - lo) // 2
        if tmp + b[mid] > k: hi = mid - 1
        else: lo = mid
    if tmp + b[hi] <= k: lo = hi
    ans = max(ans, i + lo)
print(ans)

Measured memory_bytes: 118020
n = int(input())
an = []
for _ in range(n):
  an.append(int(input()))
maxl = [an[0]]
maxr = [an[-1]]
for a in an[1:]:
  maxl.append(max(maxl[-1], a))
for a in an[:-1][::-1]:
  maxr.append(max(maxr[-1], a))
maxr = maxr[::-1]

print(maxr[1])
for i in range(1, n-1):
  print(max(maxl[i-1], maxr[i+1]))
print(maxl[n-2])

Measured memory_bytes: 17168
#include <iostream>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  for (int i = 0; i <= N / 4; i++) {
    if ((N - 4 * i) % 7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    K, N = map(int, input().split())
    A = tuple(map(int, input().split()))
    tmp = 0
    for i in range(N-1):
        tmp = max(tmp, A[i+1] - A[i])

    tmp = max(tmp, (K-A[N-1]+A[0]))
    print(K-tmp)

if __name__ == '__main__':
    main()



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

int main()
{

	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (int i=0;i<n;++i)
	{
		cin >> a[i] >> b[i];
	}

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());

	if ((n%2)!=0)
	{
		// odd
		int start=a[n/2];
		int end=b[n/2];
		cout << end-start+1 << endl;
	}
	else
	{
		// even
		int ss=a[n/2-1];
		int se=b[n/2-1];
		int es=a[n/2];
		int ee=b[n/2];
		fprintf(stderr,"s1 %d,%d s2: %d,%d\n",ss,se,es,ee);
		cout << (ee+se)-(es+ss)+1 << endl;
	}
}






Measured memory_bytes: 4768
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

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

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			int k = (int) sc.scanLong();
			char[] carr = sc.scanString().toCharArray();
			int seen = 0;
			int i = 0;
			int j = 0;
			int prev = '1';
			int ans = 0;
			for (; j < n; ++j) {
				char curr = carr[j];
				if (curr == '1') {
					prev = curr;
					continue;
				}
				if (seen <= k) {
					if (curr != prev) {
						++seen;
					}
				}
				if (seen > k) {
					ans = Math.max(ans, j - i);
					// shrink window
					++i;
					while (!(carr[i] == '1' && carr[i - 1] == '0')) {
						++i;
					}
					--seen;
				}
				prev = curr;
			}
			ans = Math.max(ans, j - i);
			System.out.println(ans);
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 33340
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e3 + 17;
ll cnt, ans, lnt, sum, n, l1, x, y, a[N], mx, b[N][N];
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> x >> y;
    for(ll i = 1; i <=  min(n,x); i ++)
    {
        if(n % i == 0 and x % i == 0)
        {
            v.pb(i);
        }
    }
    reverse(v.begin(), v.end());
    cout << v[y - 1];
    //cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>



using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)


map<string, int> mp;
#define ll long long

int main() {
    int n;
    cin >> n;
    int a[205];
    rep(i, n) {
        cin >> a[i];
    }
    int ans=100;
    rep(i, n) {
        int c=0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            c++;
        }
        ans = min(c, ans);
    }


    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,a,i,d[200010];
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++)scanf("%d",&d[i]);
  a=d[0]+n-d[m-1];
  for(i=1;i<m;i++)a=MAX(a,d[i]-d[i-1]);
  printf("%d\n",n-a);
  return 0;
}


Measured memory_bytes: 896
# coding: utf-8
# Your code here!
import sys

n,k = map(int,input().split())
al = list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

divisors = sorted(make_divisors(sum(al)), reverse=True)

for i in divisors:
    point = 0
    div_l = sorted([a%i for a in al if a%i > 0])
    while div_l:
        if div_l[0] < i - div_l[-1]:
            div_l[-1] += div_l[0]
            point += div_l[0]
            div_l.pop(0)
        else:
            div_l[0] -= (i - div_l[-1])
            point += i - div_l[-1]
            div_l.pop(-1)
            
    
    if point <= k:
        print(i)
        sys.exit()
        

Measured memory_bytes: 41836
#include<bits/stdc++.h>
using namespace std;
int N,a[100001],cnt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>N;
	for (int i=1,tmp;i<=N;++i)
	{
		cin>>tmp;
		++a[tmp];
	}
	for (int i=1;i<=100000;++i) if(a[i]) ++cnt;
	if (cnt%2==0) --cnt;
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    string s; cin >> s;
    int res=0;
    rep(i,1000){
        string pin=to_string(i);
        if(i<10) pin.insert(0,"0");
        if(i<100) pin.insert(0,"0");

        int keta=0;
        rep(j,n){
            if(pin[keta]==s[j]) keta++;
        }
        if(keta==3) res++;
    }
    cout<<res<<endl;

}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int a, b, t;
    cin >> a >> b >> t;

    int ans = t / a * b;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#include <iostream>
using namespace std;
int main() {
	ll int n;
	cin>>n;
	vector<ll int> a(n);
	for(ll int i=0;i<n;i++){
		cin>>a[i];
	}
	ll int dp[n+1][n+1];
	memset(dp,0,sizeof(dp));
	for(ll int i=1;i<=n;i++){
		dp[i][i]=a[i-1];
	}
	for(ll int i=n-1;i>=0;i--){
		for(ll int j=i+1;j<=n;j++){
			dp[i][j]=max(a[i-1]-dp[i+1][j],a[j-1]-dp[i][j-1]);
		}
	}
	cout<<dp[1][n];
	return 0;
}

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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int a,b,c;cin >> a >> b >> c;
    int d = min(c, b/a);
    cout << d << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dp[55][55][3200];

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

    ll n, k;
    cin >> n >> k;
    
    REP(i, 55)REP(j, 55)REP(k, 3200) dp[i][j][k] = 0;
    dp[0][0][0] = 1;

    REP(i, n){
    	REP(j, n){
    		REP(k, 3200){
    			if(k+2*(j+1) < 3200) dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k], dp[i+1][j+1][k+2*(j+1)] %= mod;
    			if(k+2*j < 3200) dp[i+1][j][k+2*j] += dp[i][j][k], dp[i+1][j][k+2*j] %= mod;
    			if(k+2*j < 3200) dp[i+1][j][k+2*j] += (dp[i][j][k] * 2 * j)%mod, dp[i+1][j][k+2*j] %= mod;
    			if(k+2*(j-1) < 3200 && k+2*(j-1)>=0) dp[i+1][j-1][k+2*(j-1)] += (dp[i][j][k] * j * j)%mod, dp[i+1][j-1][k+2*(j-1)] %= mod;
    		}
    	}
    }
    cout << dp[n][0][k] << endl;
    return 0;
}

Measured memory_bytes: 75904
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

print(S.count("ABC"))

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(!n)break;

        vector<P> change;
        for(int i=0;i<n;i++){
            int m,a,b;
            scanf("%d%d%d",&m,&a,&b);
            change.push_back(P(a,m));
            change.push_back(P(b,-m));
        }

        //同じ時刻に渡り始める人と渡り終わる人が居ても
        //渡り終わる時の重さの変動が負なのでソートによって渡り始める人より先にくるため題意に合う
        sort(change.begin(),change.end());
        int sum_m = 0;
        bool is_broken = false;
        for(int i=0;i<change.size();i++){
            sum_m += change[i].second;
            if(sum_m>150){
                is_broken = true;
                break;
            }
        }
        if(is_broken)cout << "NG" << endl;
        else cout << "OK" << endl;
    }

    return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
int a,b;
cin>>a>>b;
if(a>b){
    for(int i=0;i<a;i++){
        cout<<b;
    }
}else{
        for(int i=0;i<b;i++){
        cout<<a;
    }
}
}







Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <cctype>
#include <cmath>
#include <cstring>
#include <climits>
#include <complex>
#include <set>
#include <deque>
#define DEBUG(x) cerr<<"line:"<<__LINE__<<", "<<#x" == "<<(x)<<endl;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(it,s) for(__typeof(s.begin()) it=s.begin();it!=s.end();it++)
#define fst first
#define snd second
#define ALL(a) a.begin(),a.end()
#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d%d",&(x),&(y))
#define RIII(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define DRI(x) int (x);scanf("%d",&(x))
#define DRII(x,y) int (x),(y);scanf("%d%d",&(x),&(y))
#define DRIII(x,y,z) int (x),(y),(z);scanf("%d%d%d",&(x),&(y),&(z))
#define MS0(a) memset((a),0,sizeof((a)))
#define MS1(a) memset((a),-1,sizeof((a)))
#define MS(a,b) memset((a),(b),sizeof((a)))
using namespace std;

typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

#define INF (int)1e9
#define EPS (1.0e-8)
// ------------------



int dis[10+1];
int vis[10+1];

bool ok(int n) {
    while (n) {
        if (vis[n % 10]) return false;
        n /= 10;
    }
    return true;
}

int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
#endif
    int n, k; cin >> n >> k;
    for (int i = 0; i < k; i++) {
        cin >> dis[i];
        vis[dis[i]] = 1;
    }
    for (int i = n; i <= 100 * n; i++) {
        if (ok(i)) {
            cout << i << endl;
            return 0;
        }
    }

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

const ll MAX_N=200000;

ll N,X[MAX_N],X_sorted[MAX_N];

int main(){
  cin>>N;
  for(ll i=0;i<N;i++){
    cin>>X[i];
    X_sorted[i]=X[i];
  }
  sort(X_sorted,X_sorted+N);
  ll med1=X_sorted[(N/2)-1],med2=X_sorted[N/2];
  for(ll i=0;i<N;i++){
    if(X[i]<=med1)cout<<med2<<endl;
    else cout<<med1<<endl;
  }
  return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    int a = 0;
    int b = N;
    int mid;
    vector<int> cnt(N + 1,-1);
    cout << 0 << endl;
    string S;
    cin >> S;
    if(S == "Vacant") {
        return 0;
    }
    else if(S == "Male") {
        cnt.at(0) = 1;
        cnt.at(N) = 1;
    }
    else {
        cnt.at(0) = 2;
        cnt.at(N) = 2;
    }
    for(int i = 0;i < 20;i++) {
        mid = (a + b) / 2;
        cout << mid << endl;
        cin >> S;
        if(S == "Vacant") {
            return 0;
        }
        else if(S == "Male") {
            cnt.at(mid) = 1;
        }
        else if(S == "Female") {
            cnt.at(mid) = 2;
        }
        if((b - mid) % 2 == 1 && cnt.at(mid) == cnt.at(b)) {
            a = mid;
        }
        else if((b - mid) % 2 == 0 && cnt.at(mid) != cnt.at(b)) {
            a = mid;
        }
        else {
            b = mid;
        }
    }
}

Measured memory_bytes: 1236
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

func main() {
	re := bufio.NewReaderSize(os.Stdin, 200000)

	s, _, _ := re.ReadLine()

	start := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' {
			start = i
			break
		}
	}
	end := len(s)
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == 'Z' {
			end = i + 1
			break
		}
	}
	out(end - start)
}


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

using  namespace std;

int main(){
    int N,a;
    cin >> N;
    vector<pair<int, int>> A;
    for(int i=1;i<=N;i++){
        cin >> a;
        A.push_back(make_pair(a, i));
    }
    sort(A.begin(), A.end());
    for(int i=0;i<N;i++){
        cout << A[i].second;
        cout << " ";
    }
    cout << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

ll keta(ll a, ll b)
{
    int num_a = 0, num_b = 0;
    while (a)
    {
        num_a++;
        a /= 10;
    }
    while (b)
    {
        num_b++;
        b /= 10;
    }
    return max(num_a, num_b);
}

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 1001001001;
    for (int i = 0; i < (max(X,Y)+1)*2; i++)
    {
        int cnt = C * i * 2 + A * max(X - i, 0) + B * max(Y - i, 0);
        ans = min(cnt, ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
 int N,M;
 cin >> N >> M;
  vector<int> vec(N,0);
  rep(i,M*2){
  int a;
  cin >> a;
  vec.at(a-1)++;
  }
  rep(i,N){
  cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1000+5,MOD=1e9+7;
int dp[MAXN][MAXN],h,w;
char maze[MAXN][MAXN];

int main(){
	cin>>h>>w;
	dp[1][1]=1;
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cin>>maze[i][j];
			if(i==1&&j==1) continue;
			if(maze[i][j]=='.') dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
		}
	}
	cout<<dp[h][w]<<'\n';
	return 0;
}

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

int main () {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;

  long long low = 0, high = 10000000;

  long long ans = -1;
  long long mid;
  long long N;
  while (low <= high) {
    mid = (low + high) / 2;
    N = mid * 108L / 100L;
    if (N == n) {
      ans = mid;
    }
    if (N > n) high = mid-1;
    else low = mid+1;
  }

  if (ans == -1) cout << ":(";
  else cout << ans;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n,a,b;
    ll ans = 0;
    cin >> n >> a >> b;
    rep(i,1,n+1){
      ll sumDigit = 0;
      ll ii = i;
      while(ii > 0){ sumDigit +=ii%10; ii/=10;}
      if(sumDigit <= b && sumDigit >= a) ans +=i;
    }
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string A, B, C;
    cin >> A;
    cin >> B;
    cin >> C;

    cout << A[0] << B[1] << C[2] << endl;
    return 0;
}

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

import sys
sys.setrecursionlimit(10 ** 9)
#import math
#import numpy as np
N = int(input())
A = list(map(int, input().split()))

one = A.count(1)
two = A.count(2)
three = A.count(3)

dp = [[[-1] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]

def calc(a, b, c):
    if dp[a][b][c] >= 0:
        return dp[a][b][c]

    if a + b + c == 0:
        return 0

    t = N

    if a > 0:
        t += calc(a - 1, b + 1, c) * a
    if b > 0:
        t += calc(a, b - 1, c + 1) * b
    if c > 0:
        t += calc(a, b, c - 1) * c
        
    t /= a + b + c

    dp[a][b][c] = t
    return t

ans = calc(three, two, one)
print(ans)


Measured memory_bytes: 397888
# encoding:utf-8
def main():
	n, k = list(map(int, input().split()))
	xs = list(map(int, input().split()))
	
	min_dist = 10 ** 10
	for i in range(n - k + 1):
		dist = min(abs(xs[i]), abs(xs[i + k - 1])) + (xs[i + k - 1] - xs[i])
		if dist <= min_dist:
			min_dist = dist
	print(min_dist)


if __name__ == '__main__':
	main()


Measured memory_bytes: 14384
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

struct Edge {
  int to, dis, com;
};

int main() {
  while (true) {
    int n, m, c, s, g;
    cin >> n >> m >> c >> s >> g;
    if (n == 0 && m == 0 && c == 0 && s == 0 && g == 0) break;
    --s, --g;
    vector<Edge> edge[n];
    for (int i : range(m)) {
      int x, y, d, c;
      cin >> x >> y >> d >> c;
      --x, --y, --c;
      edge[x].emplace_back((Edge){y, d, c});
      edge[y].emplace_back((Edge){x, d, c});
    }
    int p[c];
    for (int i : range(c)) cin >> p[i];
    vector<int> q[c], r[c];
    for (int i : range(c)) {
      q[i].emplace_back(0);
      for (int j : range(p[i] - 1)) {
        int qq;
        cin >> qq;
        q[i].emplace_back(qq);
      }
      q[i].emplace_back(100000);
      for (int j : range(p[i])) {
        int rr;
        cin >> rr;
        r[i].emplace_back(rr);
      }
    }
    int dis[n][n];
    const int INF = 1e9;
    for (int i : range(n)) for (int j : range(n)) dis[i][j] = INF;
    for (int i : range(c)) for (int j : range(n)) {
      priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
      que.push(make_pair(0, j));
      int dd[n];
      for (int k : range(n)) dd[k] = 1e9;
      while (!que.empty()) {
        auto now = que.top(); que.pop();
        int cost = now.first;
        int pos = now.second;
        if (dd[pos] <= cost) continue;
        dd[pos] = cost;
        for (const auto& e : edge[pos]) if (e.com == i) que.push(make_pair(cost + e.dis, e.to));
      }
      for (int k : range(n)) if (dd[k] != INF) {
        int c = 0;
        for (int l : range(p[i])) {
          if (dd[k] < q[i][l + 1]) {
            is_min(dis[j][k], c + (dd[k] - q[i][l]) * r[i][l]);
            break;
          }
          c += (q[i][l + 1] - q[i][l]) * r[i][l];
        }
      }
    }
    for (int k : range(n)) for (int i : range(n)) for (int j : range(n)) is_min(dis[i][j], dis[i][k] + dis[k][j]);
    if (dis[s][g] == INF) cout << -1 << endl;
    else cout << dis[s][g] << endl;
  }
}

Measured memory_bytes: 1704
local mmi, mma = math.min, math.max
local bls = function(a, b) return a << b end
local brs = function(a, b) return a >> b end

local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = self.emptyvalue
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.update = function(self, idx)
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    self:update(idx)
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n")
local tasks = {}
for i = 1, n do
  tasks[i] = 0
end
for i = 1, n do
  local h = io.read("*n")
  tasks[h] = i
end
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end

local st = SegTree.new(n, mma, 0)
for i = 1, n do
  local pos = tasks[i]
  local z = st:getRange(1, pos)
  st:setValue(pos, z + a[pos])
end
print(st.stage[1][1])


Measured memory_bytes: 26960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

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

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
int main() {
  char input[1001] = {0};
  int total = 0,tmp;
  std::string nums = "0123456789";
  while (scanf("%s", input) && input[0] != '0') {
    total = 0;
    for (int i = 0; i < 1001; i++){
      tmp = nums.find_first_of(input[i]);
      input[i] = '0';
      if (tmp > 0) {
        if (tmp < 10) total += tmp;
        else break;
      }
    }
    printf("%d\n", total);
  }
  return 0;
}



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

using namespace std;

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

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

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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



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

    map<string, int> w;

    string prv;
    cin>>prv; //n=0
    w[prv]++;
    FOR(lp,1,n){
        string s;
        cin>>s;

        if(w[s] > 0){
            cout<<"No"<<endl;
            return 0;
        }
        
        if(s[0]!=prv[prv.size()-1]){
            cout<<"No"<<endl;
            return 0;
        }
        w[s]++;
        prv = s;
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

  int n,x,count;

  while(1){
    scanf("%d %d\n",&n,&x);
    count=0;

    if(n==0&&x==0) {
      return 0;
    }

    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
          if(j==i)
              continue;
        for(int k=1;k<=n;k++){
          if(k==i || k==j)
              continue;
          if(i+j+k==x)
            count++;
        }
      }
    }
    printf("%d\n",count/6);
  }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

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

    int ans = 0;
    int counter;

    for (int i = 9; i < N + 1; i++)
    {
        counter = 0;
        for (int j = 1; j < N + 1; j++)
        {
            if (i % j == 0)
                counter++;
        }
        if (counter == 8 && i % 2 == 1)
        {
            // printf("%d\n", i);
            ans++;
        }
    }
    cout << ans << endl;
    return (0);
}

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

using namespace std;

const int N = 1e6 + 5;

struct Data {
  long long x; 
  int y, z; 
};

int tot = 0;
long long ans[N];

void prk() {
  queue<Data> q;
  for (int i = 1; i <= 9; i++)
    q.push((Data){i, i, 1}), ans[++tot] = i;
  while (!q.empty()) {
    Data x = q.front();
    q.pop();
    if (x.z == 11)
      break;
    ans[++tot] = x.x * 10 + x.y;
    q.push((Data){ans[tot], x.y, x.z + 1});
    if (x.y - 1 >= 0) {
      ans[++tot] = x.x * 10 + x.y - 1;
      q.push((Data){ans[tot], x.y - 1, x.z + 1});
    }
    if (x.y + 1 <= 9) {
      ans[++tot] = x.x * 10 + x.y + 1; 
      q.push((Data){ans[tot], x.y + 1, x.z + 1});
    }
  }
  sort(ans + 1, ans + 1 + tot);
}

int main() {
  prk();
  int n;
  cin >> n;
  cout << ans[n] << '\n';
  return 0;
}

Measured memory_bytes: 12688
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 3e5+10;
const int N = 1e5+10;
const int E = 1e6+10;  
string s;

int main(){
	cin>>s;
	int n = s.size();
	char tmp = s[n-1];
	if(tmp=='3'){
		cout<<"bon"<<endl;
	}
	else if(tmp=='0'||tmp=='1'||tmp=='6'||tmp=='8'){
		cout<<"pon"<<endl;
	}
	else cout<<"hon"<<endl;
}

Measured memory_bytes: 3632
//==========================================c#
/* ===========================================
// null
// 
// 
=========================================== */
using System; //Console, IComparable
using System.IO; //StreamWriter 
using System.Linq; //Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; //List<T>

class Program { 
    static void Main() { 
        StreamWriter so = new StreamWriter(Console.OpenStandardOutput());
        string[] sip; int[] iip;
        
        var n = int.Parse(Console.ReadLine());
        
        var chk = true;
        iip = Console.ReadLine().Split(' ').Select(fd=>int.Parse(fd)).ToArray();
        
        for (int i = 0; i < n; i++){
            var a = iip[i];
            
            if ((a&1) == 0){
                if (a%3 == 0 || a%5 == 0){
                    continue;
                }
                else{
                    chk = false;
                    break;
                }
            }
            else{
                continue;
            }
        }

        if (chk == true){
            Console.WriteLine("APPROVED");
        }
        else{
            Console.WriteLine("DENIED"); 
        }


    } 
}


/* ===========================================
            int n = int.Parse(Console.ReadLine());

for(int i = 0; i < n; i++){
                int sum = Console.ReadLine().Split().Select(int.Parse).Sum();
                so.WriteLine(sum.ToString());
            }
            so.Close();
=========================================== */

Measured memory_bytes: 13396
n, m = map(int, input().split())
prefectures = [[] for _ in range(10 ** 5)]

for i in range(m):
    p, y = map(int, input().split())
    prefectures[p - 1].append([y, i])

ans = [''] * m
for p in range(10 ** 5):
    prefecture = prefectures[p]
    prefecture.sort(key=lambda x: x[0])
    for i in range(len(prefecture)):
        ans[prefecture[i][1]] = '{:006}{:006}'.format(p + 1, i + 1)

for i in range(m):
    print(ans[i])


Measured memory_bytes: 78368
#include <stdio.h>
#include <math.h>

int main(void) {
  int i,n,x[101],y[101];
  double Da,Db,Dc,Dd = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&x[i]);
  }
  for(i = 0; i < n; i++){
    scanf("%d",&y[i]);
  }

  for(i = 0; i < n; i++){
    if(x[i] >= y[i])Da += (x[i] - y[i]);
    else Da += (y[i] - x[i]);
  }
  printf("%lf\n",Da);

  for(i = 0; i < n; i++){
    if(x[i] >= y[i])Db += (x[i] - y[i]) * (x[i] - y[i]);
    else Db += (y[i] - x[i]) * (y[i] - x[i]);
  }
  printf("%lf\n",sqrt(Db));
  
  for(i = 0; i < n; i++){
    if(x[i] >= y[i])Dc += (x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
    else Dc += (y[i] - x[i]) * (y[i] - x[i]) * (y[i] - x[i]);
  }
  printf("%lf\n",pow(Dc,0.3333333333));

  for(i = 0; i < n; i++){
    if(x[i] > y[i] && Dd < (x[i] - y[i]))Dd = (x[i] - y[i]);
    if(x[i] < y[i] && Dd < (y[i] - x[i]))Dd = (y[i] - x[i]);
  }
  printf("%lf\n",Dd);
  return 0;
}


Measured memory_bytes: 2104
/* ex3_4
    riverstone*/


#include <stdio.h>
 
int main(void){
    int number=0;
    int i=0;

    // number の入力を取得
    scanf("%d",&number);

    // iを総当たり
    // 割り切れるものがあればyes、なければNoを出力
    for(i=1;i<10;i++){
        //numberがiで割り切れてかつ商が9以下ならいい。
        if(number % i == 0 && number/i < 10){
          printf("Yes");
          return 0;
        } 
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int F[200][20][2];
int P[200][20];

int ans=-INF;

int Sells(int bit){
    int sells=0;
    vector<P1> time;
    for(int j=0;j<5;++j){
        for(int k=0;k<2;++k){
            int b=pow(2,j*2+k);
            if(bit&b)time.push_back(P1(j,k));
        }
    }
    for(int i=0;i<N;++i){
        int kaburi=0;
        for(auto u:time){
            if(F[i][u.first][u.second])kaburi++;
        }
        sells+=P[i][kaburi];
    }
    return sells;
}

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)for(int j=0;j<5;++j)for(int k=0;k<2;++k)cin>>F[i][j][k];
    for(int i=0;i<N;++i)for(int j=0;j<=10;++j)cin>>P[i][j];
    for(int bit=1;bit<1024;++bit){
        if(ans<Sells(bit))ans=Sells(bit);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
a,b = gets.split.map(&:to_i)
sum = 0

if a >= b
    for i in 0..a-1 do
        sum = sum + (b * (10 ** i))
    end
else
    for i in 0..b-1 do
        sum = sum + (a * (10 ** i))
    end
end

puts(sum)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    int ans = n;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] != s[i + 1]) {
            ans = min(ans, max(i + 1, n - (i + 1)));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512