akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int c[3][3];
  rep(i,3)rep(j,3) cin >> c[i][j];

  int a[3], b[3];
  int x = 0;
  a[0] = x;
  a[1] = c[1][0] - (c[0][0] - x);
  a[2] = c[2][0] - (c[0][0] - x);
  b[0] = c[0][0] - x;
  b[1] = c[0][1] - x;
  b[2] = c[0][2] - x;

  bool ok = true;
  rep(i,3) {
    rep(j,3) {
      if (c[i][j] != a[i] + b[j]) ok = false;
    }
  }
  
  puts(ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int a = Integer.parseInt(sn.next());
        int b = Integer.parseInt(sn.next());
        int c = Integer.parseInt(sn.next());
        int x = Integer.parseInt(sn.next());

        for ( int i = 0; i < x; i++){
            if (a >= b){
                b = b *2;
            }else if (b >= c){
                c = c *2;
            }
        }

        if (a < b && b <c){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35740
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=0;
const int N=2e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
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; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,fa[N],pa[N],c0[N],c1[N];
struct cmp {
    int operator()(int a,int b) {
        if(1ll*c0[a]*c1[b]!=1ll*c0[b]*c1[a])
            return 1ll*c0[a]*c1[b]>1ll*c0[b]*c1[a];
        return a<b;
    }
};
set<int,cmp> s;
int getf(int x) {
    return x==fa[x]?x:fa[x]=getf(fa[x]);
}
int main() {
    n=gi();
    for(int i=2;i<=n;i++) pa[i]=gi();
    for(int i=1;i<=n;i++) (gi()?c1[i]:c0[i])=1,fa[i]=i;
    for(int i=2;i<=n;i++) s.insert(i);
    ll ans=0;
    while(!s.empty()) {
        int u=*s.begin();s.erase(s.begin());
        int p=getf(pa[u]);s.erase(p);
        ans+=1ll*c1[p]*c0[u];
        c1[p]+=c1[u],c0[p]+=c0[u],fa[u]=p;
        if(p!=1) s.insert(p);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 



int main()
{
    
                        
     fio

     
    lli n;
    cin>>n;

     lli z = ceil(n/1000.00);
     cout<<(1000*z)-n; 

     



     


     
    
     




      
     

     
              


return 0;}    


Measured memory_bytes: 3760
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld; 
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
  
	string S[7] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
	string s; cin >> s;
	int ans;
	Rep(i,0,7){
		if(s == S[i]){
			ans = i+1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        if (s.equals("Sunny")){
            System.out.println("Cloudy");
        }else if (s.equals("Cloudy")){
            System.out.println("Rainy");
        }else{
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int a[9];
    rep(i,9)cin>>a[i];
    int n;
    cin>>n;
    vector<int>b(n);
    rep(i,n){
        cin>>b[i];
        rep(j,9){
            if(b[i]==a[j])a[j]=0;
        }
    }
    if((a[0]==0&&a[1]==0&&a[2]==0)||(a[3]==0&&a[4]==0&&a[5]==0)||
    (a[6]==0&&a[7]==0&&a[8]==0)||(a[0]==0&&a[3]==0&&a[6]==0)||
    (a[1]==0&&a[4]==0&&a[7]==0)||(a[2]==0&&a[5]==0&&a[8]==0)||
    (a[0]==0&&a[4]==0&&a[8]==0)||(a[2]==0&&a[4]==0&&a[6]==0)){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for C - Dubious Document 2
	var S, T string
	fmt.Scan(&S, &T)

	var flag int
	var flag2 int
	var A string
	for i := 0; i < len(S)-len(T)+1; i++ {
		flag = 0
		for j := 0; j < len(T); j++ {
			if S[i+j] == T[j] || S[i+j] == '?' {
				continue
			} else {
				flag = 1
				break
			}
		}

		if flag == 0 {
			A = S[0:i] + T[0:len(T)] + S[i+len(T):len(S)]
			flag2 = 1
			//break
		}
	}

	if flag2 == 1 {
		for i := 0; i < len(A); i++ {
			if A[i] == '?' {
				fmt.Printf("%c", 'a')
			} else {
				fmt.Printf("%c", A[i])
			}
		}
		fmt.Println()
	} else {
		fmt.Println("UNRESTORABLE")
	}
}


Measured memory_bytes: 1840
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main(){
	char a[10],s[10];
	scanf("%s%s",a+1,s+1);
	if(a[1]==s[3]&&a[2]==s[2]&&a[3]==s[1]) printf("YES\n");
	else printf("NO\n");
}

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

using namespace std;

int main()
{
  string w;
  cin >> w;
  bool flag = true;
  for(char i = 'a'; i <= 'z'; i++) {
    if(count(w.begin(), w.end(), i) % 2) flag = false;
  }
  cout << (flag ? "Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<string>S(N);
  vector<string>ans;
  for(int i=0;i<N;i++)cin>>S[i];
  sort(S.begin(),S.end());
  int count=1;
  int MAX=1;
  for(int i=0;i<N-1;i++){
    if(S[i]==S[i+1])count++;
    else count=1;
    MAX=max(MAX,count);
  }
  int k=0;
  count=1;
  if(MAX==1)ans.push_back(S[N-1]);
  for(int i=0;i<N-1;i++){
    if(S[i]==S[i+1])count++;
    else count=1;
    if(MAX==count)ans.push_back(S[i]);
  }
  sort(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++)cout<<ans[i]<<endl;
}
    
    

Measured memory_bytes: 15988
#include<stdio.h>
#define N 100000+10
int main()
{
	int a[N];
	int n;
	int sum=0;
	int flag=1;
	int flag2=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]==2)
			flag2++;
	}
	if(flag2==0)
		printf("-1");
	else {
		int i=1;
		while(a[i]!=2){
			if(a[a[i]]==i||i==a[i]||sum+1>n){
				flag=0;break;
			}
				
			i=a[i];
			sum++;
			
		}
		if(flag==0)
			printf("-1");
		else 
			printf("%d",sum+1);
	}
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <stdio.h>
 
#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>
 
#include <string>
#include <cstring>
#include <vector>
#include <bitset>
 
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>
 
#include <ctime>
////
//#include <random>//
/////////
 
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
 
////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
 
 
void solve() {
	string S;
	cin >> S;
	bool ans = false;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == '7') {
			ans = true;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}
 
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
 
	solve();
}

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

int main() {
    int64_t X, Y, tsuru, kame;
    string ans;
    cin >> X >> Y;
    tsuru = - Y / 2 + 2 * X;
    kame = - X + Y / 2;
    if (Y % 2 != 0 || tsuru < 0 || kame < 0) {
        ans = "No";
    } else {
        ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}


// go だと固定長配列とか辛いので無理だった
type Vector struct {
	arr [] int
	back int
}
func NewVector() Vector {
	return Vector{make([]int, 0, 200000), 0}
}
func (this *Vector)PushBack(i int) {
	if len(this.arr) - 1 < this.back {
		this.arr = append(this.arr, i)
		this.back++
	} else {
		this.arr[this.back] = i
		this.back++
	}
}
func (this *Vector)randomAccess(i int) int {
	return this.arr[i]
}
func (this *Vector) popBack() {
	this.back--
	// last := len(this.arr) - 1
	// this.arr = this.arr[:last]
}




func main() {
	var q int
	fmt.Scanf("%d", &q)
	v := NewVector()
	lines, _ := ReadLongLines(q)
	for _, line := range lines {
		args := strings.Split(line, " ")
		cmd := args[0]
		switch cmd {
		case "0":
			x, _ := strconv.Atoi(args[1])
			fmt.Scanf("%d", &x)
			v.PushBack(x)
		case "1":
			x, _ := strconv.Atoi(args[1])
			fmt.Println(v.randomAccess(x))
		case "2":
			v.popBack()
		}
	}
}


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

using namespace std;

int main() {
	
	string s;

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


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

int main()
{
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++)
    {
        if (i % d == 0)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
/*
将这n个二元组看做n个向量。
移动方式遵循平行四边形定则。
所以两个向量夹角越小，相加形成的和向量模长就越大。
所以将这些向量按照极角排序。
选择的向量肯定是一个区间。
枚举左右端点，求最大值即可。
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e2+5;

struct Point{
        int x,y;
}p[MAXN];

bool cmp(Point a,Point b) {
        return atan2(a.y,a.x) < atan2(b.y, b.x);
}

int nx[MAXN];//让它循环
int main() {
        int n;
        cin>>n;
        for(int i=1;i<=n;++i)   cin>>p[i].x>>p[i].y;
        for(int i=1;i<=n;++i)    nx[i] = i+1; nx[n] = 1;
        sort(p+1,p+n+1,cmp);
        ll  ans=0;
        for(int i=1;i<=n;++i) {
                ll x = p[i].x, y = p[i].y;
                ans = max(ans, x * x + y * y);
                for(int j=nx[i];j!=i;j = nx[j]) {
                        x += p[j].x;
                        y += p[j].y;
                        ans = max(ans, x * x + y * y);
                }
        }
        printf("%.10lf\n",sqrt(ans));
        return 0;
}


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

using namespace std;

typedef long long ll;

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

	if (op == '+') cout << A+B << endl;
	else cout << A-B << endl;

	return 0;
}

Measured memory_bytes: 256
def cc():
    a, b = map(str, input().split())
    a2 = int(a)
    b2 = int(b.replace('.', ''))
    c = a2 * b2
    ans = str(c)[0:-2] if len(str(c)) > 2 else 0
    print(ans)
if __name__ == "__main__":
    cc()


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> A(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> A[i]; }

	map<Int, Int> mp;
	Int ans = 0;
	for (Int i = N; i > 0; --i) {
		if (mp.count(i + A[i]) > 0) {
			ans += mp[i + A[i]];
		}
		mp[i - A[i]] += 1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 16364
N = input()

N_int = int(N)

# 頭悪いやり方
if N_int <= 1000:
    print(1000 - N_int)
elif N_int <= 2000:
    print(2000 - N_int)
elif N_int <= 3000:
    print(3000 - N_int)
elif N_int <= 4000:
    print(4000 - N_int)
elif N_int <= 5000:
    print(5000 - N_int)
elif N_int <= 6000:
    print(6000 - N_int)
elif N_int <= 7000:
    print(7000 - N_int)
elif N_int <= 8000:
    print(8000 - N_int)
elif N_int <= 9000:
    print(9000 - N_int)
elif N_int <= 10000:
    print(10000 - N_int)
else: # 適当
    print(500)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define il inline
#define rg register
using namespace std;
typedef long long LL;
const LL m_63=1061109567;
const LL m_127=2139062143;
const LL inf=2147483647;
const double pi=atan(1.0)*4.0;
const LL llf=9223372036854775807;
const LL mod=998244353;
const LL N=1e6+7;
const LL M=5007;
LL n,m,a[N],b[N],p[N],bz[M][M],flag,sum;
il LL read(){
	LL x(0),ff(1);char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
il void write(LL x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
il void fre(){
	freopen("kubi.in","r",stdin);
	freopen("kubi.out","w",stdout);
}
int main(){
//	fre();
	n=read(),m=read();
	for(rg int i=1;i<=m;++i)a[i]=read(),b[i]=read();
	for(rg int i=1;i<=n;++i){
		p[i]=1;bz[i][i]=1;
		for(rg int j=m;j>=1;--j){
			int x=a[j],y=b[j];
			if(!bz[i][x]&&!bz[i][y])continue;
			if(bz[i][x]&&bz[i][y]){p[i]=0;break;}
			bz[i][x]=bz[i][y]=1;
		}
	}
	for(rg int i=1;i<n;++i){
		for(rg int j=i+1;j<=n;++j){
			if(p[i]&&p[j]){
				flag=0;
				for(rg int k=1;k<=n;++k){
					if(bz[i][k]&&bz[j][k]){flag=1;break;}
				}
				if(!flag)++sum;
			}
		}
	}
	printf("%lld\n",sum);
	return 0;
}
/*
4 3
1 2
3 4
2 3

*/

Measured memory_bytes: 21120
#include<stdio.h>
int main(){
	int i,j,h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		for(i=1;i<=h;i++){
			if(i%2==1){
				for(j=1;j<=w;j++){
					if(j%2==0){
						printf(".");
					}
					else{
						printf("#");
					}
				}
			}
			else{
				for(j=1;j<=w;j++){
					if(j%2==0){
						printf("#");
					}
					else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

#define ll long long

int main()
{
    ll n,a=0,b=0;
    cin>>n;

    b=n%11;
    a=n/11;
    a*=2;

    if(b<=6 && b!=0)
        a+=1;
    else if(b!=0)
        a+=2;
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// ラベル入力・ダイスの生成
		Dice dice1 = new Dice(CreateIntLabel(br.readLine()));
		Dice dice2 = new Dice(CreateIntLabel(br.readLine()));

		// 同じダイスであるか判定・出力
		if (DiceComparison(dice1, dice2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	// ラベル配列の生成
	public static int[] CreateIntLabel(String str) {
		String[] input = str.split("[\\s]+");
		int[] label = new int[input.length];
		for (int i = 0; i < input.length; i++) {
			label[i] = Integer.parseInt(input[i]);
		}
		return label;
	}

	// 2つのダイスが同じかを判定
	public static boolean DiceComparison(Dice dice1, Dice dice2) {
		// ダイス1の0番目と同じラベルをダイス2から探す
		for (int i = 0; i < dice2.label.length; i++) {
			if (dice1.label[0] == dice2.label[i]) {

				// 側面4つの並びが同じか判定
				if (ComparisonNumberSequence(dice1.getCorrespondingAspectsLabel(0),
						dice2.getCorrespondingAspectsLabel(i))) {
					return true;
				}
			}
		}
		return false;

	}

	// 配列(ダイスの側面4つ)を2つを受け取り、同じ順序ができるか判定
	public static boolean ComparisonNumberSequence(int[] array1, int[] array2) {
		// 0番目の値が同じになるまでarray2を回転させる
		while (array1[0] != array2[0]) {
			int work = array2[0];
			for (int i = 1; i < array2.length; i++) {
				array2[i - 1] = array2[i];
			}
			array2[array2.length - 1] = work;
		}

		// 内容が同じになったかを見る
		for (int i = 0; i < array1.length; i++) {
			if (array1[i] != array2[i]) {
				return false;
			}
		}
		return true;

	}

	static class Dice {
		// 回転方向上にある4つの面の添え字、対応する右の面の添え字
		enum Direction {
			Roll			(new int[] { 0, 1, 5, 4 }, 2),
			Pitch			(new int[] { 0, 3, 5, 2 }, 1),
			Yaw				(new int[] { 4, 2, 1, 3 }, 5),
			ReverseRoll	(new int[] { 0, 4, 5, 1 }, 3),
			ReversePitch	(new int[] { 0, 2, 5, 3 }, 4),
			ReverseYaw		(new int[] { 4, 3, 1, 2 }, 0);

			// 回転軸方向の4つの面
			private int[] Rotat;
			// 回転軸方向に対応する右の面
			private int rightNum;

			Direction(int[] nums, int num) {
				this.Rotat = nums;
				this.rightNum = num;
			}
		}

		// ラベル
		int[] label;

		// コンストラクタ
		Dice(int[] label) {
			this.label = label;
		}

		// 右の面の添え字を受け取り、回転方向の4面の添え字配列を返す
		int[] getCorrespondingAspects(int num) {
			for (Direction dir : Direction.values()) {
				if (dir.rightNum == num) {
					return dir.Rotat;
				}
			}
			return null;
		}

		// 右の面の添え字を受け取り、回転方向の4面のラベル配列を返す
		int[] getCorrespondingAspectsLabel(int num) {
			int[] pointers = getCorrespondingAspects(num);
			int[] CorrespondingAspectsLabel = new int[pointers.length];
			for (int i = 0; i < CorrespondingAspectsLabel.length; i++) {
				CorrespondingAspectsLabel[i] = this.label[pointers[i]];
			}
			return CorrespondingAspectsLabel;

		}

	}

}



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

int main(){
  int N;
  cin >> N;
  vector<int> array(N);
  vector<int> p(N);
  vector<int> q(N);
  rep(i, N){
    array[i] = i+1;
  }
  rep(i, N){
    cin >> p[i];
  }
  rep(i, N){
    cin >>  q[i];
  }
  bool aa, bb = true;
  int a, b;
  int cnt = 1;
  do{
    aa = true;
    bb = true;
    rep(i, N){
      if(array[i] != p[i]){
        aa = false;
      }
      if(array[i] != q[i]){
        bb = false;
      }
    }
    if(aa) a = cnt;
    if(bb) b = cnt;
    cnt++;
  }while(next_permutation(array.begin(), array.end()));
  cout << abs(a-b) << endl;
}


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

using namespace std;

class Exam {
public:
	Exam(vector<int> v) {
		ExamV = v;
	};
	void Result(int num1, int num2);

private:
	vector<int> ExamV;
};

void Exam::Result(int num1, int num2) {
	int buf = 0;
	ExamV[num1-1] = num2;

	for (int i = 0; i < ExamV.size(); i++) {
		buf = buf + ExamV[i];
	}
	printf("%d\n", buf);
}


int main() {
	vector<int> vT;
	vector<int> vPX[2];
	int N, M;
	int buf;

	scanf("%d", &N);

	for (int i = 0; i < N; i++) {
		scanf("%d", &buf);
		vT.push_back(buf);
	}
	scanf("%d", &M);
	for (int i = 0; i < M; i++) {
		scanf("%d", &buf);
		vPX[0].push_back(buf);
		scanf("%d", &buf);
		vPX[1].push_back(buf);
	}

	for (int i = 0; i < M; i++) {

		Exam* MyExam = new Exam{vT};
		MyExam->Result(vPX[0][i], vPX[1][i]);
		delete MyExam;

	}
	return 0;
}

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

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

  long long money = 1000, stock = 0;
  for (int i = 1; i < N; ++i) {
    if (A[i] > A[i - 1]) {
      stock += money / A[i - 1], money %= A[i - 1];
    } else if (A[i] < A[i - 1]) {
      money += stock * A[i - 1], stock = 0;
    }
  }
  money += stock * A[N - 1], stock = 0;

  cout << money << endl;
}


Measured memory_bytes: 3572
fun main() = Thread(null, ::abc172d, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc172d() {
    val k = readLine()!!.toLong()

    val divCount = LongArray(k.toInt() + 1)

    for (i in 1..k) {
        var num = 1
        while (num <= k / i) divCount[(num++ * i).toInt()]++
    }

    val answer = (1..k).map {
        it * divCount[it.toInt()]
    }.sum()

    println(answer)
}


Measured memory_bytes: 606104
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(void){
    int m,na,ni,i,j,P,A,b;
    int max;
    

    while(cin>>m>>ni>>na,ni!=0||m!=0||na!=0){
        max=0;
         vector<int>sco(m,0);
      for(i=0;i<m;i++){
        
          cin>>P;
          sco[i]=P;
      }
      sort(sco.rbegin(),sco.rend());
      for(j=0;j<na-ni+1;j++){
        if(max<=(sco[ni-1+j]-sco[ni+j])){
            max=(sco[ni-1+j]-sco[ni+j]);
           b=ni+j;
        }

      }
    cout<<b<<endl;
     i=0;
     j=0;
     A=0;
     b=0;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll ans = 0, cnt = 0;
	vector<ll> cnt1(n);
	while(true){
		bool flg = false;
		rep(i,n){
			a.at(i) += cnt - cnt1.at(i);
			ll k = a.at(i) / n;
			ans += k;
			cnt += k;
			cnt1.at(i) = cnt;
			a.at(i) %= n;
			if(k > 0) flg = true;
		}
		if(!flg) break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007

int M_pertition(int p,int r, vector<int> & vec, int N)
{
  //p先頭 r末尾
  int x,i,j,t;
  x = vec[r];
  i = p-1;
  for (j = p; j < r; j++)
  {
    /* code */
    if(vec[j] <= x)
    {
      i++;
      t = vec[i];
      vec[i] = vec[j];
      vec[j] = t;
    }
  }

  t = vec[i+1]; vec[i+1] = vec[r]; vec[r] = t;//最後に末尾と入れ替え

  return i + 1;
  
}
void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];//最後の要素でパーティションを作る
  }
  
  int q = M_pertition(0,N-1,vec,N);
  for (int i = 0; i < N; i++)
  {
    if(i) cout<<" ";
    if(i == q) cout<<"[";
    cout<<vec[i];
    if(i==q) cout<<"]";
  }
  cout<<endl;
  
  return;  
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(8);

  solve();

 
  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
	void Solve() {
		UL N; cin >> N;
		UL P; cin >> P;
		string S; cin >> S;

		if (P == 2 || P == 5) {
			ULL ans = 0;
			rep(i, N) {
				if ((S[i] - '0') % P == 0)
					ans += (i + 1);
			}
			cout << ans << endl;
			return;
		}


		reverse(S.begin(), S.end());

		vector<UL> V(N + 1);
		{
			UL p = 1;
			rep(i, N) {
				V[i + 1] = (S[i] - '0') * p;
				V[i + 1] += V[i];
				V[i + 1] %= P;
				p = p * 10 % P;
			}
		}
		vector<UL> F(P);
		ULL ans = 0;
		rep(i, N + 1) {
			ans += F[V[i]];
			F[V[i]]++;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 1412
A, B = map(int, input().split())
ans = 0
for i in range(A, B + 1):
    s = str(i)
    len_s = len(s)
    for j in range(int(len_s / 2)):
        if s[j] != s[len_s - j - 1] :
            break
        if j == int(len_s / 2) - 1 :
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,n) for(int i=s;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
using namespace std;
typedef vector<vector<int> > Graph;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//'0'+cnt 数字cntからcharへの変換

int func(string s,string t){
    int ans = 0;
    for(char c = 'a'; c <= 'z'; c++){
        bool foundt = false,founds = false;
        rep(i,s.size()){
            if(s.at(i) == c) founds = true;
        }
        rep(i,t.size()){
            if(t.at(i) == c) foundt = true;
        }
        if(founds&&foundt) ans++;
    }
    return ans;
}

int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans;
    for(int i = 0; i <= n; i++){
        int temp = func(s.substr(0,i),s.substr(i));
        ans = max(ans,temp);
    }

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            try {
                String str = br.readLine();
                String input[] = str.split(" ");
                int N = Integer.valueOf(input[0]);
                int A = Integer.valueOf(input[1]);
                int B = Integer.valueOf(input[2]);
                
                if(N * A > B) {
                    System.out.println(B);
                }else {
                    System.out.println(N*A);
                }
                
                
            }catch(IOException e) {
                
            }
            
    }

}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

long long gcd(long long a,long long b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}

int main(){
  ll n;
  cin >> n;
  ll a[n];
  REP(i,n){
    cin >> a[i];
  }
  if(n > 1){
    ll g = 0;
    ll gc = gcd(a[0],a[1]);
    for(int i = 2;i < n;i++){
      gc = gcd(gc,a[i]);
    }
    
    while(gc%2 == 0){
      g++;
      gc /= 2;
    }
    cout << g << endl;
  }
  else{
    ll g = 0;
    while(a[0]%2 == 0){
      g++;
      a[0] /= 2;
    }
    cout << g <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int N;

bool samecmp(long long int N,long long int memo[],long long int memo2[]){
	for(int i=1;i<=N;i++){
		if(memo[i]==0&&memo2[i]==1){
			return false;
		}
	}
	return true;
}
int main() {
	
	cout << fixed << setprecision(18);
	cin>>N;
	while(N!=0){
		long long int M,p,memo[105][105]={};
		for(int i=1;i<=N;i++){
			cin>>M;
			for(int j=1;j<=M;j++){
				cin>>p;
				memo[i][p]=1;
			}
		}
		long long int K,memo2[105]={};
		cin>>K;
		for(int j=1;j<=K;j++){
			cin>>p;
			memo2[p]=1;
		}
		long long int Num=0,ID;
		for(int i=1;i<=N;i++){
			if(samecmp(N,memo[i],memo2)){Num++;ID=i;}
		}
		if(Num==1){cout<<ID<<endl;}
		else {cout<<-1<<endl;}
		cin>>N;
	}

} 


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
 #define int long long
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int d, l;
  cin >> d >> l;
  cout << d / l + d % l << endl;
  return 0;
}



Measured memory_bytes: 3176
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    NO_TLE
    int n,k;
    cin>>n>>k;
    LL ans=0;
    rer(i,k+1,n)
    {
        ans+=(i-k)*(n/i);
        if(n%i>=k)ans+=(n%i-k+1);
    }
    if(k==0)ans-=n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//ABC098-B
#include <stdio.h>
#include <stdlib.h>

int char_to_int(char c){
	return (int)c - (int)'a';
}

int main(){
	int N, i, j, now, ans;
	scanf("%d", &N);
	char *S = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s", S);
	for(N = 0; S[N] != '\0'; N++);
	int alf1[26], alf2[26];
	for(i = 0, ans = 0; i <= N; i++){
		for(j = 0; j < 26; j++){
			alf1[j] = 0;
			alf2[j] = 0;
		}
		for(j = 0; j < i; j++){
			alf1[char_to_int(S[j])]++;
		}
		for(j = i; j < N; j++){
			alf2[char_to_int(S[j])]++;
		}
		for(j = 0, now = 0; j < 26; j++){
			if(alf1[j] * alf2[j] > 0){
				now++;
			}
		}
		if(now > ans){
			ans = now;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////
int gcd(int p, int q){
if(p % q == 0)return q;
return gcd(q, p % q);
}

void solve()
{

    ll n;
    cin>>n;
    vec a;
    inpvec(a,n);

    ll req = a[0];
    ll ans = 0;
    loop(i,1,n)
    {
        if(a[i]>=req){
            req = a[i];
        }
        else{
            ans += req-a[i];
        }
    }   
    cout<<ans;

    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 



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

using namespace std;

#define ll long long

void solve() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



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

int main()
{
  int n , m;
  cin >> n >> m;
  int ans = (n-1)*(m-1);
  cout << ans << endl;
}


Measured memory_bytes: 384
N,Q = map(int,input().split())
S = input().strip()
A = [0 for _ in range(N)]
for i in range(1,N):
    if S[i-1:i+1]=="AC":
        A[i] = A[i-1]+1
    else:
        A[i] = A[i-1]
for _ in range(Q):
    l,r = map(int,input().split())
    print(A[r-1]-A[l-1])

Measured memory_bytes: 52480
#include "bits/stdc++.h"
// #include "boost/math/common_factor.hpp" // gcd, lcm
using namespace std;

#define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  num = numeric_limits<int>::max(); // min
  int n;
  int a, b;
  array<int, 100> p;

  cin >> n;
  cin >> a >> b;
  for (auto it = p.begin(); it < p.begin() + n; ++it) {
    cin >> *it;
  }

  int tmp;
  tmp = 0;
  for (auto it = p.begin(); it < p.begin() + n; ++it){
    if (*it <= a) ++tmp;
  }
  num = min(num, tmp);

  tmp = 0;
    for (auto it = p.begin(); it < p.begin() + n; ++it){
    if (a < *it && *it <= b) ++tmp;
  }
  num = min(num, tmp);

  tmp = 0;
    for (auto it = p.begin(); it < p.begin() + n; ++it){
      if (b < *it) ++tmp;
  }
  num = min(num, tmp);

  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
using mat = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N, Z, W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    cout << max(abs(a[N - 1] - W), (N > 1 ? abs(a[N - 1] - a[N - 2]) : 0)) << endl;
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > v(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(b);
    }
    for (int i = 0; i < n; i++) {
        cout << v[i].size() << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define MN 51

typedef long long ll;

const int inf = 1 << 30;
int fa[MN], m[MN];
int f[4 * MN][MN * MN * MN], g[MN * MN * MN];
ll a[MN], b[MN]; int d, n, id[4 * MN], x;
std::vector<int> v[MN * MN * MN];
int h[MN * MN * MN];
int p[MN];

bool cmp(int x, int y) {return 1ll * a[x] * b[y] < 1ll * b[x] * a[y];}

void trans(int *f, int *g, int a, int b, int d)
{
	for(int i = 0; i <= n * n * n; i++) v[i].clear(), h[i] = 0;
	for(int i = 0; i <= n * n * n; i++)
	{
		int x = i % b;
		while(v[x].size() > h[x] && f[v[x].back()] + 1ll * (i - v[x].back()) / b * a > f[i]) v[x].pop_back();
		v[x].push_back(i);
		if((i - v[x][h[x]]) / b > d) h[x]++;
		g[i] = std::min((ll)inf, f[v[x][h[x]]] + 1ll * (i - v[x][h[x]]) / b * a);
	}
}

void solve(int x, int l, int r)
{
	for(int i = n * n * n - 1; i >= 0; i--) f[x][i] = std::min(f[x][i], f[x][i + 1]);
	
	if(l == r) {id[l] = x; return;}
	
	int mid = l + r >> 1;
	
	memcpy(f[x << 1], f[x], sizeof(f[x << 1]));
	for(int i = mid + 1; i <= r; i++)
	{
		trans(f[x << 1], g, a[i], b[i], std::min(d, n));
		memcpy(f[x << 1], g, sizeof(f[x << 1]));
	}
	
	memcpy(f[x << 1 | 1], f[x], sizeof(f[x << 1 | 1]));
	for(int i = l; i <= mid; i++)
	{
		trans(f[x << 1 | 1], g, a[i], b[i], std::min(d, n));
		memcpy(f[x << 1 | 1], g, sizeof(f[x << 1 | 1]));
	}
	
	solve(x << 1, l, mid); solve(x << 1 | 1, mid + 1, r);
}

int main()
{
	scanf("%d%d%d", &n, &x, &d);
	scanf("%d", &m[1]);
	for(int i = 2; i <= n; i++) scanf("%d%d", &m[i], &fa[i]);
	for(int i = n; i >= 1; i--)
	{
		a[i] += m[i]; b[i]++;
		a[fa[i]] += a[i], b[fa[i]] += b[i];
		p[i] = i; 
	}
	for(int i = 1; i <= n; i++) a[i] = std::min(a[i], (ll)inf);
	memset(f[1], 0x3f, sizeof(f[1])); f[1][0] = 0;
	solve(1, 1, n); 
	std::sort(p + 1, p + n + 1, cmp);
//	for(int i = 1; i <= n; i++) printf("%lld %lld %d\n", a[i], b[i], p[i]);
//	for(int i = 1; i <= n; i++, puts(""))
//		for(int j = 0; j <= 5; j++) printf("%d ", f[id[i]][j]);
	int ans = 0, now = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= n * n * n; j++)
			if(x - f[id[p[i]]][j] >= 0)
				ans = std::max((ll)ans, std::min((ll)(p[i] == 1 ? inf : d), (x - f[id[p[i]]][j]) / a[p[i]]) * b[p[i]] + j + now);
		
		now += std::max(d - n, 0) * b[p[i]];
		x -= std::max(d - n, 0) * a[p[i]];
		if(p[i] == 1) break;
		if(x < 0) break;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 70912
#include <iostream>

using namespace std;

int main()
{
    long long a,b;
    long long n;
    cin>>n>>a>>b;
    if(n==1&&a==b)
    {
        cout<<1<<endl;
    }
    else if(n==1&&a!=b)
    {
        cout<<0<<endl;
    }
    else if(a>b)
    {
        cout<<0<<endl;
    }
    else
    {
       long long  x=(b-a)*(n-2);
            cout<<x+1<<endl;

    }

}


Measured memory_bytes: 256
from collections import deque
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))

window = deque()
ev = 0
best = 0
for p in P:
    if len(window) == K:
        old = window.popleft()
        ev -= (old + 1) / 2
    window.append(p)
    ev += (p + 1) / 2
    best = max(best, ev)

print(best)

Measured memory_bytes: 25700
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (a+b > c+d) {
        cout << "Left" << endl;
    }
    else if (a+b < c+d) {
        cout << "Right" << endl;
    }
    else {
        cout << "Balanced" << endl;
    }
}


Measured memory_bytes: 256
while True :
	N, M, P = map(int, input().split())
	if(N == 0 and M == 0 and P == 0) :
		break
	else :
		X = list()
		for i in range(N) :
			x = int(input())
			X.append(x)
		top = X[M - 1]
		Sum = sum(X)
		all = Sum * (100 - P)
		if(top == 0) :
			print(0)
		else :
			ans = all // top
			print(ans)


Measured memory_bytes: 5612
import fractions
def gcd(x, y):
    gcd=fractions.gcd(x, y)
    return gcd

n, x=map(int, input().split())
a=list(map(int, input().split()))

if n==1:
    print(abs(x-a[0]))

else:
    for i in range(n):
        a[i]=abs(x-a[i])
    
    ans=gcd(a[0], a[1])

    for i in range(2, n):
        ans=gcd(ans, a[i])
    
    print(ans)


Measured memory_bytes: 16276
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 1e5 + 5;

int N;
int A[MAXN];
char op[MAXN];

void input()
{
    read(N);
    read(A[1]);
    for (int i = 2; i <= N; ++i) {
        op[i] = getchar();
        read(A[i]);
    }
}

void solve()
{
    static LL sum[MAXN];
    static int last[MAXN];

    last[N + 1] = N + 1;
    for (int i = N; i >= 1; --i) {
        sum[i] = sum[i + 1] + A[i];
        last[i] = op[i + 1] == '-' ? i + 1 : last[i + 1];
    }

    LL cur = A[1], ans = 0;
    for (int i = 2; i <= N; ++i) {
        if (op[i] == '+')
            cur += A[i];
        else {
            int j = last[i];
            chkmax(ans, cur - (sum[i] - sum[j]) + sum[j]);
            cur -= A[i];
        }
    }
    chkmax(ans, cur);

    printf("%lld\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 吃饭有时很像结婚，名义上最主要的东西，其实往往是附属品。
// 吃讲究的饭事实上只是吃菜，正如讨阔佬的小姐，宗旨倒并不在女人。
//   --钱钟书


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    string S; cin >> S;
    int slen = S.length();
    LL ans = 0;
    FOR(i,1,slen){
        if(S[i] == S[i-1]){
            ans++;
        }
    }
    cout << min(LL(N-1), ans+K*2) << endl;

}


Measured memory_bytes: 512
L, R = map(int, input().split())

ans = 10**9
rng = R - L
if rng > 2019:
    ans = 0
else:
    for i in range(L, R+1):
        for j in range(L, R+1):
            if i != j:
                ans = min(ans, i*j % 2019)

print(ans)


Measured memory_bytes: 2940