akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(void)
{
    ll R;
    cin >> R;

    printf("%lf\n", 2 * M_PI * static_cast<double>(R)); 

    return 0;
}

Measured memory_bytes: 3768
listA = [] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;

H = listA[0][0]
W = listA[0][1]
h = listA[1][0]
w = listA[1][1]

ans = (H - h) * (W - w)

print(ans)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i * i <= n; i++)
    {
        ans = i * i;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll L(N);
        rep(i, 0, N) cin >> L[i];
        sort(all(L));
        ll tail = L.back();
        ll sm = accumulate(L.begin(), L.end()-1, 0);
        if (tail < sm) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
const int MaxN = 1e5;

int main()
{
	int a,b,c,d;
	int ans,sum;
	while(~scanf("%d %d %d %d",&a,&b,&c,&d))
	{
		ans =  min(a,b);
		sum = min(c,d);
		printf("%d\n",ans+sum);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define ran 111111
int n,e,t;
int x[ran];
long long int dp2[ran];
long long int pref[ran];
long long int a[ran*4];
void upd(int i,int lef,int rig,int x,long long int val){
	if(lef == x && rig == x){
		a[i] = val;
		return;
	}
	int m = (lef+rig)/2;
	if(x <= m)
		upd(i*2,lef,m,x,val);
	else
		upd(i*2+1,m+1,rig,x,val);
	a[i] = min(a[i*2],a[i*2+1]);
}
long long int query(int i,int lef,int rig,int from,int to){
	if(lef == from && rig == to)
		return a[i];
	int m = (lef+rig)/2;
	if(to <= m)
		return query(i*2,lef,m,from,to);
	if(from > m)
		return query(i*2+1,m+1,rig,from,to);
	return min(query(i*2,lef,m,from,m),query(i*2+1,m+1,rig,m+1,to));
}
int main(){
	scanf("%d%d%d",&n,&e,&t);
	x[0] = 0;
	for(int i=1; i<=n; i++)
		scanf("%d",&x[i]);
	x[n+1] = e;
	dp2[0] = 0;
	pref[0] = -2 * x[1];
	upd(1,0,n,0,dp2[0]);
	for(int i=1; i<=n; i++){
		int lo = 0, hi = i-1;
		while(lo!=hi){
			int mi = (lo+hi)/2;
			if((x[i] - x[mi+1]) * 2 <= t)
				hi = mi;
			else
				lo = mi+1;
		}
		dp2[i] = query(1,0,n,lo,i-1) + t;
		if((x[i] - x[lo]) * 2 > t)dp2[i] = min(dp2[i], pref[lo-1] + 2 * x[i]);
		pref[i] = min(pref[i-1], dp2[i] - 2 * x[i+1]);
		upd(1, 0, n, i, dp2[i]);
	}
	cout << dp2[n] + e << endl;
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(){
    ll n,i;
    cin >> n >> i;
    n = n - 2*i ;
    if(n<0)
      n = 0 ;
    cout << n;

}
int main()
{
    ll t=1;
    // cin >> t;
    while(t--)
      solve();

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
#include <stack>
using namespace std;

//#define DEBUG (1)

#ifdef DEBUG
#define DPRINT(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINT(...)
#endif

void  getGarray(int arraySize, int *&pG, int &gSize);
void  insertionSort(int array[], const int arraySize, const int d);
void printArray(const int array[], const int arraySize);

int g_cnt = 0;

int main() {
        int arraySize;
        cin >> arraySize; cin.ignore();
        assert(arraySize > 0);

        int array[arraySize];
        for (int i = 0; i < arraySize; i++)
                cin >> array[i];

#ifdef DEBUG
        DPRINT("INPUT: ");
        printArray(array, arraySize);
#endif
        // shell sort
        int *pG, gSize;
        getGarray(arraySize, pG, gSize);

        cout << gSize << endl;
        printArray(pG, gSize);

        for (int i = 0; i < gSize; i++)
                insertionSort(array, arraySize, pG[i]);

        cout << g_cnt << endl;
        for (int i = 0; i < arraySize; i++)
                cout << array[i] << endl;

        delete [] pG;
        return 0;
}

void getGarray(int arraySize, int *&pG, int &gSize) {
        stack<int> s;
        int i = 1;
        while (i <= arraySize) {
                s.push(i);
                i *= 2;
        }
        gSize = s.size();
        pG = new int[gSize];
        for (int i = 0; i < gSize; i++) {
                pG[i] = s.top();
                s.pop();
        }
#ifdef DEBUG
        DPRINT("gSize: %d\n", gSize);
        DPRINT("pG addr %p\n", pG);
        DPRINT("pG array: ");
        printArray(pG, gSize);
#endif
}

void insertionSort(int array[], const int arraySize, const int d) {
        DPRINT("d: %d\n", d);
        //for (int i = d; i < arraySize; i += d){
        for (int i = d; i < arraySize; i++){
                int j = i;
                int v = array[j];
                while (j-d >= 0 && v < array[j-d]) {
                        array[j] = array[j-d];
                        j -= d;
                        g_cnt++;
                }
                array[j] = v;
        }
#ifdef DEBUG
        DPRINT("array: ");
        printArray(array, arraySize);
#endif
        return ;
}

void printArray(const int array[], const int arraySize) {
        for (int i = 0; i < arraySize; i++) {
                if (i > 0)      cout << " ";
                cout << array[i];
        }
        cout << endl;
}

Measured memory_bytes: 6984
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    VL a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));
    if(a[0]%2==0||a[1]%2==0||a[2]%2==0)cout<<0<<endl;
    else if(a[0]%2!=0||a[1]%2!=0||a[2]%2!=0){
        cout<<a[0]*a[1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import bisect
n,m = map(int,input().split())
data = []
for i in range(m):
    data.append(list(map(int,input().split())))
r = sorted(data,key= lambda x:(x[0],x[1]))
o = [[] for _ in range(100001)]

for i in range(m):
    o[r[i][0]].append(r[i][1])

for i in range(m):
    print("0"*(6-len(str(data[i][0]))),end="")
    print(data[i][0],end="")
    num = bisect.bisect_left(o[data[i][0]],data[i][1])+1
    print("0"*(6-len(str(num))),end="")
    print(num)

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

int main(){
    int x, y;
    cin >> x >> y;
    int flag = 0;
    
    for(int i = 0; i <= x; i++){
        if(i * 2 + (x - i) * 4 == y){
            flag = 1;
            cout << "Yes" << endl;
            break;
        }
    }
    if(flag == 0){
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let (x, y): (Vec<i64>, Vec<i64>) = {
        let (mut x, mut y) = (vec![], vec![]);
        for _ in 0..N {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            x.push(iter.next().unwrap().parse().unwrap());
            y.push(iter.next().unwrap().parse().unwrap());
        }
        (x, y)
    };

    let ans = (0..N)
        .map(|i| {
            (0..N)
                .map(|j| (((x[i] - x[j]).pow(2) + (y[i] - y[j]).pow(2)) as f64).sqrt())
                .sum::<f64>()
        })
        .sum::<f64>()
        / (N as f64);

    println!("{}", ans);
}


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

A.sort(reverse=True)
tmp = 0
tate = 0
yoko = 0
cnt = 0
for i in A:
    if tmp == i and cnt == 0:
        tate = i
        cnt += 1
        tmp = 0
        continue
    if tmp == i and cnt == 1:
        yoko = i
        cnt += 1
        break
    tmp = i

print(tate*yoko)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    string s;
    cin >> s;
    ll sum = 0;
    rep (i, s.size()) {
        sum += s[i] - '0';
    }

    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3744
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b;
    scanf("%d %d", &a, &b);
    
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}


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

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

int main(){
  ll a;
  long double b;
  cin >> a >> b;

  cout << ll(a*b);
}

Measured memory_bytes: 3732
import java.util.*;
class Main{
	public static void main (String args[])
	{
		Scanner in=new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		int c=in.nextInt();
		int diff=(b-a)/c;
		if(a%c==0 || b%c==0)
			diff=diff+1;
		System.out.println(diff);
	}
}

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

int main(){
  int i=0,n,m,road[100]={},x[100];
  cin>>n>>m;
  while(cin>>x[i]){
    road[x[i]]++;
    i++;
  }

  for(int j=1;j<n+1;j++){
    if(0<=road[j]){
      cout<<road[j]<<endl;
    }
  }
}


Measured memory_bytes: 256
/* kadai6_2
   Saikyo_Kazune
*/
#include <stdio.h>
#include <string.h>

 

 
int main(void){
    //宣言
   int SIZE = 103,length_str;
   
   char str[SIZE];
   fgets(str,SIZE,stdin);
   //文字列の長さ(null文字直前までの長さを調べる)
   length_str = strlen(str);
   //改行\nの分を削る
   length_str--;
   //答え用の文字列
   char ans[103]={'\0'};
   //先頭、末尾の文字を取る
   char head = str[0];
   char tail = str[length_str-1];
   //先頭、間の文字数、末尾の文字の順で結合する
   snprintf(ans,103,"%c%d%c",head,length_str-2,tail);
   //出力
   printf("%s\n",ans);
   return 0;
}

Measured memory_bytes: 128
fn circle() -> Result<u32, &'static str> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input)
        .map_err(|_| "read error")?;
    let r = input.trim_right().parse::<u32>()
        .map_err(|_| "parse error")?;

    Ok(r*r)
}

fn main() {
    println!("{}", circle().unwrap());
}

Measured memory_bytes: 4352
icase=0
if icase==0:
    a=int(input())
    b=int(input())
    c=int(input())
    x=int(input())
    icnt=0
    for na in range(a+1):
        for nb in range(b+1):
            r=x-500*na-100*nb
            if 0<=r and r<=c*50 and r%50==0:
                icnt=icnt+1
    print(icnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,K,S; cin>>N>>K>>S;
    if(S==1000000000){
        rep(i,K){
            cout<< S <<" ";
        }
        rep(i,N-K){
            cout<< S-1 <<" ";
        }
        cout<<"\n";
    }
    else{
        rep(i,K){
            cout<< S <<" ";
        }
        rep(i,N-K){
            cout<< S+1 <<" ";
        }
        cout<<"\n";
    }

}

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


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << "7\n";
    } else if (s == "MON") {
        cout << "6\n";
    } else if (s == "TUE") {
        cout << "5\n";
    } else if (s == "WED") {
        cout << "4\n";
    } else if (s == "THU") {
        cout << "3\n";
    } else if (s == "FRI") {
        cout << "2\n";
    } else if (s == "SAT") {
        cout << "1\n";
    }
    return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int n = s.length();
  vector<int> F;
  {
    int j = 0;
    for(int i = 0; i < n; ++i){
      if(j == t.length()) break;
      if(s[i] != t[j]) continue;
      F.push_back(i);
      ++j;
    }
  }
  if(F.size() != t.length()){
    puts("no");
    return 0;
  }
  vector<int> B;
  {
    int j = t.length()-1;
    for(int i = n-1; i >= 0; --i){
      if(j == -1) break;
      if(s[i] != t[j]) continue;
      B.push_back(i);
      --j;
    }
    reverse(B.begin(), B.end());
  }
  if(B.size() != t.length()){
    puts("no");
    return 0;
  }
  if(F != B){
    puts("no");
    return 0;
  }
  puts("yes");
}
  



Measured memory_bytes: 9000
def getChoice(pt):
    return 'rs' if pt == 'p' else 'rp' if  pt == 's' else 'sp'
n, k = map(int, input().split(' '))
r, s, p = map(int, input().split(' '))
t = input()
rsp = {'r': ('p', p), 's': ('r', r), 'p': ('s', s)}
total = 0
co = 0
last = []
for s in t:
    pt, score = rsp[s]
    l = getChoice(pt)
    if co - k >= 0:
        if pt not in last[co - k]:
            score = 0
            if co + k < n:
                fp, fs = rsp[t[co + k]]
                ca = l[0] if fp != l[0] else l[1]
                l = getChoice(ca)
          
    last.append(l)
    total += score
    co += 1
print(total)

Measured memory_bytes: 4212
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
long long p[200000];
long long p_sums[200000];
long long combin(int n, int m){
  long long numerator = 1;
  for(int i = 0; i < m; i++){
    numerator *= (n - i);
  }
  long long denominator = 1;
  for(int i = 0; i < m; i++){
    denominator *= (i + 1);
  }
  return numerator / denominator;
}
long long power(int n, int m){
  long long ans = 1;
  for(int i = 0; i < m; i++){
    ans *= (long long) n;
  }
  return ans;
}
int main(void){
  string S;
  int K;
  cin >> S;
  cin >> K;
  int N = S.size();
  long long ans = 0;
  for(int i = K; i <= N - 1; i++){
    ans += power(9, K) * combin(i - 1, K - 1);
  }
  ans += (long long) (S[0] - '1') * power(9, K - 1) *  combin(N - 1, K - 1);
  if(K == 1){
    ans ++;
  } else if(K == 2){
    if(N >= 2){
      int first_non_zero = N;
      for(int i = 1; i < N; i++){
        if(S[i] != '0'){
          first_non_zero = i;
          break;
        }
      }
      if(first_non_zero < N){
        ans += (long long) (S[first_non_zero] - '0');
        ans += (N - first_non_zero - 1) * (long long) 9;
      }
    }
  } else {
    /*
    for(int i = 1; i < N - 1; i++){
      for(int j = i + 1; j < N; j++){
        ans += (long long) (S[i] - '0') * (long long) (S[j] - '0');
      }
    }
    */
    
    if(N >= 3){
      int first_non_zero = N;
      int second_non_zero = N;
      for(int i = 1; i < N; i++){
        if(S[i] != '0'){
          first_non_zero = i;
          for(int j = i + 1; j < N; j++){
            if(S[j] != '0'){
              second_non_zero = j;
              break;
            }
          }
          break;
        }
      }
      if(first_non_zero < N){
        ans += power(9, K - 1) * combin(N - first_non_zero - 1, K - 1);
        ans += (long long) (S[first_non_zero] - '1') * (N - first_non_zero - 1) * (long long) 9;
      }
      if(second_non_zero < N){
        ans += (long long) (S[second_non_zero] - '0') + (N - second_non_zero - 1) * (long long) 9;
      }
      /*
      for(int i = 1; i < N; i++){
        if(S[i] != 0){
          ans += power(9, K - 1) * combin(N - i - 1, K - 1);

        }
      }
      ans += power(9, K - 1) * combin(N - 2, K - 1);
      if(S[1] > '1'){
        ans += (long long) (S[1] - '1') * (N - 2) * (long long) 9;
      }
      ans += (long long) (S[2] - '0') + (N - 3) * (long long) 9; 
      */
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int a[m];
    int b[2][100005];
    memset(b,0,sizeof(b));
    string s1="WA",s2="AC";
    for(int i=0;i<m;i++)
    {
        string s;
        cin>>a[i];
        cin>>s;
        if(s.compare(s1)==0)
        {
            if(b[1][a[i]]==0)
            {
                b[0][a[i]]++;
            }
        }
        else
        {
            b[1][a[i]]=1;
        }
    }
    int right=0,wrong=0;
    for(int i=0;i<100005;i++)
    {
        if(b[1][i]==0)
        {
            continue;
        }
        else
        {
            right++;
            wrong+=b[0][i];
        }
    }
    cout<<right<<" "<<wrong;
    return 0;
}







Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
const int MAX_N = 100025;
ll dp[MAX_N],arr[MAX_N];
signed main(){
    int n;scanf("%d",&n);
    for(int i = 1;i<=n;++i) scanf("%lld",&arr[i]);
    for(int i = 2;i<=n;++i)
    {
        if(i==2) dp[i] = dp[i-1]+abs(arr[i]-arr[i-1]);
        else dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    printf("%lld\n",dp[n]);
    return 0;
}


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

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    
    sort(a.begin(), a.end());
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        x -= a.at(i);
        if(x >= 0) count++;
        else break;
    }
    if(x > 0) count--;
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
   // freopen("input.txt", "r", stdin);
    SPEED
    string s;
    cin >> s;
    int n = int(s.size());
    int ans = 0;
    for (int i = 0; i < n / 2; ++i) {
        ans += s[i] != s[n - 1 - i];
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int main(){
  while(true){
    int n,m,p;
    cin >> n>>m>>p;
    if(n==0 && n==0 && p==0) break;

    int sum=0;
    int win;
    rep(i,n){
      int d;
      scanf("%d", &d);
      sum+=d;
      if(i==m-1) win=d;
    }

    if(win==0) cout << 0 << endl;
    else cout << sum*(100-p)/win<< endl;
    // sum*100*(100-p)/100/win
  }
}

Measured memory_bytes: 1244
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N;
	char s[101];

	scanf("%zu\n%s", &N, s);

	size_t redCount = 0;
	size_t blueCount = 0;
	
	for (size_t i = 0; i < N; i++) {
		if (s[i] == 'R') {
			redCount++;
		}
		else {
			blueCount++;
		}
	}

	puts((redCount > blueCount ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <functional>
#include <time.h>
#include <math.h>

using namespace std;


int main() {

	int a, b;
	cin >> a >> b;
	if (((a / 10) >= 1) || ((b / 10) >= 1) || (a * b < 0)) {
		cout << -1;
		exit(0);
	}

	cout << a * b;

}

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

Ans = []
maxA,minA,maxAi,minAi = A[0],A[0],0,0
for i in range(1,N):
    if A[i] > maxA:
        maxA = A[i]
        maxAi = i
    if A[i] < minA:
        minA = A[i]
        minAi = i

if abs(maxA) >= abs(minA):
    for i in range(N):
        if i != maxAi:
            Ans.append((maxAi,i))
    for i in range(N-1):
        Ans.append((i,i+1))
else:
    for i in range(N):
        if i != minAi:
            Ans.append((minAi,i))
    for i in range(N-1):
        Ans.append((N-1-i,N-1-i-1))

print(len(Ans))
for (x,y) in Ans:
    print(x+1,y+1)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),k=sc.nextInt();
		int min = Math.min(a, b);
		int cnt=0;
		int ans=0;

		for(int i=min;1<=i;i--) {

			if(a%i==0 && b%i==0) {
				cnt++;
				if(cnt==k) {
					ans=i;
				}
			}

		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
#define mod 1000000007
int32_t main() {
    int n;
    cin>>n;
    vi dp(n+1,0),a(n);
    for(auto &i:a)
    cin>>i;
    dp[0]=0,dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 4844
// https://atcoder.jp/contests/abc175/tasks/abc175_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0, t = 0;
    REP(i, s.size()) {
        if (s[i] == 'R') {
            t++;
        } else {
            ans = max(ans, t);
            t = 0;
        }
    }
    ans = max(ans, t);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
N = int(input())
ans = 0
maxcnt = -1
for i in range(1,N+1):
    cnt = 0
    now = i
    while now % 2 == 0:
        now /= 2
        cnt += 1
    if maxcnt < cnt:
        maxcnt = cnt
        ans = i
print(ans)
    

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

int main() {
  int a, b;
  cin >> a >> b;
  if((a+b) % 2 != 0) cout << "IMPOSSIBLE" << endl;
  else cout << (a+b)/2 << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int a,b,c;

signed main() {
    cin >> a >> b >> c;
    if (a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}



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

int main() {
  int N,K;
  cin >> N >> K;
  int COUNT = 0;
  vector<int> h(N);
   for (int i = 0; i < N; i++) {
    cin >> h.at(i);
     if (h.at(i) >= K)
       COUNT++;
  } 
  cout << COUNT << endl;
}

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

int main(){
    string S,T;
    cin >> S >> T;
    int i=0;

    while(1){
        if(S[i]!=T[i]){
            cout << "No" << endl;
            break;
        }
        i++;
        if(i==S.length()){
            cout << "Yes" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3572
#pragma comment(linker, "/STACK: 2000000")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define double long double
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 998244353;
string ss;
int n, p, cnt[10010], s[200020], ans;

int pw(int x, int y){
	if(y==0) return 1LL;
	int xd=pw(x, y/2)%p;
	return (((xd*xd)%p)*((y%2==1 ? x : 1)))%p;
}

int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>p>>ss;
	if(p==2 || p==5){
		for(int i=0; i<=n-1; i++){
			if((ss[i]-'0')%p==0) ans+=(i+1);
		}
		return cout<<ans, 0;
	}
	for(int i=0; i<=n-1; i++){
		s[i]+=(i>0 ? s[i-1] : 0)+pw(10, n-1-i)*(ss[i]-'0');
		s[i]%=p;
	}
	cnt[0]++;
	for(int i=0; i<=n-1; i++){
		ans+=cnt[s[i]];
		//cout<<i<<" "<<cnt[s[i]]<<endl;
		cnt[s[i]]++;
	}
	cout<<ans;
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vll h(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    auto judge = [&](ll a) {
        ll sum = 0;
        for (size_t i = 0; i < N; i++)
        {
            sum += max(0LL,(h[i] - B * a + A - B - 1) / (A - B));
        }
        return sum <= a;
    };
    ll ok = 1e9 + 1, ng = 0;
    while (abs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2;
        if (judge(mid))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    cout << ng + 1 << endl;
    return 0;
}

Measured memory_bytes: 3968
import sys
import itertools


def prime_list(n):
    limit = int(n ** 0.5) + 1
    lis = range(1, n + 1, 2)
    lis[0] = 2
    while True:
        if len(lis) == 0:
            break
        p = lis.pop(0)
        yield p
        if p <= limit:
            lis = [x for x in lis if x % p != 0]


primes = []
for p in prime_list(50000):
    primes.append(p)
c = [0] * 50001 * 2
for i, j in itertools.combinations(primes, 2):
    c[i+j] += 1
for i in primes:
    c[i+i] += 1
while True:
    n = int(sys.stdin.readline())
    if n == 0:
        exit()
    print c[n]

Measured memory_bytes: 6208
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back







int main(){

    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int cnt=0;

    while (b<=a){
        b*=2;
        cnt++;
    }

    while (c<=b){
        c*=2;
        cnt++;
    }

    if (cnt<=k){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }


}








            






Measured memory_bytes: 3616
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        w: [i32; n],
    }
    let mut a = 0;
    let mut b: i32 = w.iter().sum();
    let mut mi = b;
    for i in 0..n{
        a += w[i];
        b -= w[i];
        mi = min(mi, (a-b).abs());
    }
    println!("{}",mi);

    // let ans = if x<a {0} else {10};
    // puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;

void solve(){

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

    ll x;
    cin >> x;
    ll money=100;
    for (int i=1;i<x;i++){
        money=money+money*0.01;
        if (money>=x){
            cout << i;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

using namespace std;

void solve(int N, vector<pair<pair<string, int>, int>> vec);

void solve(int N, vector<pair<pair<string, int>, int>> vec) {
  sort(vec.begin(), vec.end());
  for (auto v : vec) {
    cout << v.second + 1 << endl;
  }
}

int main() {
  int N;
  cin >> N;
  vector<pair<pair<string, int>, int>> vec;
  string S;
  int P;
  for (int i = 0; i < N; i++) {
    cin >> S;
    cin >> P;
    vec.emplace_back(make_pair(make_pair(S, -P), i));
  }

  solve(N, vec);
  return 0;
}


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

use strict;
use warnings;

my $XN = <STDIN>; chomp($XN);
my $PN = <STDIN>; chomp($PN);

my ( $X, $N ) = split qr(\s+), $XN;
my @nums = sort { $a <=> $b } split qr(\s+), $PN;

if ( $N == 0 ) {
  print $X, "\n";
  exit 0;
}

my %exists = map { $_ => 1 } @nums;

my $start = ( $X > $nums[$#nums] ) ? $X + 1 : $nums[$#nums] + 1;
my $diff = abs($X - $start);
my $n = $start;

for ( my $x = $start; $x > -2; $x-- ) {
  if ( exists $exists{$x} ) {
    next;
  }

  if ( abs($X - $x) <= $diff ) {
    $diff = abs($X - $x);
    $n = $x;
  }
}

print $n, "\n";


Measured memory_bytes: 5140
N, K=map(int, input().split())
h=list(map(int, input().split()))

dp=[float("inf")]*N
dp[0]=0

for i in range(1, N):
	if i==1:
		dp[i]=min(dp[i], abs(h[i]-h[i-1]))
	else:
		start=max(0, i-K)
		dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(start, i))

print(dp[-1])

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007      //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

//for (auto& e : array) 
//cout << count << endl;



signed main()
{
    int K, S;
    cin >> K >> S;

    ll count = 0;

    REP(i, K+1){
        REP(j, K+1){
            if(0 <= S-i-j && S-i-j <= K)
                ++count;
        }
    }

    cout << count << endl;

}
/*
REP(bit, (1 << N))
{
    vector<int> S;
    REP(i, N)
    {
        if (bit & (1 << i))
        { // 列挙に i が含まれるか
            S.push_back(i);
        }
    }

    for (auto& s: S)
    {
        int hon = S[i];
        REP(j, M)
        {
            R[j] = R[j] + A[hon][j];
        }
        price2 += C[hon];
    }
}
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = 1LL<<55;
const Int mod = (1e9)+7;
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  
  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;
  auto tmp = A;
  auto B = A;
  if(prev_permutation(B.begin(), B.end())) cout<<B<<endl;
  cout<<tmp<<endl;
  if(next_permutation(A.begin(), A.end())) cout<<A<<endl;

  
  
  return 0;
}



Measured memory_bytes: 3148
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    class Edge
    {
        internal int t;
        internal int w;

        public Edge(int t, int w)
        {
            this.t = t;
            this.w = w;
        }

    }



    class Program
    {

        static int[] d;    
        static int n;
        static List<Edge>[] g;
        const int INF = int.MaxValue;

        
        static void Bfs(int s)
        {
            for (int i = 0; i < n; i++)
            {
                d[i] = INF;
            }

            var q = new Queue<int>();
            q.Enqueue(s);
            d[s] = 0;

            while(q.Count != 0)
            {
                int u = q.Dequeue();

                for(int i = 0; i < g[u].Count; i++)
                {
                    Edge e = g[u][i];

                    if(d[e.t] == INF)
                    {
                        d[e.t] = d[u] + e.w;
                        q.Enqueue(e.t);
                    } 
                }

            }
            
        }

        static void Solve()
        {

            Bfs(0);

            int x = 0;
            int max = -1;
            for(int i = 0; i < n; i++)
            {
                if(d[i] == INF)
                {
                    continue;
                }
                if(max < d[i])
                {
                    x = i;
                    max = d[i];
                }
            }

            Bfs(x);
            
            max = -1;
            for(int i = 0; i < n; i++)
            {
                if(d[i] == INF)
                {
                    continue;
                }
                max = Math.Max(max, d[i]);
            }

            Console.WriteLine(max);

        }

        
        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());


            g = new List<Edge>[n];            
            d = new int[n];

            for(int i = 0; i < n; i++)
            {
                g[i] = new List<Edge>();
            }


            for(int i = 0; i < n - 1; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                int s = int.Parse(str[0]);
                int t = int.Parse(str[1]);
                int w = int.Parse(str[2]);

                g[s].Add(new Edge(t, w));
                g[t].Add(new Edge(s, w));
            }

            Solve();

        }
    }
}



Measured memory_bytes: 38788
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  string s; cin >> s;
  int n = stoi(s);
  
  int sum = 0;
  for (auto c: s) {
    sum += c-'0';
  }
  if (n % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3636