akhauriyash/Code-Regression huggingface dataset:
import sys
n = int(input())
# 1とかの時例外処理

import math
def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def factorization(n):
    '''
    [base,power]のリストを返す
    '''
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n,1])

    return arr

base_power = [0] * 100
for i in range(2,n+1):
    arr = factorization(i)
    for base, power in arr:
        base_power[base] += power

More_2 = 0
More_4 = 0
More_14 = 0
More_24 = 0
More_74 = 0
for base in range(100):
    if base_power[base] >= 2:
        More_2 += 1
    if base_power[base] >= 4:
        More_4 += 1
    if base_power[base] >= 14:
        More_14 += 1
    if base_power[base] >= 24:
        More_24 += 1
    if base_power[base] >= 74:
        More_74 += 1

ans = 0
if More_2 - 2 > 0 and More_4 >= 2:
    ans += nCr(More_4,2)*(More_2-2)
if More_2 - 1 > 0 and More_24 > 0:
    ans += More_24 * (More_2-1)
if More_14 > 0 and More_4-1>0:
    ans += More_14 * (More_4-1)
if More_74 > 0:
    ans += More_74
print(ans)


Measured memory_bytes: 62852
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=1e7+5;

void solve()
{
	int n;
	cin>>n;
	
	if(n%7==0) n/=7;
	
	int curr=0;
	int now=1;
	int moves=1;
	
	while(moves<mx)
	{
		curr+=now;
		curr%=n;
		
		if(curr%n==0)
		{
			cout<<moves;
			return;
		}
		
		now*=10;
		now%=n;
		moves++;
	}
	
	cout<<-1;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int t=1;
	//cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


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


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


def ceil(a, b):
    return (a + b - 1) // b


def main():
    H, W = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))

    c = []
    for i, a in enumerate(A, start=1):
        c += [i] * a

    no = 0
    ans = [[-1] * W for _ in range(H)]
    for y in range(H):
        if y % 2 == 0:
            for x in range(W):
                ans[y][x] = c[no]
                no += 1
        else:
            for x in range(W - 1, -1, -1):
                ans[y][x] = c[no]
                no += 1

    for line in ans:
        print(*line, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4712
#coding: UTF-8

NK = list(map(int, input().split()))
A = list(map(int, input().split()))

N,K = NK[0],NK[1]

wb = True
counter = 0


while wb:
    if counter == 0:
        N = N - K
    else:
        N = N - (K - 1)
    counter+=1
    if N <= 0:
        wb = False

print(counter)

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 1000000007
int main() {
	int m = ri();
	std::string s;
	std::cin >> s;
	std::reverse(s.begin(), s.end());
	for (auto &c : s) c -= '0';
	int n = s.size();
	if (n == 1) {
		if (m < 10) std::cout << m << std::endl;
		else std::cout << -1 << std::endl;
		return 0;
	}
	int cur = 1;
	int cnt[10] = { 0 };
	for (int i = 0; i < n; i++) {
		cnt[s[i]] += cur;
		if (cnt[s[i]] >= MOD) cnt[s[i]] -= MOD;
		cur = (int64_t) cur * 10 % MOD;
	}
	int pos[10];
	std::iota(pos, pos + 10, 0);
	do {
		if (!pos[s.back()]) continue;
		int x = 0;
		for (int i = 0; i < 10; i++) {
			x += (int64_t) pos[i] * cnt[i] % MOD;
			if (x >= MOD) x -= MOD;
		}
		if (x == m) {
			std::string res;
			for (int i = 0; i < n; i++) res.push_back('0' + pos[s[i]]);
			std::reverse(res.begin(), res.end());
			std::cout << res << std::endl;
			return 0;
		}
	} while (std::next_permutation(pos, pos + 10));
	std::cout << -1 << std::endl;
	return 0;
}





Measured memory_bytes: 3364
def I(): return int(input())
def MI(): return map(int, input().split())
def LMI(): return list(map(int, input().split()))

N = I()
A = [I() for _ in range(N)]

seen = set()
i = 0
light = 1
while light != 2:
    seen.add(light)
    light = A[light - 1]
    if light in seen:
        print(-1)
        exit(0)
    i += 1
print(i)


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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 200002

int n;
char s[MAXN];
int a[MAXN];
int c[MAXN];

inline bool check() {
	for (int i = 0; i < n; ++i) {
		int left = (i - 1 + n) % n;
		int right = (i + 1 + n) % n;
		if (!c[i]) {
			if (a[i] && c[left] != c[right]) return 0;
			if (!a[i] && c[left] == c[right]) return 0;
		} else {
			if (!a[i] && c[left] != c[right]) return 0;
			if (a[i] && c[left] == c[right]) return 0;
		}
	}
	return 1;
}

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);
	scanf("%s", s);

	for (int i = 0; i < n; ++i) {
		a[i] = s[i] == 'o';
	}

	for (int f1 = 0; f1 < 2; ++f1) {
		for (int f2 = 0; f2 < 2; ++f2) {
			c[0] = f1;
			c[1] = f2;
			for (int i = 2; i < n; ++i) {
				if (!c[i - 1])
					c[i] = a[i - 1] ? c[i - 2] : 1 - c[i - 2];
				else
					c[i] = !a[i - 1] ? c[i - 2] : 1 - c[i - 2];
			}
			if (check()) {
				for (int i = 0; i < n; ++i)
					printf("%c", c[i] ? 'W' : 'S');
				puts("");
				return 0;
			}
		}
	}

	puts("-1");

	return 0;
}


Measured memory_bytes: 1280
# -*- coding: utf-8 -*-
N ,K=map(int ,raw_input().split())
S =raw_input()
s = S[K-1]
s = s.lower()
S1 = ''
if K > 1:
    S1 = S[:K-1]
S2 = ''
if K<N:
    S2 = S[K:]
s =S1+s+S2
print s

Measured memory_bytes: 2568
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        long x = sc.NextLong();
        for (long a = -3000; a <= 3000; a++)
        {
            long a5 = a * a * a * a * a;
            for (long b = -3000; b <= 3000; b++)
            {
                if (a5 - b * b * b * b * b == x)
                {
                    Console.WriteLine($"{a} {b}");
                    return;
                }
            }
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

int main()
{
 	int N;
  	char S[100];
	std::cin >> N;
  	std::cin >> S;
  
  	if (N%2 != 0)
      	std::cout << "No" << std::endl;
    else {
  
  	bool flag = true;
  	for (int i=0;i<N/2;i++) {
     	if (S[i] != S[i+N/2]) {
          flag = false; 
          break;
        }
    }
  
    if (flag)
    	std::cout << "Yes" << std::endl;
    else
       	std::cout << "No" << std::endl;
    }
  
 	return 0;
}
  
  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <cmath>
#include <limits>
#include <stack>

using namespace std;

int main(){
  long X;
  cin >> X;
  for(int i=1;i<=X;++i){
    if(X<=i*(i+1)/2){
       cout << i << endl;
       break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = [list(map(int,input().split())) for i in range(M)]

l = -1
r = float("inf")

for x,y in A :
    if l < x :
        l = x
    if y < r :
        r = y
print(max(0,r-l+1))


Measured memory_bytes: 27332
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

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

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here

	ll N, W; cin >> N >> W;

	ll w1,w, v;
	vl va[105];

	cin >> w1 >> v;

	va[0].pb(v);

	FOR(i, 1, N)
	{
		cin >> w >> v;
		w -= w1;
		va[w].pb(v);
	}
	rep(i, 4) rvsort(va[i]);
//	rep(i, 4) Print(va[i].size());
	ll ans = 0;

	rep(i, (int)va[3].size()+1)
	{
		ll totalw3 = i * (w1 + 3);
		if (totalw3 > W) continue;
		ll value3 = 0;
		rep(s, i) value3 += va[3][s];
		//Print(value);
		rep(j, (int)va[2].size()+1)
		{
			ll totalw2 = totalw3 +j * (w1 + 2);
			if (totalw2 > W) continue;
			ll value2 = value3;
			rep(s, j) value2 += va[2][s];
			rep(k, (int)va[1].size()+1) 
			{
				ll totalw1 =totalw2+ k * (w1 + 1);
				if (totalw1 > W)continue;
				ll value = value2;
				rep(s, k) value += va[1][s];
				ll nokori = min((W - totalw1) / w1, (ll)va[0].size());
				rep(s, nokori) value += va[0][s];

				ans = max(ans, value);
			}
			
		}

	}

	Print(ans);

	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int isPrime(int x)
{
    int up = sqrt(x);
    if(x==1)
        return 0;
    if(x==2||x==3)
        return 1;
    for(int i = 2;i<=up;i++)
    {
        if((x%i)==0)
            return 0;
    }
    return 1;
    
}
int main()
{
    int a,ans;
    scanf("%d",&a);
    for(int i = a;;i++)
    {
        if(isPrime(i))
        {
            ans = i;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

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

void solve() {
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	
	// each hr = 30deg, each minute = .5 deg
	double hp = 30*h + 0.5*m;
	// each minute = 6 degrees
	double mp = ((60*h + m) % 60) * 6;
	double ang = abs(hp-mp);
	
	double c = sqrt(a*a + b*b - 2*a*b*cos(ang*M_PI/180.0));
	
	cout.precision(15);
	cout << c << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  priority_queue<pair<ll, ll>> pq;
  rep(i, n) pq.push({b[i], i});
  ll ans = 0;
  while (!pq.empty()) {
    ll i = pq.top().second;
    pq.pop();
    if (b[i] < a[i]) break;
    if (b[i] == a[i]) continue;
    ll x = (b[i] - a[i]) / (b[(i - 1 + n) % n] + b[(i + 1) % n]);
    ans += x;
    b[i] -= x * (b[(i - 1 + n) % n] + b[(i + 1) % n]);
    if (x) pq.push({b[i], i});
  }
  cout << (a == b ? ans : -1) << '\n';


  




  
  return 0;
}

Measured memory_bytes: 9584
mod = 10**9+7
n,k = map(int,input().split())
ki = [[]for _ in range(n)]
l = max(n,k)
frac = [1]*(l+1)
for i in range(1,l+1):
    frac[i] = (frac[i-1]*i)%mod
invfrac = [1] *(l+1)
invfrac[-1] = pow(frac[-1],mod-2,mod)
for i in range(l-1,0,-1):
    invfrac[i] = (invfrac[i+1]*(i+1))%mod

def P(x,y):
    return (frac[x]*invfrac[x-y])%mod
    

for i in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)

stack = [0]
visited = [0]*n
visited[0] = 1
ans = 1
while stack:
    next = []
    for now in stack:
        visited[now] = 1
        
        if now !=0:
            ans *=P(k-2,len(ki[now])-1)
            if len(ki[now])-1 >= k-1:ans = 0
            
            ans %=mod
        for x in ki[now]:
            if visited[x]:continue
            next.append(x)
    stack = next
ans *= P(k,len(ki[0])+1)
ans %=mod
print(ans)


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

int m[300][300];
vector<pair<int, pair<int, int> > > v;

int main()
{
  int n;cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      {
	scanf("%d",&m[i][j]);
	if(i!=j)
	  v.push_back(make_pair(m[i][j],make_pair(i,j)));
      }

  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      for(int k=0;k<n;k++)
	if(k!=i && k!=j && m[i][k]+m[k][j]<m[i][j])
	  {
	    printf("-1\n");
	    return 0;
	  }

  sort(v.begin(),v.end(),greater<pair<int, pair<int, int> > >());

  for(auto e : v)
    {
      int d=e.first;
      int u=e.second.first;
      int v=e.second.second;
      assert(d==m[u][v]);
      for(int k=0;k<n;k++)
	if(k!=u && k!=v && m[u][k]>0 && m[k][v]>0 && m[u][k]+m[k][v]==d)
	  {
	    //printf("cut %d-%d because of %d : %d+%d=%d\n",u,v,k,m[u][k],m[k][v],m[u][v]);
	    m[u][v]=0;
	    break;
	  }
    }
  ll res=0;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
      res+=m[i][j];
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1'000'000'007 //10^9+7

int main(){
  int N,M;cin>>N>>M;
  vector<ll>dp(N+1, -1);
  for(int i=0; i<M; i++){
    int a;cin>>a;
    dp[a] = 0;
  }
  dp[0] = 1;
  for(int i=1; i<=N; i++){
    if(dp[i]==0)continue;
    else if(i>=2){
      dp[i] = dp[i-1] + dp[i-2];
    }if(i==1){
      dp[i] = dp[i-1];
    }
    dp[i]%=LIMIT;
  }

  cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#define INF 100000
int dy[9]={1,1,1,1,1,2,2,2,3};
int dx[9]={2,1,0,-1,-2,1,0,-1,0};
int d[2][60][30];
int cost[60][30];
bool used[2][60][30];
int w,h;
bool check(int i,int j,int k){
	if(j>=0&&j<h&&k>=0&&k<w&&!used[i][j][k]&&cost[j][k]!=-1)return true;
	return false;
}
int min(int a,int b){return a<b?a:b;}
int main(){
	while(1){
	scanf("%d %d",&w,&h);
	if(w==0)return 0;
	int i,j,k;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			d[0][i][j]=INF;
			d[1][i][j]=INF;
			used[0][i][j]=false;
			used[1][i][j]=false;
			cost[i][j]=-1;
			char c;
			scanf(" %c",&c);
			if(c=='T')cost[i][j]=0;
			else if(c=='S'){
				d[0][i][j]=0;
				d[1][i][j]=0;
			}
			else if(c!='X')cost[i][j]=c-'0';
		}
	}
	while(1){
		int ni=-1,nj,nk;
		for(i=0;i<2;i++)for(j=0;j<h;j++)for(k=0;k<w;k++)if(!used[i][j][k]&&(ni==-1||d[i][j][k]<d[ni][nj][nk])){ni=i;nj=j;nk=k;}
		if(ni==-1)break;
		used[ni][nj][nk]=true;
		for(i=0;i<9;i++){
			int x=nj+dx[i];
			int y=nk;
			if(ni==0)y+=dy[i];
			else y-=dy[i];
			if(check((ni+1)%2,x,y)){
				if(d[(ni+1)%2][x][y]>d[ni][nj][nk]+cost[x][y]){
					d[(ni+1)%2][x][y]=d[ni][nj][nk]+cost[x][y];
				}
			}
		}
	}
	int ans=INF;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(cost[i][j]==0){
				ans=min(ans,d[0][i][j]);
				ans=min(ans,d[1][i][j]);
			}
		}
	}
	if(ans==INF)printf("-1\n");
	else printf("%d\n",ans);
	}
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for(int i = 0; i < h; i++) {
        cin >> g[i];
    }
    vector<string> red(h, string(w, '.'));
    vector<string> blue(h, string(w, '.'));
    for(int j = 0; j < w; j++) {
        if(j & 1) {
            red[0][j] = '#';
        } else {
            for(int i = 0; i < h - 1; i++) {
                red[i][j] = '#';
            }
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(g[i][j] == '#') {
                red[i][j] = blue[i][j] = '#';
            } else if(red[i][j] != '#') {
                blue[i][j] = '#';
            }
        }
    }
    for(int i = 0; i < h; i++) {
        print(red[i]);
    }
    print();
    for(int i = 0; i < h; i++) {
        print(blue[i]);
    }
    // print();
    // for(int i = 0; i < h; i++) {
    //     for(int j = 0; j < w; j++) {
    //         if(red[i][j] == blue[i][j] && red[i][j] == '#') {
    //             cout << '#';
    //         } else {
    //             cout << '.';
    //         }
    //     }
    //     cout << endl;
    // }
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int a[N],n;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int f=0,now=0;
	long long sum=0,ans=0;
	for(int i=0;i<n;i++)
	{
		now^=a[i],sum+=a[i];
		while(now!=sum)sum-=a[f],now^=a[f],f++;
		ans+=i-f+1;
	}
	cout<<ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
    using namespace std;
    signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a*b>c){
    cout<<c<<"\n";
    }
    if(a*b<=c){
    cout<<a*b<<"\n";
    }
    return(0);
    }

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

using namespace std;

#define int long long

signed main(){
	int n,k,s;
	cin >> n >> k >> s;
	for(int i=1;i<=k;i++){
		cout << s << " ";
	}
	if(s!=(int)1e9){
		for(int i=k+1;i<=n;i++){
			cout << (int)1e9 << " ";
		}
	}else{
		for(int i=k+1;i<=n;i++){
			cout << 1 << " ";
		}
	}
}

Measured memory_bytes: 1280
from collections import defaultdict

N, K = map(int, input().split())
A = list(map(int, input().split()))
cum = [0]*(N+1)
for i in range(1,N+1):
    cum[i] = cum[i-1] + A[i-1]
ans = 0
dic = defaultdict(int)
v_by_indx = defaultdict(int)
for i in range(N+1):
    if i-K >= 0:
        dic[v_by_indx[i-K]] -= 1
    diff = (cum[i]-i)%K
    ans += dic[diff]
    dic[diff] += 1
    v_by_indx[i] = diff
print(ans)


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

using namespace std;

int main(){
    ios_base::sync_with_stdio (false);
    long long a[250];
    int c=0,n,i,j,l=1;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    while(l!=0){
        for(i=0;i<n;i++){
            if(a[i]%2==1) l=0;
            else a[i]=a[i]/2;
        }
        if(l==1)
            c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
s = list(input())
flag = 0
count = 0

if s[0] == 'A':
    flag += 1
#print(flag)
a = s.pop(0)
b = s.pop(0)
c = s.pop(-1)

if s.count('C') == 1:
    flag += 1
#print(flag)
if flag ==2:
    s.append(b)
    s.append(c)
    #print(s)
    for i in range(len(s)):
        if s[i].islower():
            count += 1
        #print(count)
    if (count+1) == len(s):
        flag += 1
##print(flag)
if flag == 3:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    ll n,tmp,ans = 0;
    cin>>n;
    unordered_map<ll,ll>mp;
    rep(i,n){
        cin>>tmp;
        mp[tmp]++;
    }
    for(auto &itr:mp){
        if(itr.first >itr.second){
            ans += itr.second;
        }
        else {
            ans += itr.second - itr.first;
        }
    }
    cout<<ans<<endl;

}




Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;
    int h[N];
    for(int i=0;i<N;i++)
        cin >> h[i];

    int ans = 0;
    for(int i=0;i<N;i++){
        if(h[i] >= K){
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
// AtCoder ABC133: C - Remainder Minimization 2019
// 2019.9.2 bal4u

#include <stdio.h>

int a[2030];
int main()
{
	int i, j, t, L, R, ans;
	
	scanf("%d%d", &L, &R);
	if (R - L >= 2020) { puts("0"); return 0; }
	j = 0; for (i = L; i <= R; i++) a[j++] = i % 2019;
	ans = 2019, R = j;
	for (i = 0; i < R; i++) for (j = i+1; j < R; j++) {
		t = a[i]*a[j] % 2019;
		if (t < ans) ans = t;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
const static int MAX_N = 200000;
unsigned N, K;
unsigned A[MAX_N];

bool solve(unsigned length){
    unsigned answer = 0;
    for (unsigned i = 0; i < N; i++){
        answer += (A[i] - 1)/length;
        if(answer > K) return false;
    }
    return true;
}

int main(){
    scanf("%u %u", &N, &K);
    for(int i = 0; i < N; ++i){
        scanf("%u", A + i);
    }
	unsigned ok = 1000000000, ng = 0;
	while(ok - ng > 1){
		unsigned mid = (ok + ng)/2;
		if(solve(mid)) ok = mid;
		else ng = mid;
	}
    printf("%u\n", ok);
	return 0;
}

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

using namespace std;

#define ll long long

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

signed main(){
    int n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    ll lcm = 1;
    for (auto ai : a){
        ll g = gcd(lcm, ai);
        lcm = g * (lcm / g) * (ai / g);
    }

    cout << lcm << endl;

    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int H, W;
vector<vector<int>> c(10, vector<int>(10)), A;

void warshal(){
  REP(k, 10){
    REP(i, 10){
      REP(j, 10){
        if(c[i][j] > c[i][k] + c[k][j]){
          c[i][j] = c[i][k] + c[k][j];
        }
      }
    }
  }
}

int main(){
  cin >> H >> W;
  REP(i, 10){
    REP(j, 10){
      cin >> c[i][j];
    }
  }
  warshal();
  A.resize(H, vector<int>(W));
  ll ans = 0;
  REP(i, H){
    REP(j, W){
      cin >> A[i][j];
      if(A[i][j] != -1){
        ans += c[A[i][j]][1];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
    long int mod = 1000000007;
    int n;
    scanf("%d", &n);
    char s[2][n];

    for (int i = 0; i < 2; i++){
        char row[n];
        scanf("%s", row);
        for (int j = 0; j < n; j++){
            s[i][j] = row[j];
        }
    } 
    // int m = 1;
    char nxt = s[0][0];
    long int ans;
    int state;
    if (s[0][0] == s[1][0]) {
        ans = 3;
        state = 1;
    }
    else {
        ans = 6;
        state = 2;
    }
    for (int i = 1; i < n; i++){
        if (nxt != s[0][i]){
            if (s[0][i] == s[1][i]){
                if (state == 1){
                    ans *= 2;
                    nxt = s[0][i];
                    state = 1;
                }
                else{
                    ans *= 1;
                    nxt = s[0][i];
                    state = 1;
                }
            }
            else{
                if (state == 1){
                    ans *= 2;
                    nxt = s[0][i];
                    state = 2;
                }
                else{
                    ans *= 3;
                    nxt = s[0][i];
                    state = 2;
                }
            }

        }
        ans %= mod;
        // cout << ans << "\n";
    }

    printf("%ld\n", ans);
}


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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct SegmentTree{
    vector<int> A;
    ll N; // node num
 
    // 初期化
    SegmentTree(ll size){
        N = _powerOfTwo(size); //2べき
        A.resize(N * 2); // 木なので2倍必要
    }
 
    void Add(int X, int diff){
        int index = N + X - 1; // 葉のインデックス
        A[index] += diff;
        // 親にも反映
        while(index > 0){
            index = (index-1) / 2;
            A[index] += diff;
        }
    }
  
    void DebugPrint(){
        pn(A[0]);
    }
 
    // 引数以上の2のべき乗 5=>8
    ll _powerOfTwo(int n){
        ll ret = 1;
        while(ret < n){
            ret *= 2;
        }
        return ret;
    }
 
    // 区間[a,b)の総和。ノードk =[l,r) に着目している
    ll _rangeSum(int a, int b, int k, int l, int r){
        //cout << "_rangeSum() " << a << " " << b << " " << k << " " << l << " " << r << endl;
 
        // 重ならない
        if(r <= a || b <= l){
            return 0;
        }
        // 内包する
        else if(a <= l && r <= b){
            return A[k];
        }
        // 重なる部分もある
        else{
            ll center = (l+r) / 2;
            // 左下の子
            ll sum0 = _rangeSum(a, b, 2*k+1, l, center);
            // 右下の子
            ll sum1 = _rangeSum(a, b, 2*k+2, center, r);
            return sum0 + sum1;
        }
    }
 
    // [a, b) までの和
    // 半開区間
    ll RangeSum(int a, int b){
        //cout << "range sum [" << a << "," << b << ")" << endl;
        return _rangeSum(a, b, 0, 0, N);
    }
};

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

    // input
    ll N, Q;
    cin >> N >> Q;

    auto st = SegmentTree(N);

    FOR(i, 0, Q){
        ll com, x, y;
        cin >> com >> x >> y;

        // add
        if(com==0){
            st.Add(x-1, y);
        }
        // get sum
        else{
            // cout << "range " << x << " " << y+1 << endl;
            ll sum = st.RangeSum(x-1, y);
            p(sum);
        }

        // st.DebugPrint();
    }
    
    return 0;
}


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

int main(){
    string n;
    int res=0;
    cin >> n;
    for(int i=0; i<3; ++i){
        if(n[i] == n[2-i]){
            res ++;
        }
    }
    if(res == 3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005


ll A[SIZE];

int main(){

	ll N;
	scanf("%lld",&N);

	ll all = 0;

	for(ll i = 0; i < N; i++){

		scanf("%lld",&A[i]);
		all ^= A[i];
	}

	printf("%lld",all^A[0]);
	for(ll i = 1; i < N; i++){

		printf(" %lld",all^A[i]);
	}

	printf("\n");

	return 0;
}


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

ll N, ans = 0;

void dfs(ll x, ll a, ll b, ll c) {
	if (x > N) return;
	if (a && b && c) ans++;
	dfs(10 * x + 3, 1, b, c);
	dfs(10 * x + 5, a, 1, c);
	dfs(10 * x + 7, a, b, 1);
}

int main() {
	cin >> N;
	dfs(0, 0, 0, 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define bit(n,m)((n>>m)&1)

#define M 1000000007
//a^b=x,a+b=y,a|b=bとして(a,b)と(x,y)が1対1対応するので(a,b)の個数を数えれば良い
//dp[見た桁数][a^bが(n mod 2**keta)以下か][a+b>=2**ketaか][(a+b mod 2**keta)が(n mod 2**keta)以下か]
ll dp[99][2][2][2];
int main(){
	ll n;
	scanf("%lld",&n);
	dp[0][1][0][1]=1;
	rep(keta,0,62){
		rep(p,0,2)rep(q,0,2)rep(r,0,2){
			//0a,0bのとき0x,(0+繰り上がり)y
			dp[keta+1][p||bit(n,keta)][0][(q^r)?r:bit(n,keta)]+=dp[keta][p][q][r];
			//0a,1bのとき1x,(1+繰り上がり)y
			dp[keta+1][p&&bit(n,keta)][q][(q^r)?bit(n,keta):r]+=dp[keta][p][q][r];
			//1a,1bのとき0x,1(繰り上がり)y
			dp[keta+1][p||bit(n,keta)][1][(q^r)?r:bit(n,keta)]+=dp[keta][p][q][r];
		}
		rep(p,0,2)rep(q,0,2)rep(r,0,2)dp[keta+1][p][q][r]%=M;
	}
	printf("%lld\n",dp[62][1][0][1]);
	return 0;
}

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

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

    while (true) {
        int a, b;
        string s;
        cin >> a >> s >> b;

        if (s == "+") {
            cout << (a + b) << endl;
        } else if (s == "-") {
            cout << (a - b) << endl;
        } else if (s == "*") {
            cout << (a * b) << endl;
        } else if (s == "/") {
            cout << (a / b) << endl;
        } else {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3228
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var i int
  var r, g, b string
  fmt.Scan(&r, &g, &b)

  rgb :=  r + g + b
  i, _ = strconv.Atoi(rgb)

  if i % 4 == 0 {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }
}

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


public class Main 
{
	static ArrayList<Integer> prime = new ArrayList<>();
	
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		create();
		
		for(; scanner.hasNext(); )
		{
			int n = scanner.nextInt();
			int i = 0;
			int min=0, max=0;
			for(; i<prime.size(); i++)
			{
				if(n == prime.get(i))
				{
					min = prime.get(i-1);
					max = prime.get(i+1);
					break;
				}
				else if(n < prime.get(i))
				{
					min = prime.get(i-1);
					max = prime.get(i);
					break;
				}
			}
			System.out.println(min + " " + max);
		}
	}
	
	private static void create()
	{
		for(int i=2; i<=99999; i+=(i==2)?1:2)
		{
			int p = (int)Math.sqrt(i);
			boolean is_prime = true;
			for(int j=2; j<=p; j+=(j==2)?1:2)
			{
				if(i % j == 0)
				{
					is_prime = false;
					break;
				}
			}
			if(is_prime)
			{
				prime.add(i);
			}
		}
	}
}

Measured memory_bytes: 26984
import java.util.*;
 
 
class Main {
    static int abc[];
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int A[] = new int[N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i=0; i<N; i++){
            sum += A[i];
        }
        if(sum%2==0){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 50324
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"A=abs;n=int(input());p=eval('list(map(int,input().split())),'*n);x,y,h=[x for x in p if x[2]][0]\n"
"for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007

bool dbgflag = false;

ll make_primes(ll max_value, vector<ll>&primes) {
  ll q = 2;
  ll cnt = 0;
  while (q <= max_value) {
    bool flag = true;
    for (ll p: primes) {
      if (q % p == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      primes.emplace_back(q);
      cnt++;
    }
    q++;
  }
  return cnt;
}

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

  int n;
  cin >> n;

  vector<map<int, int>> factorize(n);
  vector<ll> primes;
  ll pn = make_primes(n, primes);

  for (int i = 1; i <= n; i++) {
    int num = i;
    //if (dbgflag) cout << num << endl;
    for (int p: primes) {
      while (num % p == 0) {
        factorize[i-1][p]++;
        num /= p;
      }
    }
  }

  map<int, int> nf;
  for (int i = 0; i < n; i++) {
    for (int p: primes) {
      nf[p] += factorize[i][p];
    }
  }

  //if (dbgflag) cout << (nf[2]+1) * (nf[3]+1) * (nf[5]+1) * (nf[7]+1) << endl;
  int cnt = 0;
  vector<int> fcts = {1};
  
  for (int p: primes) {
    int s = fcts.size();
    for (int i = 0; i < s; i++) {
      for (int j = 1; j <= nf[p]; j++) {
        int k = (fcts[i])*(j+1);
        //cout << j << " " << k << endl;
        if (!((k == 1) || (k == 3) || (k == 5) || (k == 15) || (k == 25) || (k == 75))) continue;
        fcts.emplace_back((fcts[i])*(j+1));
      }
    }
  }

  for (int f: fcts) {
    if (dbgflag) cout << f << endl;
    if (f == 75) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <stdlib.h>

using namespace std;


int a[100001] = {};

int main()
{
  int n;
  map<int,int> m;
  int ans = 0;
  int p = 0;


  cin >> n;
  int tmp;

  cin >> tmp;
  m.insert(make_pair(tmp,p++));
  a[0]++;

  for(int i=0;i<n-1;i++){
    cin >> tmp;
    decltype(m)::iterator it = m.find(tmp);

    if(it != m.end()){
      a[ it->second ]++;
    }
    else{
      m.insert(make_pair(tmp,p));
      a[p++]++;
    }
  }


  for(int i=0;i< 100001;i++){
    ans += ( a[i]%2 );
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k, q; cin >> n >> k >> q;
    int cnt[n];
    memset(cnt, 0, sizeof cnt);
    for(int i=0;i<q;i++){
        int a; cin >> a;
        cnt[a-1]++;
    }
    for(int i=0;i<n;i++){
        if(k - q + cnt[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
 
int dist(int x1,int y1,int x2,int y2){
  return abs(x1-x2)+abs(y1-y2);
}
 
int main(){
  int N,M;
  int a[100],b[100],c[100],d[100];
  scanf("%d %d",&N,&M);
  for(int i=0;i<N;i++){ scanf("%d %d",&a[i],&b[i]); }
  for(int j=0;j<M;j++){ scanf("%d %d",&c[j],&d[j]); }
  for(int i=0;i<N;i++){
    int min=INT_MAX;
    int index=0;
    for(int j=0;j<M;j++){
      int distance = dist(a[i],b[i],c[j],d[j]);
      if(min >  distance ){
         min = distance;
         index=j;
      }
     }
     printf("%d\n", index+1);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll a[26],b[26];
int main() {
	for(int i=0;i<26;i++){
		a[i]=b[i]=INF;
	}
	string s,t;
	cin>>s>>t;
	for(int i=0;i<t.size();i++){
		ll nowt=t[i]-'a';
		ll nows=s[i]-'a';
		if(a[nowt]==INF){
			a[nowt]=nows;
			continue;
		}
		if(a[nowt]!=nows){
			cout <<"No";
			return 0;
		}
	}
	for(int i=0;i<t.size();i++){
		ll nowt=t[i]-'a';
		ll nows=s[i]-'a';
		if(b[nows]==INF){
			b[nows]=nowt;
			continue;
		}
		if(b[nows]!=nowt){
			cout <<"No";
			return 0;
		}
	}	
	cout <<"Yes";
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int x , n;
	cin >> x >> n;

	mset(A,0);
	loop(i,0,n)
	{
		int a;
		cin >> a;
		A[a] = 1;
	}


	int ans = 1005;

	int cnt = 0;

	loop(i,0,105)
	{
		if(A[i] == 0)
		{
			if(ans > abs(i-x))
			{
				ans = abs(i-x);
				cnt = i;
			}
		}
	}

	cout << cnt;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 19260
///Bismillahir Rahmanir Rahim
#define ll long long
#define pii pair<ll,ll>
#define m_p  make_pair
#define ull unsigned long long
#define spd  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
ll ans[N],cum_sum[N];
int main()
{
    spd;
    ll n,i,cnt=0,mx=0;
    string s;

    cin>>s;

    for(i=0;i<s.size();i++)
    {
        if(s[i]=='S')
        {
            mx = max(mx,cnt);
            cnt = 0;
        }

        else
            cnt++;
    }

    mx = max(mx,cnt);
    cout<<mx<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,k=1;
    cin>>n;
    for(i=1;i<10;i++)
    {
        for(j=1;j<10;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes"<<endl;
                goto a;
            }
            else
            {
                k=0;
            }
        }
    }
    if(k==0)
        cout<<"No"<<endl;
    a:
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=100010;
int fa[N],p[N],f[N],g[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
int main() {
    int n,m,ans=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++) fa[i]=i,p[i]=gi();
    for(int i=1;i<=m;i++) fa[find(gi())]=find(gi());
    for(int i=1;i<=n;i++) {
	int x=find(i);
	f[i]=x,g[p[i]]=x;
    }
    for(int i=1;i<=n;i++) ans+=(f[i]==g[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;



template <typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}


int main()
{

    int N,M;
    cin >> N >> M;
    string S;
    cin >> S;
    
    int posi = N;
    vi ans;
    while (posi > 0) {
        int move = 0;
        reps(i,1,M+1){
            if(S[posi-i] == '0') move = i;
        }
        if(move == 0){
            out(-1);
            return 0;
        }
        
        if(posi - move < 0) move = posi;
        ans.pb(move);
        posi -= move;
    }
    
    reverse(all(ans));
    outve(ans);

    return 0;
}


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

int dp[301][301];
int n;
int a[301];

bool dfs(int l, int r) {
	if (r - l <= 0) return dp[l][r] = true;
	if ((r - l) % 2) return dp[l][r] = false;
	if (dp[l][r] != -1) return dp[l][r];
	
	bool ret = false;
	if (abs(a[l] - a[r - 1]) <= 1) { ret |= dfs(l + 1, r - 1); }
	for (int i = l + 1; i < r; i++) {
		if (ret) { break; }
		ret |= (dfs(l, i) && dfs(i, r));
	}
	return (dp[l][r] = ret);
}

int dp2[301];

int main() {
	int i, j;
	
	while (cin >> n) {
		if (!n) break;
		for (i = 0; i < n; i++) cin >> a[i];
		for (i = 0; i < n; i++) for (j = 0; j <= n; j++) dp[i][j] = -1;
		for (i = 0; i < n; i++) for (j = i; j <= n; j++) dfs(i, j);
		
		for (i = 0; i <= n; i++) dp2[i] = 114514;
		dp2[0] = 0;
		for (i = 0; i < n; i++) {
			dp2[i + 1] = min(dp2[i + 1], dp2[i] + 1);
			for (j = i + 1; j <= n; j++) {
				if (dp[i][j]) {
					dp2[j] = min(dp2[j], dp2[i]);
				}
			}
		}
		cout << n - dp2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using P = pair<int, int>;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 998244353;
    int n;
    cin>>n;
    switch(n%10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon"<<endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon"<<endl;
            break;
        default:
            cout<<"bon"<<endl;
            break;
    }
}


Measured memory_bytes: 3640