akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,((n)+1))
#define repst(i,s,n) reps(i,s,((n)+1))
#define reprt(i,n,t) for(ll (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// dp[i][j]: i項目を見ている時点でj個括弧が開いているときのそこまでの式の値の最大値
// +の直後に括弧を開いても意味はない また-の直後には必ず括弧を開いても問題ない(すぐ閉じればなかったことにできるため)
// こうすると括弧が偶数個開いているときは項の正負はそのまま、奇数個開いているときは逆転するので括弧を開いている場所を保持しなくて済む
// 括弧は0,1,2個の3通りだけ考えればいい 3つ目の括弧を開くのは今開いている2つの括弧を閉じて新しい括弧を1つ開くのと同じなため
// 例えば -(1-(3-(4.. は -(1-(3))-(4.. と同じ

ll n, f, a[114514], p[114514], dp[114514][3];
char c;

signed main() {
	cin >> n >> f;
	rep(i,n-1) {
		cin >> c >> a[i];
		p[i] = (c=='+');
	}
	rep(i,n) rep(j,3) dp[i][j] = -linf;
	dp[0][0] = f;
	rep(i,n-1) {
		if (p[i]) {
			dp[i+1][2] = dp[i][2] + a[i];
			dp[i+1][1] = max(dp[i+1][2], dp[i][1] - a[i]);
			dp[i+1][0] = max(dp[i+1][1], dp[i][0] + a[i]);
		} else {
			dp[i+1][2] = dp[i][1] + a[i];
			dp[i+1][1] = tmax(dp[i+1][2], dp[i][0] - a[i], dp[i][2] - a[i]);
			dp[i+1][0] = max(dp[i+1][1], dp[i][1] + a[i]);
		}
	}
	cout << *max_element(dp[n-1], dp[n-1]+3) << ln;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int stickler(int arr[], int n)
{
    int inc[n-1],exc[n-1];
    inc[0]=abs(arr[0]-arr[1]);
    exc[0]=0;
    if(n>2){
    inc[1]=min(inc[0]+abs(arr[2]-arr[1]),abs(arr[2]-arr[0]));
    exc[1]=inc[0];}
    for(int i=2;i<n-1;i++)
    {
        inc[i]=min(inc[i-1]+abs(arr[i+1]-arr[i]), inc[i-2]+abs(arr[i+1]-arr[i-1]));
        exc[i]=inc[i-1];
    }
    return(inc[n-2]);
}
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
       cout<< stickler(arr,n);
    return 0;
}



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

using namespace std;

int main(){
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

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

    int m = 0;
    m = max(m, a[0] + (k-a[n-1]));
    for(int i=0; i<n-1; i++){
        m = max(m, a[i+1]-a[i]);
    }

    int ans = k - m;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int i,j,k,n;
	double sum = 0;
	double max = 0;
	double a[200000];
	double t;
	
	scanf("%d%d",&n,&k);
	
	for(i=0;i<k;i++){
		scanf("%lf",&t);
		a[i]=t;
		sum += (a[i]+1)/2;
	}

	for(i=k;i<n;i++){
		scanf("%lf",&t);
		a[i]=t;
	}
	
	max = sum;

	for(i=1;i<n-k+1;i++){
		sum = sum - (a[i-1]+1)/2 + (a[k+i-1]+1)/2;
		if(sum>max)
			max = sum;
	}
	
	printf("%lf",max);
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 101

void dv(int);
void dfs();

int n;
int M[N][N];
int cl[N],d[N],f[N],tt;

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      M[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  dfs();
  return 0;
}

void dv(int u){
  int v;

  cl[u] = GRAY;
  d[u] = ++tt;

  for(v = 0; v < n; v++){
    if(M[u][v] == 0) continue;
    if(cl[v] == WHITE){
      dv(v);
    }
  }
  cl[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;
  for(u = 0; u < n; u++){
    cl[u] = WHITE;
  }
  tt = 0;

  for (u = 0; u < n; u++){
    if(cl[u] == WHITE) dv(u);
  }
  for (u = 0; u < n; u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
    

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
    int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    char ch;cin>>ch;
    map<char,char> mp={ {'A','T'},{'T','A'},{'C','G'},{'G','C'} };
    cout<<mp[ch];
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

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

  ll n;
  std::cin>>n;

  std::map<ll,ll> kind;
  rep(i,0,n){
    ll a;
    std::cin>>a;
    kind[a]++;
  }

  if(kind.size()%2==1)std::cout<<kind.size()<<"\n";
  else std::cout<<kind.size()-1<<"\n";

  return 0;
}

Measured memory_bytes: 6528
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2, degrees
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



def primes(n):
    is_prime = [1] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = 0
    return {i for i in range(n + 1) if is_prime[i]}



n = 10 ** 5
prime_set = primes(n)
q = I()
C = [0] * (n + 1)
for i in range(n + 1):
    if i % 2 and i in prime_set and (i + 1) // 2 in prime_set:
        C[i] = 1


acc = list(accumulate(C))
for i in range(q):
    l, r = LI()
    print(acc[r] - acc[l - 1])


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

using namespace std;

const int mod = 1e9+7;

int ad(int x,int y) { x+=y; return x>=mod?x-mod:x; }
int sb(int x,int y) { x-=y; return x<0?x+mod:x; }
int mu(int x,int y) { return 1ll*x*y%mod; }
void up(int &x,int y) { x+=y; if(x>=mod)x-=mod; }
void de(int &x,int y) { x-=y; if(x<0)x+=mod; }
int ksm(int a,int b) {
	int ans = 1;
	for(;b;b>>=1,a=mu(a,a))
		if(b&1) ans = mu(ans,a);
	return ans;
}
int n,m;
int f[17][1<<16],a[17];
int ANS;
int jv[ (1<<16)+5 ],jc[ (1<<16)+5 ];
int GC(int a,int b) {
	if(a<b) return 0;
	return mu(jc[a],mu(jv[b],jv[a-b]));
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+m,greater<int>());
	f[0][0] = 1;
	jc[0] = 1; 
	for(int i=1;i<=(1<<n);i++) jc[i] = mu(jc[i-1],i);
	jv[1<<n] = ksm(jc[1<<n],mod-2);
	for(int i=(1<<n)-1;i>=0;i--) jv[i] = mu(jv[i+1],i+1);
	for(int i=1;i<=m;i++) {
		for(int s=0;s<(1<<n);s++) {
			if(!f[i-1][s]) continue;
			up(f[i][s],f[i-1][s]);
			int res = (1<<n)-1-s;
			for(int j=0;j<n;j++) {
				if((s>>j)&1) continue;
				up(f[i][s|(1<<j)], mu(mu(jc[(1<<j)],f[i-1][s]),GC(res-a[i]+1,(1<<j)-1)) );
			}
		}
	}
	for(int s=0;s<(1<<n);s++) {
		int cc = 0;
		for(int i=0;i<n;i++) if((s>>i)&1) cc++;
		if(cc&1) de(ANS,mu(jc[(1<<n)-1-s],f[m][s]));
		else up(ANS,mu(jc[(1<<n)-1-s],f[m][s]));
	}
	ANS = mu(ANS,(1<<n));
	printf("%d",ANS);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int a,b,c,sum1 = 0,sum2 = 0;
  cin>>a>>b>>c;
  sum1 = b - a;
  sum2 = c - b;
  
  if(sum1 == sum2)
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;
  }

Measured memory_bytes: 3620
a, b, c, d = map(int, input().split())

count = 0
while(True):
  if count%2 == 0:
    c -= b
  else :
    a -= d
  
  if (c <= 0) :
    print("Yes")
    break
  elif (a <= 0) :
    print("No") 
    break
  else :
    pass
  count += 1

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m;
string s, t;

int main() {
	cin >> n >> m >> s >> t;
	
	LL l = lcm(n, m), x = l / lcm(l / n, l / m);
	
	inc(i, x) {
		if(s[i * (l / m)] != t[i * (l / n)]) { l = -1; break; }
	}
	
	cout << l << endl;
	
	return 0;
}


Measured memory_bytes: 512
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

absmin = float('inf')
minusnum = 0
ans = 0
for ai in a:
    absmin = min(absmin, abs(ai))
    
    if ai < 0:
        minusnum += 1
        
    ans += ai if ai > 0 else -ai
        
if minusnum % 2 == 0:
    print(ans)

else:
    print(ans - 2*absmin)

Measured memory_bytes: 14412
N = int(input())
W = list(map(int, input().split()))

ans = 10**9
for T in range(1, N+1):
    S1 = 0
    S2 = 0
    for i in range(0,len(W)):
        if (i <= T):
            S1 += W[i]
        else:
            S2 += W[i]
    ans = min(ans, abs(S1-S2))

print(ans)


Measured memory_bytes: 3060
def solve(N, K, ABs):
    counts = {i: 0 for i in range(1, 10 ** 5 + 1)}
    for a, b in ABs:
        counts[a] += b
    s = 0
    for c, count in counts.items():
        s += count
        if K <= s:
            return c


if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    ABs = []
    for _ in range(N):
        ABs.append(tuple(map(int, input().split(" "))))
    print(solve(N, K, ABs))


Measured memory_bytes: 28632
s=input()
n=len(s)
k=0
s1=s[0:(n-1)//2+1]
s2=s[(n+3)//2-1:]
for i in range(len(s1)):
    if s1[i]==s[-i-1]:
        pass
    else:
        k=1
        break
for j in range(len(s2)):
    if s2[j]==s[-j-1]:
        pass
    else:
        k=1
        break
if k==1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3188
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  // val a = new Array[Int](N)

  val N, K = in.next().toInt

  if (N == 2) {
    if (K == 0) {
      println(1)
      println("1 2")
    }
    else {
      println(-1)
    }
  }
  else if (N == 3) {
    if (K == 0) {
      println(3)
      println("1 2")
      println("2 3")
      println("3 1")
    }
    else if (K == 1) {
      println(2)
      println("1 2")
      println("2 3")
    }
    else
      println(-1)
  }
  else {
    if (K == N) {
      pw.println(N)
      pw.println(s"$N 1")
      for (i <- 1 until N)
        pw.println(s"$i ${i+1}")
    }
    else {
      var tmp = ((N-2) * (N-1)) / 2

      if (tmp < K)
        pw.println(-1)
      else {
        var ans: List[(Int, Int)] = Nil

        for (i <- 2 to N) {
          ans = (i, 1) :: ans
        }


        var l = 2
        var r = 3
        while(tmp > K) {
          ans = (l, r) :: ans

          if (r == N) {
            l += 1
            r = l + 1
          }
          else {
            r += 1
          }

          tmp -= 1
        }

        pw.println(ans.length)
        ans.foreach {case (a, b) => pw.println(s"$a $b")}
      }
    }

    pw.flush()
  }
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 29548
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

vector<int> g[100000];

void dfs(vector<int> &d, int u, int v, int l) {
    d[v] = l;
    for (auto t : g[v]) {
        if (t == u)
            continue;
        dfs(d, v, t, l + 1);
    }
}

int main() {
    int n, u, v, a, b;
    cin >> n >> u >> v;
    u--; v--;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> d_u(n, 0), d_v(n, 0);
    dfs(d_u, u, u, 0);
    dfs(d_v, v, v, 0);

    int mind = INF, maxd = 0;
    for (int i = 0; i < n; ++i) {
        if (d_u[i] == d_v[i])
            mind = min(mind, d_u[i]);
        if (d_u[i] < d_v[i])
            maxd = max(maxd, d_u[i] + (d_v[i] - d_u[i]) - 1);
    }
    if (mind == INF)
        mind = -1;
    cout << max(maxd, mind) << endl;

    return 0;
}

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

int main(){
	int n, i;
	int a[100];
	cin >> n;
	
	for ( i = 0; i < n; i++ )
		cin >> a[i];
	
	for ( i = n-1 ; i > 0; i-- ){
		cout << a[i] << " ";
	}
	cout << a[0] << endl;
}

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

int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int sum = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        sum += (d+a-1)/a;
    }
    cout << x + sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 公約数
int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}


// min
int main(void){
  long int n, x;
  long int a[100001];
  long int d[100001];
  long int ans = 0;

  // それぞれの現在地からの幅の最大公約数を求めて解を出す

  scanf("%ld%ld", &n, &x);

  for(int i = 0; i < n; i++){
    scanf("%ld", &a[i]);
  }

  // それぞれの現在地からの距離を求める
  for(int i = 0; i < n; i++){
    d[i] = labs(x - a[i]);
  }

  // 最大公約数を求める
  ans = d[0];
  for(int i = 1; i < n; i++){
    if(ans > d[i]){
      ans = gcd(ans, d[i]);
    }else{
      ans = gcd(d[i], ans);
    }
  }
  
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int n,m,sum,inn1,inn2,a[10005];
int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&inn1,&inn2);
		cout<<sum-a[inn1]+inn2<<endl;
	}
}


Measured memory_bytes: 256
n,*z=`dd`.split.map &:to_i
t=(e=[*0...n]).dup
a=z.shift n+1
n.downto(1){|i|a[i]-=a[i-1]}
k,*z=z
z.map{|x|t[x-2],t[x-1]=t[x-1],t[x-2]}
(k%2>0&&e=e.map{|q|t[q]};t=t.map{|q|t[q]};k/=2)while k>0
k,*a=a
n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 74668
n,y = map(int, input().split())
for a in range(n+1):
    for b in range(n+1):
        c = n - a - b
        if (10000*a + 5000*b + 1000*c) == y and a + b + c == n and c >= 0:
            print(a,b,c)
            exit(0)
print(-1,-1,-1)

Measured memory_bytes: 9060
#include<iostream>
#include<cstdio>
using namespace std;
bool le[3];
int main(){
	register char l[3];
	l[0]=getchar();
	l[1]=getchar();
	l[2]=getchar();
	for(register int i=0;i<=2;i++){
		switch(l[i]){
			case 'a':le[0]=true;
				break;
			case 'b':le[1]=true;
				break;
			case 'c':le[2]=true;
				break;
		}
	}
	if((le[0]&&le[1])&&le[2]){
		putchar('Y');
		putchar('e');
		putchar('s');
	}
	else {
		putchar('N');
		putchar('o');
	}
	return 0;
}

Measured memory_bytes: 256
open System

let rec f (n : int64) :string  =
    if n = 0L then ""
    else
        let nm = n - 1L
        let nm26 = nm / 26L
        (f nm26) +   string(char(int64('a')+ nm%26L))

[<EntryPoint>]
let main argv =
    let [|n|] = stdin.ReadLine().Split() |> Array.map int64
    f n |> printf "%s"

    0 


Measured memory_bytes: 29552
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double EPS=1e-9;
const long long INF = 100001000010000100ll;

template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;


string L, R;

int dp[4000+10][4000+10];

int main(){
	while(cin >> L >> R){
		memset(dp, 0, sizeof(dp));
		int ans=0;
		rp(i, R){
			rp(j, L){
				if(R[i]==L[j]){
					if(i > 0 && j > 0){
						dp[i][j] = dp[i-1][j-1] + 1;
					}else{
						dp[i][j]=1;
					}
				}else{
					dp[i][j]=0;
				}
				ans=max(ans, dp[i][j]);
			}
		}
		cout << ans << endl;
	}

	return 0;

}

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

int main() {
    int n, m;
    cin >> n >> m;
    int voteNum[n];
    rep(i, n) cin >> voteNum[i];
    // 総得票数
    int sum = 0;
    rep(i, n) sum += voteNum[i];
    // 各得票数において選べるか選べないか
    int cnt = 0;
    rep(i, n) {
        if (voteNum[i]*4*m >= sum) cnt += 1;
    }
    // 選べる数に応じて出力
    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
list($A, $B) = explode(" ", trim(fgets(STDIN)));

if ($A == $B) {
    echo $A * 2 . "\n";
} elseif ($A < $B) {
    echo $B * 2 - 1  . "\n";
} else {
    echo $A * 2 - 1 . "\n";
}

Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;

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

    int s = b.front() + b.back();
    for (int i = 1; i < n - 1; i++) {
        s += min(b[i - 1], b[i]);
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp.split('')
ans = S[1...N].count('E')
now = ans
(1..N).each do |i|
    if S[i-1] == 'W'
        now += 1
    end
    if S[i] == 'E'
        now -= 1
    end
    ans = now if ans > now
end
puts ans

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


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			var rc = Console.ReadLine().Split(' ');
			int r = int.Parse(rc[0]);
			int c = int.Parse(rc[1]);
			int[,] t = new int[r + 1, c + 1];

			for(int r_i = 0; r_i < r ; r_i++)
			{
				var num = Console.ReadLine().Split(' ');
				
				for(int c_i = 0; c_i < c; c_i++)
				{
					var n = int.Parse(num[c_i]);
					t[r_i, c_i] = n;
					t[r_i, c] += n;
					t[r, c_i] += n;

					Console.Write("{0} ", t[r_i, c_i]);
					
					if(c_i == c - 1)
					{
						Console.WriteLine(t[r_i, c]);
						t[r,c] += t[r_i, c];
					}
					
				}
			}

			for(int rsum = 0; rsum < c; rsum++)
			{
				Console.Write("{0} ", t[r, rsum]);
			}

			Console.WriteLine(t[r, c]);
		}
	}
}



Measured memory_bytes: 17928
from bisect import bisect_right
n=int(input())
a=sorted(list(map(int,input().split())))
x=a[-1]
c=bisect_right(a,x//2)
if x%2==0:
    if x//2 in a:
        print("{} {}".format(x,x//2))
    else:
        if a[c]-x//2>=x//2-a[c-1]:
            print("{} {}".format(x,a[c-1]))
        else:
            print("{} {}".format(x,a[c]))

        
else:
    if x//2 in a :
        print("{} {}".format(x,x//2))
    elif x//2+1 in a:
        print("{} {}".format(x,x//2+1))
    else:
        if a[c]-(x//2+1)>=x//2-a[c-1]:
            print("{} {}".format(x,a[c-1]))
        else:
            print("{} {}".format(x,a[c]))

Measured memory_bytes: 20084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int k;
int ans[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

signed main() {
	cin >> k;
	cout << ans[k - 1] << endl;
}


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

const int N = 510;
int dat[N][N];

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

  int n,m,q; cin >> n >> m >> q;
  for(int i = 0; i < m; i++){
    int l,r; cin >> l >> r;
    dat[l][r]++;
  }

  for(int i = 1; i < N; i++){
    for(int j = 1; j < N; j++){
      dat[i][j] += dat[i][j-1];
    }
  }

  for(int i = 1; i < N; i++){
    for(int j = 1; j < N; j++){
      dat[i][j] += dat[i-1][j];
    }
  }

  for(int i = 0; i < q; i++){
    int p,q; cin >> p >> q;
    p--;
    cout << dat[p][p]-dat[p][q]-dat[q][p]+dat[q][q] << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mx 100000000
int md=1e9+7;
int __gcd(int a, int b) {if(b==0) return a; return __gcd(b, a%b);}
int poww(int a, int b) {int res=1;while(b) {if(b&1){res*=a;res%=md;}a*=a;a%=md;b>>=1;}return res;}
void ainp(int arr[], int n) {for(int i=0;i<n;i++) cin>>arr[i];}
void vinp(vector<int> v,int n){for(int i=0;i<n;i++){int a;cin>>a;v.push_back(a);}}
map<int, int> mapp;
set<int> s;vector<int> v;

void fun()
{ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}



signed main()
{  fun();
	int n;
	cin>>n;
	int arr[n];
	ainp(arr,n);
	int m;
	cin>>m;
	while(m-->0)
	{
		int p,x;
		cin>>p>>x;
		int res=0;
		for(int i=0;i<n;i++)
		{
			if(i==p-1)
			{
				res+=x;
			}
			else
			{
				res+=arr[i];
			}
		}
		cout<<res<<"\n";
	}
	
}



Measured memory_bytes: 256
listA=[]

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

H=int(listA[0])
A=int(listA[1])

if H % A == 0:
    print(int(H / A))
else:
    print(int(H / A) + 1)

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

using namespace std;

int main()
{
    int n;
    cin>>n;

    vector<int>A,B,C;
    B.push_back(-1);
    C.push_back(-1);

    int i,x;

    for(i=0;i!=n;i++)
    {
        cin>>x;
        A.push_back(x);
    }

    for(i=0;i!=n;i++)
    {
        cin>>x;
        B.push_back(x);
    }

    for(i=0;i!=n-1;i++)
    {
        cin>>x;
        C.push_back(x);
    }

    int s = B[A[0]];
    for(i=1;i!=n;i++)
    {
        s += B[A[i]];

        if(A[i] == A[i-1]+1)
            s += C[A[i-1]];
    }

    cout<<s;

    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<cctype>
#include<string.h>
#include <stdlib.h>

#define PI 3.1415926
void swap(int* x, int* y) {
	int a = *x;
	int b = *y;
	*x = b;
	*y = a;
}
int factorial(int n);
int sum(int n, int*);
int ave(int n, int*);
int min(int n, int*), min(int n, int m);
int max(int n, int*), max(int n, int m);

int main() {
	int L, A, B, C, D,ans1,ans2;
	scanf("%d %d %d %d %d", &L, &A, &B, &C, &D);
	ans1 = L - A / C-1;
	if (A%C == 0) {
		ans1++;
	}
	ans2 = L - B / D-1;
	if (B%D==0) {
		ans2++;
	}
	printf("%d\n", min(ans1,ans2));
	return 0;
}

int factorial(int n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else {
		return 1;
	}
}
int sum(int n, int *all) {
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += all[i];
	}
	return total;
}
int ave(int n, int *all) {
	int total = 0;
	for (int i = 0; i<n; ++i) {
		total += all[i];
	}
	return total / n;
}
int min(int n, int *all) {

	int min = all[0];
	for (int i = 1; i < n; ++i) {
		if (all[0] > all[i]) {
			min = all[i];
		}
	}
	return min;
}
int max(int n, int *all) {
	int max = all[0];
	for (int i = 1; i<n; ++i) {
		if (all[0]<all[i]) {
			max = all[i];
		}
	}
	return max;
}
int max(int n, int m) {
	if (n >= m) {
		return n;
	}
	else {
		return m;
	}
}
int min(int n, int m) {
	if (n >= m) {
		return m;
	}
	else {
		return n;
	}
}

Measured memory_bytes: 2700
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
int main(){
    char s[4];
    scanf("%s",&s);
    int len = strlen(s);
    int ans = 0;
    for(int i = 0; i < len; i++){
        if(s[i] == 'o')
            ans++;
    }
    printf("%d\n",ans*100 + 700);
return 0;
}


Measured memory_bytes: 256
def lower_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m][2] < v then l = m
    else r = m
    end
  end
  r
end

loop do
  n, q = gets.split.map(&:to_i)
  break if n == 0
  era = []
  n.times do
    name, ey, wy = gets.split
    era << [name, ey.to_i, wy.to_i]
  end
  era.sort_by! { |e| e[2] }
  q.times do
    y = gets.to_i
    x = lower_bound(era, y)
    if x != n && era[x][2] - y < era[x][1]
        puts "#{era[x][0]} #{era[x][1] - (era[x][2] - y)}"
    else puts "Unknown"
    end
  end
end

Measured memory_bytes: 8892
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;
int main(){
  ll n; cin >>n; ll sum=0;
  for(int i=2; i<=sqrt(n); i++){
    int tem=i;
    while(n%i==0){
      if(n%tem==0){n/=tem; tem*=i; sum++;}
      else n/=i;
    }
  }
  if(n-1) sum++;
  cout <<sum;
return 0;}

Measured memory_bytes: 3668
import java.util.*

fun main(args:Array<String>) {
    val sc = Scanner(System.`in`)
    var a: Int; var b: Int; var op: String

    while (true) {
        a = sc.nextInt()
        op = sc.next()
        b = sc.nextInt()

        if (op == "?") break

        when (op) {
            "+" -> {
                println(a+b)
            }
            "-" -> {
                println(a-b)
            }
            "*" -> {
                println(a*b)
            }
            "/" -> {
                println(a/b)
            }
        }
    }
}


Measured memory_bytes: 25624
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, K;
  cin >> N >> K;
  vec<ll> h(N);
  REP(i, N) cin >> h[i];

  sort(ALL(h));
  ll answer = numeric_limits<ll>::max();
  for (ll i = 0; i + K <= N; i++) {
    const ll diff = h[i + K - 1] - h[i];
    answer = min(answer, diff);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3992
#include <iostream>

int main() {
	int a, b, c;

	std::cin >> a >> b >> c;

	if (a >= 0 && a <= 100 && b >= 0 && b <= 100 && c >= 0 && c <= 100) {
		if (a < b && b < c && a < c)
			std::cout << "Yes" << std::endl;
		else
			std::cout << "No" << std::endl;
	}

	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a+b==3)
        cout << 3;
    if(a+b==4)
        cout << 2;
    if(a+b==5)
        cout << 1;

}

Measured memory_bytes: 256
/*
[abc126] F - XOR Matching
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int M, K;

vector<int> solve() {
    if (K >= 1 << M) {
        return {};
    }
    if (M == 0) {
        return {0, 0};
    }
    if (M == 1) {
        if (K == 0) {
            return {0, 0, 1, 1};
        }
        return {};
    }

    vector<int> ans;
    for (int i = 0; i < 1 << M; i++) {
        if (i == K) {
            continue;
        }
        ans.push_back(i);
    }
    ans.push_back(K);
    for (int i = (1 << M) - 1; i >= 0; i--) {
        if (i == K) {
            continue;
        }
        ans.push_back(i);
    }
    ans.push_back(K);

    return ans;
}

int main() {
    cin >> M >> K;

    auto ans = solve();
    if (ans.empty()) {
        cout << -1 << endl;
        return 0;
    }
    for (int n : ans) {
        cout << n << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2932
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - 12/22
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 4;

/* typedef */

/* global variables */

char s[N + 1];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  int cnt = 0;
  for (int i = 0; i < N; i++)
    if (s[i] == '2') cnt++;
  printf("%d\n", cnt);
  return 0;
}


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

int main(){
    int a, b, ans;
    string op;
    while(true){
        cin >> a >> op >> b;
        if (op == "?") break;
        else if ( op == "+") ans = a + b;
        else if ( op == "*") ans = a * b;
        else if ( op == "/") ans = a / b;
        else ans = a - b;
        cout << ans << endl;
    }
    
    
    // double r;
    // double pi = 3.141592653589;
    // cin >> r;
    
    // double area = r*r*pi;
    // double circumference = 2*r*pi;
    
    // // 桁数を揃える
    // cout << std::setprecision(16) << std:: fixed <<  area << " " << circumference;
    
    return 0;
}


Measured memory_bytes: 3156
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;


int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, X;
    cin >> N >> X;

    vector<int> x(N + 1);
    REP(i, N) cin >> x[i];
    x[N] = X;
    sort(x.begin(), x.end());

    int ans = x[1] - x[0];
    FOR(i, 1, x.size() - 2) {
        ans = gcd(ans, x[i+1] - x[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    s = set()
    cnt = collections.Counter(arr)
    for i in range(n):
        if arr[i] in s:
            continue
        elif cnt[arr[i]] >= 2:
            s.add(arr[i])
        for j in range(2, 10**6//arr[i]+1):
            s.add(arr[i]*j)
    ans = 0
    for i in arr:
        if i in s:
            continue
        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 104780
import sys
input = sys.stdin.readline
D, N = [int(x) for x in input().split()]
ans = []
for i in range(1, 1010001):
    if i % (100 ** D) == 0 and i % (100 ** (D + 1)) != 0:
        ans.append(i)
print(ans[N-1])


Measured memory_bytes: 42680
object Main {
  def main(args: Array[String]): Unit = {
    val lis : Array[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
    var a : Int = lis(0)
    var b : Int = lis(1)
    var c : Int = lis(2)
    if (c <= a + b)
      println("Yes")
    else
      println("No")
  }
}

Measured memory_bytes: 25380
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)
using namespace std;

int main()
{
	int r, b, g, n; scanf("%d%d%d%d", &r, &g, &b, &n);
	int ans = 0;
	for (int i = 0; i * r <= n; i++)
		for (int j = 0; j * g <= n; j++)
		{
			if (n - i * r - j * g < 0) break;
			if ((n - i * r - j * g) % b == 0) ans++;
		}
	printf("%d\n", ans);
	return 0;
}


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	string s, t;
	cin >> s >> t;
	cout << t << s;
}

int main(){ 
#ifndef ONLINE_JUDGE
 //   freopen("input1.txt","r",stdin);
  //  freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
     //cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    ll n, k; cin >> n >> k;
    ll r = n % k;
    ll ans = min(r, abs(r - k));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

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

    if (N >= B - 1) {
        std::cout << A * (B - 1) / B << std::endl;
    } else {
        std::cout << A * N / B << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S; cin >> S; 
	bool ok = false; 
	if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) ok = true; 
	if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) ok = true; 
	if(S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) ok = true; 
	cout << (ok? "Yes" : "No") << endl; 
}

Measured memory_bytes: 256
using System;
using System.Linq;
 
public class ABC135_A
{
    public static void Main()
    {
        int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
 
      	int result = (ints[0] - ints[1]);
      	if(result < 0) result *= -1;
        if(result % 2 == 0) Console.WriteLine(Math.Max(ints[0],ints[1]) - (result / 2));
      	else Console.WriteLine("IMPOSSIBLE");
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<map>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
typedef pair<int,int> pii;
long long dp[2010][2010]={0},in[2020],n,o;
queue<pii>q;
int main(){
	cin>>n;
	rep(i,n){cin>>in[i];dp[i][1]=in[i],q.push(pii(i,1));}
	while(!q.empty()){
		pii r=q.front();q.pop();
		int a=r.first,b=r.second,s=a-1,t=(s+1+b)%n,w;
		if(s==-1)s=n-1;
		rep(i,2){
			if(b%2&&in[s]<in[t])s=a;
			w=b%2?0:in[(i?t:s)];
			if(dp[s][++b]<dp[a][b-1]+w){
				dp[s][b]=dp[a][b-1]+w;
				if(b!=n)q.push(pii(s,b));
			}
			if(--b%2==0)s=a;
		}
	}
	rep(i,n)o=max(o,dp[i][n]);
	cout<<o<<endl;
}

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

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

using namespace std;


int main(){
	int n,d;
	cin>>n>>d;
	cout<<(n+2*d)/(2*d+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
#include <math.h>
//#include <vector>

using namespace std;


int main() {
  long int Q, H, S, D, N;

  long int tmp;
  
  cin >> Q >> H >> S >> D >> N;

  if(4*Q<S) S=4*Q;
  if(2*H<S) S=2*H;
  if(2*S<D) D=2*S;

  if(N%2){
    tmp = (N-1)/2*D+S;
  }else{
    tmp = N/2*D;
  }
  
  cout << tmp;
 
  return 0;
}


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

int main( void ) {
    
    int a, b, c;
    cin >> a >> b >> c;
    
    bool ok = false;
    for( int i = 1, d = a % b; i <= 200; i ++, d = ( d + a ) % b ) {
        if( d == c )
            ok = true;
    }
    
    if( ok == true )
        cout << "YES";
    else
        cout << "NO";
    
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        a:i64,
        b:i64,
        c:i64,
    }
    let ans = c-min(a-b,c);
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
n = gets.to_i

a = (1..n).to_a.map { |e| [e.to_s[0], e.to_s[-1]] }
b = (1..n).to_a.map { |e| [e.to_s[0], e.to_s[-1]] }
b_h = b.group_by { |bi| "#{bi[0]}#{bi[1]}" }.map { |k,v| [k, v.size] }.to_h

count = 0
a.each { |ai|
  count += b_h["#{ai[1]}#{ai[0]}"] || 0
}

puts count


Measured memory_bytes: 82684
#include <iostream>
#include<vector>

using namespace std;
int main(void){
      int n;
      cin >> n;
      string s;
      cin >> s;
      vector<int> v(26,1);
      
      for(int i = 0;i < s.size();i++){
            v[s[i] - 'a']++;
      }
      long ans = 1;
      for(int i = 0;i < v.size();i++){
            ans = ans * v[i] % 1000000007;
      }
      ans = (ans - 1 + 1000000007) % 1000000007;
      cout << ans << endl;
}
   


Measured memory_bytes: 3768
from heapq import heappop, heappush

x, y, z, k = map(int, input().split())
aaa = sorted(map(int, input().split()), reverse=True)
bbb = sorted(map(int, input().split()), reverse=True)
ccc = sorted(map(int, input().split()), reverse=True)

q = [(-(aaa[0] + bbb[0] + ccc[0]), 0, 0, 0)]
ans = []
added = {(0, 0, 0)}
for _ in [0] * k:
    s, ai, bi, ci = heappop(q)
    ans.append(-s)
    for da, db, dc in ((1, 0, 0), (0, 1, 0), (0, 0, 1)):
        aj, bj, cj = ai + da, bi + db, ci + dc
        if aj >= x or bj >= y or cj >= z:
            continue
        if (aj, bj, cj) in added:
            continue
        added.add((aj, bj, cj))
        heappush(q, (-(aaa[aj] + bbb[bj] + ccc[cj]), aj, bj, cj))

print('\n'.join(map(str, ans)))


Measured memory_bytes: 5312
#include<stdio.h>
   int main(void){
      int a,b,c,tmp;
      scanf("%d %d %d",&a,&b,&c);


      if(c<=a){
         tmp = c;
         c = a;
         a = tmp;
      }

      if(a>=b){
         tmp = b;
         b = a;
         a = tmp;
      }

      if(b>=c){
         tmp = c;
         c = b;
         b = tmp;
      }


      printf("%d %d %d\n",a,b,c);

      return 0;
   }


Measured memory_bytes: 2128