akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 998244353;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

ll modadd(ll x, ll y) {
    return ((x + y) % mod + mod) % mod;
}

ll modminus(ll x, ll y) {
    return (x - y + mod) % mod;
}

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

ll modpower(ll x, ll y) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else if (y % 2 == 0) {
        ll p = modpower(x, y / 2);
        return p * p % mod;
    } else {
        ll p = modpower (x, y / 2);
        return (p * p) % mod * (x % mod) % mod;
    }
}

ll dpl[3010][3010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, S;
    cin >> N >> S;
    ll A[N];
    REP(i, 0, N) {
        cin >> A[i];
    }
    dpl[0][0] = 1;
    REP(i, 0, N) {
        dpl[i + 1][0] = 1;
        REP(j, 0, S + 1) {
            dpl[i + 1][j] = modadd(dpl[i + 1][j], dpl[i][j]);
            if (j + A[i] <= S) {
                dpl[i + 1][j + A[i]] = modadd(dpl[i + 1][j + A[i]], dpl[i][j]);
            }
        }
    }
    ll ans = 0;
    REP(l, 0, N + 1) {
        ans = modadd(ans, dpl[l][S]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 70784
x1, y1, x2, y2 = map(int, input().split())
dx=x2-x1
dy=y2-y1
x3=x2-dy
y3=y2+dx
x4=x1-dy
y4=y1+dx
list=[x3,y3,x4,y4]
mapped=map(str, list)
kotae=' '.join(mapped)
print(kotae)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h := scanInt()
	w := scanInt()
	k := scanInt() - 1

	cnt := make([]int, w+1)
	for i := 1; i <= w; i++ {
		bitExhaustiveSearch(i, func(arr []bool) {
			f := true
			for j := 0; j < i-1; j++ {
				if arr[j] && arr[j+1] {
					f = false
				}
			}
			if f {
				cnt[i]++
			}
		})
	}

	cnt[0] = 1

	memo := make([][]int, h+1)
	for i := 0; i < h+1; i++ {
		memo[i] = make([]int, w)
		for j := 0; j < w; j++ {
			memo[i][j] = -1
		}
	}
	for i := 0; i < w; i++ {
		memo[h][i] = 0
	}
	memo[h][k] = 1

	var dfs func(y, x int) int
	dfs = func(y, x int) int {
		if memo[y][x] != -1 {
			return memo[y][x]
		}
		res := 0
		res += dfs(y+1, x) * (cnt[max(0, x-1)] * cnt[max(0, w-2-x)] % mod) % mod
		if x > 0 {
			res += dfs(y+1, x-1) * (cnt[max(0, x-2)] * cnt[max(0, w-2-x)] % mod) % mod
		}
		if x < w-1 {
			res += dfs(y+1, x+1) * (cnt[max(0, x-1)] * cnt[max(0, w-3-x)] % mod) % mod
		}
		res %= mod
		debug("ans", y-1, x, res)
		memo[y][x] = res
		return res
	}

	fmt.Fprintln(wr, dfs(0, 0))
}

const mod = 1000000007

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}

func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i>>uint(j)&1 == 1 {
				a[j] = true
			} else {
				a[j] = false
			}
		}
		fn(a)
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll x1, x2, y1, y2;
  cin >> x1 >> x2 >> y1 >> y2;
  ll maxmul = LONG_MIN;
  maxmul = max(maxmul, x1 * y1);
  maxmul = max(maxmul, x1 * y2);
  maxmul = max(maxmul, x2 * y1);
  maxmul = max(maxmul, x2 * y2);
  cout << maxmul;
  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vint;
typedef vector<uint> vuint;
typedef vector<ull> vull;
typedef vector<ll> vll;

#define init(type,var) type var;cin>>var;
#define vinit(type,var,n) vector<type> var((uint)n);rep(i,0,n)cin>>var[i];
#define linit(type,var,n) list<type> var;rep(i,0,n){type _v;cin>>_v;var.push_back(_v);}
#define range(container) container.begin(),container.end()
#define rep(i,first,end) for(ull i=(first);i<(end);i++)
#define outl(out) cout<<(out)<<endl;

const ull INF = (ull)(-1LL);

typedef ull ntype;

typedef vector<ntype> vntype;
typedef list<ntype> lntype;

int main(void)
{
	init(ntype, x);

	ntype b = 100;
	uint c = 0;
	while (b < x){
		b = (ntype)(b * 1.01);
		c++;
	}

	outl(c);

	return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var a=sc.Ia;
		var ans=new int[n];
		for(int i = 0;i<a.Length;i++) {
			ans[a[i]-1]++;
		}
		Console.WriteLine("{0}",String.Join("\n",ans));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 45320
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N, T; cin >> N >> T;
    vector <int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    int max_dif=0, cnt=0, minA=A[0];
    for(int i=1;i<N;i++){
    	if(A[i]-minA==max_dif) cnt++;
    	if(A[i]-minA>max_dif){
    		max_dif=A[i]-minA; cnt=1;
    	}
    	if(minA>A[i]) minA=A[i];
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),t = 0,h = 0;
        for(int i = 0;i < n;++i){
            String a = sc.next(),b = sc.next();
            int c = a.compareTo(b);
            if(c > 0) t += 3;
            else if(c < 0) h += 3;
            else{
                ++t;
                ++h;
            }
        }
        System.out.printf("%d %d\n",t,h);
    }

}

Measured memory_bytes: 30244
// AOJ 0372: Three Meals
// 2017.11.14 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { long long b; int n, t; } T;
T tbl[3][1440]; int sz[3];
long long a[3][1440];

int bitcount64(long long x)
{
	x = ((x & 0xAAAAAAAAAAAAAALL) >>  1) + (x & 0x55555555555555LL);
	x = ((x & 0xCCCCCCCCCCCCCCLL) >>  2) + (x & 0x33333333333333LL);
	x = ((x & 0xF0F0F0F0F0F0F0LL) >>  4) + (x & 0x0F0F0F0F0F0F0FLL);
	x = ((x & 0x00FF00FF00FF00LL) >>  8) + (x & 0xFF00FF00FF00FFLL);
	x = ((x & 0xFF0000FFFF0000LL) >> 16) + (x & 0x00FFFF0000FFFFLL);
	x = ((x & 0xFFFFFF00000000LL) >> 32) + (x & 0x000000FFFFFFFFLL);
	return (int)x;
}

int cmp(T *a, T *b) { if (b->n - a->n) return b->n - a->n; return b->t - a->t; }

int main()
{
	int n, i, j, k, at, ht, f, ans;
	long long b, bb;
	
	scanf("%d", &n);

	for (b = 1, i = 0; i < n; i++, b <<= 1) for (j = 0; j < 3; j++) {
		int sh, sm, eh, em, t;
		scanf("%d%d%d%d", &sh, &sm, &eh, &em);
		sh = sh*60+sm, eh = eh*60+em;
		for (t = sh; t <= eh; t++) a[j][t] |= b;
	}
	for (j = 0; j < 3; j++) {
		T *tp;
		for (tp = tbl[j], i = 0; i < 1440; i++) if ((b = a[j][i]) > 0) {
			tp->b = b, tp->n = bitcount64(b), tp->t = i, tp++;
		}
		sz[j] = tp - tbl[j];
		qsort(tbl[j], sz[j], sizeof(T), cmp);
	}
	n = tbl[0][0].n;
	if (tbl[1][0].n < n) n = tbl[1][0].n;
	if (tbl[2][0].n < n) n = tbl[2][0].n;

	ans = 0;
	for (i = 0; i < sz[0]; i++) {
		if (tbl[0][i].n <= ans) goto done;
		at = tbl[0][i].t, b = tbl[0][i].b;
		for (j = 0; j < sz[1]; j++) {
			if (tbl[1][j].n <= ans) break;
			if ((ht = tbl[1][j].t) <= at) continue;
			bb = tbl[1][j].b & b;
			if (bitcount64(bb) <= ans) continue;
			for (k = 0; k < sz[2]; k++) {
				if (tbl[2][k].n <= ans) break;
				if (tbl[2][k].t <= ht) continue;
				if ((f = bitcount64(tbl[2][k].b & bb)) > ans) {
					ans = f;
					if (ans == n) goto done;
				}
			}
		}
	}
done:
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
  int K, N;
  cin >> K >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  int ans = A[N-1] - A[0];
  for(int i = 1; i < N; i++){
    ans = min(ans, K + A[i-1] - A[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
  int n, x, i, j, k;
  int count;

  while(1){
    count=0;
    scanf("%d%d", &n, &x);
    if(n == 0 && x == 0) break;

    for(i = 1; i <= n; i++){
      for(j = i+1; j <= n; j++){
        for(k = j+1; k <= n; k++){
          if(x == (i+j+k)) count++;
        }
      }
    }
    printf("%d\n", count);
  }

  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;


int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    int sum;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    sort(A.rbegin(),A.rend());
    sum = accumulate(A.begin(),A.end(),0);

//   cout << sum/(4*M) << endl;
    rep(i,M){
        if(A.at(i)<(float)sum/(4*M)){
            cout << "No" << endl;
            return 0;
        }
    }
    

    cout << "Yes" << endl;

    

    
    
}

Measured memory_bytes: 3632
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int main() {
	string s,t;
	cin>>s>>t;
	for(char c='a';c<='z';c++)
		if(s+c==t) puts("Yes"),exit(0);
	puts("No"); 
	return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int a,b,c;cin >> a >> b >> c;
  cout << a*b/2 << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
  long int n, d, i, x, y, ans;
  ans = 0;
  scanf("%ld %ld", &n, &d);
  
  for(i = 0; i < n; i++) {
    scanf("%ld %ld", &x, &y);
    if (sqrt(x*x + y*y) <= d)
      ans++;
  }
  
  printf("%ld", ans);
  
  return(0);
}

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

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

    cout << sum << endl;

}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<iostream>
using namespace std;

string s;
int main (){
    cin >> s;
    int y = (s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+ s[3]-'0';
    int m = (s[5]-'0')*10 + (s[6]-'0');
    int d = (s[8]-'0')*10 + (s[9]-'0');

    if( y >= 2019 && m >= 5) {
        cout << "TBD" << endl;
        return 0;
    } else cout << "Heisei" << endl;
    return 0;
}


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

using namespace std;

void solve()
{
    string s;
    cin >> s;
    int k = s.size();
    while (s[k - 1] != 'F')
        k--;
    cout << s.substr(0, k - 1) << endl;
}

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


Measured memory_bytes: 256
def solve(K, S):
    count = 0
    
    for x in range(K+1):
        for y in range(K+1):
            z = S - (x + y)
            
            # zが条件を満たすか
            if K >= z >= 0:
                count += 1
                    
    print(count)

if __name__ == '__main__':
    K, S = map(int, input().split())
    solve(K, S)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
#pragma comment(linker, "/STACK:1024000000,1024000000")
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 1e5+5;
const int MOD = 1e9 + 7;

int main()
{
    char str1[55],str2[55];
    long long ans=1;
    int n;
    scanf("%d",&n);
    getchar();
    scanf("%s",str1);
    getchar();
    scanf("%s",str2);

    int p=0,pre;

    if(str1[p]==str2[p])
    {
        ans*=3;
        p++;
        pre=1;
    }
    else
    {
        ans*=6;
        p+=2;
        pre=2;
    }
    while(p<n){
        if(str1[p]==str2[p])    //x
        {
            if(pre==1) ans=(ans*2)%MOD;
            else ans=ans*1;
            pre=1;
            p++;
            continue;
        }
        else
        {
            if(pre==1) ans=(ans*2)%MOD;
            else ans=(ans*3)%MOD;
            pre=2;
            p+=2;
            continue;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;
class  Main{
  public   static  void main(String[]args){
Scanner in =new Scanner(System.in);
String s;
s=in.next();
if (s.equals("ABC"))
  System.out.print("ARC");
else  System.out.print("ABC");





  }
}

Measured memory_bytes: 35740
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

memo = defaultdict(int)
answer = 0
for i, x in enumerate(A, 1):
    answer += memo[i - x]
    memo[x + i] += 1

print(answer)

Measured memory_bytes: 61572
N = int(input())
A = []
for _ in range(N):
    a = int(input())
    b = []
    for _ in range(a):
        b.append(list(map(int, input().split())))
    A.append(b)
# 証言リスト A[i人目][j個目の証言] -> [誰が, bit(1は正、0は誤)]

# bitが1であれば正しい証言、0であれば間違った証言とする
# 正しい証言だけ確認して、[i, 1]と証言した i も1かどうか、[j,0]と証言したjが0かどうか



def F(i):
    cnt = 0
    B = [-1]*N                #B = [-1,-1,-1]
    r = 0
    for j in range(N):    # i=1,  j=0,1,2
        if (i>>j)&1:         # 001 ->  1,0,0  j=0
            r += 1               # r = 1    
            if B[j] == 0:     #B[0] == -1  
                return 0
            B[j]=1              # B = [1,-1,-1]   
            for p,q in A[j]: # A[0] = [[2, 1], [3, 0]]   
                if q == 0:
                    if B[p-1]==1:  # B[2] == -1
                        return 0
                    B[p-1] = 0  # B = [1,1,0]
                else:
                    if B[p-1]==0:  # B[1] == -1
                        return 0
                    B[p-1] = 1      # B = [1,1,-1]
            else:
                cnt += 1          # cnt = 1
        else:         # j=1
            if B[j]==1:       #B[1] ==1
                return 0
            B[j]=0
            
    if cnt == r:
        return cnt

ans = 0
for i in range(1<<N):
    ans = max(ans,F(i))
print(ans)

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

int main() {
  int n;
  cin >> n;
  set<int> st;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    st.emplace(x);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = sorted(list(map(int, input().split())))

c = Counter(A)
t = [True] * (10**6 + 1)

ans = 0
for k, v in c.items():
    if t[k]:
        if v == 1:
            ans += 1
        for j in range(k, 10**6+1, k):
            t[j] = False

print(ans)

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

using namespace std;

int h[13];

int f[15][30][30];

int main(){
    int n;
    cin>>n;
    h[0]=2;
    while (n--){
        int val;
        cin>>val;
        h[val]++;
    }
    if ((*max_element(h,h+13))>2){
        cout<<0;
        return 0;
    }
    f[0][12][12]=30;
    for(int cur=0;cur<12;cur++) {
        if (h[cur+1]==1){
            for(int L=12-cur;L<=12;L++)
                for(int R=12;R<=cur+12;R++) if (f[cur][L][R]){
//                    cout<<cur<<" "<<L<<" "<<R<<" "<<f[cur][L][R]<<'\n';
                    f[cur+1][L][12+cur+1]=max(f[cur+1][L][12+cur+1],min(f[cur][L][R],12+cur+1-R));
                    f[cur+1][12-cur-1][R]=max(f[cur+1][12-cur-1][R],min(f[cur][L][R],L-(12-cur-1)));
                }
            continue;
        }
        if (h[cur+1]==2){
            for(int L=12-cur;L<=12;L++)
                for(int R=12;R<=cur+12;R++) if (f[cur][L][R])
                    f[cur+1][12-cur-1][12+cur+1]=max(f[cur+1][12-cur-1][12+cur+1],min(min(L-(12-cur-1),(12+cur+1)-R),f[cur][L][R]));
            continue;
        }
//        cout<<"tick\n";
        for(int L=12-cur;L<=12;L++)
            for(int R=12;R<=cur+12;R++) f[cur+1][L][R]=f[cur][L][R];
    }
    int ans=0;
    for(int L=0;L<30;L++)
        for(int R=0;R<30;R++) ans=max(ans,min(f[12][L][R],24-(R-L)));
    cout<<ans;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split(' ');
    let d = input[0];//距離　メートル
    let t = input[1];//約束時間　分後
    let s = input[2];//分速　m/分
    
    if(t >= d/s){
        console.log("Yes");
    }else {
        console.log("No");
    }

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




Measured memory_bytes: 29552
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define N (int)1e5
#define mod (int)(1e9 + 7)
typedef long long LL;
LL q, a, b, c, d, sum, sum2;
LL r[N + 1], r2[N + 1];
string s, t, s2, t2;

int main()
{
	cin >> s >> t >> q;
	for (int i = 0; i < s.size(); i++)
	{
		r[i + 1] = r[i] + 1;
		if (s[i] == 'B')
			r[i + 1]++;
	}
	for (int i = 0; i < t.size(); i++)
	{
		r2[i + 1] = r2[i] + 1;
		if (t[i] == 'B')
			r2[i + 1]++;
	}
	while (q--)
	{
		cin >> a >> b >> c >> d;
		if ((r[b] - r[a - 1]) % 3 == (r2[d] - r2[c - 1]) % 3)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 2432
import sys
sys.setrecursionlimit(10**6)

n = int(input())
d = {}

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

max_v = max(d.values())
kv_list = [kv for kv in d.items() if kv[1] == max_v]
kv_list.sort()
for kv in sorted(kv_list):
    print(kv[0])


Measured memory_bytes: 45388
/*
 * atcoder/abc137_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <queue>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100001;
int N, M;
vector<int> A[MAX];
void solve() {
  cin >> N >> M;
  int a, b;
  loop(n,0,N) {
    cin >> a >> b;
    A[a].push_back(b);
  }

  ll total = 0;
  priority_queue<int> Q;
  for (int i=1; i<=M; i++) {
    for (auto&&b: A[i]) Q.push(b);
    if (Q.size()) {
      total += Q.top(); Q.pop();
    }
  }
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N-1);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }
    for(int i=0; i<N; i++){
        cin >> B.at(i);
    }
    for(int i=0; i<N-1; i++){
        cin >> C.at(i);
    }
    int sum=0;
    for(int i=0; i<N; i++){
        sum+=B.at(A.at(i)-1);
        if(i!=0){
            if(A.at(i)==A.at(i-1)+1){
                sum+=C.at(A.at(i-1)-1);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
//  val b = sc.nextInt
//  val a = List.fill(n)(sc.nextInt)
//  val b = List.fill(m)(sc.nextInt)
//  val c = List.fill(n - 1)(sc.nextInt)
  val list = List.fill(n, 2)(sc.next)

  val ans = list.foldLeft(0.0){ case (acc, x :: y :: Nil) => y match {
    case "JPY" => acc + x.toInt
    case _ => acc + x.toDouble * 380000
  }}

  println(ans)

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 167592
A,B,C,D,E,F=map(int,input().split())
water=[]
suger=[]
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if 0<100*(i*A+j*B)<=F:
            water.append(100*(i*A+j*B))
        if 100*(i*A+j*B)>F:
            break

for i in range((F*E//(100+E))//C+1):
    for j in range((F*E//(100+E))//D+1):
        if 0<=i*C+j*D<=F*E/(100+E):
            suger.append(i*C+j*D)
        if i*C+j*D>F*E/(100+E):
            break


c=0
w=100*A #初期値に注意！！！！！！
s=0
for i in range(len(water)):
    for j in range(len(suger)):
        if water[i]+suger[j]<=F and water[i]*E/100>=suger[j] and suger[j]/(water[i]+suger[j])>c:
            c=suger[j]/(water[i]+suger[j])
            w=water[i]
            s=suger[j]

print(w+s,s)


Measured memory_bytes: 74156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int k = scan.nextInt();

		for (int i=a; i<=b; i++) {
			if (i-a<k || b-i<k) {
				System.out.println(i);
			}
		}

		scan.close();

	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdlib>
using namespace std;
#define MOD 100000
int main(){
	int n,m,ans=0;
	int d[100001];
	cin>>n>>m;
	d[0]=d[1]=0;
	for(int i=2;i<=n;i++){
		cin>>d[i];
		d[i] += d[i-1];
	}
	int pos=1,step;
	for(int i=0;i<m;i++){
		cin>>step;
		ans = (ans+abs(d[step+pos]-d[pos]))%MOD;
		pos += step;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1548
import sys

input = sys.stdin.readline
x = [0, 0, 0]
for _ in range(int(input())):
    a, b, c = map(int, input().split())
    a += max(x[1], x[2])
    b += max(x[0], x[2])
    c += max(x[0], x[1])
    x = [a, b, c]
print(max(x))

Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
using namespace std;
int a[10010],b[10010];
int main()
{
    int n,i;
    scanf("%d",&n);
    for (i=1;i<=n;i++) scanf("%d",&a[i]);
    for (i=1;i<=n;i++) scanf("%d",&b[i]);
    long long x=0,y=0;
    for (i=1;i<=n;i++)
        if (a[i]<b[i])
        {
            x+=(b[i]-a[i])/2;
            if (b[i]%2!=a[i]%2)
            {
                x++;
                y++;
            }
        }
        else
            y+=a[i]-b[i];
    if (x>=y) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task6 solver = new Task6();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task6 {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			while (true) {
				int n = sc.nextInt();
				int m = sc.nextInt();
				if (n == 0 && m == 0) break;

				int total = 0;
				Way[] ways = new Way[n];
				for (int i = 0; i < n; i++) {
					int d = sc.nextInt();
					int p = sc.nextInt();
					ways[i] = new Way(d, p);
					total += d * p;
				}

				Arrays.sort(ways);

				for (int i = 0; i < n; i++) {
					int def = Math.min(ways[i].d, m);
					total -= ways[i].p * def;
					m -= def;
				}

				out.println(total);
			}

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}

	static class Way implements Comparable<Way> {
		int d;
		int p;

		Way(int d, int p) {
			this.d = d;
			this.p = p;
		}

		public int compareTo(Way w) {
			return -(this.p - w.p);
		}

	}
}




Measured memory_bytes: 33896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
        int n = sc.nextInt();
        int k = sc.nextInt();
        double answer=0;
        for(int i=1;n+1>i;i++) {
        	int count=i;
        	int j=0;
        	while(true) {
        		if(count>=k)
        			break;
        		count = count*2;
        		j++;
        	}
        	answer=answer+1/(double)n*Math.pow(0.5,j);
        	//System.out.println(answer);
        }
        System.out.println(answer);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b==15){
    cout << "+";
  } else if (a*b==15){
    cout << "*";
  } else {
    cout << "x";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
	char u[10000000],b;
	int i[26],a,len;
	for(a=0;a<26;a++){
		i[a]=0;
	}
	cin>>u;
	len=strlen(u);
	for(len--;len>=0;len--){
		i[u[len]-97]=1;
	}
	for(a=0;a<26;a++){
		if(i[a]==0){
			b=a+97;
			cout<<b;
			return 0;
		}
	}
	cout<<"None";
    return 0;
} 

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

struct Data {
  ll v;
  int c;
  bool operator < ( const Data &d ) const {
    if( v != d.v ) {
      return v < d.v;
    } else {
      return c < d.c;
    }
  }
};

int main() {
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<Data> Q;
  int p;
  rep(i,A) {
    cin >> p;
    Q.push((Data){p,0});
  }
  rep(i,B) {
    cin >> p;
    Q.push((Data){p,1});
  }
  rep(i,C) {
    cin >> p;
    Q.push((Data){p,2});
  }
  vector<int> rem(2);
  rem[0] = X;
  rem[1] = Y;
  ll ans = 0;
  int abc = X+Y;
  while( abc > 0 ) {
    Data d = Q.top(); Q.pop();

    if( d.c == 2 ) {
      ans += d.v;
      --abc;
    } else {
      if( rem[d.c] > 0 ) {
	--rem[d.c];
	ans += d.v;
	--abc;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10604
N, M, D = map(int, input().split())
S = [input() for i in range(N)]

ans = 0

if D == 1: print(sum([s.count('.') for s in S]))
else:
    for i in range(N):
        count = 0
        
        for s in S[i]:
            if s == '.': count += 1
            else: 
                if count >= D: ans += 1 + count - D
                count = 0
        if count >= D: ans += 1 + count - D
        
    for j in range(M):
        count = 0
        for i in range(N):
            if S[i][j] == '.': count += 1
            else:
                if count >= D: ans += 1 + count - D
                count = 0
        if count >= D: ans += 1 + count - D
    print(ans)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int cal[30];
int dp[(1<<16)];
int val[(1<<16)];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<n;i++)
    {
        cin>>x>>y>>a;
        A[x]^=a;
        A[y]^=a;
    }

    for(int i=0;i<n;i++){
        cal[A[i]]++;
    }

    int res = 0;
    int vv = 0;

    for(int i=1;i<=15;i++){
        res+=(cal[i]>>1);
        if(cal[i]&1)vv|=(1<<(i-1));
    }

    for(int i=1;i<(1<<15);i++)
        dp[i] = dp[i>>1]+(i&1);
    for(int i=1;i<(1<<15);i++)
        dp[i]--;

    for(int i=1;i<(1<<15);i++){
        for(int j=0;j<15;j++){
            if(i&(1<<j)){
                val[i]^=(j+1);
            }
        }
    }

    for(int i=1;i<(1<<15);i++){
        if(val[i])continue;

        cur = i;

        for(int j=(i-1)&i;j;j=(j-1)&i){
            if(!val[j])dp[i] = min(dp[i],dp[j]+dp[i^j]);
        }

    }

    res+=dp[vv];

    cout<<res<<"\n";


    return 0;
}


Measured memory_bytes: 4280
import heapq
[N, M] = [int(i) for i in input().split()]
A = [int(i)*(-1) for i in input().split()]

heapq.heapify(A)

for i in range(M):
    a = -heapq.heappop(A) // 2
    heapq.heappush(A, -a)
    

print(-sum(A))

Measured memory_bytes: 14184
h,w,d= map(int,input().split())
loc=[[] for _ in range(w*h+1)]
cost=[0]*(w*h+1)
for i in range(h):
    l= list(map(int,input().split()))
    for j in range(w):loc[l[j]]=[i,j]
for t in range(w*h+1,0,-1):
    if t+d < w*h+1:
        ti,tj=loc[t+d]
        fi,fj=loc[t]
        tempcost= abs(fi-ti)+abs(fj-tj)
        cost[t]=cost[t+d]+tempcost
q= int(input())
for i in range(q):
    l,r= map(int,input().split())
    print(cost[l]-cost[r])

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

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

int main() {
    long long a, b;
    while(cin >> a) {
        cin >> b;
        long long tmp = gcd(a, b);
        cout << tmp << ' ' << a * b / tmp << endl;
    }
}


Measured memory_bytes: 3060
import java.util.Scanner;

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

    static void solve(Scanner sc) {
        int n = sc.nextInt();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += Math.abs(sc.nextInt() - sc.nextInt()) + 1;
        }
        System.out.println(sum);
    }
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, ans = 0;
	long long d;
	cin>>n>>d;
	d = d * d;
	while(n--){
		long long x, y;
		cin>>x>>y;
		if(d >= ((x * x) + (y * y))) ans++;
	}
	cout<<ans<<'\n';
	return 0;
}
//ios_base::sync_with_stdio(false);
//cin.tie(0);
//tod-ngen


Measured memory_bytes: 3612
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

# n, k = map(int, input().split())
n = int(input())
x = list(map(int,input().split()))
x.sort()
# print(x)
base = x[0]
min = 10 ** 9
for _ in range(x[n-1] - x[0] + 1):
    dist = sum((base - x[j])**2 for j in range(n))
    min = dist if dist <= min else min
    base += 1

print(min)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
int Res(int a, int b) {
  if (a > b) {
    return Res(b, a);
  }
  if (b % a == 0) {
    return 2 * b - a;
  }
  
  return 2 * (b / a) * a + Res(a, b % a);
}
    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int n, x;
  cin>>n>>x;
  cout<<n + Res(x, n - x)<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 36

int main(){
  int n,i,j,minj;
  char tmp[3],A[N][3],B[N][3],S[N][3];
  
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%s",A[i]);
  }
  
  for(i=0;i<n;i++){
    strcpy(B[i],A[i]);
    strcpy(S[i],A[i]);
  }
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(B[j][1]<B[j-1][1]){
	strcpy(tmp,B[j]);
	strcpy(B[j],B[j-1]);
	strcpy(B[j-1],tmp);
      }
    }
  }

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(S[j][1]<S[minj][1]){
	minj = j;
      }
      
    }
    strcpy(tmp,S[i]);
    strcpy(S[i],S[minj]);
    strcpy(S[minj],tmp);
  }

  for(i=0;i<n;i++){
    printf("%s",B[i]);
    if(i<n-1){
      printf(" ");
    }else{
      printf("\nStable\n");
    }
  }

  for(i=0;i<n;i++){
    printf("%s",S[i]);
    if(i<n-1){
      printf(" ");
    }else{
      printf("\n");
    }
  }
  j=0;
  for(i=0;i<n;i++){
    if(strcmp(B[i],S[i])!=0){
      j=1;
    }
  }
  
  if(j==0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  return 0;
}



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

using namespace std;

int main() {
    int n;
    string s;

    cin >> n;
    cin >> s;

    if(n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var S, ans string
	fmt.Scan(&S)

	D := make(map[rune]int)

	for _, s := range S {
		D[s] += 1
	}

	if D['a']*D['b']*D['c'] == 1 {
		ans = "Yes"
	} else {
		ans = "No"
	}

	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int k;
void check(char tex[]){
	char* tt; int n;
	tt=tex;
	n=strlen(tt);
	if(ispunct(tt[n-1])){tt[n-1]='\0';n--;}
	if(ispunct(tt[0])){tt=&tt[1];n--;}
	if(2<n && n<7){printf("%s%s",k>0?" ":"",tt);k++;}
}
int main(void){
	char tex[100];k=0;
	while(scanf("%s",tex)!=EOF)check(tex);
	printf("\n");
	return 0;
}

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

ll vis[100001];
void dfs(vector<ll> v[],int e)
{
	vis[e]=1;
	for(auto itr: v[e])
	{
		if(!vis[itr])
		{
			dfs(v,itr);
		}
	}
}


int main()
{
	string s,t,u;
	ll a,b;
	cin>>s>>t>>a>>b>>u;
	if(u==s)
		a--;
	else
		b--;
	cout<<a<<" "<<b<<"\n";
	return 0;
}

Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/


int main() {
	ll a, b, c; 
	cin >> a >> b >> c;
	if (a == b && b == c) {
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) cout << 0 << endl;
		else cout << -1 << endl;
		return 0;
	}

	ll cnt = 0;
	ll ca, cb;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		ca = a; cb = b;
		a = (b + c) / 2;
		b = (c + ca) / 2;
		c = (cb + ca) / 2;
		cnt++;
	}
	cout << cnt << "\n";
} 



Measured memory_bytes: 256
n = int(input())
c = 0
a = [105,165,195]
if (n<105):
    print(0)
elif (105<=n and n<135):
    print(1)
elif (n >= 195):
    print(5)
elif (135<=n and n<165):    
    print(2)
elif (165<=n and n<189):
    print(3)
else:
    print(4)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

#define INF (1<<29)
#define Cost first.first
#define Dir first.second
#define X second.first
#define Y second.second

using namespace std;

typedef pair<int,int> p2;
typedef pair<p2,p2> p4;

int w,h,g[4][31][31],s[31][31],c[4];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int dijkstra(){

  priority_queue<p4,vector<p4>, greater<p4> >que;

  for(int i=0;i<4;i++)
    for(int j=0;j<31;j++)
      for(int k=0;k<31;k++)g[i][j][k]=INF;
  
  g[0][0][0]=0;
  
  p4 st = p4(p2(0,0),p2(0,0));
  que.push(st);

  bool fg=false;

  while(!que.empty()){
    p4 now = que.top();
    que.pop();

    if(now.Y==h-1 && now.X==w-1)return now.Cost;    
    if(g[now.Dir][now.Y][now.X]<=now.Cost && fg)continue;
    fg=true;
    g[now.Dir][now.Y][now.X]=now.Cost;
    
    for(int d=0;d<4;d++){
      int index=(now.Dir+d)%4;
      int nx=now.X+dx[index],ny=now.Y+dy[index];
      if(0<=nx && nx<w && 0<=ny && ny<h){
	p4 next;
	next.Cost=now.Cost+c[d]*(s[now.Y][now.X]!=d);
	next.Dir=index;
	next.X=nx,next.Y=ny;
	que.push(next);
      }
    }
  }
  return -1;
}

int main(void){
  
  while(cin >> w >> h,w|h){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> s[i][j];
      }
    }
    
    for(int i=0;i<4;i++)cin >> c[i];

    cout << dijkstra() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1348