akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

ll n;
ll sum[1000001];
ll dp[1000001];

int main(){
    L(n);
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    sum[0] = n;
    dp[1] = n*n;
    sum[1] = (sum[0]+dp[1])%MOD;
    for(int i = 2; i <= n-1; i++){
        if(i == 2){
            dp[i] = dp[i-1]+n*(n-1);
            dp[i] %= MOD;
        } else{
            dp[i] = (n-1)*(n-1)+n-i+1;
            dp[i] = (dp[i]+dp[i-1]+sum[i-3])%MOD;
        }
        sum[i] = (sum[i-1]+dp[i])%MOD;
    }
    cout << dp[n-1] << endl;
}
































Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    int kosuto[100000];
    int n,m;
    cin >> n >> m;
    int num[m];
    for(int i=0;i<m;i++){
    cin >> num[i];
    kosuto[num[i]] = 1;
    }
    int flag = 1;
    while(flag){
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
        if(kosuto[i] > 0 ){
            if(kosuto[i+num[j]] == 0) kosuto[i+num[j]] = kosuto[i]+1;
            else{kosuto[i+num[j]] = min(kosuto[i+num[j]],kosuto[i]+1);
            if(i+num[j] == n) flag = 0;
            }
        }
        }
    }
    }
    cout << kosuto[n]<< endl;
    return 0;
}

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

typedef long long ll;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll mic = 0, zeroc = 0, pluc = 0;
    for(i = 0;i < n;++i){
       cin >> a.at(i);
       if(a.at(i) < 0){
           ++mic;
        }else if(a.at(i) == 0){
            ++zeroc;
        }else{
            ++pluc;
        }
    }
    sort(a.begin(), a.end());
    if(n == 2){
        cout << a.back() - a.front() << endl;
        cout << a.back() << " " << a.front() << endl;
        return 0;
    }else if(n == 3){
        if(a.back() == a.front()){
            cout << abs(a.at(0)) << endl;
            cout << a.at(0) << " " << a.at(0) << endl;
            cout << max(0, (int)a.at(0)) << " " << min(0, (int)a.at(0)) << endl;
            return 0;
        }
    }
    bool flag = false;
    ll c,d;
    if(pluc == 0 || mic == 0){
        flag = true;
    }
    if(pluc == 0){
        ll tmp = a.back() - a.front();
        c = a.back();
        d = a.front();
        a.front() = 0;
        a.back() = tmp;
        ++pluc;
        if(zeroc){
            --zeroc;
            --mic;
        }else{
            mic -= 2;
        }
    }else if(mic == 0){
        ll tmp = a.front() - a.back();
        c = a.front();
        d = a.back();
        a.front() = tmp;
        a.back() = 0;
        if(zeroc){
            --pluc;
            --zeroc;
        }else{
            pluc -= 2;
        }
        ++mic;
    }
    ll sum = 0;
    deque<ll> de;
    for(i = 0;i < n;++i){
        sum += abs(a.at(i));
        if(a.at(i) != 0){
            de.push_back(a.at(i));
        }
    }
    cout << sum << endl;
    if(flag){
        cout << c << " " << d << endl;
    }
    while(de.size() != 2){
        if(mic == 1){
            ll top = de.front();
            ll back = de.back();
            cout << top << " " << back << endl;
            de.pop_front();
            de.pop_back();
            de.push_front(top - back);
            --pluc;
        }else{
            ll top = de.front();
            ll back = de.back();
            cout << back << " " << top << endl;
            de.pop_front();
            de.pop_back();
            de.push_back(back - top);
            --mic;
        }
    }
    cout << de.back() << " " << de.front() << endl;
    for(i = 0;i < zeroc;++i){
        cout << sum << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int A = s.nextInt();
        int B = s.nextInt();
        double A_min = A;
        double A_max = A + 0.999;
        double B_min = B;
        double B_max = B + 0.999;
        int x_min, x_max;
        int y_min, y_max;
        int ans;
        x_min = (int) Math.ceil(A_min / 0.08);
        x_max = (int) Math.floor(A_max / 0.08);
        y_min = (int) Math.ceil(B_min / 0.1);
        y_max = (int) Math.floor(B_max / 0.1);

        if (x_max < y_min || x_min > y_max) {
            ans = -1;
        } else {
            if (x_min > y_min) {
                ans = x_min;
            } else {
                ans = y_min;
            }
        }

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

Measured memory_bytes: 23764
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 998244353;

     signed main(){
     
int n;
string ans;
cin>>n;

while(n!=0){
 if(n%26)  ans.push_back(char('a'+(n%26-1)));
 else{ ans.push_back('z');n-=26;}
   n/=26;
}
for(int i=ans.size()-1;i>=0;i--)cout<<ans[i];
cout<<endl;
     }


 


 






    





      

        


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, d, x[15][15];
signed main() {
	cin >> n >> d;
	rep(i, n) {
		rep(j, d)cin >> x[i][j];
	}
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			if (i == j)continue;
			int cnt = 0;
			rep(k, d) {
				cnt += pow(x[i][k] - x[j][k], 2);
			}
			if ((int)sqrt(cnt) == sqrt(cnt))ans++;
		}
	}
	cout << ans / 2 << endl;
	return 0;
}

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

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

    bool b1 = s.at(2) == s.at(3);
    bool b2 = s.at(4) == s.at(5);

    if (b1 && b2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define int long long
#define double long double
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
//typedef long long ll;
typedef pair<int, int> pii;
 
void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

const int N = 2e5 + 10;
int ind[N];
int yy[N];
int xx[N];
int ans[N];
int ll[N];
int rr[N];
int cnt[N];

signed main() {
	fast();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		ind[x] = i;
		yy[x] = y;
		xx[y] = x;
	}
	int mx = 0;
	for (int i = n - 1; i >= 0; i--) {
		mx = max(mx, yy[i]);
		if (mx + i + 1 == n) cnt[mx + 1] = mx + 1;
	}
	for (int i = 1; i < n; i++) {
		cnt[i] = max(cnt[i], cnt[i - 1]);
	}
	for (int i = 1; i < n; i++) {
		if (yy[i] < yy[ll[i - 1]]) {
			ll[i] = i;
		} else {
			ll[i] = ll[i - 1];
		}
	}
	rr[n - 1] = n - 1;
	for (int i = n - 2; i >= 0; i--) {
		if (yy[i] > yy[rr[i + 1]]) {
			rr[i] = i;
		} else {
			rr[i] = rr[i + 1];
		}
	}
	for (int i = 0; i < n; i++) {
		if (i != 0 && yy[rr[i]] > yy[ll[i - 1]]) {
			ans[ind[i]] = ans[ind[ll[i - 1]]];
		} else {
			ans[ind[i]] = n - i - cnt[yy[i]];
		}
	}
	for (int i = 0; i < n; i++) cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int j = 0;
    for ( int i = 0; i < 16; i ++ ) {
        if ( s[i] != t[i] ) {
            j ++;
        }
    }
    cout << j << endl;
}


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() {
  int A, B;
  cin >> A >> B;
  if (A < 10 && B < 10) {
    cout << A*B << endl;  
  } else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import sys

list=1000000*[1]

list[0] = 0
list[1] = 0
for i in range(1,1000000):
	if list[i] == 1:
		for j in range(i*i,1000000,i):
			list[j] = 0

for i in range(2,1000000):
	list[i] += list[i-1]
	
for line in sys.stdin:
	a = int(line)
	print list[a]

Measured memory_bytes: 67740
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = max(max(a, b), c) - min(min(a, b), c);
    out(ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main()
{
    int arr[200005],n,k=1,temp=0;
    cin >> n ;
    for(int i=0;i<n;i++){cin >> arr[i];}
    for(int i=0;i<n;i++)
    {
        if(arr[i]==k){temp++;k++;}
    }
    if(temp==0){cout << "-1" << endl;}
    else{cout << n-temp << endl;}
    return 0;
}


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

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

using namespace std;

const int MOD=1000000007;

int n,k;
vector<vector<int>> G;

// c1: # of colored nodes with distance 1
// c2: # of colored nodes with distance 2
int dfs(int u,int p,int c1,int c2){
	if(k<=c1+c2) return 0;

	long long res=k-(c1+c2);
	int i=0;
	for(int v:G[u]) if(v!=p) {
		res=res*dfs(v,u,1,c1+i)%MOD;
		i++;
	}
	return res;
}

int main(){
	cin>>n>>k;
	G.resize(n);
	rep(i,n-1){
		int u,v; cin>>u>>v; u--; v--;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	cout<<dfs(0,-1,0,0)<<endl;

	return 0;
}


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

int main(){
	int i,j,k,v,u;
	double a[101],b[11];
	double n,w,vmax;
	double res;
	while(1){
		cin >> n >> w;
		if(n == 0)break;
		res = vmax = 0;
		for(i = 0;i < 101;i++){
			a[i] = 0;
		}
		for(i = 0;i < 11;i++){
			b[i] = 0;
		}
		for(i = 0;i < n;i++){
			cin >> v;
			a[v]++;
		}
		k = 0;
		for(i = 0;;i += w){
			for(j = i;j < i + w;j++){
				if(j == 101)break;
				b[k] += a[j];
			}
			vmax = max(vmax,b[k]);
			if(b[k] != 0)u = k;
			if(j == 101)break;
			k++;
		}
		j = 0;

		double x = u;
		for(i = 0;i <= k;i++){
				//cout << x << " " << u <<  " : " << b[j] << " " << vmax <<endl; 
				res += (x/u)*(b[j]/vmax);
				x--;
			j++;
		}
		res += 0.01;
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    string s,t,s2;
    int n,a,b;
    cin >> s >> n;
    
    rep(i,0,n){
        cin >> t;
        if(t == "print"){
            cin >> a >> b;
            rep(j,a,b+1){
                cout << s[j];
            }
            cout << endl;
        }
        else if(t == "replace"){
            cin >> a >>  b >> t;
            
            rep(j,a,b+1){
                s[j] = t[j-a];
            }
        }
        else{
            cin >> a >> b;
            
            s2 = s;
            
            rep(j,a,b+1){
                s[j] = s2[b-j+a];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3244
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var sc *bufio.Scanner

const bufferSize = 1024

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	s := nextString()
	t := nextString()

	ans := len(t)
	for i := 0; i < len(s)-len(t)+1; i++ {
		a := len(t)
		for j := 0; j < len(t); j++ {
			if s[i+j] == t[j] {
				a--
			}
		}
		if a < ans {
			ans = a
		}
	}

	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 1764
#include <iostream>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a*b<c){
    cout<<a*b<<endl;
  }else if(a*b>c){
    cout<<c<<endl;
  }else if(a*b==c){
    cout<<a*b<<endl;
  }
}


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

int main(){
  int n, d; cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  int cnt = 0;
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x.at(i).at(j);
    }
  }
  
  for(int i = 0; i < n; i++){  // ある点i
    
    for(int j = i + 1; j < n; j++){ //ある点j
      float dist = 0;
      for(int k = 0; k < d; k++){
        dist += pow(abs(x.at(i).at(k) - x.at(j).at(k)), 2);
      }

      if(ceil(sqrt(dist)) == floor(sqrt(dist))){
        cnt++;
      }
    }
  }
       
  cout << cnt << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
num = sum(a) - a[0]
x = a[0]
ans = num - x
for i in range(n-2):
    x += a[i+1]
    num -= a[i+1]
    ans = min(ans,abs(num-x))
print(ans)

Measured memory_bytes: 94276
s = int(input())
l = [s]

def f(n):
    if n%2 == 0:
        return n/2
    else:
        return 3*n+1

for i in range(1,1000000):
    a = f(l[i-1])
    if a in l:
        break
    l.append(f(l[i-1]))
print(i+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///using P = pair<int,int>;
///pow(x,n)
///cout << fixed << setprecision(桁数);
///string = to_string(数値)
///int = stoi(文字列)
///(int)(char-'0')
///string = itoa(int)
///円周率: M_PI

///0b:2進数 16進数

const unsigned int BIT_FLAG_0 = (1<<0);
const unsigned int BIT_FLAG_1 = (1<<1);
const unsigned int BIT_FLAG_2 = (1<<2);
const unsigned int BIT_FLAG_3 = (1<<3);
const unsigned int BIT_FLAG_4 = (1<<4);
const unsigned int BIT_FLAG_5 = (1<<5);
const unsigned int BIT_FLAG_6 = (1<<6);
const unsigned int BIT_FLAG_7 = (1<<7);

int main() {
    int N; cin>>N;
    vector<int> f(N);
    for(int n=1; n<=N; ++n){
        int cnt=0;
        for(int x=1; x*x+x+x+3<=n;++x){
            for(int y=1;x*x + y*y + 1 + x*y + y + x <=n; ++y){
                for(int z=1;x*x + y*y +z*z + x*y + y*z + z*x <= n; ++z){
                    if(x*x + y*y +z*z + x*y + y*z + z*x==n) ++cnt;
                }
            }
        }
        f[n-1]=cnt;
    }
    rep(i,N){
        cout << f[i] << endl;
    }
}

Measured memory_bytes: 3624
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

def main():
    n, m = map(int, input().split())
    a = list(map(int ,input().split()))
    s = sum(a)
    b = max(-1, n-s)
    print(b)

main()

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

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

  int sum = a;
  int count = 1;

  if (b == 1){
    cout << 0 << endl;
    return 0;
  }

  while (true) {
    if (sum >= b) {
      break;
    }
    sum += a;
    sum--;
    count += 1;
  }
  cout << count << endl;
  return 0;
}

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

int main(void){
	int n, m;
	vector<int> p, y;
	cin >> n >> m;
	vector<vector<int>> v;
	vector<map<int,int>> mp;
	p.resize(m); y.resize(m); mp.resize(n+1); v.resize(n+1);
	for(int i = 0; i < m; ++i){
		cin >> p[i] >> y[i];
		v[p[i]-1].push_back(y[i]);
	}
	
	for(int i = 0; i < n; ++i){
		sort(v[i].begin(), v[i].end());
		for(int j = 0; j < v[i].size(); ++j){
			mp[i].insert(make_pair(v[i][j],j+1));
		}
	}

	for(int i = 0; i < m; ++i){
		printf("%06d%06d\n",p[i], mp[p[i]-1].at(y[i]));
	}
	
	return 0;
}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long ll;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}


int main() {
	string s; cin >> s;
	vector<int> v(26,0);
	rep(i,s.size()){
		v[s[i]-'a']++;
	}
	rep(i,26){
		if (v[i]%2){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


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;
pair<int,int> P;

int main() {
    int n;
    cin >> n;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    sort(L.begin(),L.end(),std::greater<int>());
    ll sum = 0;
    rep(i,n-2) {
        for (int j = i+1; j < n-1; ++j) {
            for (int k = j+1; k < n; ++ k) {
                if (L[i] < L[j]+L[k]) sum++;
                else break;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#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, b;
  string s;
  cin >> a >> s >> b;
  if(s == "+") cout << a+b << endl;
  else cout << a-b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,X;
    cin >> N >> X;
    int x[N];
    int y[N];
    rep(i,N) {
        cin >> x[i]; 
        y[i]=abs(x[i]-X);
    }
    int ans=y[0];
    rep(i,N){
        ans=__gcd(ans,y[i]);
    }
    cout << ans << endl;



}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	H,W,K = inputMap()
	maps = []
	for i in range(H):
		s = inputStr()
		maps.append(s)

	ans = 0
	for i in range(2**H):
		iBin = bin(i)[2:]
		pl = ""
		for ttt in range(len(iBin), H):
			pl += "0"
		iBin = pl + iBin
		iBin = iBin[::-1]
		for j in range(2**W):
			jBin = bin(j)[2:]
			pl = ""
			for ttt in range(len(jBin), W):
				pl += "0"
			jBin = pl + jBin
			jBin = jBin[::-1]

			kuro = 0
			for iii,mapH in enumerate(maps):
				if iBin[iii] == "1":
					continue
				for jjj,mapW in enumerate(mapH):
					if jBin[jjj] == "1":
						continue
					if mapW == "#":
						kuro += 1
			#print(kuro)
			if kuro == K:
				ans += 1
	print(ans)




#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 79168
#include<bits/stdc++.h>
#define MN 100000
#define MM 200000
using namespace std;
int n,a,b,c1=0,c2=0;
int p[MN+5],pn=0,col[MN+5];
int hd[MN+5],nxt[MM+5],to[MM+5],rn=0;
void add(int u,int v){
	++rn;
	nxt[rn]=hd[u];
	hd[u]=rn;
	to[rn]=v;
}
bool dfs(int u){
	p[++pn]=u;
	if(u==n) return true;
	for(int i=hd[u];i!=-1;i=nxt[i])
		if(p[pn-1]!=to[i])
			if(dfs(to[i]))
				return true;
	--pn;
	return false;
}
void spr(int u){
	for(int i=hd[u];i!=-1;i=nxt[i])
		if(col[to[i]]==0){
			col[to[i]]=col[u];
			spr(to[i]);
		}
}
int main(){
	memset(hd,0xff,sizeof(hd));
	memset(col,0,sizeof(col));
	cin>>n;
	for(int i=1;i<=n-1;i++){
		cin>>a>>b;
		add(a,b),add(b,a);
	}
	dfs(1);
	for(int i=1;i<=pn;i++)
		if(i<=((pn+1)>>1)) col[p[i]]=1;
		else col[p[i]]=2;
	for(int i=1;i<=pn;i++) spr(p[i]);
	for(int i=1;i<=n;i++){
		if(col[i]==0) return 1;
		if(col[i]==1) c1++;
		if(col[i]==2) c2++;
	}
	if(c1<=c2)
	cout<<"Snuke"<<endl;
	else
	cout<<"Fennec"<<endl;
	return 0;
}

Measured memory_bytes: 4480
a = []
bingo = [[False for _ in range(3)] for __ in range(3)]
for _ in range(3):
  a.append(list(map(int, input().split())))
n = int(input())
for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if b == a[j][k]:
        bingo[j][k] = True
n_bingo = 0
for r in range(3):
  if bingo[r][0] and bingo[r][1] and bingo[r][2]:
    n_bingo += 1
for c in range(3):
  if bingo[0][c] and bingo[1][c] and bingo[2][c]:
    n_bingo += 1
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
  n_bingo += 1
if bingo[0][2] and bingo[1][1] and bingo[2][0]:
  n_bingo += 1

if n_bingo > 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
#include <iostream>

const int MAXN = 100 + 5,MAXG = 1e5 + 5;

using namespace std;

int n,maxweight,cost[MAXN],weight[MAXN];
long long dp[MAXG];

int main()
{
    cin>>n>>maxweight;
    for(int i = 1; i <= n; i++)
        cin>>weight[i]>>cost[i];
    for(int i = 1; i <= n; i++)
        for(int j = maxweight - weight[i]; j >= 0; j--)
            dp[j + weight[i]] = max(dp[j + weight[i]],dp[j] + cost[i]);
    cout<<dp[maxweight];
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define bs inline bool scan
ii(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
ii() {return in(gcu());}
bs(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bs(char &c){c=gcu();gcu();return c!=EOF;}
// bs(string &s){int c; s = "";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#undef bs
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
// vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

vector<bool> sieve;

void make_sieve(int m) {
	sieve = vector<bool>(m, true);
	sieve[1] = false;
	for (int i = 3, e = sqrt(m); i <= e; i += 2) {
		if (!sieve[i])
			continue;
		for (int j = i * i; j < m; j += i)
			sieve[j] = false;
	}
}

bool is_prime(int n) {
	return (n % 2) ? sieve[n] : n == 2 ? true: false;
}

int main() {
	make_sieve(1000000);
	for (int a, b, c; a = in(), b = in(), c = in();) {
		for (int i = 0;; a += b) {
			if (is_prime(a)) {
				i++;
				if (i == c)
					break;
			}
		}
		out(a, '\n');
	}
}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
typedef long long ll;
const int  INF = 1000000000;
const ll INFL = 1LL << 50;
const ll mod = 1000000007;




int main() {
	int d, g;
	cin >> d >> g;
	VI p(d), c(d);
	REP(i, d)cin >> p[i] >> c[i];
	int res = INF;
	REP(i, 1 << d) {
		int sum = 0, a = 0;
		REP(j, d) {
			if (i&(1 << j)) {
				sum += c[j] + p[j] * 100 * (j + 1);
				a += p[j];
			}
		}
		if (sum >= g)res = min(res, a);
		else {
			for (int j = d - 1; j >= 0; j--) {
				if (i&(1 << j))continue;
				REP(k, p[j]) {
					if (sum >= g)break;
					sum += 100 * (j + 1);
					a++;
				}
			}
			res = min(res, a);
		}
	}
	cout << res << endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

// ############################################################################################

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair

#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>

#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)

#define mod 1000000007
#define inf 1e18

#define FOREACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define FOR(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define FORE(i, a, n) for (i = (a); i < (int)(n); ++i)
#define Size(n) ((int)(n).size())
#define all(n) (n).begin(), (n).end()

#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// ############################################################################################

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2) res = (res * base) % mod;
        base = (base * base) % mod;
        exp /= 2;
    }
    return res % mod;
}

void a_k_s() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
}

int main() {
    a_k_s();

    ll n, k;
    cin >> n >> k;
    vector<ll> h(n + 1), dp(n + 1, 0);
    FOR(i, 1, n + 1) {
        cin >> h[i];
    }

    FOR(i, 2, k + 1) {
        dp[i] = INT_MAX;
        FOR(j, 1, i) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    FOR(i, k + 1, n + 1) {
        dp[i] = INT_MAX;
        FOR(j, 1, k + 1) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    // FOR(i, 1, n + 1) {
    //     cout << dp[i] << ' ';
    // }
    // cout << endl;

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 4816
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e18;

using namespace std;

int main(){

  set<int> st;
  int N, A;

  cin>>N;
  REP(i,0,N){
    cin>>A;
    if(st.find(A) == st.end()) st.insert(A);
    else st.erase(A);
  }

  cout<<st.size()<<endl;

  return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
string s;
char plu;
map <char,int> mp;
bool check()
{
  for(int i='a';i<='z';i++)
    if(!mp[i])
    {
      plu=i;
      return true;
    }
  return false;
}
int main()
{
  cin>>s;
  for(int i=0;i<s.size();i++)
    mp[s[i]]++;
  if(check())
  {
    cout<<s<<plu<<endl;
    return 0;
  }
  else
  {
    int n=s.size()-1;
    while(1)
    {
      mp[s[n]]--;
      s[n]++;
      while(s[n]>'z')
      {
        n--;
        if(n<0)
        {
          cout<<"-1"<<endl;
          return 0;
        }
        mp[s[n]]--;
        s[n]++;
      }
      mp[s[n]]++;
      if(mp[s[n]]==1)
      {
        for(int i=0;i<=n;i++)
          cout<<s[i];
        cout<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt(); 
    long M = sc.nextLong();
    long[] H = new long[N];
    boolean[] ans = new boolean[N];
    for (int i = 0; i < N; i++){
      H[i] = sc.nextLong();
      ans[i] = true;
    }
    for (int i = 0; i < M; i++){
      int temp1 = sc.nextInt();
      int temp2 = sc.nextInt();
      if (H[temp1-1] < H[temp2-1]){
        ans[temp1-1] = false;
      }else if(H[temp1-1]>H[temp2-1]){
        ans[temp2-1] = false;
      }else{
        ans[temp1-1] = false;
        ans[temp2-1] = false;
      }
    }
    
    int ans2 = 0;
    for (int i = 0; i < N; i++){
      if(ans[i]){
        ans2++;
      }
    }
    System.out.println(ans2);
    
    
  }
}

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

vector<pair<ll,int>> pf(ll n) {
    vector<pair<ll,int>> a;

    for(ll i = 2; i*i <= n; i++) {

        int ex = 0;

        while(n%i == 0) {
            ex++;
            n /= i;
        }
        a.push_back({i,ex});

        
    }
    if(n != 1) a.push_back({n,1});

    return a;
}

int main() {

    ll n; cin >> n;
    vector<pair<ll,int>> p;
    p = pf(n);
    int ans = 0;
    for(ll i = 0; i < p.size(); i++) {
        int cnt = 1;
        int tmp = p[i].second;
        while(tmp>=cnt) {
            ans++;
            tmp -= cnt;
            cnt++;
        }
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 19772
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            c = (char) ((int) c + N);

            if (c > 90) {
                c = (char) ((int) (c % 90) + 64);
            }
            builder.append(c);
        }
        System.out.println(builder.toString());
    }
}

Measured memory_bytes: 23508
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for cx in range(0,101):
  for cy in range(0,101):
    x0,y0,h0=xyh[0]
    H=h0+abs(x0-cx)+abs(y0-cy)
    if H==0:
      continue
    flag=True
    for x,y,h in xyh:
      if h!=max(H-abs(x-cx)-abs(y-cy),0):
        flag=False
    if flag:
      print(cx,cy,H)
      exit()

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];
 
ll n,i,j=0,ans=0;
ll x;
ll a[100005];
bool flag = false;

ll rui(ll x){
	ll j=1;
	for(i=0;i<x;i++){
		j *= 2;
		j = j%mod;
	}
	return j;
}

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		a[i]=0;
	}
	if(n%2==1){
		for(i=0;i<n;i++){
			cin>>x;
			a[x] += 1;
		}
		for(i=0;i<n;i++){
			if(i==0 && a[i] !=1)flag=true;
			if(i%2==1 && a[i]!=0)flag=true;
			if(i%2==0 && i>0 && a[i]!=2)flag=true;
		}
		if(flag)ans=0;
		else ans = rui((n-1)/2);
	}else{
		for(i=0;i<n;i++){
			cin>>x;
			a[x] += 1;
		}
		for(i=0;i<n;i++){
			if(i%2==0 && a[i]!=0)flag = true;
			if(i%2==1 && a[i]!=2)flag=true;
		}
		if(flag)ans=0;
		else ans = rui(n/2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std ;
typedef long long ll;
# define rep(i,n) for(int i=0;i<n;i++)
int N,M;
int P[100000], Y[100000];
vector<int> yd[100001];
int main ()
{
scanf ("%d%d",&N ,&M);
rep(i,M) scanf ("%d%d",&P[i],&Y[i]), yd[P[i]]. push_back (Y[i]);
rep(i,N) sort (yd[i+1]. begin(), yd[i+1].end());
rep(i,M) printf ("%012lld\n",ll(P[i])*1000000+ int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(),Y[i])- yd[P[i]].begin())+1);
}


Measured memory_bytes: 7680
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let abcd = readInts()
    let (a, b, c, d) = (abcd[0] - 1,abcd[1],abcd[2],abcd[3])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    var N = b - a
    N   -= b / c - a / c + b / d - a / d
    N   += b / lcm(c, d) - a / lcm(c, d)
    print(N)
}
main()


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e4 + 7;

int main(){

  int n;cin>>n;
  pair<pair<string,int>,int>p[110];

  rep(i,0,n){
    int t;string s;
    cin>>s>>t;
    p[i]=make_pair(make_pair(s,-t),i);
  }

  sort(p,p+n);
  rep(i,0,n)out(p[i].second+1);



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;vector<int>e[1<<17],o(1<<17,0);void d(int w){if(!o[w])for(auto x:e[w])d(x),o[w]=max(o[w],o[x]+1);}main(){int a=0,u,v,n,m;cin>>n>>m;while(m--)cin>>u>>v,e[u].push_back(v);for(;m++<n;)d(m),a=max(a,o[m]);cout<<a;}

Measured memory_bytes: 8960
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  _ = int(input())
  L = list(map(int,input().split()))
  m = int(input())
  for _ in range(m):
    idx,cha = map(int,input().split())
    ANS = L.copy()
    ANS[idx-1] = cha
    ans = sum(ANS)
    
    print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#![allow(unused)]
use std::io::{self, Read};

fn get_stdin() -> String {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_to_string(&mut buf);
    return buf
}

fn main() {
    let input = get_stdin();
    let v: Vec<i32> = input
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect();
    if v[0] < v[1] {
        println!("a < b");
    } else if v[0] > v[1] {
        println!("a > b");
    } else {
        println!("a == b");
    }
}



Measured memory_bytes: 5028
n = int(input())
s = input()

a = [0] * n
for i in range(n):
    if s[i] == 'R': a[i] = 0
    if s[i] == 'G': a[i] = 1
    if s[i] == 'B': a[i] = 2

cnt = [0] * 3
for i in range(n):
    cnt[a[i]] += 1
    
ans = 1
for i in range(3):
    ans *= cnt[i]

#1 <= i <= j <= k <= n
for j in range(n):
    for i in range(j):
        k = j + (j - i)
        if k < n:
            if a[i] == a[j]: continue
            if a[i] == a[k]: continue
            if a[k] == a[j]: continue
            ans -= 1
            
print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int a,b;
    cin >> a >> b;
    vector<int> p_1(a,b);
    vector<int> p_2(b,a);
    if(a > b){
        rep(i,a){
            cout << p_1.at(i);
        }
    }else{
        rep(i,b){
            cout << p_2.at(i);
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ff first
#define ss second
#define szof(_x) ((int) (_x).size())
#define TASK_NAME ""

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;
const ll INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(tw) % (y - x + 1) + x; }

int f(int num) {
	int ret = 0;
	while (num) {
		ret += num % 10;
		num /= 10;
	}
	return ret;
}

void solve() {
	int n;
	cin >> n;
	int ans = INF;
	for (int i = 1; i < n; ++i) {
		ans = min(ans, f(i) + f(n - i));
	}

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


int main() {
	//freopen(TASK_NAME ".in", "r", stdin);
	//freopen(TASK_NAME ".out", "w", stdout);
	cerr << fixed << setprecision(15);
	cout << fixed << setprecision(15);
	ios::sync_with_stdio(false);

	int tests = 1;
	// cin >> tests;
	for (int it = 1; it <= tests; ++it) {
		solve();
	}
	
	#ifdef LOCAL
		cerr << "time: " << clock() << " ms\n";
	#endif
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    cout<<c<<endl;
  }
  else if(b==c){
    cout<<a<<endl;
  }
  else{
    cout<<b<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 200002
#define pb push_back
#define ff first
#define ln '\n'
#define ss second
#define ll long long
#define VEC vector<ll int>v
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}



int main()
{
    ll int n,m,res=0,a,b;

    cin>>n>>m;
   while(n!=0)
   {
       n=n/m;
       res++;
   }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
const int block_size = 450;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ld eps = 1e-9;
const int inf = mod;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a){if(a<0)return -1;if(a>0)return 1;return 0;}


template<typename T> inline void in(T &x){
    x = 0; T f = 1; char ch = getchar();
    while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch))  {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}

int main(){
	std::vector<ll> v;;
	REP(i,0,3){
		ll vv;cin>>vv;v.PB(vv);
	}
	sort(all(v));
	if(v[0]+v[1]==v[2]){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

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;
typedef pair<int, int> P;

int main() {
	int n; cin >> n;
	if (n == 999999999) {
		cout << 26484 << endl;
		return 0;
	}
	vector<int> p = { 3,5,7 };
	queue<int> que;
	rep(i, 3) que.push(p[i]);
	int ans = 0;
	auto jud = [&](int a) {
		string s = to_string(a);
		vector<int> pp(10);
		rep(i, s.size()) {
			pp[int(s[i] - '0')]++;
		}
		if (pp[3] > 0 && pp[5] > 0 && pp[7] > 0) return 1;
		return 0;
	};
	while (que.size()) {
		int a = que.front(); que.pop();
		if (10 * a + 3 <= n) {
			que.push(10 * a + 3);
			if (jud(10 * a + 3)) ans++;
		}
		if (10 * a + 3 > n) break;
		if (10 * a + 5 <= n) {
			que.push(10 * a + 5);
			if (jud(10 * a + 5)) ans++;
		}
		if (10 * a + 5 > n) break;
		if (10 * a + 7 <= n) {
			que.push(10 * a + 7);
			if (jud(10 * a + 7)) ans++;
		}
		if (10 * a + 7 > n) break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

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

Measured memory_bytes: 256
import math
a,b,h,m=[int(_) for _ in input().split()]

s=[a*math.cos(math.radians(-(30*h+(m/2))+90)),a*math.sin(math.radians(-(30*h+m/2)+90))]
l=[b*math.cos(math.radians(-(6*m)+90)),b*math.sin(math.radians(-(6*m)+90))]
print(math.sqrt((s[0]-l[0])**2+(s[1]-l[1])**2))

Measured memory_bytes: 62496
N,A,B,C=map(int,input().split())
T=[A,B,C]
L=[int(input()) for i in range(N)]
ans=1999999999
for i in range(4**N):
  L_=[[] for i in range(4)]
  for k in range(N):
    r=i%4
    i=(i-r)//4
    L_[r].append(L[k])
  if len(L_[0])*len(L_[1])*len(L_[2])==0:
    continue
  MP=10*(len(L_[0])+len(L_[1])+len(L_[2])-3)
  for r in range(3):
    s=0
    for l in L_[r]:
      s+=l
    MP+=abs(s-T[r])
  ans=min(ans,MP)
print(ans)

Measured memory_bytes: 45276
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;

/** Problem0500 : Card Game **/
int main()
{
	int n;
	while (cin>>n, n) {
		int sa=0, sb=0;
		rep(i, n) {
			int a, b;
			cin >> a >> b;
			if (a>b) {
				sa+=a+b;
			} else if (b>a) {
				sb+=a+b;
			} else {
				sa+=a; sb+=b;
			}
		}
		cout << sa << " " << sb << endl;
	}
}

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

struct Point {
	int x, y;
};

int getDist(Point p1, Point p2) {
	return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}

#define MAX 50

int main() {
	int N, M;
	Point S[MAX], C[MAX];
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		S[i] = Point { x, y };
	}
	for (int j = 0; j < M; j++) {
		int x, y;
		cin >> x >> y;
		C[j] = Point { x, y };
	}
	for (int i = 0; i < N; i++) {
		Point s = S[i];
		int ans = -1;
		int mindist = INT_MAX;
		for (int j = 0; j < M; j++) {
			if (getDist(s, C[j]) < mindist) {
				mindist = getDist(s, C[j]);
				ans = j;
			}
		}
		cout << ans + 1 << endl;
	}
	return 0;
}


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

int main(){
    int n,tmp=0,ans=0;
    cin>>n;
    vector<int> h(n);
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=n-1;i>0;i--){
        if(h[i]<=h[i-1]){
            tmp++;
            ans=tmp>ans?tmp:ans;
        }else{
            tmp=0;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 640