akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void shortestPath(const vector<vector<int> >& edges, int start, vector<int>& dist)
{
    int n = edges.size();
    dist.assign(n, INT_MAX);
    dist[start] = 0;
    queue<int> q;
    q.push(start);

    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(unsigned i=0; i<edges[v].size(); ++i){
            int u = edges[v][i];
            if(dist[u] == INT_MAX){
                dist[u] = dist[v] + 1;
                q.push(u);
            }
        }
    }
}

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

    vector<vector<int> > edges(3*n);
    for(int i=0; i<m; ++i){
        int u, v;
        cin >> u >> v;
        -- u;
        -- v;
        for(int j=0; j<3; ++j)
            edges[3*u+j].push_back(3*v+(j+1)%3);
    }

    int s, t;
    cin >> s >> t;
    -- s;
    -- t;
    vector<int> dist;
    shortestPath(edges, 3*s, dist);
    int ans = dist[3*t];
    if(ans == INT_MAX)
        cout << -1 << endl;
    else
        cout << (ans / 3) << endl;

    return 0;
}


Measured memory_bytes: 17792
<?php
fscanf(STDIN, '%d', $n);//個数
$d_arr = explode(' ', trim(fgets(STDIN)));//美味しさ

$total_heal = 0;
for($s = 0; $s < $n-1; $s++) {
    $heal = 0;
    for($r = $s+1; $r < $n; $r++) {
        $heal += (int)$d_arr[$s] * (int)$d_arr[$r];
    }
    $total_heal += $heal;
}
echo $total_heal.PHP_EOL;

Measured memory_bytes: 4728
let f s =  (* string -> char list *)
  let as_ = Array.make (String.length s) 'c' in 
  String.iteri (fun i x -> as_.(i) <- x) s;
  Array.to_list as_ ;;

let rec hd_eq a1 a2 = match (a1, a2) with
    ([], _) -> true
  | (_, []) -> false
  | (x :: xs, y :: ys) when x = y -> hd_eq xs ys
  | (x :: xs, y :: ys) -> false ;;

let rec inc a1 a2 =
  if a2 = [] then false
  else if hd_eq a1 a2 then true
  else (match a2 with
          [] -> false
        | x :: xs -> inc a1 xs) ;;

let () =
  let s1 = let s = read_line() in s ^ s in
  let s2 = read_line() in
  let list = f s1 in
  let word = f s2 in
  if inc word list then print_endline "Yes"
  else print_endline "No" ;;


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

char s[105];int l,ans=1e9;

int main()
{
    scanf("%s",s),l=strlen(s);
    for(int i=0,t,k;i<26;++i)
    {
	t=k=-1;
	for(int j=0;j<l;++j)
	    if(s[j]=='a'+i)k=std::max(k,j-t-1),t=j;
	ans=std::min(ans,std::max(k,l-t-1));
    }
    printf("%d\n",ans);
    
    return 0;
}

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

int main(){
	ll n;scanf("%lld",&n);
	ll g;
	rep(i,n){
		ll t;scanf("%lld",&t);
		if(i==0)g=t;
		else g=g/__gcd(g,t)*t;
	}
	printf("%lld\n",g);
}


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

typedef long long ll;

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

    string s;
    cin >> s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]=='A' && s[i+1]=='C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
using namespace std;
#define llg long long
#define maxn 150010
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);

inline llg getint()
{
    llg w=0,q=0; char c=getchar();
    while((c<'0' || c>'9') && c!='-') c=getchar();
    if (c=='-')  q=1, c=getchar(); while (c>='0' && c<='9') w=w*10+c-'0', c=getchar();
    return q ? -w : w;
}
int main()
{
	llg a,b;
	cin>>a>>b;
	if (a%b==0) {cout<<-1; return 0;}
	llg x=a;
	while (x%b==0) x+=a;
	cout<<x;
	return 0;
} 


Measured memory_bytes: 256
n,v[100],i,j,c,t;
main(){
	for(;scanf("%d",&n),n;){
		for(i=0;i<n;i++)
			scanf("%d",v+i);
		c=0;
		for(i=n-1;i>=1;i--){
			for(j=0;j<i;j++){
				if(v[j]>v[j+1]){
					t=v[j],v[j]=v[j+1],v[j+1]=t;
					c++;
				}
			}
		}
		printf("%d\n",c);
	}
	exit(0);
}

Measured memory_bytes: 0
def merge(A, left, mid, right):
    count = 0
    L = A[left: mid]
    R = A[mid: right]
    L.append(10e9 + 1)
    R.append(10e9 + 1)
    i, j = 0, 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            count += (len(L)-1) - i
    return count

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = int((left + right)/2)
        v1 = merge_sort(A, left, mid)
        v2 = merge_sort(A, mid, right)
        v3 = merge(A, left, mid, right)
        return v1 + v2 + v3
    else:
        return 0

n = int(input())
A = list(map(int, input().split(' ')))

ans = merge_sort(A, 0, n)
print(ans)


Measured memory_bytes: 27488
package main

import "fmt"

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	n := nextInt()

	dic := map[int]int{}
	for range make([]struct{}, n) {
		a := nextInt()
		for i := range make([]struct{}, 3) {
			dic[a+i-1]++
		}
	}
	ans := 0
	for _, cnt := range dic {
		if cnt > ans {
			ans = cnt
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8064
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a, b;
	cin >> a >> b;
	if(a<=8 && b <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

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

int main() {
  string S;
  string T;
  cin >> S;
  cin >> T;
  int N = S.size();
  int count =0;
  
  for (int i=0; i<N; i++){
    if (S.at(i) != T.at(i)){
      count++;
    }
  }
  if (count == 0 & T.size() == S.size()+1){
    cout << "Yes"<<endl;
  }
  else{
    cout << "No"<< endl;
  }
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; ++i) { cin >> v[i]; }

	sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 1; i < N; ++i) {
		ans = (ans + v[i]) / 2.0;
	}

	cout.precision(15);
	cout << fixed << ans << endl;

	return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    string ans = "Yes";
    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0){
            ans = "Yes";
            break;
        }

        a -= d;
        if(a <= 0){
            ans = "No";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
import math

def is_common(dists, factor):
    count = 0
#    print("factor: " + str(factor))
#    print(factors)
#    print(factor)
#    print(factors[1:]

    for dist in dists:
        if dist % factor != 0:
            return False
    
    return True

def divide_to_prime_factors(num):
    factor = 1
    factors = []

    while factor <= math.sqrt(num):
        if num % factor == 0:
            factors.append(factor)
            if factor * factor != num:
                factors.append(int(num / factor))

        factor += 1

    return factors

n_and_x = input().split(" ")
city_num = int(n_and_x[0])
start = int(n_and_x[1])

city_places = [int(n) for n in input().split(" ")]

city_distances = []
for place in city_places:
    city_distances.append(abs(place - start))

dist_factors = reversed(sorted(divide_to_prime_factors(city_distances[0])))

step = 1
for fact in dist_factors:
    if is_common(city_distances[1:], fact):
        step = fact
        break

#        print(fact_count)
#step = int(max(city_distances) / 2)

#can_travel = False
#while can_travel == False:
#    can_travel = True
#    for city in city_places:
#        if abs(city - start) % step != 0:
#           can_travel = False
#    if can_travel == False:
#        step -= 1

print(step)


Measured memory_bytes: 14252
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  ll l, r;
  cin >> l >> r;
  ll mod = 2018;
  if (r - l > 2018)
    cout << 0;
  else {
    for (ll i = l; i < r; ++i) {
      for (ll j = i + 1; j <= r; ++j) {
        mod = min(mod, (i * j) % 2019);
        if (mod == 0) goto end;
        ;
      }
    }
  end:
    cout << mod;
  }
  return 0;
 }


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int inf=0x3f3f3f3f;
int n;
int Ans=inf;

inline void file() {
	freopen("AGC025A.in","r",stdin);
	freopen("AGC025A.out","w",stdout);
}

inline int calc(int s) {
	int sum=0;
	while (s) {
		sum+=s%10; s/=10;
	}
	return sum;
}

int main() {
//	file();
	scanf("%d",&n);
	For (i,1,n/2)
		chkmin(Ans,calc(i)+calc(n-i));
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
constexpr int kMax = 1e5 + 1;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int l[kMax], r[kMax];

int main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;
  l[0] = 0, r[N-1] = 0;
  for (int i = 0; i < N; ++i) {
    l[i + 1] = gcd(l[i], A[i]);
  }
  for (int i = N-2; i >= 0; --i) {
    r[i] = gcd(r[i + 1], A[i + 1]);
  }
  int vmax = 0;
  for (int i = 0; i < N; ++i) {
    vmax = max(vmax, gcd(l[i], r[i]));
  }
  cout << vmax << endl;
}


Measured memory_bytes: 4560
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

#define mod ((int)1e9 + 7)

int solve(char **maze, int **dp, int i, int j, int h, int w){
	if(i>h-1 || j>w-1){
		return 0;
	}
	if(dp[i][j]==-1){
		if(i==h-1 && j==w-1){
			return dp[i][j] = 1;
		}
		if(maze[i][j]=='#'){
			return dp[i][j] = 0;
		}
		return dp[i][j] = ((solve(maze, dp, i+1, j, h, w)%mod) + (solve(maze, dp, i, j+1, h, w)%mod))%mod;
	}
	else{
		return dp[i][j];
	}
}

void test(char** maze, int h, int w){
	int **dp = new int*[h];
	for(int i = 0; i < h; i++){
		dp[i] = new int[w];
		for(int j = 0; j < w; j++){
			dp[i][j] = -1;
		}
	}
	cout << solve(maze, dp, 0, 0, h, w) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/input.txt", "r", stdin);
	freopen("/home/afzalrao/Desktop/Academics/2nd Year/3rd Sem/ESO207/CP/Text Files/output.txt", "w", stdout);
	#endif
	int h, w;
	cin >> h >> w;
	char **maze = new char*[h];
	for(int i = 0; i < h; i++){
		maze[i] = new char[w];
		for(int j = 0; j < w; j++){
			cin >> maze[i][j];
		}
	}
	test(maze, h, w);
	return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
	char s[100000];
	scanf("%s",s);
	int alp[26];
	for(int i=0;i<strlen(s);i++){
		alp[s[i]-97] = 1;
	}
	for(int i=0;i<26;i++){
		if(alp[i] == 0){
			printf("%c",i+97);
			return 0;
		}
	}
	printf("None");
	return 0;
}

Measured memory_bytes: 256
// heuristics01_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

ll eval_func(int D, vector<ll>& C, vector<vector<ll>>& S, vector<int>& T){

    ll score = 0;
    vector<int> last(26, 0);
    REP(i, D){
        int x = T[i];
        score += S[i][x];
        last[x] = i+1;

        REP(j, 26){
            score -= C[j] * (i+1 - last[j]);
        }
        print(score);
    }
    return score;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int D;
    cin >> D;
    vector<ll> C(26);
    REP(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26, 0));
    REP(i, D) REP(j, 26) cin >> S[i][j];

    vector<int> T(D);
    REP(i, D) {cin >> T[i]; T[i]--;}

    ll score = eval_func(D, C, S, T);
//    print(score);


    return 0;
}


Measured memory_bytes: 3708
uses crt;
var s:string;
i,n:integer;
begin
        clrscr;
        readln(n);
        readln(s);
        if n mod 2 <> 0 then writeln('No')
        else begin
                for i:=0 to trunc(n/2)-1 do begin
                        if s[i+1]<>s[trunc(n/2)+i+1] then begin
                                writeln('No');
                                exit;
                        end;
                end;
                writeln('Yes');
                exit;
        end;
        readln;
end.


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

int main() {
    int a, b, r = 0;

    cin >> a >> b;

    for (int i = a; i <= b ; i++) {
        int s = i % 10, t = i / 10000 % 10; //10001,
        int u = i / 10 % 10, v = i / 1000 % 10; //01010;
        if (s == t && u == v) r++;
    }

    cout << r;
}

Measured memory_bytes: 256
import math


def main():
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    min_capa = min([A, B, C, D, E])
    print(math.ceil(N / min_capa) + 4)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        
        String[] line = reader.readLine().split(" ");
        double num = Math.sqrt(Integer.parseInt(line[0] + line[1]));
        
        if(num == Math.rint(num)){ writer.println("Yes");
        }else{ writer.println("No"); }
        
        reader.close();
        writer.close();
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
   
  ll n,k ;
  cin>>n>>k ;
  ll ans = n%k ;
  if(ans == 0)
   {
       cout<<0<<endl ;
   }
  else if(ans>k/2)
   {
       cout<<k-ans<<endl ;
   }
   else
   {
       cout<<ans<<endl ;
   }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){

	int N, K;
	string str;
	vector<int> p;

	p.resize(26);
	for(int i=0; i<26; i++){
		p[i]=0;
	}

	cin>>N>>K;
	for(int i=0; i<N; i++){
		cin>>str;
		p[str[0]-'A']++;
	}

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

	int cnt=0;
	bool flag;
	while(true){
		int c=0;
		flag=false;
		for(int i=0; i<26; i++){
			if(p[i]>0){
				p[i]--;
				c++;
			}

			if(c==K){
				flag=true;
				break;
			}
		}

		if(flag){
			cnt++;
		}else{
			break;
		}

		sort(p.begin(), p.end(), greater<int>());
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

signed main() {
    string s, t;
    cin >> s >> t;
    bool ok = true;
    rep(i, s.size()) {
        if(s[i]!=t[i]) ok = false;
    }
    
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;



    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vc=vector<char>;
using vpii=vector<pii>;


struct v_t
{
	int n;
	int x[10];
	v_t()
	{
		n=-1;
		for(int i=0;i<10;i++) x[i]=0;
	}
	vc out(void)
	{
		vc ret;
		for(int i=9;i>=1;i--)
		{
			ret.resize(ret.size()+x[i], i+'0');
		}
		ret.push_back('\0');
		return ret;
	}
	int cmp(v_t&rhs)
	{
		int ret;

		ret=n-rhs.n;
		if(!ret)
		{
			for(int i=9;i>=0;i--)
			{
				ret=x[i]-rhs.x[i];
				if(ret) break;
			}
		}
		return ret;
	}
	bool operator<(v_t&rhs)
	{
		return cmp(rhs)<0;
	}
};


void a_chop(vpii&a)
{
	int x[10]={};
	vpii temp;

	for(auto ma:a)
	{
		int nd=ma.second;
		if(x[nd]<ma.first) x[nd]=ma.first;
	}
	for(int i=1;i<=9;i++)
	{
		if(x[i]==0) continue;
		temp.push_back(make_pair(x[i], i));
	}
	a=temp;
}


vc solve(vpii&a, int n)
{
	vector<v_t> dp(n+1);
	int an=a.size();

	dp[0].n=0;
	for(int i=0;i<an;i++)
	{
		for(int j=0;j+a[i].second<=n;j++)
		{
			if(dp[j].n<0) continue;
			v_t nx=dp[j];
			int idx=j+a[i].second;
			nx.n++;
			nx.x[a[i].first]++;
			if(dp[idx]<nx) dp[idx]=nx;
		}
	}
	return dp[n].out();
}


int main(void)
{
	int needs[]={1000, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int n, m;


	while(scanf("%d%d", &n, &m)==2)
	{
		vpii a(m);

		for(int i=0;i<m;i++)
		{
			int ax;
			scanf("%d", &ax);
			a[i]=make_pair(ax, needs[ax]);
		}
		a_chop(a);

		vc ans=solve(a, n);
		printf("%s\n", &ans[0]);
	}

	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define int long long

int n, x;
signed main() {
	cin >> n >> x;
	vector<int> a(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (size_t i = 0; i < n; i++)
	{
		x -= a[i];
		if (i == n-1) {
			if(x == 0) ans++;
			break;
		}
		if(x>=0) ans++;
		else break;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#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++)

int main(){
    ll a, b, k;
    cin >> k >> a >> b;
    if(a % k == 0 || b % k == 0){
        cout << "OK" << endl;
    }else{
        ll l = (a + k - 1) / k;
        ll u = b / k;
        if(u < l){
            cout << "NG" << endl;
        }else{
            cout << "OK" << endl;
        }
    }
    return 0;
}

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

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

    string s;
    cin >> s;

    char now;
    int cnt = 0;
    REP(i, s.size()){
        if(i){
            if(s[i] != now){
                cnt++;
                now = s[i];
            }
        }
        else now = s[i];
    }
    cout << cnt << endl; 

    return 0;
}

Measured memory_bytes: 1100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<P> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;
	sort(all(p));
	ll tot = 0;
	ll ans = 0;
	rep(i, n) {
		if (tot + p[i].second >= m) {
			while (tot < m) {
				tot++;
				ans += p[i].first;
			}
			break;
		}
		tot += p[i].second;
		ans += (ll)p[i].first * p[i].second;
	}
	cout << ans << endl;
	return 0;
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

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

	int ans = 0;
	rep(i,3)
	{
		if(s[i] == '1') ans++;
	}

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

Measured memory_bytes: 256
/*
* Problem URL: https://atcoder.jp/contests/dp/tasks/dp_b
*/

#include <bits/stdc++.h>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
using namespace std;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(w) (int) w.size()

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

typedef vector<int> vi;
typedef long long int lli;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;

int main() {
	int n, k;
	cin>>n>>k;
	vi arr(n+1);
	FOR(i, 1, n+1) cin>>arr[i];
	//cout<<getAns(1);
	int dp[n+1];
	FOR(i, 1, n+1) dp[i] = INT_MAX;
	dp[0] = dp[1] = 0;
	FOR(i, 1, n+1){
		FOR(j, 1, k+1){
		    if(i-j > 0)
			dp[i] = min(dp[i], dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	//FOR(i, 1, n+1)cout<<dp[i]<<" ";cout<<endl;
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 4052
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = min(A)+min(B)
for i in range(m):
    x, y, d = map(int, input().split())
    cnt = min(cnt, A[x-1] + B[y-1] - d)
print(cnt)


Measured memory_bytes: 18736
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,res;
signed main(){
	cin>>n;
	for(int i=1,a,b;i<n;i++){
		cin>>a>>b;	if(a>b) swap(a,b);
		res+=a*(n-b+1);
	}
	cout<<n*(n+1)*(n+2)/6-res;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  int mask = 1;

  for (int i = 0; i < n; ++i) {
    int ai;
    cin >> ai;

    for (int i = 0; i < 32; i++) {
      int lsb = (~ai & mask);
      // cout << ai << " " << lsb << endl;

      if (lsb == 0) {
        break;
      } else {
        sum += 1;
        ai = ai >> 1;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void)
{
    int a,b,x;
    cin >> a >> b >> x;
    if(x < a) cout << "NO";
    else if(a+b < x) cout << "NO";
    else cout << "YES";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i, c=0, ans=0; cin >> N; string s[N], X; int t[N];
for(i=0; i<N; i++){ cin >> s[i] >> t[i]; }
cin >> X;
for(i=0; i<N; i++){ if(X==s[i]){ c=i; break; } }
for(i=c+1; i<N; i++){ ans+=t[i]; }
cout << ans << "\n";
}

Measured memory_bytes: 256
import itertools
n, k = (int(i) for i in input().split())
P = [int(i) for i in input().split()]

probs = list(itertools.accumulate([(1+p)/2 for p in P]))
probs.insert(0,0)

ans = 0

for i in range(n-k+1):
    ans = max(ans, -probs[i]+probs[i+k])

print(ans)


Measured memory_bytes: 33268
/**
 *    Author:  "Robin Singh" !!!
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0
#define rtn return 
#define nl "\n"      // avoid endl
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const ll INF = (1LL<<61);
const int inf = (1<<30);
//-------------------------------------------------------------------------------------------------------------
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//-------------------------------------------------------------------------------------------------------------

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c-a, y = d-b; 
    cout << c-y << ' ' << d+x << ' ' << a-y << ' ' << b+x;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

int main() {
  i64 a, b, c;
  cin >> a >> b >> c;
  cout << max(0ll, c - (a - b)) << endl;
}


Measured memory_bytes: 764
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a<=8 && b<=8){
            System.out.println("Yay!");
        }else{
            System.out.println(":(");
        }
    }
}


Measured memory_bytes: 22868
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
//#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;

struct node{
    int l,f,s;

    node(){
        l=0;f=0;s=0;
    }
};


void mymain(){
    string a,b;
    cin >> a >> b;
    int n = a.size();
    int m = b.size();
    node dp[n+1][m+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
            dp[i][j]=node();
    for(int i=1;i<=n;i++){
        for(int j = 1;j<=m;j++){
            if(a[n-i] == b[m-j]){
                dp[i][j].l = dp[i-1][j-1].l + 1;
                dp[i][j].f=i-1;
                dp[i][j].s=j-1;
                //deb(dp[i][j].s)
                //deb(i)deb(j)
            }
            else{
                dp[i][j].l = max(dp[i-1][j].l,dp[i][j-1].l);
                if(dp[i][j].l == dp[i-1][j].l){
                    dp[i][j].f=i-1;dp[i][j].s=j;
                }else{
                    dp[i][j].f = i;dp[i][j].s=j-1;
                }
            }
        }
    }

    /*for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            cout << dp[i][j].l <<","<<dp[i][j].f<<","<<dp[i][j].s<<"  ";
        }
        cout << endl;
    }

    cout << dp[n][m].l << endl;*/

    string ans ;
    /*int val = 1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(dp[i][j].f == i-1 && dp[i][j].s == j-1 && dp[i][j].l==val){
                ans += a[n-i];
                val++;
            }
        }
    }
    */
    int curi=n,curj=m;
    while(curi!=0 && curj!=0){
        int fromi=dp[curi][curj].f,fromj=dp[curi][curj].s;
        if(fromi == curi-1 && fromj == curj-1){
            ans += a[n-curi];
        }
        curi=fromi;
        curj=fromj;
    }




    //reverse(all(ans));
    cout << ans << endl;


}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t;
t=1;
//cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*
abcdef
deabcd
*/


Measured memory_bytes: 211328
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 100000 
typedef long long LL;
using namespace std;
int main(){
	LL n;
	while(scanf("%I64d",&n)!=EOF){
		LL ans=1;
		for(int i=2; i<=1e5; ++i){
			if((LL)i*(LL)i>n) break;
			else ans=(LL)i*(LL)i;
		}
		printf("%I64d\n",ans);
	}
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

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

int main(){
    string S;
    cin >> S;
    int N = S.length();
    bool same = S[0] == S[N-1];
    bool even = (N % 2 == 0);

    bool f_win;
    if(same & even){
        f_win = true; 
    }
    else if(same & !even){
        f_win = false;
    }
    else if(!same & even){
        f_win = false;
    }
    else if(!same & !even){
        f_win = true;
    }

    if(f_win)
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}


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

int main(){
   int n,k;
   cin>>n>>k;
   int a[n];
   for(int i=0;i<n;i++)
   cin>>a[i];
   sort(a,a+n);
   int sum=0;
   for(int i=0;i<k;i++)
   sum+=a[i];
   cout<<sum<<endl;
}

Measured memory_bytes: 3640
// https://atcoder.jp/contests/abc129/tasks/abc129_a
#include <bits/stdc++.h>
#define debugi(x) cerr << "x -> " << x << endl;
#define For(i, n) for (__typeof(i) i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

#define ONLINE_JUDGE

#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

void solve()
{
    int i;
    vector<int> flight_times(3, INT_MAX);
    For(i, 3)
    {
        cin >> flight_times[i];
    }
    sort(all(flight_times));
    cout << flight_times[0] + flight_times[1] << endl;
}
int main()
{
    _;
    ull testcases = 1LL;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // cin >> testcases;
    while (testcases--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    long long a,b,c,k;
    cin >> a >> b >> c >>k;
    long long ans = a-b;
    if(k%2 != 0){
        ans *= -1;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3508
#include<iostream>
#include<string>

using namespace std;

int main() {
	string str;
	cin >> str;

	int s, g;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'A') {
			s = i; break;
		}
	}

	for (int i = str.size() - 1; i >= 0; i--) {
		if (str[i] == 'Z') {
			g = i; break;
		}
	}

	int res = g - s+1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/agc012/tasks/agc012_a
"use strict";
function Main(input) {
  const params = input.trim().split("\n");
  const N = Number(params[0].trim());
  const sortedA = params[1]
    .trim()
    .split(" ")
    .map(Number)
    .sort((a, b) => b - a);

  let total = 0;
  for (let i = 0; i < N; i++) {
    total += sortedA[i * 2 + 1];
  }

  console.log(total);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 56088
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int m, n, M = 7368792, t;
  vector<bool> E(M, true);
  while (cin >> m >> n, m) {
    while (n > 0) {
      if (E[m]) {
	--n;
	for (int i = 2; i < (M+m-1)/m; ++i) E[i*m] = false;
      }
      E[m] = true;
      ++m;
    }
    t = m;
    while (!E[m]) ++m;
    cout << m << endl;
    for (int i = t; i < M; ++i) E[i] = true;
  }
  return 0;
}

Measured memory_bytes: 3372
void main() {
    int[] abc = readln.split.to!(int[]);
    abc.sort!"a < b";
    writeln(abc[0] * abc[1] / 2);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
	int n , sum = 0, i , m;
	scanf("%d %d",&n,&m);
	int a[m];
	for(i=0 ; i<m ; i++)
	{
		scanf("%d",&*(a+i));
		sum+=a[i];
	}
	if(n-sum<0) printf("-1");
	else printf("%d",n-sum);
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  int R,S,P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  vector<char> modK[K];
  for (int i = 0; i < N; i++) {
    modK[i % K].push_back(T[i]);
  }
  ll ans = 0;
  for (int i = 0; i < K; i++) {
    char bc = modK[i][0];
    int streak = 1;
    for (int j = 1; j < (int)modK[i].size(); j++) {
      if (bc == modK[i][j]) {
        streak++;
      } else {
        ll r = ((streak+1) / 2);
        if (bc == 'r') {
          r *= P;
        } else if (bc == 's') {
          r *= R;
        } else {
          r *= S;
        }
        ans += r;
        streak = 1;
        bc = modK[i][j];
      }
    }
    ll r = ((streak+1) / 2);
    if (bc == 'r') {
      r *= P;
    } else if (bc == 's') {
      r *= R;
    } else {
      r *= S;
    }
    ans += r;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8524
n = int(input())
a = list(map(int, input().split()))
cash = 1000
kabu = 0
up=False
down=False
buysell = [0]*n
                          
buyable=True
for index,(i,j) in enumerate(zip(a[:-1], a[1:])):
  if i <= j:
    if buyable:
      buysell[index] = 1
      buyable=False
  else:
    if not buyable:
      buysell[index] = -1
      buyable=True
else:
  if not buyable:
    buysell[-1] = -1

for index,i in enumerate(buysell):
  if i == 0:
    continue
  if i> 0:
    kabu = cash // a[index]
    cash -= kabu * a[index]
  else:
    cash += kabu * a[index]
    kabu = 0
print(cash)

Measured memory_bytes: 9260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    string s;
    cin >> s;

    bool flg = true;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++){
        if (i == 0) {
            if (s[i] != 'A') flg = false;
            else flg = true;
        }
        else if (i == 1) {
        	if ('A' <= s[i] && s[i] <= 'Z') flg = false;
        }
        else if (2 <= i && i <= s.size() -2) {
            if (s[i] == 'C') cnt++;
            else if ('A' <= s[i] && s[i] <= 'Z') flg = false;
        }
        else {
            if ('A' <= s[i] && s[i] <= 'Z') flg = false;
        }
    }
    
    flg = (cnt == 1) && flg;
    if (flg) cout << "AC" << endl;
    else cout << "WA" << endl;
}


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

void solve() {
    ll X;
    cin >> X;
    for ( ll a = 0; a < 200; a++ ) {
        for ( ll b = 0; b < 200; b++ ) {
            if ( a*a*a*a*a-b*b*b*b*b == X ) {
                cout << a << " " << b << "\n";
                return;
            }
            if ( a*a*a*a*a+b*b*b*b*b == X ) {
                cout << a << " " << -b << "\n";
                return;
            }
        }
    }
    return;
}

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

Measured memory_bytes: 3672
n, q = map(int, input().split())
listS = list(input())
index=0
listA=[]
listM=[0]*n
index2=1
countM=0
while index2 < len(listS):
    if listS[index2-1]=="A" and listS[index2]=="C":
        countM+=1
    listM[index2] = countM               
    index2+=1

while index < q:
    l, r = map(int, input().split())
    listA.append(listM[r-1]-listM[l-1])
    index+=1
for ans in listA:
    print(ans)

Measured memory_bytes: 11344
#include <cmath>
#include <iostream>
int main() {
  int n;
  std::cin >> n;
  int a[100000000];
  for (int i = 0; i < 100000000; ++i) a[i] = 1;
  
  std::cout << n * M_PI * 2 << std::endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b,c,d;
cin>>a>>b>>c>>d;
int T,A;
  if(a%d==0){
    T=a/d;
  }
  else{
    T=a/d+1;
  }
  if(c%b==0){
    A=c/b;
  }
  else{
  A=c/b+1;
  }
  if(T+1<=A){
    cout<<"No"<<endl;
  }
  else{
cout<<"Yes"<<endl;
  }
}


Measured memory_bytes: 3636
import fractions
from functools import reduce

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

def lcm(x, y):
    return x*y//fractions.gcd(x, y)

# a//b (MOD p)
def div_mod(a, b, p):
    return (a * pow(b, p-2, p)) % p

ans = 0
target = reduce(lcm, A)
for i in range(N):
    ans += div_mod(target, A[i], MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 6108
//全探索（nC2個の組み合わせをすべて調べる）
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < (ll)(r); i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007LL;

int A[105][105];

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    
    ll ans = 0;
    if(X < Y) {
        if(A+B > 2*C) ans += C*2*X;
        else ans += (A+B)*X;
        Y -= X; X = 0;
    }else{
        if(A+B > 2*C) ans += C*2*Y;
        else ans += (A+B)*Y;
        X -= Y; Y = 0;
    }
    if(X > 0){
        if(A > 2*C) ans += 2*C*X;
        else ans += A*X;
    }
    if(Y > 0){
        if(B > 2*C) ans += 2*C*Y;
        else ans += B*Y;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, T, X, W, l, r;
ll C;
vector<int>R, L;

int main() {
	cin >> N >> C >> T;
	for (int i = 0; i < N; ++i) {
		cin >> X >> W;
		(W == 1 ? R : L).push_back(X);
	}
	if (R.empty()) {
		for (int i = 0; i < N; ++i) {
			cout << (L[i] % C - T%C + C) % C << endl;
		}
	}
	else if (L.empty()) {
		for (int i = 0; i < N; ++i) {
			cout << (R[i] % C + T%C) % C << endl;
		}
	}
	else {
		l = -1;
		r = intmax;
		while (l + 1 != r) {
			int m = (l + r) / 2;
			ll p = C*(m / L.size()) + L[m%L.size()] - R[0];
			if (T * 2 <= p) {
				r = m;
			}
			else {
				l = m;
			}
		}
		vector<int>res;
		for (int i = 0; i < R.size(); ++i) {
			res.push_back((R[i] % C + T%C) % C);
		}
		for (int i = 0; i < L.size(); ++i) {
			res.push_back((L[i] % C - T%C + C) % C);
		}
		sort(res.begin(), res.end());
		int t = (R[0] % C + T%C) % C;
		int k = lower_bound(res.begin(), res.end(), t) - res.begin();
		k = (k - r % N + N) % N;
		for (int i = 0; i < N; ++i) {
			cout << res[(k + i) % N] << endl;
		}
	}
}

Measured memory_bytes: 2120
def slove():
    import sys
    input = sys.stdin.readline
    n, a, b = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(1, n + 1):
        s = str(i)
        t = 0
        for j in range(len(s)):
            t += int(s[j])
        if a <= t <= b:
            cnt += i
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 39408
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
bool pass[9][9];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
        
    REP(i,M){
        int a,b;
        cin >> a >> b;
        pass[a-1][b-1] = true;
        pass[b-1][a-1] = true;
    }
    vector<int> v;
    REP(i,N){
        v.pb(i);
    }
    int ans = 0;
    do{
        bool flag = true;
        REP(i,N-1){
            if(v[0] != 0){
                flag = false;
                break;
            }
            if(!pass[v[i]][v[i+1]]){
                flag = false;
                break;
            }
        }
        if(flag){ans ++;}
    }while(next_permutation(All(v)));
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, buf int
	fmt.Scan(&n)
	mp := make(map[int]struct{})
	for i := 0; i < n; i++ {
		fmt.Scan(&buf)
		mp[buf] = struct{}{}
	}
	fmt.Println(len(mp))
}


Measured memory_bytes: 1848
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int n;
int N[100001];

int min(int x, int y){
  return x < y ? x : y;
}

int main(){
  int i,count;
  ll ans = 0;
  
  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    scanf("%d",&count);
    N[i] = count;
  }

  for(i = 1; i <= n; i++){
    int c = N[i]/2;
    ans += c;
    N[i] -= c*2;
    if(i+1 <= n && N[i] != 0 && N[i+1] != 0){
	N[i]--;
	N[i+1]--;
	ans++;
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 512
n = int(input())
s = str(input())
if n%2==1:
    print('No')
else:
    m = int(n/2)
    #isError = False
    #for i in range(m):
    #    if s[i]!=s[i+m]:
    #        isError = True
    #        break
    #if isError:
    #    print('No')
    #else:
    #    print('Yes')
    #print(s[:m])
    #print(s[m:])
    if s[:m]!=s[m:]:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long

signed main(void)
{
	int n, ans = 0, num[50][50] = {0};
	cin >> n;
	while (n--)
	{
		double x; cin >> x;
		int tmp = x * 1e9 + 0.5;
		int n2 = 0, n5 = 0;
		while (tmp % 2 == 0) {n2++; tmp /= 2;}
		while (tmp % 5 == 0) {n5++; tmp /= 5;}
		reps (i, n2 <= 18 ? 18 - n2 : 0, 50)
		{
			reps (j, n5 <= 18 ? 18 - n5 : 0, 50)
			{
				ans += num[i][j];
			}
		}
		num[n2][n5]++;
	}
	cout << ans << endl;
	return 0;
}


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

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 34; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}
long long Div(long long a, long long b, long long m) {
	return (a*modpow(b, m - 2, m)) % m;
}

long long N, fact[1000009], factinv[1000009], inv[1000009], mod = 1000000007;
const int MAX_N = 1000006;

void init() {
	fact[0] = 1; for (int i = 1; i <= MAX_N; i++) { fact[i] = 1LL * fact[i - 1] * i; fact[i] %= mod; }
	for (int i = 0; i <= MAX_N; i++) factinv[i] = Div(1, fact[i], mod);
	for (int i = 1; i <= MAX_N; i++) inv[i] = Div(1, i, mod);
}
long long ncr(long long n, long long r) {
	if (r < 0 || n < r) return 0;
	long long R = factinv[r] * factinv[n - r]; R %= mod;
	return (R*fact[n]) % mod;
}

int main() {
	cin >> N;
	if (N == 2) { cout << "1" << endl; return 0; }
	if (N == 3) { cout << "4" << endl; return 0; }
	if (N == 4) { cout << "16" << endl; return 0; }

	long long sum = 0; init();

	for (int i = 3; i <= N; i++) {
		long long E = 2 * (i - 1) - (N - 2);
		long long V = ncr(i - 1, E);
		long long U = E*(E - 1); U %= mod;
		U *= inv[i - 1]; U %= mod;
		U *= inv[i - 2]; U %= mod;
		U = (mod + 1 - U); U %= mod;
		U *= (i - 2); U %= mod; U += 2; U %= mod;

		V *= U; V %= mod;
		V *= (fact[i - 1] * fact[N - 1 - i]) % mod; V %= mod;
		sum += (V*i) % mod; sum %= mod;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 23808
function main()
  
  (A,B,C,X,Y) = map(x -> parse(Int,x), split(readline()))
  
  if (X-Y) >= 0
    println(min((A*X+B*Y),(2C*max(X,Y)),(2C*Y+A*(X-Y))))
  else
    println(min((A*X+B*Y),(2C*max(X,Y)),(2C*X+B*(Y-X))))
  end
  
end

main()

Measured memory_bytes: 110608
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;
int main(){
  ll x;cin>>x;
  ll y=100;
  ll n=0;
  while(1){
    y*=1.01;
    n++;
    if(y>=x){
      cout<<n;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    long double rad = (double)(H*30 + M*0.5 - M*6)*M_PI/180.0;
    long double ans = sqrt(A*A + B*B -2.0*A*B*cos(rad));
    printf("%10.10Lf\n", ans);

    return 0;
}

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

  if ( b < a){
    d = a;
    a = b;
    b = d;
  }

  if ( a < c && b < c){
    printf("%d %d %d\n",a,b,c);
  }else if (a < c && c < b) {
    printf("%d %d %d\n",a,c,b);
  }else {
    printf("%d %d %d\n",c,a,b);
  }
  return 0;
}

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

const int P = 1e9 + 7;

int n, k, ans;
unordered_map<int, int>f;

int qp (int a, int b) { int c = 1; for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; return c; }

int d (int n) {
	if (f.count(n)) return f[n];
	int ret = qp(k, (n + 1) >> 1);
	for (int i = 1; i * i <= n; ++i) if (n % i == 0) {
		ret = (ret + P - d(i)) % P;
		if (i > 1 && i * i != n) ret = (ret + P - d(n / i)) % P;
	}
	return f[n] = ret;
}

void calc (int x) {
	int ret = d(x);
	if (!(x & 1)) x >>= 1;
	ans = (1ll * ret * x + ans) % P;
}

int main () {
	scanf("%d%d", &n, &k); f[1] = k;
	for (int i = 1; i * i <= n; ++i) if (n % i == 0) {
		calc(i);
		if (i * i != n) calc(n / i);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(void){
    int n,k;cin>>n>>k;char c,t;
    for(int i=1;i<=n;i++){
        cin>>c;
        t=c+32;
        if(i==k)cout<<t;
        else cout<<c;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256