akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

#define ll long long

using namespace std;

int main(int argc, char* argv[]){
  ll n, distance, goal, start=0, all=0;
  cin >> n;
  std::vector<ll> a(n+2);//位置
  std::vector<ll> one(n+2);
  std::vector<ll> two(n+2); 

  a[0] = 0;
  a[n+1] = 0;
  for (ll i=1; i<n+1; i++){
    cin >> a[i];
    one[i] = abs(a[i] - a[i-1]);
    all += abs(a[i]- a[i-1]);
    if (i>=2){
      two[i] = abs(a[i] - a[i-2]);
    }
  }
  one[n+1] = abs(a[n+1] - a[n]);
  two[n+1] = abs(a[n+1] - a[n-1]);
  all += abs(a[n+1]-a[n]);

  for(ll i=1; i<n+1; i++){
    distance = all - (one[i]+one[i+1]) + two[i+1];
    cout << distance << endl;
  }
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<queue>
#include<algorithm>
#include<utility>
#include<vector>
#include<climits>
using namespace std;

#define MAX_M 110

struct edge{int to,cost;};
typedef pair<int,int> P;

vector<edge> c[2][MAX_M];

int dijkstra(int s,int e,bool r){
	int d[MAX_M];
	for(int i=0;i<MAX_M;i++){
		d[i]=INT_MAX;
	}
	priority_queue<P,vector<P>,greater< P > > que;
	
	d[s]=0;
	
	que.push(P(0,s));
	
	while(!que.empty()){
		P p=que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first) continue;
		for(int i=0;i<c[r][v].size();i++){
			edge e=c[r][v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
	
	return d[e];
}

int main(){
	int n,m;
	while(cin>>n>>m,n!=0||m!=0){
		for(int r=0;r<2;r++){
			for(int i=0;i<MAX_M;i++){
				c[r][i].clear();
			}
		}
		for(int i=0;i<n;i++){
			int a,b,cos,tim;
			cin>>a>>b>>cos>>tim;
			edge co,t;
			co.to=b;co.cost=cos;
			t.to=b;t.cost=tim;
			c[0][a].push_back(co);
			c[1][a].push_back(t);
			co.to=a;t.to=a;
			c[0][b].push_back(co);
			c[1][b].push_back(t);
		}
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int s,e;
			bool r;
			cin>>s>>e>>r;
			int ans=dijkstra(s,e,r);
			cout<<ans<<endl;
		}
	}
}

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

const static int MAX = 100005;

int main() {
  int Q, l[MAX], r[MAX], dp2[MAX];
  bool dp[MAX];

  cin >> Q;
  for (int i = 0; i < Q; i++) scanf("%d%d", &l[i], &r[i]);

  dp[0] = dp[1] = false;
  dp[2] = true;
  int x;
  bool is_prime;

  for (int i = 3; i < MAX; i++) {

    if (i % 2 == 0) {
      dp[i] = false;
      continue;
    }

    is_prime = true;
    x = 3;
    while (x <= sqrt(i)) {
      if (i % x == 0) {
        is_prime = false;
        break;
      }
      x += 2;
    }

    if (is_prime) {
      dp[i] = true;
    } else {
      dp[i] = false;
    }
  }

  dp2[0] = dp2[1] = dp2[2] = 0;
  for (int i = 3; i < MAX; i++) {
    if (dp[i] && dp[(i+1)/2]) dp2[i] = dp2[i-1] + 1;
    else dp2[i] = dp2[i-1];
  }


  for (int i = 0; i < Q; i++) {
    if (dp2[l[i]] - dp2[l[i]-1] == 1) cout << dp2[r[i]] - dp2[l[i]] + 1 << endl;
    else cout << dp2[r[i]] - dp2[l[i]] << endl;
  }


    
  return 0;

}

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

int main()
{
    int n;
    int x, y;
    
    cin >> n;
    
    x = 800 * n;
    y = 200 * (n / 15);
    
    cout << x - y << "\n";
    
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
import sys
from math import sqrt
def main():
    input = sys.stdin.readline
    n = int(input())
    r = sqrt(n)
    r = str(r)
    r_i = r.split('.')
    inte = int(r_i[0])
    g_list = []
    for j in range(inte):
        g = gcd(inte-j, n)
        g_list.append(g)
    g_list.sort()
    min_g = g_list[-1]
    max_g = n / min_g
    max_g_list = list(str(int(max_g)))
    
    print(len(max_g_list))
    
    
        
        

if __name__ == "__main__":
    main()


Measured memory_bytes: 69336
n,k = map(int,input().split())
L = list(map(int,input().split()))
num = [1,2,3,4,5,6,7,8,9,0]
li = list(set(num).difference(set(L)))

flag = False
while True:
    n = str(n)
    for i in range(len(n)):
        if int(n[i]) in li:
            flag = True
        else:
            flag= False
            break
    if flag:
        print(n)
        exit()
    n = int(n)
    n +=1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
typedef pair<int, int> pii;
typedef long long ll;
const int maxn = 200000 + 5;
char s[maxn], t[maxn];
int p[26], q[26];
int main()
{
    while (scanf("%s%s", s, t) == 2) {
        memset(p, -1, sizeof(p));
        memset(q, -1, sizeof(q));
        int n = strlen(s);
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (p[s[i] - 'a'] == -1 && q[t[i] - 'a'] == -1) {
                p[s[i] - 'a'] = t[i] - 'a';
                q[t[i] - 'a'] = s[i] - 'a';
            } else if (p[s[i] - 'a'] == t[i] - 'a' && q[t[i] - 'a'] == s[i] - 'a') {
                continue;
            } else if (p[s[i] - 'a'] != t[i] - 'a' || q[t[i] - 'a'] != s[i] - 'a') {
                flag = false;
                break;
            }
        }
        if (flag)
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, q; cin >> n >> q;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<long long> ruiseki(n+1, 0), odd(n, 0), even(n, 0);
  REP(i, n) ruiseki[i+1] = ruiseki[i] + a[i];
  even[0] = a[0];
  FOR(i, 1, n) {
    if (i % 2 == 0) {
      odd[i] = odd[i-1];
      even[i] = even[i-1] + a[i];
    } else {
      odd[i] = odd[i-1] + a[i];
      even[i] = even[i-1];
    }
  }
  vector<pair<int, int>> x(q);
  REP(i, q) {
    cin >> x[i].first;
    x[i].second = i;
  }
  sort(ALL(x));
  map<int, long long> mp;
  int left = 0, width = n/2, border = (n+1)/2;
  REP(repeat, q) {
    int xx = x[repeat].first;
    while (left < n-1) {
      if (abs(a[left] - xx) > abs(a[left+width] - xx)) {
        ++left;
        if (left+width-1 == border) {
          --width;
          ++border;
        }
      } else break;
    }
    long long res = ruiseki[n] - ruiseki[left+width];
    if (n % 2 == 0) {
      if ((n-left) % 2 == 0) {
        if (left-1>=0) res += odd[left-1];
      } else if (left - 2 >= 0) res += odd[left-2];
    } else {
      if ((n-left) % 2 == 0) {
        if (left-1>=0) res += even[left-1];
      } else if (left - 2 >= 0) res += even[left-2];
    }
    mp[x[repeat].second] = res;
    // cout << left << " " << width << " " << border << '\n';
  }
  REP(i, q) cout << mp[i] << '\n';
  return 0;
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll N,K;
    cin>>N>>K;
    ll Ans=0;
    for(ll i=K;i<N+2;i++){
        Ans+=(i*(N-i+1)+1)%MOD;
        Ans%=MOD;
    }
    cout<<Ans<<endl;
}

Measured memory_bytes: 3616
package main

import (
	"fmt"
	"math"
)

func main() {
	var X int
	fmt.Scan(&X)
	count := 1
	a := 100.0
	for {
		a *= 1.01
		a = math.Trunc(a)
		if X <= int(a) {
			break
		}
		count++
	}
	fmt.Println(count)
}

Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int n,ans;
    cin>>n;
    if(n>=400 && n<=599)ans=8;
    else if(n>=600 && n<=799)ans=7;
      else if(n>=800 && n<=999)ans=6;
       else if(n>=1000 && n<=1199)ans=5;
        else if(n>=1200 && n<=1399)ans=4;
         else if(n>=1400 && n<=1599)ans=3;
          else if(n>=1600 && n<=1799)ans=2;
           else if(n>=1800 && n<=1999)ans=1;
           cout<<ans<<endl;





    return 0;
}







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

using namespace std;

typedef long long ll;

typedef double T;
typedef pair<int, int> P;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<T> VT; 
typedef vector<VT> VVT;
typedef vector<P> VP;

const ll MOD = 1e9+7;
const T EPS = 1e-7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    VI l(n+1, 0); 
    for (int i = 0; i < n; ++i) {
        l[i+1] = (s[i] == 'W') ? l[i] + 1 : l[i];
    }
    int r = 0, ans = 1e6;
    for (int i = n-1; i >= 0; --i) {
        ans = min(ans, l[i] + r);
        if (s[i] == 'E') ++r;
    }
    cout << ans << "\n";

}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
int xyz[200000];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= 100; i++)
	{
		for (int j = 1; j <= 100; j++)
		{
			for (int k = 1; k <= 100; k++)
			{
				xyz[i * i + j * j + k * k + i * j + i * k + j * k]++;
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		cout << xyz[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3776
/*
*         ****FOX****
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <limits>
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#include <utility>
#include <list>
#include <cstdio>
#include<forward_list>
#include<algorithm>
#include<string>
#define Omar_Hafez ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.1415926536
#define ll long long
#define ull unsigned long long
#define lli long long int
using namespace std;
int main()
{
    Omar_Hafez
    int n,a=0,w=0,t=0,r=0; cin >> n;
    string x;
    for (int i = 0; i < n; i++)
    {
        cin >> x; 
        if (x[0] == 'A') a++;
        else if (x[0] == 'W') w++;
        else if (x[0] == 'T')t++;
        else if (x[0] == 'R')r++;
    }
    cout << "AC " << "x " << a << "\n";
    cout << "WA " << "x " << w << "\n";
    cout << "TLE " << "x " <<t << "\n";
    cout << "RE " << "x " << r << "\n";
        return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

#define M 100000

int pp[M], yy[M];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return pp[i] != pp[j] ? pp[i] - pp[j] : yy[i] - yy[j];
}

void initialize(char *s, int p, int x) {
	int i;

	for (i = 11; i >= 0; i--)
		if (i < 6 && p > 0)
			s[i] = (p % 10) + '0', p /= 10;
		else if (i >= 6 && x > 0)
			s[i] = (x % 10) + '0', x /= 10;
		else
			s[i] = '0';
}

int main() {
	static int ii[M];
	static char id[M][13];
	int n, m, i, x;

	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &pp[i], &yy[i]);
		ii[i] = i;
	}
	qsort(ii, m, sizeof *ii, compare);
	for (i = 0, x = 1; i < m; i++, x = i > 0 && pp[ii[i]] != pp[ii[i - 1]] ? 1 : x + 1)
		initialize(id[ii[i]], pp[ii[i]], x);
	for (i = 0; i < m; i++)
		printf("%s\n", id[i]);
	return 0;
}


Measured memory_bytes: 3832
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<long long> L(N);
	for (int i = 0; i < N; i++) cin >> L[i];
	sort(L.begin(), L.end());
	long long COUNT = 0;
	for (int i = 0; i < N - 1; i++) COUNT += L[i];
	cout << (COUNT > L[N - 1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)

input = sys.stdin.readline

n, m, x = map(int, input().split())

books = []
for i in range(n):
	book = list(map(int, input().split()))
	books.append(book)
    
ans = float('inf')
for s in range(1 << n):
  cost = 0
  d = [0] * m
  for i in range(n):
    if (s >> i & 1):
      cost += books[i][0]
      for j in range(m):
        d[j] += books[i][j+1]
  ok = True
  for j in range(m):
    if(d[j] < x):
      ok = False
  if ok:
    ans = min(cost, ans)
if (ans == float('inf')):
  print("-1")
else :
  print(ans)
  

Measured memory_bytes: 68480
#include <vector>

using namespace std;

void judge(int n, int k, int m){
	vector<int> vec(n);
	int i=0;
	for(;i<n;i++)vec[i]=i+1;
  i=(m-1)%vec.size();
	vec.erase(vec.begin()+i);
	while(vec.size()>1){
    i+=(k-1)%vec.size();
    if(i>=vec.size())i-=vec.size();
		vec.erase(vec.begin()+i);
	}
	cout << vec.at(0) << endl;
}

int main(){
	int n,k;
	while(true){
		cin >> n >> k;
		if(!n&&!k)break;
		judge(n,k,k);
	}
	return 0;
}

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

int main(){
	int N;
	cin>>N;
	vector<double> A(N);
	for (int i = 0;i<N;i++){
		cin>>A.at(i);
	}
	double under =0;
	for (int i = 0;i<N;i++){
		if(A.at(i)!=0){
			under+=(1/A.at(i));
		}
	}
	cout<<(1/under)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<bitset>

int main() {
  std::string str;
  std::bitset<26> bit;
  std::cin >> str;
  for (int i=0; i<str.size(); i++) {
    bit.set(int(str.at(i)) - 'a', 1);
  }
  int flag = 0;
  char ans;
  for (int i=0; i<26; i++) {
    if (!bit.test(i)) {
      ans = 'a'+i;
      flag=1;
      break;
    }
  }
  if (flag) {
    std::cout << ans << std::endl;
  }
  else {
    std::cout << "None" << std::endl;
  }
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
  int n,k;
  cin>>n;
  cin>>k;
  int sum=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x<k){
      if(x>k-x){
        sum+=(k-x)*2;
      }
      else{
        sum+=x*2;
      }
    }
    else{
      if(x<x-k){
        sum+=x*2;
      }
      else{
        sum+=(x-k)*2;
      }
    }
  }
  cout<<sum;
}

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

#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repr(i, a, b) for (int i = (int)(a - 1); i >= b; i--)
#define rep(i, n) repl(i, 0, n)
#define each(itr, v) for (auto itr : v)
#define pb(s) push_back(s)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x " = " << x << endl
#define maxch(x, y) x = max(x, y)
#define minch(x, y) x = min(x, y)
#define uni(x) x.erase(unique(all(x)), x.end())
#define exist(x, y) (find(all(x), y) != x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX / 3

int main() {
  cin.sync_with_stdio(false);
  string s, t;
  int k;
  cin >> s >> k;
  t = s;
  sort(all(t));
  uni(t);
  set<string> v;
  rep(i, s.size()) {
    repl(j, i + 1, min(i + 1 + k, (int)s.size() + 1)) {
      v.insert(s.substr(i, j - i));
    }
  }
  vector<string> vv;
  each(itr, v) vv.pb(itr);
  cout << vv[k - 1] << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
char a[100001]; 
int k[100001];
int len,l;
int dfs()
{
	int j,i;
	for(i=0;i<len-1;i++)
	{
		if(a[i]!=a[i+1])
		{
			for(j=i+2;j<len;j++)
			{
				a[j-2]=a[j];
			}
			len-=2;
			return 1;
		}
	}
	return 0;
}
int main()
{
	int i,ret=1;
	scanf("%s",a);
	l=len=strlen(a);
	while(ret)
	{
		ret=dfs();
	}
	printf("%d",l-len);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

int gcd(int x,int y)
{
  int r;
  r=x%y;

  while(r>0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}

int main()
{
  int x,y;
  std::cin>>x>>y;

  std::cout<<gcd(x,y)<<"\n";

  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  int l, r;
  l = A + B;
  r = C + D;
  
  if (l > r){
    cout << "Left" << endl;
  }else if(l == r){
    cout << "Balanced" << endl;
  } else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
    for d in range(10, D+1):
        d = str(d)
        d10, d1 = map(int, (d[1], d[0]))
        if d10 >= 2 and d1 >= 2 and d10*d1 == m:
            ans += 1
print(ans)


Measured memory_bytes: 9172
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}

int main() {
    ll N, K;
    cin >> N >> K;
    
    ll res = 0;
    auto cube = [](ll i){return i * i * i;};
    if(K % 2 != 0)
        res = cube(N / K);
    else
        res = cube(N / K) + cube((N + K / 2) / K);
    
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int counts[100000];
int main()
{
	int n, x, y;
	cin >> n >> x >> y;
	x--;
	y--;

	rep(i,n){
		for (int j = i+1; j < n; j++){
			int d = j - i;
			d = min(d, abs(x - i) + abs(y - j) + 1);
			counts[d]++;
		}
	}
	rep(i,n-1){
		cout << counts[i+1] << endl;
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


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


def main():
    L, R, d = inpl()
    ans = 0
    for i in range(L, R + 1):
        if i % d == 0:
            ans += 1
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61912
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;


int main() {
	int n, l;
	cin >> n >> l;
	int sum = 0;

	int pre = inf;
	ff(i, 1, n + 1) {
		int a= l + i - 1;
		sum += a;
		if(abs(pre)>abs(a))pre=a;
	}

	cout << sum - pre << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

ll isOver(ll k, ll i){
    ll ret = 0;
    while(i<k){ ret++; i *= 2; }
    return ret;
}

long long modPow(long long x, long long n, long long mod = MODV){
    if(n == 0) return 1;
    if(n%2 == 0) return modPow(x*x%mod, n/2, mod)%mod;
    return x%mod * modPow(x%mod, n-1, mod)%mod;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, k; cin >> n >> k;
    double ans = 0;
    repf(i, n) ans += (1.0/n)*(1.0/modPow(2, isOver(k, i)));
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int d = sc.nextInt();
		
		//確率の計算
		//1パターンずつしかないもの
		double x1 = 0;
		if(n > d){
			x1 = 1.0/n/n * d * 2;
		}
		
//		System.out.println(x1);
		
		//2パターンありえるもの
		double x2 = 0;
		if(n > 2*d){
			x2 = 1.0/n/n * (n - 2*d);
		}
		if(d != 0){
			x2 *= 2.0;
		}
//		System.out.println(x2);
		
		double x3 = x1 + x2;
		
		System.out.printf("%.10f\n",x3*(m - 1));
	}

}


Measured memory_bytes: 23252
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
inline LL gcd(LL a,LL b)
{
	return !b?a:gcd(b,a%b);
}

int main()
{
	int n;
	scanf("%d",&n);
	
	LL a,b,A=1,B=1;
	LL G;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld %lld",&a,&b);
		if(a>A && b>B) A=a,B=b;
		else
		{
			G=max((A/a)+(A%a?1:0),B/b+(B%b?1:0));
			A=a*G,B=b*G;
		}
	}
	
	printf("%lld\n",A+B);
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)
#define fi first
#define se second

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

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

vector<int>v;
class DHandstand {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n, k;
        cin >> n >> k;
        string s;
        cin >> s;
        v.clear();
        int now = 1;
        int time = 0;
        for(int i = 0; i < n; ++i){
            if(now + '0' == s[i])time++;
            else {
                v.push_back(time);
                now = 1 - now;
                time = 1;
            }
        }
        if(time)v.push_back(time);
        // for(int i = 0; i < v.size(); ++i)cout << v[i] << " ";
        // cout << endl;
        int len = 2*k + 1;
        int res = 0;
        bool flag = s[0] == '1' ? 1 : 0; // if first element is 0, flag is true
        for(int i = 0; i < v.size(); i+=2){
            int tmp = 0;
            int r = i + len;
            for(int j = i; j < v.size() && j < r; ++j){
                tmp += v[j];
            }
            res = max(res, tmp);
        }
        out << res << '\n';
    }
};



int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    DHandstand solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	
	int n;
	while(cin>>n){
	int count=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			for(int k=0;k<10;k++){
				for(int x=0;x<10;x++){
					if(i+j+k+x==n){count++;}
				}
			}
		}
	}
		cout<<count<<endl;
	}
			
	return 0;
	}

Measured memory_bytes: 1160
from math import ceil


INF = float('inf')
H, N = map(int, input().split())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

dp = [INF for _ in range(H+1)]
dp[0] = 0

for i in range(N):
    a, b = AB[i]
    for j in range(1, ceil(H/a)+1):
        s = 1 + (j-1) * a
        t = min(H, s + a - 1)
        for k in range(s, t+1):
            dp[k] = min(dp[k], dp[max(0, k-a)] + b)


print(dp[H])


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

struct Point{
  double x,y;
  Point (double x = 0,double y = 0):x(x),y(y){}
  Point operator + (Point p) { return Point(x + p.x, y + p.y);}
  Point operator - (Point p) { return Point(x - p.x, y - p.y);}
  Point operator * (double a) { return Point(x * a, y * a);}
  double norm(){return x*x + y*y;}
};

typedef Point Vector;

double norm(Vector v){
  return v.x*v.x + v.y*v.y;
}

struct Segment{
  Point p1,p2;
};

double dot(Vector a,Vector b){
  return a.x*b.x + a.y*b.y;
}

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

Point reflect(Segment s,Point p){
  return p + (project(s,p) - p)*2.0;
}

int main(){
  Segment p;
  Point q,r;

  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &p.p1.x, &p.p1.y, &p.p2.x, &p.p2.y, &q.x, &q.y) != EOF){

    r = reflect(p,q);
    
    printf("%f %f\n",r.x,r.y);
  }
}

Measured memory_bytes: 0
h,w=map(int,input().split())
A=[]
B=[]
for i in range(h):
    A.append([int(i) for i in input().split()])
for i in range(h):
    B.append([int(i) for i in input().split()])

for i in range(h):
    A[i]=[abs(A[i][q]-B[i][q]) for q in range(w)]
    

DP=[[[0 for i in range(12801)] for q in range(w)] for r in range(h)]
DP[0][0][A[0][0]]=1

for i in range(h):
    for q in range(w):
        now=DP[i][q]
        if i<h-1:
            nex=DP[i+1][q]
            for r in range(12801):
                if now[r]==1:
                    nxsc=A[i+1][q]
                    nex[abs(r-nxsc)]=1
                    if r+nxsc<12801:
                        nex[r+nxsc]=1
                        
        if q<w-1:
            nex=DP[i][q+1]
            for r in range(12801):
                if now[r]==1:
                    nxsc=A[i][q+1]
                    nex[abs(r-nxsc)]=1
                    if r+nxsc<12801:
                        nex[r+nxsc]=1

las=DP[-1][-1]
ans=12801
for i in range(12800,-1,-1):
    if las[i]==1:
        ans=i
print(ans)
                        
                        

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

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> numList = new ArrayList<Integer>();
        while(sc.hasNext()){
            int n = sc.nextInt();
            if(n == 0){
                break;
            }else{
                numList.add(n);
            }
        }
        for(int i = 1; i <= numList.size(); i++){
            System.out.println("Case " + i + ": " + numList.get(i - 1));
        }
    }
}


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

using namespace std;

typedef long long ll;

int main(){
	map<string, int> mp;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string cur;
		cin >> cur;
		mp[cur]++;
	}
	cout << "AC x " << mp["AC"] << '\n';
	cout << "WA x " << mp["WA"] << '\n';
	cout << "TLE x " << mp["TLE"] << '\n';
	cout << "RE x " << mp["RE"] << '\n';
}


Measured memory_bytes: 3628
#include<cstdio>

using namespace std;

long long numofp(long long *size, long long *patty, long long cur, long long left)
{
	if (cur == 0)
	{
		return left;
	}

	if (left <= 1)
	{
		return 0;
	}

	if (left >= 2 && left <= size[cur - 1] + 1)
	{
		return numofp(size, patty, cur - 1, left - 1);
	}

	if (left == size[cur - 1] + 2)
	{
		return patty[cur - 1] + 1;
	}

	if (left >= size[cur - 1] + 3 && left <= size[cur] - 1)
	{
		return patty[cur - 1] + 1 + numofp(size, patty, cur - 1, left - size[cur - 1] - 2);
	}

	return patty[cur];
}

int main()
{
	long long size[51];
	long long patty[51];
	long long n, x;
	long long i;

	size[0] = 1;
	patty[0] = 1;

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

	for (i = 1; i <= n; i++)
	{
		size[i] = size[i - 1] * 2 + 3;
		patty[i] = patty[i - 1] * 2 + 1;
	}

	printf("%lld\n", numofp(size, patty, n, x));

	return 0;
}

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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a > k) {cout << ":(" << endl; return 0;}
    cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        System.out.println(((a * (a-1))/2 + (b * (b-1))/2));
    }

}

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

int main() {
	int n;
	while(cin>>n){
		int num[n];
		int isdiv[int(1e6)+1]={};
		for(int i=0;i<n;i++){
			cin>>num[i];
		}
		sort(num,num+n);
		int cnt=0;
		for(int i=0;i<n-1;i++){
			if(isdiv[num[i]]==0){
				if(num[i]!=num[i+1]){
					cnt++;
				}
				for(int j=num[i];j<=num[n-1];j+=num[i]){
					isdiv[j]=1;
				}
			}
		}
		cout<<cnt+(isdiv[num[n-1]]==0)<<'\n';
	}
}

Measured memory_bytes: 8320
N = int(input())
l = []

for _ in range(N):
    a, b =map(int, input().split())
    l.append((a-b, a+b))

l = sorted(l, key=lambda x:x[1])
start = l[0][1]
ans = 1

for i in range(1, N):
    # print(f"start{start}, ")
    if start <= l[i][0]:
        ans += 1
        start = l[i][1]
print(ans)

Measured memory_bytes: 19024
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    long C = Long.parseLong(sc.next());

    long x[] = new long[N];
    long v[] = new long[N];

    long calorie;
    long calorieForwardMax[] = new long[N + 1];
    long calorieForwardReturn[] = new long[N + 1];
    calorieForwardMax[0] = 0;
    calorieForwardReturn[0] = 0;
    long sumV = 0;

    for (int i = 0; i < N; i++) {
      x[i] = Long.parseLong(sc.next());
      v[i] = Long.parseLong(sc.next());
      sumV += v[i];
      calorie = sumV - x[i];
      calorieForwardMax[i + 1] = Math.max(calorie, calorieForwardMax[i]);
      calorieForwardReturn[i + 1] = Math.max(calorie - x[i], calorieForwardReturn[i]);
    }

    long calorieBackMax[] = new long[N + 1];
    long calorieBackReturn[] = new long[N + 1];
    calorieBackMax[0] = 0;
    sumV = 0;
    for (int i = 0; i < N; i++) {
      sumV += v[N - 1 - i];
      calorie = sumV - (C - x[N - 1 - i]);
      calorieBackMax[i + 1] = Math.max(calorie, calorieBackMax[i]);
      calorieBackReturn[i + 1] = Math.max(calorie - (C - x[N - 1 - i]), calorieBackReturn[i]);
    }

    long max = 0;
    for (int i = 0; i <= N; i++) {
      if (max < calorieForwardMax[i]) {
        max = calorieForwardMax[i];
      }
      if (max < calorieBackMax[N - i]) {
        max = calorieBackMax[N - i];
      }
      if (max < calorieForwardReturn[i] + calorieBackMax[N - i]) {
        max = calorieForwardReturn[i] + calorieBackMax[N - i];
      }
      if (max < calorieBackReturn[N - i] + calorieForwardMax[i]) {
        max = calorieBackReturn[N - i] + calorieForwardMax[i];
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 61604
#include    <stdio.h>

int main(void)
{
    long int	a;
    char    name[16] = {0, };

    if (fscanf(stdin, "%ld", &a) == EOF) {
	return 1;
    }

    int	i = 0;
    while (a > 0) {
	a -= 1;
	int surplus = (a) % 26;
	name[i++] = 'a' + surplus;
	a /= 26;
    }

    while (i-- > 0) {
	printf("%c", name[i]);
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 1660
import itertools

N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
grid = [list(map(int, input().split())) for _ in range(N)]

ans = 10**10

group = {g: {c: 0 for c in range(C)} for g in range(3)}
for i, row in enumerate(grid):
    for j, r in enumerate(row):
        group[(i+j)%3][r-1] += 1

for tup in itertools.combinations(range(C), 3):
    for c1, c2, c3 in itertools.permutations(tup):
        temp = 0
        for c in range(C):
            for g, col in zip(range(3), [c1, c2, c3]):
                temp += group[g][c] * D[c][col]
        if ans > temp:
            ans = temp
            
print(ans)


Measured memory_bytes: 5620
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int count = 0;
    for(int i = 1; i <= n; i++){
        if(i % 2 != 0){
            count++;
        }
    }

    cout << float(count) / float(n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int r, g, b, N;
int ans;

signed main(){
    cin >> r >> g >> b >> N;
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            int a = N - r * i - g * j;
            if(a >= 0){
                if(a % b == 0){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}
/*



*/

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int cnt[100];

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 0; i < k; ++i)
	{
		int d;
		scanf("%d", &d);
		for (int i = 0; i < d; ++i)
		{
			int a;
			scanf("%d", &a);
			cnt[a - 1] += 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (cnt[i] == 0)
		{
			ans += 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1000010;
int n;
int a[N];
char s[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline bool check(int k) {
    for(int i=0;i<n;i++) a[i]=9*(s[i]-'0');
    int m=n,ans=0;
    a[0]+=9*k;
    for(int i=0;i<m;ans+=a[i++]%10)
	if(a[i]>9) {
	    if(i==m-1) a[m++]=0;
	    a[i+1]+=a[i]/10;
	}
    return ans<=k*9;
}
int main() {
    scanf("%s",s);
    n=strlen(s),reverse(s,s+n);
    int l=1,r=n;
    while(l<=r) {
	int mid=(l+r)>>1;
	if(check(mid)) r=mid-1;
	else l=mid+1;
    }
    cout<<l;
    return 0;
}

Measured memory_bytes: 3840
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int curTime = 0;
        int[] wTime = new int[86400];
        for (int i = 0; i < n; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            curTime = (curTime + ab[0]) % wTime.Length;
            wTime[curTime]++;
            curTime = (curTime + ab[1]) % wTime.Length;
        }

        long[] ruisekiwa = new long[wTime.Length * 2];
        for (int i = 1; i < ruisekiwa.Length - 1; i++)
        {
            ruisekiwa[i + 1] = ruisekiwa[i] + wTime[(i - 1) % wTime.Length];
        }
        long max = 0;
        for (int i = 0; i < ruisekiwa.Length - 10802; i++)
        {
            max = Max(max, ruisekiwa[i + 10801] - ruisekiwa[i]);
        }
        Console.WriteLine(max);
    }
}


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

class unionfind {
  vector<int> parent;
  public:  
  void init(int n) {
    for (int i = 0; i < n; i++) {
      parent.push_back(i);
    }
  }
  
  void merge(int m, int n) {
    if (find(m) == find(n)) return;
    parent.at(find(m)) = find(n);
  }
  
  int find(int n) {
    if (parent.at(n) == n) return n;
    return parent.at(n) = find(parent.at(n));
  }
};

int main()
{
  int n;
  cin >> n;
  unionfind t;
  t.init(200000);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    t.merge(x - 1, y + 99999);
  }
  vector<int> sx(200000), sy(200000);
  for (int i = 0; i < 100000; i++) {
    sx.at(t.find(i))++;
    sy.at(t.find(i + 100000))++;
  }
  long s = 0;
  for (int i = 0; i < 200000; i++) {
    s += (long)sx.at(i) * sy.at(i);
  }
  cout << s - n << endl;
}


Measured memory_bytes: 2676
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
  	int mod = N % 500;
    if (mod <= A) System.out.println("Yes");
    else System.out.println("No");
  }
 }

Measured memory_bytes: 22228
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static int exception(ArrayList<Integer> parse){
		int result = 0;
		for(int j = 0; j < parse.size(); ++j){
			if(parse.get(j) < -1000000 || parse.get(j) > 1000000){
				result = 0;
			}
			else {
				result = 1;
			}
		}
		return result;
	}
	public static void main(String[] args){
		/**
		 * ?????°?????£?¨?
		 */
		int n=0;
		int a=0,b=0; //int????????¨?????°
		long sum = 0;
		String str;
		/**
		 * ???????????£?¨?
		 */
		ArrayList<String> st = new ArrayList<String>();
		ArrayList<Integer> parse = new ArrayList<Integer>();
		/**
		 * ?????????????????\?????¨????????????????´?
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); //????????°
		for(int i = 0;i < n; ++i){
			st.add(scan.next());
			parse.add(Integer.parseInt(st.get(i))); //int????????¨int????????????????´?
			sum += parse.get(i); // ????¨????
		}
		Collections.sort(parse); //int???????????????????????????
		if(exception(parse) == 0){
			System.out.println("??\??????????????§???.???????????????.");
		}
		else if(exception(parse) == 1){
		System.out.println(parse.get(0)+" "+parse.get(n-1)+" "+sum);
		}
	}

}

Measured memory_bytes: 42452
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include<algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  string a,b;
  cin >> a >> b;
  int n = a.size();
  int vec[100][100] = {};
  
  for(int i=0;i<n;i++){
    vec[a.at(i)-'0'][b.at(i)-'0']++;
  }
  for(int i=('a'-'0');i<=('z'-'0');i++){
    bool flag1 = 0,flag2 = 0;
    for(int j=('a'-'0');j<=('z'-'0');j++){
      if(vec[j][i] > 0){
        if(flag1 == 1){
          cout << "No" << endl;
          return 0;
        }
        else
        flag1 = 1;
      }
      if(vec[i][j] > 0){
        if(flag2 == 1){
          cout << "No" << endl;
          return 0;
        }
        else
        flag2 = 1;
      }
    }
  }
    
  cout << "Yes" << endl;
}

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

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

signed main(){
	int x;
	cin >> x;
	__int128 n = 100;
	int ans = 0;
	while(n < x){
		ans += 1;
		n = (n*101/100);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,sum,gc[203][203];
char a[10];
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			gc[i][j]=__gcd(i,j);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=n;k++)
				sum+=gc[gc[i][j]][gc[j][k]];
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3952
#include<stdio.h>
int hantei(int);

int main(){

  int i,n,s,h,c=0;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&s);
        if(hantei(s) == 1) c++;
    }
    printf("%d\n",c);
    return 0;
}

int hantei(int s){
  int i;
  if(s < 2) return 0;
  for(i = 2;i * i <= s;i++){
    if(s % i == 0) return 0;
  }
  return 1;
}



Measured memory_bytes: 2108
def greatest_common_divisor(x, y):
    while True:
        if x == 0 or y == 0:
            break
        elif x >= y:
            x %= y
        else:
            y %= x

    return x+y

if __name__ == '__main__':
    x, y = map(int, input().split())
    gcd = greatest_common_divisor(x, y)
    print(gcd)



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

class Mondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = line[0];
        var M = line[1];
        var A = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).OrderBy(x=>x).ToArray();
        var list = new List<long[]>();
        for (int i=0;i<M;++i)
        {
            var bc = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            list.Add(new long[2] { bc[0] , bc[1] });
        }
        var l=list.OrderByDescending(x => x[1]).ThenByDescending(x=>x[0]).ToArray();
        var index = 0;
        var array = new long[N];
        foreach (var i in l)
        {
            for (int j=0;j<i[0];j++)
            {
                array[index] = i[1];
                index++;
                if (N <= index) break;
            }
            if (N <= index) break;
        }
        var ans = 0L;
        for (int i = 0; i < N;++i) ans += array[i] < A[i] ? A[i] : array[i];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 34144
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

const long long MOD = 1e9 + 7;

// mod m での a の逆元
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

ll n, ans, sum, a[100010];
ll fact = 1, ifact[100010], invcul[100010];

int main() {
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	for (ll i = 2;i <= n;i++) {
		fact *= i;//階乗を求める
		fact %= MOD;
	}
	for (int i = 0;i < n;i++) {
		ifact[i + 1] = modinv(i + 1, MOD);
		invcul[i + 1] = fact * ifact[i + 1] % MOD;
		sum += invcul[i + 1];
		sum %= MOD;//ここを忘れていた。切腹。
	}
	ans += sum * a[0] % MOD;
	for (int i = 1;i < n;i++) {
		sum -= invcul[n - i + 1];
		sum += MOD;
		sum += invcul[i + 1];
		sum %= MOD;
		ans += sum * a[i] % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


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

int par[100001];
int high[100001];
//n要素で初期化
void init(int n){
  for(int i=0; i<n; i++){
    par[i]=i;
    high[i]=0;
  }
}
//木の根を求める
int find(int x){
  if(par[x]==x){
    return x;
  }
  else{
    return par[x]=find(par[x]);
  }
}

//xとyの属する集合を併合
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(high[x]<high[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(high[x]==high[y])high[x]++;
  }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
  return find(x)==find(y);
}   
int main(){
	int n,m;
  	cin>>n>>m;
  	int a[101],b[101];
  	for(int i=0; i<m; i++){
      cin>>a[i]>>b[i];
      a[i]--; b[i]--;
    }	
  	int ans=0;
  	for(int i=0; i<m; i++){
        init(n);
      	set<int>st;
      	for(int j=0; j<m; j++){
          if(j!=i){unite(a[j],b[j]);}
        }
      	for(int j=0; j<n; j++){
          st.insert(find(j));
        }
      	if(st.size()>1)ans++;
    }
  	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
inline bool isprime(int x) {
  if (x <= 1) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int main() {
  int x;
  cin >> x;

  while (!isprime(x)) x++;

  cout << x << endl;
  return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, c, k;cin >> n >> c >> k;
    vector<int> t(n);
    for(int i=0;i<n;i++) cin >> t[i];
    sort(t.begin(), t.end());
    int ans = 1;
    int b = 0;
    for(int i=1;i<n;i++){
        if(t[b]+k < t[i] || i-b+1 > c){
            ans++;
            b = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n,m;
		cin>>n>>m;
		vector<pii> v;
		ll int idx=1;
		for(ll int i=m;i>=1;i-=2)
		{
			v.pb({idx,idx+i});
			idx++;
		}
		idx=n;
		for(ll int i=m-1;i>=1;i-=2)
		{
			v.pb({idx,idx-i});
			idx--;
		}
		for(auto it:v)
		{
			cout<<it.F<<" "<<it.S<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 5328