akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

L = 1

for Ai in A:
    L = lcm(L, Ai)

L %= MOD
ans = 0

for Ai in A:
    ans += L*pow(Ai, MOD-2, MOD)
    ans %= MOD

print(ans)


Measured memory_bytes: 41836
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/agc023/editorial.pdf
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def nCr(n, r):
    # 10C7 = 10C3
    r = min(r, n-r)
    return factorial(n) // (factorial(r) * factorial(n-r))

N = INT()
aN = LIST()

sm = [0] * (N+1)
for i in range(N):
    sm[i+1] = sm[i] + aN[i]

c = Counter(sm)
ans = 0
for k, v in c.items():
    if v >= 2:
        ans += nCr(v, 2)
print(ans)


Measured memory_bytes: 43112
import sys
input = sys.stdin.readline

def same(node_a, node_b):
    if node_a.root() == node_b.root():
        return True
    else:
        return False

def unite(node_a, node_b):
    root_a = node_a.root()
    root_b = node_b.root()
    if root_a == root_b:
        return False
    if root_b.depth > root_a.depth:
        root_a, root_b = root_b, root_a
    root_b.is_root = False
    root_b.parent = root_a
    root_a.depth = max(root_a.depth, root_b.depth+1)
    return True

class Node:
    def __init__(self):
        self.is_root = True
        self.parent = None
        self.depth = 1
    
    def root(self):
        node = self
        while not node.is_root:
            node = node.parent
        return node

def main():
    n, q = map(int, input().split())

    nodes = [Node() for i in range(n)]

    for i in range(q):
        c, x, y = map(int, input().split())
        if c == 0:
            unite(nodes[x-1], nodes[y-1])
        else:
            if same(nodes[x-1], nodes[y-1]):
                print(1)
            else:
                print(0)

if __name__ == "__main__":
    main()


Measured memory_bytes: 7956
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int i,j,k,l,n,a[202];
    set<int>s;
   cin>>n;
    for(i=0;i<n;i++){cin>>a[i];}
    for(i=0;i<n;i++){s.insert(a[i]);}
        cout<<s.size()<<endl;
     


}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;
    cin>>N;
    LL A[N];
    REP(i,N)cin>>A[i];

    sort(A,A+N);
    set<LL> used;

    int cnt=0;
    LL ans=1;

    REP(i,N){
        if(used.find(A[N-1-i])!=used.end()){
            cnt++;
            ans*=A[N-1-i];
            used.erase(A[N-1-i]);
            if(cnt==2)break;
        }else{
            used.insert(A[N-1-i]);
        }

    }

    if(cnt==2){
        cout<<ans<<endl;
    }else{
        cout<<0<<endl;
    }

    return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    int n;
    cin >> n;
    vector<int> v(n);
    forn(i, n)cin >> v[i];
    int ans = 0;
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            for(int k = j + 1; k < n; k++) {
                int arr[3] = {v[i], v[j], v[k]};
                sort(arr, arr + 3);
                if(arr[0] != arr[1] && arr[1] != arr[2] && arr[2] < arr[0] + arr[1]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    int ans = 1e9;

    for (int left = 0; left + K <= N; left++) {
        // xi〜xi+Kまで。
        
        int right = left + K - 1;

        int dist = x[right] - x[left];

        // 先にleftから。
        ans = min(ans, dist + abs(x[left]));

        // 先にrightから。
        ans = min(ans, dist + abs(x[right]));

    }

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

Measured memory_bytes: 3784
//by lqs_boyfriend
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
int n,mod;
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
int fact[100005],inv[100005];
int C(int nn,int mm){
	return fact[nn]*inv[mm]%mod*inv[nn-mm]%mod;
}
inline void add(int &x,int y){
	x+=y;x%=mod;
}
inline int Inv(int x){
	return modpow(x,mod-2);
}
signed main(){
	cin>>n>>mod;
	fact[0]=1;
	for(int i=1;i<=1e5;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=0;i<=1e5;i++)inv[i]=modpow(fact[i],mod-2);
	int ans=0;
	for(int i=0;i<=n*3;i++){
		for(int j=0;j*2+i<=n*3;j++){
			if(i<j)continue;
			int tmp=n*3-i-j*2;
			if(tmp%3)continue;
			int c1=tmp/3;
			add(ans,fact[n*3]*inv[i]%mod*inv[j]%mod*inv[c1]%mod*Inv(modpow(3,c1))%mod*Inv(modpow(2,j))%mod); 
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

ll c,d;

int main(){
    ll i,j;
    ll n,a,b;
    cin>>n>>a>>b>>c>>d;
    n--;
    ll dif=b-a;
    for(i=0;i<n;i++){
        ll ne=n-i;
        if(dif>=i*c-d*ne&&dif<=i*d-c*ne) {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;



    

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    int n;
    cin >> n;
    vi p(n);
    rep(i, n){
        cin >> p[i];
    }
    int ans = 0;
    REP(i, n-1){
        if((p[i-1] > p[i] && p[i+1] < p[i])||(p[i-1] < p[i] && p[i+1] > p[i])){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

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++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int n,ans = 0,now = 0;
	string s;
	cin >> n >> s;
	REP(i, n) {
		if (s[i] == 'I') {
			now++;
			ans = max(ans, now);
		}
		else {
			now--;
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A= list(map(int, input().split()))
A.sort()

ANS = A[2] - A[1]
A[0] +=  A[2] - A[1]
if (A[2] - A[0]) % 2 == 0:
    ANS += (A[2] - A[0])//2
    print(ANS)
else:
    ANS += (A[2] - A[0]+1)//2
    print(ANS+1)

Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

Anum = [0] * N
for i in A:
    Anum[i-1] += 1

cnt = 0
for i in Anum:
    cnt += i*(i-1)//2

for k in range(N):
    ans = cnt - (Anum[A[k]-1]-1)
    print(ans)


Measured memory_bytes: 26140
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p = p[:x]
q = q[:y]
p.append(0)
q.append(0)
r += [0] * (10 ** 3)


wa = x + y

lsp = x - 1
lsq = y - 1

pi = 0
qi = 0
ri = 0

ans = 0

for i in range(wa):
    if x > 0 and p[pi] == max(p[pi], q[qi], r[ri]):
        ans += p[pi]
        pi += 1
        x -= 1
    elif y > 0 and q[qi] == max(p[pi], q[qi], r[ri]):
        ans += q[qi]
        qi += 1
        y -= 1
    elif r[ri] == max(p[pi], q[qi], r[ri]):
        ans += r[ri]
        ri += 1
        if y > 0 and p[lsp] >= q[lsq]:
            y -= 1
            if lsq == 0:
                continue
            else:
                lsq -= 1
        elif x > 0 and p[lsp] < q[lsq]:
            x -= 1
            if lsp == 0:
                continue
            else:
                lsp -= 1

print(ans)

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

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

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

    int k;
    cin>>k;
    string ans = "";
    for(int i = 0; i < k; i++){
        ans += "ACL";
    }
    cout<<ans<<"\n";
}

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

int main() {
  int N;
  int result=0;
  cin >> N;
  
  for(int i=0;i < N ; i++){
      int A,s=0;
      cin >> A;
    for(int j =0; A%2==0;j++){
      s+=1;
      A/=2;
     }
    if(i==0){
      result=s;
    }else{
      result = s < result? s:result;
    }
   }
  cout << result << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;
int main() {
	int n, q;
	int S[100000], T;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> S[i];
	}
	cin >> q;
	int count = 0;
	for (int i = 0;i < q;i++) {
		cin >> T;
		int max = n - 1;
		int min = 0;
		int mid = (max + min) / 2;
		while (max >= min) {
			if (T == S[mid]) {
				count++;
				break;
			}
			if (T > S[mid]) {
				min = mid + 1;
				mid = (max + min) / 2;
			}
			if (T < S[mid]) {
				max = mid - 1;
				mid = (max + min) / 2;
			}
		}
	}
	cout << count<<endl;
 
}

Measured memory_bytes: 1548
import sys

d = [int(i) for i in sys.stdin.read().split('\n') if i != '']
k = d[5]
d = d[:5][::-1]


def check(k, d):
    for i in range(len(d[:4])):
        for j in range(i, len(d)):
            if d[i] - d[j] > k:
                return False
    return True


if check(k, d):
    print('Yay!')
else:
    print(':(')


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

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3576
<?php
/*
    Problem URL : http://arc074.contest.atcoder.jp/tasks/arc074_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

    // $queue = new SplPriorityQueue();

    // $queue->insert('a', 10);
    // $queue->insert('b', 100);
    // $queue->insert('c', 50);
    // $queue->insert('d', 50);
    // $queue->insert('e', 1);

    // // 個数 → 5
    // print('count:' . $queue->count());
    // $queue->setExtractFlags (SplPriorityQueue::EXTR_DATA);
    // $queue->setExtractFlags (SplPriorityQueue::EXTR_BOTH);
    // $queue->setExtractFlags (SplPriorityQueue::EXTR_PRIORITY);
    // $arr = $queue->extract();
    // print('count:' . $queue->count());    
    // var_dump($arr);
    // $queue->insert('f', 55);
    // $arr = $queue->extract();
    // var_dump($arr);
    // $queue->insert('', 45);
    // $arr = $queue->extract();
    // var_dump($arr);
    // exit;

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
$b = array_reverse($a);

$ans = -PHP_INT_MAX;

$x = array_slice($a, 0, $N);
$y = array_slice($b, 0, $N);

$queue1 = new SplPriorityQueue();
$queue2 = new SplPriorityQueue();

$queue1->setExtractFlags (SplPriorityQueue::EXTR_PRIORITY);
$queue2->setExtractFlags (SplPriorityQueue::EXTR_PRIORITY);

for ($i = 0; $i < $N; $i++) {
    $queue1->insert('', PHP_INT_MAX - $a[$i]);
    $totalA += $a[$i];
    $queue2->insert('', $b[$i]);
    $totalB += $b[$i];
}

for ($i = $N; $i <= $N * 2; $i++) {

    $sumX[$i] = $totalA;
    $sumY[$i] = $totalB;

    $queue1->insert('', PHP_INT_MAX - $a[$i]);
    $queue2->insert('', $b[$i]);

    $pop1 = PHP_INT_MAX - $queue1->extract();
    $pop2 = $queue2->extract();

    $totalA += ($a[$i] - $pop1);
    $totalB += ($b[$i] - $pop2);
}

for ($i = $N; $i <= $N * 2; $i++) {
    $tmp = $sumX[$i] - $sumY[$N * 3 - $i];
    $ans = max($ans, $tmp);
}

echo $ans . PHP_EOL;


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

long long gosen = 5000000000000000;
int main(){
    string s;
    long long k;
    cin >> s >> k;
    int len = s.length();
    for(int i = 0; i < len; i++){
        int num = s[i] - '0';
        k -= pow(num,gosen);
        if(k <= 0){
            cout << s[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
int main(){
  int N;
  std::cin >> N;
  std::vector<int> a(N,0),b(N,0);
  ll asum=0,bsum=0,lack=0;
  for(int i = 0; i < N; i++){
    std::cin >> a[i];
    asum+=a[i];
  }
  int cnt=0,rcnt=0;
  for(int i = 0; i < N; i++){
    std::cin >> b[i];
    bsum+=b[i];
    if (b[i]>a[i]) {
      lack+=b[i]-a[i];
      cnt++;
    }
    if (b[i]==a[i]) rcnt++;
  }
  if(bsum>asum){
    std::cout << -1 << std::endl;
    return 0;
  }else if(cnt==0){
    std::cout << cnt << std::endl;
    return 0;
  }
  int bufi=0;
  std::vector<int> rest(N-cnt-rcnt,0);
  for(int i = 0; i < N; i++){
    if (b[i]<a[i]) {
      rest[bufi]=a[i]-b[i];
      bufi++;
    }
  }
  bufi=N-cnt;
  std::sort(rest.begin(),rest.end(),std::greater<int>());
  for(int i = 0; i < bufi; i++){
    lack-=rest[i];
    cnt++;
    if (lack<=0) break;
  }
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long 
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);
using namespace std;
int gcd(int a,int b)
{
  int ans;
    if(b==0)
    {
      return a;
    }
  ans=gcd(b,a%b);
  return ans;
      
}

int main()
{
//  OJ;
 string s;
 cin>>s;
 for(int i=0;i<s.size();i++)
 {
   if(s[i]=='?')
   {
     s[i]='D';
   }

 }
 cout<<s;
}


Measured memory_bytes: 3724
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A+1):
        for j in range(B+1):
                reX = (X - 500*i - 100*j)//50
                if 0 <= reX <= C:
                        count+=1
   
   
print(count)




   


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    int X;
    cin >> X;
    int ans = 1;
    for (int b = 2; b <= X; b++){
        int p = 2;
        while(p <= 10){
            int x = pow(b, p);
            if (X < x){
                if (p == 2){
                    goto OUT;
                }
                else{
                    int y = pow(b, p - 1);
                    ans = max(ans, y);
                    break;
                }
            }
            else p++;
        }
    }
    OUT:
    cout << ans << endl;
}

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

void fastInputOutput(){ios_base::sync_with_stdio(false);cin.tie(NULL);}


ll GCD(ll a, ll b){ll gcd, g;g = __gcd(a, b);return g;}
ll LCM(ll a, ll b){ll gcd, g;g = __gcd(a, b);return (a/g)*b;}
ll POW(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}

const ll INF_LONG = 1LL<<61;
const unsigned int inf_int = 1<<31;
const ll mod = 1e9+7;
double phi = acos(-1);

int main()
{
    fastInputOutput();
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for(int i = 1; i <= m;i++)
    {
        int tem; cin >> tem;
        sum += tem;
    }
    if(sum > n)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << n -sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3692
s=list(input())
zan=[]
delete_pair=0
for i in range(len(s)):
    if zan==[]: #自分が先頭の時
        zan.append(i)
        #print(zan)
        continue
    if s[i]!=s[zan[-1]]:
        delete_pair+=1
        del zan[-1]
    else:
        zan.append(i)
    #print(zan)
print(delete_pair*2)

Measured memory_bytes: 7848
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
//****************************************************                
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define vvll vector<vector<ll>>
#define mtp make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions
void solve();

int binary(int a[],int l,int r,int find)
{
    if(l>r)
    {
        return -1; 
    }else
    {
        int mid=(l+r)/2;
        if(a[mid]==find)
        {
            return mid+1;
        }else if(a[mid]>find)
        {
            binary(a,l,mid-1,find);
        }else
        {
            binary(a,mid+1,r,find);
        }   
    }   
}

int main()
{
    FAST_IO;
    ll testcases = 1;
    // cin >> testcases; //comment for 1 test case
    while(testcases--)
    {
        solve();
    }
}

void solve()
{
	ll n;
	cin>>n;
	string ans="";
	while(n!=0)
	{
		ll md=n%26;
		n=n/26;
		if(md!=0)
		{
			ans=char('a'+md-1)+ans;
		}else
		{
			ans='z'+ans;
			n--;
		}
	}
	cout<<ans;
	nl;
}

Measured memory_bytes: 3596
from itertools import permutations
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

ver = [[] for _ in range(N)]
# 頂点xから移動できる頂点を格納する

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

ans = 0

for i in permutations(range(1, N)):
    here = 0
    for j in i:
        if j not in ver[here]:
            break
        here = j
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int D, N;
  cin >> D >> N;

  if (N == 100)
  {
    N = 101;
  }

  rep(i, D)
  {
    N *= 100;
  }

  cout << N << endl;

  return 0;
}


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

typedef complex<double>Point;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point p;
    double r;
    Circle(const Point &p=Point(),double r=0.0):p(p),r(r){}
};

typedef Point Vector;
typedef Segment Line;
typedef vector<Point>Polygon;

const double PI=acos(-1);
const double EPS=1e-8;
const double INF=1e16;

inline double square(double a){return a*a;}
inline double norm(const Point &a){return square(a.real())+square(a.imag());}
inline double dot(const Point &a,const Point &b){return (conj(a)*b).real();}
inline double cross(const Point &a,const Point &b){return (conj(a)*b).imag();}
inline double toDeg(double t){return t/PI*180.0;}
inline double toRad(double t){return t/180.0*t;}
#define equals(a,b) (fabs((a)-(b))<EPS)

bool isOrthogonal(Vector a,Vector b){
    return equals(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Segment s1,Segment s2){
    return isOrthogonal(s1.p1-s1.p2,s2.p1-s2.p2);
}

bool isParallel(Vector a,Vector b){
    return equals(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1,Segment s2){
    return isParallel(s1.p1-s1.p2,s2.p1-s2.p2);
}

Point project(Segment s,Point p){
    Vector base=s.p2-s.p1;
    double r=dot(p-s.p1,base)/norm(base);
    return s.p1+base*r;
}

void getPoint(Point &p){
    double x,y;
    scanf("%lf%lf",&x,&y);
    p=Point(x,y);
}

int main(){
    Segment s;
    getPoint(s.p1);
    getPoint(s.p2);

    int q;
    scanf("%d",&q);

    while(q--){
        Point p;
        getPoint(p);
        Point x=project(s,p);
        Vector z=x-p;
        Vector y=p+2.0*z;
        printf("%.20lf %.20lf\n",y.real(),y.imag());
    }
    return 0;
}

Measured memory_bytes: 1260
while True:
    N, A, B, C, X = map(int, raw_input().split())

    if N == 0 and A == 0 and B == 0 and C == 0 and X == 0:
        break

    Y = map(int, raw_input().split())

    ans, i = 0, 0

    while True:
        if X == Y[i]:
            i += 1

        if i == N:
            break

        X = (A*X + B) % C

        ans += 1
        if ans > 10000:
            ans = -1
            break

    print ans



Measured memory_bytes: 4648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s,t; cin >> t;
    s=t.substr(0,n);
    t=t.substr(n);
    reverse(t.begin(), t.end());
    ll res=0;
    map<pair<string,string>,ll> mp;
    for(int i=0;i<(1<<n);i++){
        string r="",rr="";
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                r+=s[j];
            }
            else{
                rr+=s[j];
            }
        }
        mp[make_pair(r,rr)]++;
    }
    for(int i=0;i<(1<<n);i++){
        string r="",rr="";
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                r+=t[j];
            }
            else{
                rr+=t[j];
            }
        }
        res+=mp[make_pair(r,rr)];
    }
    cout << res << endl;
}

Measured memory_bytes: 60836
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e6 + 5;

set<int> sx[N], sy[N];
queue<pair<int, pair<int, int>>> q;

void enqueue(int x, int y, int d) {
    q.push({d, {x, y}});
    sx[x].erase(y);
    sy[y].erase(x);
}

// https://codeforces.com/contest/877/problem/D
// https://atcoder.jp/contests/abc170/tasks/abc170_f

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
        int n, m, k;
        cin >> n >> m >> k;
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        char c[n + 5][m + 5];
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= m; j++) {
                cin >> c[i][j];
                sx[i].insert(j);
                sy[j].insert(i);
            }
        }

        enqueue(x1, y1, 0);
        while(!q.empty()){
            int d = q.front().first;
            int x = q.front().second.first;
            int y = q.front().second.second;
            q.pop();

            if(x == x2 && y == y2)
                return cout << d, 0;
            
            auto it = sx[x].lower_bound(y);
            while(it != sx[x].end() && *it - y <= k && c[x][*it] == '.') {
                enqueue(x, *it, d + 1);
                it = sx[x].lower_bound(y);
            }

            it = sx[x].lower_bound(y);
            while(it != sx[x].begin() && y - *(--it) <= k && c[x][*it] == '.') {
                enqueue(x, *it, d + 1);
                it = sx[x].lower_bound(y);
            }

            it = sy[y].lower_bound(x);
            while(it != sy[y].end() && *it - x <= k && c[*it][y] == '.') {
                enqueue(*it, y, d + 1);
                it = sy[y].lower_bound(x);
            }

            it = sy[y].lower_bound(x);
            while(it != sy[y].begin() && x - *(--it) <= k && c[*it][y] == '.') {
                    enqueue(*it, y, d + 1);
                    it = sy[y].lower_bound(x);
            }
        }

        cout << "-1\n";
    }
    
    return 0;
}



Measured memory_bytes: 192144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a,b,c,d,cnt=1;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0)
	{
		if(cnt%2)c-=b;
		else a-=d;
		cnt++;
	}
	if(a<=0)cout<<"No"<<endl;
	else if(c<=0)cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string a;
  long long int s;
    cin>>a;
  s=a.size();
  if(a[s-1]=='s')
  {
    a.append(1,'e');
    a.append(1,'s');
  }
  else
    a.append(1,'s');
    cout<<a;
}


Measured memory_bytes: 3624
#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 MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); 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 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string S;
	cin >> S;

	string target = "AKIHABARA";

	int pt = 0;
	int pt2 = 0;
	while (true) {
		if (pt < target.size() && pt2 < S.size() && target[pt] == S[pt2]) {
			pt++;
			pt2++;
		} else if (pt < target.size() && target[pt] == 'A') {
			pt++;
		} else {
			cout << "NO" << endl;
			return 0;
		}
		if (pt >= target.size()) {
			if (pt2 == S.size()) {
				cout << "YES" << endl;
			} else {
				cout << "NO" << endl;
			}
			return 0;
		}
	}

	cout << "YES" << endl;

    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int memory;
  
  vector<int> card;
  for(int i;i<n;i++){
    cin>>memory;
    card.push_back(memory);
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  
  int score_of_alice,score_of_bob;
  for(int i;i<n;i++){
    if(i%2==0){
      score_of_alice+=card.at(i);
    }else if(i%2==1){
      score_of_bob+=card.at(i);
    }else{
      break;
    }
  }
  cout<<(score_of_alice-score_of_bob)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 4005
using namespace std;

typedef long long ll;
ll n, m, M = 1000000007, d[N][N];
int main()
{
	ll i, j, r1, r2;
	cin >> n >> m;
	d[0][0] = d[0][1] = 1;
	d[1][0] = d[1][1] = 1;
	for (i = 2; i <= n + m; i++) {
		d[i][0] = 1;
		for (j = 1; j <= i; j++) {
			d[i][j] = (d[i - 1][j - 1] + d[i - 1][j]) % M;
		}
	}
	for (i = 1; i <= m; i++) {
		r1 = d[n - m + 1][i];
		r2 = d[m - 1][m - i];
		printf("%lld\n", (r1 * r2) % M);
	}
    return 0;
}


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

int main()
{
  int64_t K, A, B, k;
  cin >> K >> A >> B;
  if (B - A > 2)
  {
    k = K - (A - 1);
    if (k % 2 == 0)
    {
      cout << A + ((B - A) * k / 2) << endl;
    }
    else
    {
      cout << A + ((B - A) * (k / 2)) + 1 << endl;
    }
  }
  else
  {
    cout << 1 + K << endl;
  }
}

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

int main(void)
{
	while(1){
		int H, W;
		cin >> H >> W;
		if(!(H || W)) break;

		for(int i = 1; i <= H; i++) {
			for(int j = 1; j <= W; j++) {
				cout << ((i + j) % 2 == 0 ? "#" : ".");
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

ll gcd( ll a, ll b )
{
	if(b==0)
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
ll lcm (ll a, ll b)
{
	return (a*b)/gcd(a,b);
}

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
ll n;
ll arr[4000];
ll dp[3005][3005];

ll solve(ll l,ll r)
{
	if(r<l) return 0;
	else if(dp[l][r]!=-1) return dp[l][r];
	return dp[l][r]= max (min (solve (l+2, r), solve (l+1, r-1)) + arr[l],
					min (solve (l+1, r-1), solve (l, r-2)) + arr[r]);
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >>n;
	ll sum=0;
	for(int i =0;i<n;i++) cin >> arr[i],sum+=arr[i];
	for(int i =0;i<3005;i++) for(int j =0;j<3005;j++) dp[i][j]=-1;
	for(int i =0;i<n;i++) dp[i][i] = arr[i];
	ll a = solve(0,n-1);
	ll b = sum - a;

	cout << a-b << endl;
	


	return 0;
}


//Hello, this is a snippet.


Measured memory_bytes: 70912
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    ans = float("inf")
    for m in range(-100, 101):
        ans = min(ans,
                  sum((aa-m)**2 for aa in a))
    return ans


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main() {

    string S,T;
    cin >> S >> T;

    bool ans = false;

    for (char i = 'a'; i <= 'z'; i++) {
        if (T == S + i) {
            ans = true;
        }
        }

    if(ans){
        cout << "Yes"<< endl;
    }else{
        cout << "No" << endl;
    }
        
}

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

int main() {
  int n,a;
  cin >>n;
  a=0;
  if(n<10){
    a+=n;
  }
  if(n>=10 && n<100){
    a=9;
  }
  if(n>=100 && n<1000){
    a+=9;
    a+=n-99;
  }
  if(n>=1000 && n<10000){
    a=909;
  }
  if(n>=10000 && n<100000){
    a=909;
    a+=n-9999;
  }
  if(n==100000){
    a=90909;
  }
  cout <<a<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    N, K = map(int, input().split())
    integers = [list(map(int, input().split())) for _ in range(N)]
    # bitwise orの結果の候補を計算
    len_bin_k = len('{:b}'.format(K))
    keys = [K]
    for shift in range(1, len_bin_k + 1):
        if (K >> shift) & 1 == 1:
            # 右からshift bit目が0で、それより右が全部1の数
            # （例）K:1100101、shift:3 => 1100011
            keys.append(((K >> shift) << shift) - 1)
    vals = defaultdict(int)
    for a, b in integers:
        for k in keys:
            # bitwise orの結果を変えない整数の場合は価値を合算
            if k | a == k:
                vals[k] += b
    if len(vals.values()) == 0:
        print(0)
    else:
        print(max(vals.values()))


if __name__ == '__main__':
    main()

Measured memory_bytes: 27496
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
const LL INF = 999999999999;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a*c <= b ? c : b/a) << endl;
}


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

int main(){
    int n,a=0,b=0,c,d;
    cin >> n;
    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin >> w[i];
        a+=w[i];
    }
    for(int i=0;i<n;i++){
        b+=w[i];
        c=abs(a-2*b);
        d=min(d,c);
    }
    cout << d << endl;
}


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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;

    bool found = false;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if (i * j == N)
            {
                found = true;
            }

            if (found == true)
            {
                break;
            }
        }
        if (found == true)
        {
            break;
        }
    }

    if (found == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;

	LL minXY=min(X,Y);
	LL c=2*C*max(X,Y);
	cout<<min(min(2*C*minXY+(X-minXY)*A+(Y-minXY)*B,A*X+B*Y),c)<<endl;
/*
	if (A*X+B*Y<C*max(X,Y)){
		cout<<A*X+B*Y<<endl;
		return 0;
	}
	if (2*C>=A+B){
		cout<<A*X+B*Y<<endl;
		return 0;
	}
	LL c=2*C*max(X,Y);
	LL d=A*X+B*Y;
	if (X==Y){
		cout<<min(min(2*X*C,c),d)<<endl;
	}else if (X>Y){
		cout<<min(min(2*Y*C+A*(X-Y),c),d)<<endl;
	}else{
		cout<<min(min(2*X*C+A*(Y-X),c),d)<<endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 256
def main
  n = gets.to_i
  s = gets.split.map(&:to_i)
  q = gets.to_i
  t = gets.split.map(&:to_i)

  count = t.inject(0) do |result, value|
    result += 1 if linear_search(s, value)
    result
  end

  puts count
end

def linear_search(array, value)
  i = 0
  size = array.size
  array[size] = value

  while array[i] != value
    i += 1
  end

  return i != size
end

main



Measured memory_bytes: 8860
S = input()
flag = False

for i, m in enumerate(S):
    # 'Odd' index
    if i % 2 == 0 and m == 'L':
        print('No')
        flag = True
        break
    # 'Even' index
    elif i % 2 == 1 and m == 'R':
        print('No')
        flag = True
        break
    else:
        continue

if not flag:
    print('Yes')

Measured memory_bytes: 3060
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


N = read_a_int()
H = read_ints()

# https://atcoder.jp/contests/dp/tasks/dp_a
# 全探索ではナンセンス(というより処理が終わらない)
# i+1 or i+2のうち小さい方を選びつづければいいということにすぐに気がつく
# こういったように、今の状態から次の状態が決まるときはDPが使えることがおおい(この問題はgreedy気味にも捉えることができるが。)
# 途中までの状態が決まれば、最善手を選ぶことで次の状態が決定できるのを実装する。
# 今回の場合だったらhまでの最善の状態というのはmin(2つ前までの最善の状態+差, 1つ前までの最善の状態+差)なのでこれでdpテーブルを埋めていくことができる。
# こういった最小化問題はinfで初期化すると良い

import numpy as np
ii64 = np.iinfo(np.int64)
dp = np.full((N), ii64.max, dtype=np.int64)
dp[0] = 0
dp[1] = abs(H[0] - H[1])

# この概念はいわゆる貰うDP
# for i in range(2, N):
#     dp[i] = min(dp[i - 1] + abs(H[i - 1] - H[i]),
#                 dp[i - 2] + abs(H[i] - H[i - 2]))

# print(dp[-1])
# 配るDPで実装してみる
for i in range(0, N-2):
    dp[i + 1] = min(dp[i] + abs(H[i] - H[i+1]), dp[i+1])
    dp[i + 2] = min(dp[i] + abs(H[i] - H[i + 2]), dp[i + 2])

# これだと最後のdp[N-1]がdp[N-2]から値を受け取れないので最後につじつま合わせ

dp[-1] = min(dp[-2] + abs(H[-2] - H[-1]), dp[-1])

print(dp[-1])


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  rep(i, n) {
    bool f = true;
    rep(j, n - i) if (s[i + j] != t[j]) f = false;
    if (f) {
      cout << n + i << endl;
      return 0;
    }
  }

  cout << 2 * n << endl;
}


Measured memory_bytes: 256
s = str(input())
t = str(input())
S = []
T = []

for i in s:
    S.append(i)
for j in t:
    T.append(j)

S = sorted(S)
T = sorted(T, reverse=True)

S = ''.join(S)
T = ''.join(T)

if S < T:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Measured memory_bytes: 3064
N=gets.to_i
t=gets.split.map(&:to_i)
v=gets.split.map(&:to_i)
(1...N).each{|i|t[i]+=t[i-1]}
t.map!{|i|i*2}
t<<0

x=[0]*(t[-2]+1)
N.times do |i|
  if v[i] < x[t[i-1]]
    x[t[i-1]]=v[i]
    (t[i-1]-1).downto(t[i-2]){|j|x[j]=[x[j+1]+0.5, x[j]].min}
  end
  (t[i-1]+1).upto(t[i]){|j|x[j]=[x[j-1]+0.5, v[i]].min}
end

x[-1]=0
t[-2].downto(1){|i|x[i-1]=[x[i-1], x[i]+0.5].min}

p x.each_cons(2).map{|l,r|
  (l+r)*0.5/2.0
}.inject(:+)


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

using namespace std;
int main(void){

    long long x;
    cin >> x;
    
    long long count = x/11;
    long long remaind = x%11;

    if(remaind == 0) {
        cout << count*2 << endl;
        return 0;
    }
    else if(remaind <= 6) {
        cout << 1 + count*2 << endl;
        return 0;
    }
    else if(remaind > 6) {
        cout << 2 + count*2 << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
char prime[1000000]={};
 
int isprime(unsigned long n)
{
    unsigned long i, n1=n-1;
    if(n < 2){
        return 0;
    }else if(n == 2){
        return 1;
    }else if(n%2){
        for(i=3; i*i<=n; i+=2){
            if(n%i == 0){ return 0; }
        }
        return 1;
    }
    return 0;
}
 
 
int main(void)
{
    unsigned long i, j, n, cnt=0;
 
    //initialize
    for(i=0; i<1000000; i++){
        prime[i] = isprime(i+1);
    }
 
    while(scanf("%ld", &n) != EOF){
        cnt = 0;
        for(i=1; i<=n; i++){
            cnt += prime[i-1];
        }
        printf("%ld\n", cnt);
    }
    return 0;
}

Measured memory_bytes: 1572
S = input()
flag = 1
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] != "R" and S[i] != "U" and S[i] != "D":
            flag = 0
    elif i % 2 == 1:
        if S[i] != "L" and S[i] != "U" and S[i] != "D":
            flag = 0

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

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        bool f = true;
        f = f && s[0] == 'A';
        f = f && !Char.IsUpper(s[1]);
        int c = 0;
        for (int i = 2; i < s.Length - 1; i++)
        {
            if (s[i] == 'C')
            {
                c++;
                if (c >= 2)
                {
                    Console.WriteLine("WA");
                    return;
                }
                continue;
            }
            f = f && !Char.IsUpper(s[i]);
        }
        f = f && !Char.IsUpper(s[s.Length - 1]);
        f = f && c == 1;
        Console.WriteLine(f ? "AC" : "WA");
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<int> vec;

struct disjoint{
	vec p;
	disjoint(){}
	disjoint(int n):p(n+1){
		for(int i=1;i<=n;i++)
			p[i]=i;
	}

	int find(int x){
		if(p[x]==x)return x;
		return p[x]=find(p[x]);
	}

	bool merge(int x,int y){
		x=find(x),y=find(y);
		if(x==y)return 0;
		p[x]=y;
		return 1;
	}

	bool chk(int x,int y){
		return find(x)==find(y);
	}
}z[2][2];

int N;
const int MAX_N = 100010;

char a[MAX_N];

int main(){
	scanf("%d",&N);
	scanf("%s",a+1);
	
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			z[i][j]=disjoint(N*2);
			if(i==j){
				z[i][j].merge(1,2);
				z[i][j].merge(1+N,2+N);
			}else{
				z[i][j].merge(1,2+N);
				z[i][j].merge(2,1+N);
			}
			for(int k=1;k<=N;k++){
				int cnt=0;
				if(a[k]=='o')cnt++;
				if(i==0)cnt++;
				if(z[i][j].chk(1,k))cnt++;
				int l=(k-1>=1?k-1:N),r=(k+1<=N?k+1:1);
				if(cnt&1){
					z[i][j].merge(l,r);
					z[i][j].merge(l+N,r+N);
				}else{
					z[i][j].merge(l,r+N);
					z[i][j].merge(r,l+N);
				}
			}
			bool ok=true;
			for(int k=1;k<=N;k++){
				if(z[i][j].chk(k,k+N))ok=false;
			}
			if(ok){
				for(int k=1;k<=N;k++){
					int cnt=(i==0);
					if(z[i][j].chk(1,k))cnt++;
					if(cnt&1)putchar('W');
					else putchar('S');
				}
				puts("");
				return 0;
			}
		}
	}

	puts("-1");

	return 0;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>

int main(){
  char	stra[16] = {0};
  char	strb[16] = {0};
  int	a, b;
  
  scanf("%s %s", stra, strb);
  a = atoi(stra);
  b = atoi(strb);
  
  //aをb個
  if( a < b ){
    for(int i=0; i<b; i++){ printf("%s", stra); }
  
  //bをa個	//a==bを含む
  }else{
    for(int i=0; i<a; i++){ printf("%s", strb); }
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

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

int main()
{
	unsigned long long m = 100;
	unsigned long long x;
	unsigned int y;

	// input
	cin >> x;

	// calc
	for ( y=1; ; y++ )
	{
		m += m / 100;
		if (m >= x) { break; }
	}

	// output
	cout << y;
	cout << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int main()
{
	fast_cin();
	int H, W;
	cin >> H >> W;

	map<char, int> cnt;
	for (int i = 0; i < H * W; ++i) {
		char x;
		cin >> x;
		cnt[x]++;
	}

	int odd = 0, not4 = 0;
	for (auto &x : cnt) {
		if (x.second % 2 == 1) {
			++odd;
			if (x.second % 4 == 3) {
				++not4;
			}
		} else if (x.second % 4 == 2) {
			++not4;
		}
	}

	if (H % 2 && W % 2) {
		if (odd == 1 && not4 <= H / 2 + W / 2) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else if (H % 2 || W % 2) {
		if (H % 2 && odd == 0 && not4 <= W / 2) {
			cout << "Yes" << endl;
		} else if (W % 2 && odd == 0 && not4 <= H / 2) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		if (odd == 0 && not4 == 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  string s;
  cin>>s;
  if ( s.length()>n)
  	cout<<s.substr( 0,n)<<"...\n";
  else
  	cout<<s<<'\n';
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> a >> b;
	int cnt = (a + 1) / 2;
	if (cnt>=b)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools

n,m,k = map(int,input().split())
a = list(map(int,('0 '+input()).split()))
b = list(map(int,('0 '+input()).split()))

asum = list(itertools.accumulate(a))
bsum = list(itertools.accumulate(b))

ans = 0
j=m
for i in range(n+1):
    if asum[i]>k:
        break
    
    while asum[i]+bsum[j]>k:
        j-=1
        
    ans = max(ans,i+j)

print(ans)

Measured memory_bytes: 132476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin>>a;
  if(a<=111)
    cout<<111<<endl;
  else if(a<=222)
    cout<<222<<endl;
  else if(a<=333)
    cout<<333<<endl;
  else if(a<=444)
    cout<<444<<endl;
  else if(a<=555)
    cout<<555<<endl;
  else if(a<=666)
    cout<<666<<endl;
  else if(a<=777)
    cout<<777<<endl;
  else if(a<=888)
    cout<<888<<endl;
  else
    cout<<999<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K,Q;
    cin >> N >> K >>Q;
    int A[N];
    for(int i = 0; i < N; i++){
        A[i] = 0;
    }
    for(int i = 0; i < Q; i++){
        int a; cin >> a;
        A[a-1]++;
    }
    for(int i = 0; i < N; i++){
        A[i] = K - (Q-A[i]);
        if(A[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	int N, K, a0, a, b, ma = 0;
	cin >> K >> N;
	for (int i = 1;i <= N;i++) {
		cin >> a;
		if (i == 1) {
			a0 = a + K;
			b = a;
			continue;
		}
		ma = max(ma, a - b);
		b = a;
	}
	ma = max(a0 - b, ma);
	cout << K - ma << endl;
}

Measured memory_bytes: 256