akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
  int n = 0;
  int i = 0;
  long a[10000] = {0};
  long min = 1000001;
  long max = -1000001;
  long sum = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%ld", &a[i]);

  for(i = 0; i < n; i++){
    if(a[i] > max)
      max = a[i];
    
    if(a[i] < min)
      min = a[i];

    sum += a[i];
  } 

  printf("%ld %ld %ld\n", min, max, sum);
  
  return 0;
}

Measured memory_bytes: 684
A, B = map(int, input().split())

#print((25*0.1)//1 == 2)
flag = 1
for i in range(1,100000):
    if (i*0.08)//1==A and (i*0.1)//1==B:
        flag = 0
        print(i)
        break

if flag:
    print("-1")

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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;

signed main(){
    cin >> N;
    ll p = pow(10, 9);
    ll Q = p-N%p;
    ll P = N/p+1;
    if(Q==p) {
        P = N/p;
        Q = 0;
    }
    cout << 0 << " " << 0 << " " << p << " " << Q << " " << 1 << " " << P;
    return 0;
}

Measured memory_bytes: 256
import copy
n,m=map(int, input().split(" "))
d={}
for i in range(m):
    p,y=map(int, input().split(" "))
    d[i]=10**10*p+y
#print(d)
#dct = sorted(d.items())
d2={}
dct=sorted(d.items(), key=lambda x: x[1])
#print(dct)
init=-999

count=1
for k, v in dct:#.items():
    pref=str(v//10**10)
    if pref != init:
        count=1
    else:
        count+=1

    in_pref=str(pref)
    in_count=str(count)
    while len(in_pref)!=6:
        in_pref="0"+in_pref
    while len(in_count)!=6:
        in_count="0"+in_count

    init=pref
    d2[k]=in_pref+in_count

dct2=sorted(d2.items(), key=lambda x: x[0])
for k, v in dct2:
    print(v)


Measured memory_bytes: 45632
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define M 1000000
using namespace std;

void solve(){
    
    ll n;
    cin>>n;
    ll A;
    ll P=100;
    int t=1;
    while(true){

        P = P*pow((1.01),1);
        
        if(P>=n){
            cout<<t;
            break;
        }


        t++;
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    long t;
    // cin>>t;
    t=1;
    while(t--)
    {
    solve();
    }
}


Measured memory_bytes: 3652
#define rep(i, n) for(int i=0; i<n; i++)
template<class T> inline void chmin(T & a, const T b) { if (a > b) a = b; }
template<class T> inline void chmax(T & a, const T b) { if (a < b) a = b; }
typedef long long llong;

#include <bits/stdc++.h>
using namespace std;
int main(void) {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) scanf("%d", &a[i]);

	llong res = 0;
	llong sum = 0;
	int right = 0;
	for (int left = 0; left < n; left++) {
		while (right < n && (sum ^ a[right]) == (sum + a[right])) {
			sum += a[right];
			right++;
		}

		res += (right - left);

		if (left == right) right++;
		else sum -= a[left];
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    int a[3]={0};
    a[A-1] = 1;
    a[B-1] = 1;
    for(int i =0;i < 3;i++)
    {
        if(a[i]==0)
        {
           cout << i+1 << endl; 
        }
    }
    return 0;
}


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

int main(){

    int n;
    cin >> n;

    deque<int> v;

    for (int i = 0; i < n; i++)
    {
        int a; cin >> a;
        if(a==0){
            int b,c; cin >> b >> c;
            if(b == 0)
                v.push_front(c);
            else
                v.push_back(c);
        }
        else if(a==1){
            int b; cin >> b ;
            cout << v[b] << endl;
        }
        else{
            int b; cin >> b;
            if(b == 0)
                v.pop_front();
            else
                v.pop_back();
        }

    }


}


Measured memory_bytes: 4508
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define ll long long
#define ii pair<int,int>
ll ara[200005];char st[200004];
ll aa[200004]; ll bb[200004];
int main()
{
    ll a,b,c,d,m,n,i,j,k,l,t,x,y,z;

        ll ans=0;
        ll maxi=0,mini=0,sum=0,mul=1;
        string st,ch;
        cin>>st>>ch;
        n=st.length();
        for(i=0;i<n;i++)
        {
            if(st[i]!=ch[i]) ans++;
        }
        cout<<ans<<endl;



    return 0;
}






Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

/*
    Author: Koushik Sahu
    Created: 29 August 2020 Sat 17:43:13
*/

int n, a;
ll ans=0;

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>n;
    ll prev = -1; 
    for(int i=0; i<n; i++){
        cin>>a;
        if(prev==-1){
            prev = a;
        }else{
            ans += ((prev*a)%MOD);
            ans %= MOD;
            prev += a;
            prev %= MOD;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3640
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  ll X,Y;
  cin>>X>>Y;
  int count=0;
  ll A=X;
  while(A<=Y){
    count++;
    A=A*2;

  }
  cout<<count<<endl;
}

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

const double EPS = 1e-12;

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b)))
		return 0;
	return a + b;
}

struct P {
	double x, y;
	P() {};
	P(double x, double y) : x(x), y(y) {
	}

	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}

	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}

	P operator * (double d) {
		return P(x * d, y * d);
	}

	P operator / (double d) {
		return P(x / d, y / d);
	}

	// 内積
	double dot(P p) {
		return add(x * p.x, y * p.y);
	}

	// 外積
	double det(P p) {
		return add(x * p.y, -y * p.x);
	}
};

// 線分上に点があるか
bool on_seg(P p1, P p2, P q) {
	return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}

// 直線と直線の交点
P intersection(P p1, P p2, P q1, P q2) {
	return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

// 2直線の直行判定
bool line_orth(P a1, P a2, P b1, P b2) {
	return fabs((a1 - a2).dot(b1 - b2)) < EPS;
}

// 2直線の平行判定
bool line_paral(P a1, P a2, P b1, P b2) {
	return fabs((a1 - a2).det(b1 - b2)) < EPS;
}

// 進行方向
int ccw(P a, P b, P c) {
	a = b - a; b = b - c;
	if (a.det(b) > 0)
		return +1;
	else if (a.det(b) < 0)
		return -1;
	return 0;
}

int main(void) {
	string str;
	while (getline(cin, str)) {
		replace(str.begin(), str.end(), ',', ' ');
		stringstream buf(str);
		P p[4];
		for (int i = 0; i < 4; i++) {
			buf >> p[i].x >> p[i].y;
		}

		int cnt = 0, n = 0;
		for (int i = 0; i < 4; i++) {
			int c = ccw(p[i], p[(i+1)%4], p[(i+2)%4]);
			cnt += c;
			n += abs(c);
		}

		cout << (abs(cnt) == n ? "YES" : "NO") << endl;
	}
}

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

int main()
{
  int a,b,x;
  cin >> a >> b;
  if((a + b) % 2 == 0)
    x = (a + b)/2;
  else 
    x = (a + b) / 2 + 1;
    
  cout << x << endl;
}

Measured memory_bytes: 3564
#include<stdio.h>

const int N=100;
const int K=100;

int main(void)
{
	int n ,m ,a[K][N]={0},b[N]={0} ,c[N]={0} , d[N]={0};
	
	scanf("%d %d",&n ,&m);
	
	for(int i =0 ; i<n ; i++)
	{
		for(int j =0;j<m ; j++)
		{
			scanf(" %d",&a[i][j]);
			
			b[i]+=a[i][j];
		}
		
	}
	for(int i =0 ; i<n ; i++)
	{
		for(int j =0;j<m ; j++)
		{
			printf("%d",a[i][j]);
			printf(" ");
		}
		printf("%d",b[i]);	
		printf("\n"); 
	}
	for(int j =0 ; j<m ; j++)
	{
		for(int i =0 ; i<n ; i++)
		{
			c[j]+=a[i][j];
			d[j+1]+=b[i];
			
		}
	}
	int j;
	for(int j =0 ; j<m ; j++)
	{    
	   printf("%d",c[j]);
	   printf(" ");

	}
	printf("%d",d[j+1]);
	printf("\n"); 
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A,B,C;
  	cin>> A >> B >> C;
  	string ans="No";
  	
  if(A==B && B!=C){
    ans="Yes";
  }
  if(A==C && A!=B){
    ans="Yes";
  }
  if(B==C && A!=B){
   	ans="Yes";
  }
  
  	
  	cout<<ans<<endl;
}

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 N;
    cin >> N;
    int B[N-1];
    int A[N];
    rep(i,N-1)cin >> B[i];
    A[0]=B[0];
    for(int i=1;i<N-1;i++){
        A[i]=min(B[i-1],B[i]);
    }
    A[N-1]=B[N-2];
    int ans=0;
    rep(i,N)ans+=A[i];
    cout << ans << endl;

    
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  char c;
  int i=1;
  int e=0;
  while((c=getchar())!=EOF){
    if(i%2==1 && c=='L'){
      e++;
    }else if(i%2==0 && c=='R'){
      e++;
    }
    i++;
  }
  puts((e==0)?("Yes"):("No"));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define bash push_back
#define all(x) x.begin(),x.end()
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
const int INF=1 << 30;
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vit;
typedef map<string,int> mstit;
typedef priority_queue<int> pqit;
 

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int a[4];
  FOR(I,3) cin >>a[I];
  sort(a,a+3,greater<int>());
  cout <<a[0]*10+a[1]+a[2] fin;


  

  return 0;
}


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

using namespace std;

int m,n;
vector<int>v;

bool C(int x){

  int cnt=0,sum=0,i=0;
  while(i<n && cnt<m){
    if(sum+v[i]<=x)sum+=v[i],i++;
    else sum=0,cnt++;
  }
  return m>cnt;
}

int main(void){

  while(cin >> m >> n,m|n){
    v.clear();

    int l=0,r=100000000,a;
    for(int i=0;i<n;i++){
      cin >> a;
      v.push_back(a);
    }
    
    while(r-l>1){
      int mid=(l+r)/2;
      if(C(mid))r=mid;
      else l=mid;
    }
    cout << r << endl;
  }

  return 0;
}

Measured memory_bytes: 1216
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <functional>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int Q, l, r, q[100005], ans[100005], i, j;

	for (i = 0; i < 100005; i++) {
		q[i] = 1;
	}
	q[0] = q[1] = 0;
	for (i = 2; i < 1100; i++) {
		if (q[i] == 1) {
			for (j = i * 2; j < 100005; j += i) {
				q[j] = 0;
			}
		}
	}

	for (i = 0; i < 100005; i++) {
		ans[i] = q[i];
	}

	for (i = 1; i < 100005; i++) {
		ans[i] = ans[i - 1] + q[i];
		if (q[i] == 1) {
			if (q[(i + 1) / 2] != 1) {
				ans[i]--;
			}
		}
	}

	cin >> Q;
	for (i = 0; i < Q; i++) {
		cin >> l >> r;
		cout << ans[r] - ans[l - 1] << endl;
	}
}

Measured memory_bytes: 1408
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def dfs(x):
        fx = ans[x]
        nf = fx*inv[s[x]-1]%mod
        sx = s[x]
        for y in v[x]:
            sy = s[y]
            nsx = sx-sy
            nsy = s[x]
            if ans[y] == None:
                fy = nf*s[y]*f[nsy-1]*p[nsx]%mod
                ans[y] = fy
                s[x] = nsx
                s[y] = nsy
                dfs(y)
                s[x] = sx
                s[y] = sy

    n = I()
    f = [1]
    for i in range(1,n+1):
        f.append(f[-1]*i%mod)
    inv = [None]*(n+1)
    inv[n] = pow(f[n],mod-2,mod)
    for i in range(n)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod

    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = [0]*n
    d[0] = 1
    q = deque([0])
    p = [None]*n
    while q:
        x = q.popleft()
        nd = d[x]+1
        for y in v[x]:
            if not d[y]:
                d[y] = nd
                p[y] = x
                q.append(y)
    V = list(range(n))
    V.sort(key = lambda x:-d[x])
    m = d[V[0]]
    s = [0]*n
    res = 1
    for i in V:
        j = p[i]
        s[i] += 1
        if j != None:
            s[j] += s[i]
            res *= inv[s[i]]
        if d[i] == m:
            continue
        res *= f[s[i]-1]
        res %= mod
    ans = [None]*n
    ans[0] = res
    p = [pow(i,mod-2,mod) for i in range(n+1)]
    dfs(0)
    for i in ans:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


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

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

#define MAX 100005
#define INF INT_MAX

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

void preorder(Node u);
void inorder(Node u);

Node root;

Node treeMinimum(Node x)
{
    return NIL;
}
Node treeMaximum(Node x)
{
    return NIL;
}
Node treeSearch(Node u, int k)
{
    Node ret;
    if (u == NIL) return NIL;

    if (k < u->key) ret = treeSearch(u->left, k);
    else if (k > u->key) ret = treeSearch(u->right, k);
    else ret = u;

    return ret;
}
Node treeSuccessor(Node x)
{
    return NIL;
}
void treeDelete(Node z)
{
    Node y; // node to be deleted
    Node x; // child of y
}

void insert(int k)
{
    Node y = NIL;
    Node x = root;
    Node z;

    z = (Node)malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (k < x->key) x = x->left;
        else x = x->right;
    }
    if (y == NIL) root = z;
    else if (k < y->key) y->left = z;
    else y->right = z;
}

void inorder(Node u)
{
    if (u == NIL) return;
    
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);    
}
void preorder(Node u)
{
    if (u == NIL) return;

    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main(int, char**)
{
    int n, i, x;
    string com;
    cin >> n;

    for ( i = 0; i < n; i++ ){
        cin >> com;
        if ( com[0] == 'f' ){
            cin >> x;
            Node t = treeSearch(root, x);
            if ( t != NIL ) cout << "yes" << endl;
            else cout << "no" << endl;
        } else if ( com[0] == 'i' ){
            cin >> x;
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if ( com[0] == 'd' ){
            cin >> x;
            treeDelete(treeSearch(root, x));
        }
    }
    return 0;
}



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

int main(){
    int N; cin >> N;
    int C[N+1], S[N+1], F[N+1];
    for(int i = 1; i < N; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i = 1; i < N; i++){
        ll t = 0;
        for(int j = i; j < N; j++){
            if(t < S[j]) t += S[j]-t;
            // if(i == 2 && j == 3){
            //     cout << j<< ' '<<t << endl;
            //     cout << t% F
            // }
            if(t % F[j] != 0){
                // if(i == 2 && j == 3) cout << "here" << endl;
                t += F[j] - (t % F[j]);
            }
            t += C[j];
            // if(i == 2) cout << j<< ' '<<t << endl;
        }
        cout << t << endl;
    }
    cout << 0 << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    double x;
    cin >> x;

    cout << setprecision(20) << pow(x / 3.0, 3.0) << endl;
}

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

vector<int> st;
vector<int> top;

vector<int> calc(int a, int b, int n) {
    if (n == 1) return {a, b};
    int s = __builtin_ffs(a^b);
    int t = 0;
    if ((a & (1 << (s-1))) != 0) t = (1 << (s-1));
    int u = (1 << (s-1)) - 1;
    int aa = (a & u) + ((a >> 1) & ~u);
    int bb = (b & u) + ((b >> 1) & ~u);
    int d = aa ^ 1;
    //cout << a << b << " " << aa << " " << bb << " " << d <<  endl;
    vector<int> e = calc(aa, d, n-1), f = calc(d, bb, n-1);
    for (int i = 0; i < (int)e.size(); i++) e[i] = ((e[i] & ~u) << 1) + t + (e[i] & u);
    for (int q : f) e.push_back(((q & ~u) << 1) + u + 1 - t + (q & u));
    return e;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    B ^= A;
    if (__builtin_parity(B) == 0) {
        cout << "NO" << endl;
        return 0;
    }
    vector<int> base;
    base.push_back(0);
    for (int i = 0; i < N; i++) {
        int t = 1 << i;
        if ((B & t) == 0) {
            for (int j = (int)base.size()-1; j >= 0; j--) {
                base.push_back(base[j]+t);
            }
        }
    }
    
    for (int i = 0; i < N; i++) {
        if (((B>>i) & 1) != 0) st.push_back(i);
    }
    
    top = calc(0, (1<<(int)st.size()) - 1, (int)st.size());
    
    for (int i = 0; i < (int)top.size(); i++) {
        int nt = 0;
        for (int j = 0; j < (int)st.size(); j++) {
            if ((top[i] >> j)&1) nt += (1 << (st[j]));
        }
        top[i] = nt;
    }
    
    //for (int x : top) cout << x << endl;
    vector<int> ans;
    for (int i = 0; i < (int)top.size(); i++) {
        if (i%2 == 0) {
            for (int j = 0; j < (int)base.size(); j++) {
                ans.push_back(A^top[i]^base[j]);
            }
        }else {
            for (int j = (int)base.size()-1; j >= 0; j--) {
                ans.push_back(A^top[i]^base[j]);
            }
        }
    }
    cout << "YES\n";
    for (int i = 0; i < (1<<N); i++) {
        if (i < (1<<N)-1) printf("%d ", ans[i]);
        else printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1820
#include <iostream>
using namespace std;
int main(void){
    int N = 0;
    int t = 0;
    cin >> N;
    for(int i = 1;i < 10;i++){
        if(N % i == 0)
        t=i;
    }
    
    if(N / t > 9)
    cout << "No" << endl;
    else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()

lis = ["Sunny","Cloudy","Rainy"]

idx = (lis.index(s) +1) % 3
ans = lis[idx]

print(ans)

Measured memory_bytes: 12504
n = int(input())
h = list(map(int,input().split()))
res = 'Yes'
if n != 1:
    for i in range(n-1,0,-1):
        if h[i]<h[i-1]:
            h[i-1] -= 1
        if h[i]<h[i-1]:
            res = 'No'
            break
print(res)

Measured memory_bytes: 14396
n=int(input())
li = []
for i in range(n):
  li += [int(input())]
x = li[0]
if x == 2:
    print(1)
    exit()
ans = -1
count=0
for i in range(n):
  x = li[x-1]
  count +=1
  if x == 2:
    print(count+1)
    exit()
print(-1)


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

const int N = 3003, mod = 1e9 + 7;

int n, a[N], dp[2][N][N];

int solve(int l, int r, bool p) {
	if (l > r) {
		if (!p) return 0;
		return INT_MAX;
	}
	if (dp[p][l][r]) return dp[p][l][r];
	if (l == r) {
		if (!p) return a[l];
		else return -a[r];
	}
	if (!p) return dp[p][l][r] = max(a[l] + solve(l + 1, r, 1), a[r] + solve(l, r - 1, 1));
	return dp[p][l][r] = min(solve(l + 1, r, 0) - a[l], solve(l, r - 1, 0) - a[r]);
}

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	cout << solve(1, n, 0);
}

Measured memory_bytes: 139904
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

//---------------------------------------------
// priority queue
//---------------------------------------------
type pqi struct{ a int }

type priorityQueue []pqi

func (pq priorityQueue) Len() int            { return len(pq) }
func (pq priorityQueue) Swap(i, j int)       { pq[i], pq[j] = pq[j], pq[i] }
func (pq priorityQueue) Less(i, j int) bool  { return pq[i].a < pq[j].a }
func (pq *priorityQueue) Push(x interface{}) { *pq = append(*pq, x.(pqi)) }
func (pq *priorityQueue) Pop() interface{} {
	x := (*pq)[len(*pq)-1]
	*pq = (*pq)[0 : len(*pq)-1]
	return x
}

type dat struct {
	score, k int
}

func f() {
	N := getInt()
	ans := 0
	L := make([]dat, 0)
	R := make([]dat, 0)
	for i := 0; i < N; i++ {
		k, l, r := getInt(), getInt(), getInt()
		ans += min(l, r)
		if l > r {
			L = append(L, dat{abs(l - r), k})
		}
		if r > l && k != N {
			R = append(R, dat{abs(l - r), N - k})
		}
	}

	sort.Slice(L, func(i, j int) bool {
		return L[i].k < L[j].k
	})
	sort.Slice(R, func(i, j int) bool {
		return R[i].k < R[j].k
	})

	// out(L, R)
	// L
	pqL := priorityQueue{}
	k := 1
	for i := 0; i < len(L); i++ {
		if L[i].k != k {
			for len(pqL) > k {
				heap.Pop(&pqL)
			}
			k = L[i].k
		}
		heap.Push(&pqL, pqi{L[i].score})
	}
	for len(pqL) > k {
		heap.Pop(&pqL)
	}
	// L
	pqR := priorityQueue{}
	k = 1
	for i := 0; i < len(R); i++ {
		if R[i].k != k {
			for len(pqR) > k {
				heap.Pop(&pqR)
			}
			k = R[i].k
		}
		heap.Push(&pqR, pqi{R[i].score})
	}
	for len(pqR) > k {
		heap.Pop(&pqR)
	}
	for _, e := range pqL {
		ans += e.a
	}
	for _, e := range pqR {
		ans += e.a
	}
	// out(pqL, pqR)
	out(ans)
}

func main() {
	sc.Split(bufio.ScanWords)
	T := getInt()
	for i := 0; i < T; i++ {
		f()
	}
}


Measured memory_bytes: 13652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 10000000000000


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

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

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

template<class T>
class Vec3
{
	public:
		T act[3];
};

int Stair( int now, vector<ll> &H )
{
	if( H[now] >= H[now+1] ){}
	
}

int main(void) {
	
	ll N,K,Q;
	inp(N);
	inp(K);
	inp(Q);
	vector<int>A(Q);
	vector<ll>point(N,0);
	rep(q,Q){
		inp(A[q]);
		A[q]--;
	}

	
	if(K>Q){
		rep(i,N) out("Yes");
		return 0;
	}
	
	rep(q,Q){
		point[A[q]]++;
	}
	rep(i,N){
		string ans;
		if(Q-point[i]<K){ans="Yes";
		}else{ans="No";}
		out(ans);
	}
	
		
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
ahu=[]
asei=[]
hu=0
ans=0
for i in range(1,n+1):
  if a[i-1]-i<0:
    hu+=1
    ahu.append(abs(a[i-1]-i))
  else:
    asei.append(a[i-1]-i)
  ans+=abs(a[i-1]-i)  
sei=n-hu
asei.sort()
ahu.sort()
#print(ahu)
#print(asei)
#print(ans)
rui=0
if sei<hu:
  for i in range((hu-sei)//2+1):
    ans-=(hu-sei-2*i)*(ahu[i]-rui)
    rui=ahu[i]
  print(ans)
elif sei>hu:
  for i in range((sei-hu)//2+1):
    ans-=(sei-hu-2*i)*(asei[i]-rui)
    rui=asei[i]
  print(ans)
else:
  print(ans)



Measured memory_bytes: 30972
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793

int main(){
    int a,b,c;
    double s,l,h;
    scanf("%d %d %d",&a,&b,&c);
    s = a*b*sin(c*PI/180)/2;
    l = sqrt(a*a+b*b-2*a*b*cos(c*PI/180))+a+b;
    h = b*sin(c*PI/180);
    printf("%f %f %f\n",s,l,h);
}

Measured memory_bytes: 1088
A, B = map(int, input().split())
C = [0] * 1001
D = [0] * 1001
for i in range(80):
  C[-(-(i + 1) * 100 // 8)] += 1
for i in range(100):
  D[(i + 1) * 10] += 1
for i in range(1000):
  C[i + 1] += C[i]
  D[i + 1] += D[i]
for i in range(1, 1001):
  if C[i] == A and D[i] == B:
    print(i)
    break
else:
  print(-1)


Measured memory_bytes: 3064
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#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 ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll modpow(ll x,ll y,ll M=mod)
{
	ll ans=1;
	while(y>0){
		if(y&1) ans=(ans*x)%M;
		y=y>>1;
		x=(x*x)%M;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n,k;
	cin>>n>>k;
	lvi fact(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++)
	{
		fact[i]=(fact[i-1]*i)%mod;
	}
	ll ans=0;
	for(ll i=0;i<=min(k,n-1);i++)
	{
		ll nmr=(fact[n]*fact[n-1])%mod;
		ll dnm=(fact[n-i]*fact[i])%mod;
		dnm=(dnm*fact[n-1-i])%mod;
		dnm=(dnm*fact[i])%mod;
		ll res=(nmr*modpow(dnm,mod-2))%mod;
		ans=(ans+res)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

int gcd(int n, int m) {
  if (n == 0) {
    return m;
  } else if (m < n) {
    return gcd(m, n);
  } else {
    return gcd(m % n, n);
  }
}


int main() {
  long long int n, m;
  while ((cin >> n >> m)) {
    long long int gcd_nm = gcd(n, m);
    long long int lcm_nm = n * m / gcd_nm;
    cout << gcd_nm << " " << lcm_nm << endl;
  }
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

int main() {

    int n, m;
    cin >> n >> m;
    map<int, vector<int>> v;

    rep(i, n) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    ll sum = 0;
    priority_queue<int> q;
    rep(i, m + 1) {
        if (v.find(i) != v.end()) {
            for (int b : v[i]) {
                q.push(b);
            }
        }
        if (!q.empty()) {
            int t = q.top();
            sum += t;
            q.pop();
        }
    }
    cout << sum << endl;
}





Measured memory_bytes: 10880
#include <iostream>

using namespace std;

int main()
{
    int N,K;
    int a,b;

    cin >> N >> K;

    for(int i=0; i<K; ++i) {
        cin >> a >> b;
        if(a>=b) {
            if(a+b<=N+1) { // upper
                cout << (b-1)%3 +1 << endl;
            } else { // right
                cout << (N-a)%3 +1 << endl;
            }
        } else {
            if(a+b<=N+1) { // left
                cout << (a-1)%3 + 1 << endl;
            } else { // lower
                cout << (N-b)%3 + 1 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdint>

int main() {
  std::int64_t A, V, B, W, T;
  std::cin >> A >> V >> B >> W >> T;
  if (V <= W) {
    std::cout << "NO" << std::endl;
    return 0;
  }
  if ((V - W) * T < std::abs(A - B)) {
    std::cout << "NO" << std::endl;
    return 0;
  }
  std::cout << "YES" << std::endl;
  return 0;
}


Measured memory_bytes: 3620
k,x=map(int,input().split())

ans=[]

lx=max(-1000000,x-k+1)
rx=min(1000000,x+k-1)

if k ==1:
    print(x)
else:
    for i in range(lx,x):
        ans.append(str(i))
    ans.append(str(x))
    for i in range(x+1,rx+1):
        ans.append(str(i))
    print(" ".join(ans))

Measured memory_bytes: 3060
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/agc009/tasks/agc009_b

//参考：
//http://tutuz.hateblo.jp/entry/2018/10/09/052545

//ポイント：
//グラフとトーナメントを対応させ、DFSを行う

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
vector<vector<LL>> adj;

LL ans = INF;

LL dfs(LL now=1,LL prev=-1){
	//頂点1を根としてみなした時、
	//頂点nowより下の木が表す
	//トーナメントの深さをこの関数は返す
	vector<LL> depth;
	for(auto next:adj[now]){
		if(next==prev) continue;
		depth.push_back(dfs(next,now));
	}
	if(depth.size()==0) return 0;
	sort(depth.begin(),depth.end(),greater<LL>());
	LL ret = -1;
	for(int i=0;i<depth.size();i++){
		depth[i] += (i+1);
		ret = max(ret,depth[i]);
	}
	return ret;
}

void solve(){
	ans = dfs();
}

int main(){
    cin >> N;
    adj = vector<vector<LL>>(N+1);
    for(int i=2;i<=N;i++){
    	LL a;cin >> a;
    	adj[i].push_back(a);
    	adj[a].push_back(i);
    }

    solve();

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

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    ll e[N+1];
    e[0] = 1;
    rep(i, N) e[i+1] = 2*e[i];
    ll S;
    map<ll, ll> mp;
    rep(i, e[N]){
        cin >> S;
        if(mp.count(S)) mp[S]++;
        else mp[S] = 1;
    }
    vector<ll> vec;
    map<ll, ll>::iterator ite;;
    ite = mp.end();
    ll tmp;
    ite--;
    tmp = ite->first;
    vec.push_back(tmp);
    mp[tmp]--;
    if(mp[tmp] == 0) mp.erase(tmp);
    rep(i, N){
        rep(j, e[i]){
            ll k = vec[j];
            if(!mp.count(k)) mp[k] = 0;
            ite = mp.find(k);
            if(ite == mp.begin()){
                cout << "No" << endl;
                exit(0);
            }
            ite--;
            tmp = ite->first;
            vec.push_back(tmp);
            mp[tmp]--;
            if(mp[tmp] == 0) mp.erase(tmp);
            if(mp[k] == 0) mp.erase(k);
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;
using ll = long long int ;
using vi = vector<ll>;
using matrix = vector<vi>;
const int mod = 1000000007;
int n;
matrix cross(matrix a, matrix b) {
    matrix c(n, vi(n, 0));
    for (int i = 0; i<n; ++i) {
        for (int k = 0; k<n; ++k) {
            for (int j = 0; j<n; ++j) {
                c[i][j] += a[i][k] * b[k][j];
                if (c[i][j] >= mod) c[i][j] %= mod;
            }
        }
    }
    return c;
}

matrix bxp(matrix base, ll xp) {
    matrix ans(n, vi(n));
    for (int i = 0; i<n; ++i) ans[i][i] = 1;
    while (xp) {
        if (xp&1ll) ans = cross(ans, base);
        base = cross(base, base);
        xp>>=1ll;
    }
    return ans;
}

int main() {
    int m;
    ll k;
    scanf("%d %lld", &n, &k);
    matrix base(n, vi(n));
    for (int i = 0; i<n; ++i) {
        for (int j = 0; j<n; ++j) {
            scanf("%lld", &base[i][j]);
        }
    }
    base = bxp(base, k);
    ll ans = 0;
    for (int i = 0; i<n; ++i) {
        for (int j = 0; j<n; ++j) {
            ans += base[i][j];
            if (ans >= mod) ans -= mod;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;


signed main() {

    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    if (n & 1) cout << 1.0 * (n / 2 + 1) / n;
    else cout << 0.5 << endl;
    
    return 0;
}

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

int h, w;
int a[80][80];
int b[80][80];
bool tbl[80][80][12800];

const int MAXV = 12800;

int main(void) {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> b[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			bool *v = tbl[i][j];
			memset(v, 0, MAXV);
			int r = abs(a[i][j] - b[i][j]);
			if (i == 0 && j == 0) {
				v[r] = true;
				continue;
			}
			if (i > 0) {
				bool *v0 = tbl[i - 1][j];
				for (int k = 0; k < MAXV; k++) {
					if (v0[k]) {
						v[k + r] = true;
						v[abs(k - r)] = true;
					}
				}
			}
			if (j > 0) {
				bool *v0 = tbl[i][j - 1];
				for (int k = 0; k < MAXV; k++) {
					if (v0[k]) {
						v[k + r] = true;
						v[abs(k - r)] = true;
					}
				}
			}
		}
	}
	bool *v = tbl[h - 1][w - 1];
	int m = (1 << 30);
	for (int i = 0; i < MAXV; i++) {
		if (v[i]) {
			if (i < m) {
				m = i;
			}
		}
	}
	cout << m << endl;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int ans=0;
    while(n>=500){
        ans+=1000;
        n-=500;
    }
    while(n>=5){
        ans+=5;
        n-=5;
    }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,D;
    cin>>N>>D;
    int x;
    vector<vector<int>>X(N,vector<int>());
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>x;
            X[i].pb(x);
        }
    }
    int num;
    int sq;
    int count=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            num=0;
            for(int k=0;k<D;k++){
                num+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            sq=sqrt(num);
            if(sq*sq==num)count++;
        }
    }
    cout<<count<<endl;
}

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

int main()
{
  string n;
  cin >> n;
  ll sum = 0;

  for (ll i = 0; i < n.length(); i++)
  {
    sum += n[i] - '0';
  }

  if (sum % 9)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3748
import java.util.Scanner;

class UnionFindTree {
	int[] par;
	int[] rank;
	int[] peers; //仲間の数
	int[] dis; //根からの距離

	public UnionFindTree(int n){
		par = new int[n];
		rank = new int[n];
		peers = new int[n];

		for(int i=0;i<n;i++){
			par[i] = i;
			peers[i] = 1;
		}
	}

	//木の根を求める
	int find(int x){
		if(par[x] == x){
			return x;
		}
		else{
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y){
		int px = find(x);
		int py = find(y);

		if(px == py){
			return;
		}
		else if(rank[px] < rank[py]){
			peers[py] += peers[px];
			par[px] = py;

		}
		else{
			peers[px] += peers[py];
			par[py] = px;
			if(rank[px]==rank[py]){
				rank[px]++;
			}
		}

	}


	//xとyが同じ集合に属するか
	boolean isEquivalent(int x, int y){
		return find(x) == find(y);
	}

	//xの仲間の数を求める
	int peersnum(int x){
		return peers[find(x)];
	}
}

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[][] S = new int[M][2];
		for(int i = 0 ; i < M ; i++){
			S[i][0] = sc.nextInt();
			S[i][1] = sc.nextInt();
		}
		sc.close();

		int count = 0;
		for(int i = 0 ; i < M ; i++){
			UnionFindTree uf = new UnionFindTree(N);

			for(int j = 0 ; j < i ; j++){
				uf.unite(S[j][0]-1, S[j][1]-1);
			}
			for(int k = i+1 ; k < M ; k++){
				uf.unite(S[k][0]-1, S[k][1]-1);
			}

			int edge = uf.find(0);
			for(int l = 1 ; l < N ; l++){
				if(edge != uf.find(l)){
					count++;
					System.gc();
					break;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 36436
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int A,B;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> A >> B;
  if (A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B/2 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
a = set()
b = set()
ans = 0
for i in range(1,N):
    X = set(S[:i])
    Y = list(set(S[i:]))
    cnt = 0
    for s in Y:
        if s in X:
            cnt += 1
    ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
typedef long long int lli;
const lli mod = 1e9+7;
using namespace std;

int main()
{
	fast;
	
	int x,y,z;cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N + 1, 0);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  for (int i = 0; i < K; i++){
    vector<int> B(N + 1, 0);
    for (int j = 0; j < N; j++){
      B[max(j - A[j], 0)]++;
      B[min(j + A[j] + 1, N)]--;
    }
    for (int j = 0; j < N; j++){
      B[j + 1] += B[j];
    }
    bool update = false;
    for (int j = 0; j < N; j++){
      if (A[j] != B[j]){
        update = true;
        break;
      }
    }
    if (update){
      A = B;
    } else {
      break;
    }
  }
  for (int i = 0; i < N; i++){
    cout << A[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 4844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    
    ll sum = 0;
    for(int i = 1;i<=n;i++){
        if(i%3 != 0 && i%5 != 0)
         sum += i;
    }
    cout << sum;
}









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

using namespace std;

int n;

int v[3];

map <string, int> ap;

vector <string> rez;
int mx;

string s;

int main()
{
    cin >> n;

    for(int i = 1; i <= n; i ++)
    {
        cin >> s;
        ap[s] ++;

        int x = ap[s];

        if(x > mx)
        {
            mx = x;
            rez.clear();
        }

        if(x == mx)
            rez.push_back(s);
    }

    sort(rez.begin(), rez.end());

    for(auto u : rez)
        cout << u << "\n";

    return 0;
}


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

int main(){
  int ans[3] = {0, 0, 0};

  for(int i = 0; i < 10; i++){
    int x;
    cin >> x;

    for(int j = 0; j < 3; j++){
      if(x > ans[j]){
        for(int k = 2; k > j; k--){
          ans[k] = ans[k - 1];
        }
        ans[j] = x;
        break;
      }
    }
  }

  for(int i = 0; i < 3; i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
	int n, x[100], y[100], i, p;
	double sum, max = 0;
	
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &x[i]);
	for(i=0; i<n; i++) scanf("%d", &y[i]);
	
	for(p=1; p<=3; p++){
		sum = 0;
		for(i=0; i<n; i++){
			sum += pow(fabs(x[i]-y[i]), p);
		}
		switch(p){
		case 2:
			sum = sqrt(sum);
			break;
		case 3:
			sum = cbrt(sum);
			break;
		}
		printf("%f\n", sum);
	}
	
	for(i=0; i<n; i++){
		if(fabs(x[i]-y[i]) > max) max = fabs(x[i]-y[i]);
	}
	printf("%f\n", max);
	
	return 0;
}

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

int main(){
    long long n;
    cin>>n;
    string s;
    cin>>s;
    n=s.size();
    long long a=count(s.begin(),s.end(),'R');
    long long b=count(s.begin(),s.end(),'G');
    long long c=count(s.begin(),s.end(),'B');
    long long ans;
    long long less=0;

    for(long long i=0;i<n;i++){
        for(long long j=i+1;j<n;j++){
            if((s[i]=='R' && s[j]=='G') ||(s[i]=='G' && s[j]=='R')){
                if(s[2*j-i]=='B' )less++;
            }
            if((s[i]=='G' && s[j]=='B') ||(s[i]=='B' && s[j]=='G')){
                if(s[2*j-i]=='R')less++;
            }
            if((s[i]=='R' && s[j]=='B') ||(s[i]=='B' && s[j]=='R')){
                if(s[2*j-i]=='G')less++;
            }
        }
    }
    ans=a*b*c;
    ans=ans-less;
    cout<<ans;

}

Measured memory_bytes: 3644
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int a[3],k;cin >> a[0] >> a[1] >> a[2] >> k;
	sort(a, a +3);
	rep(i, k) a[2] *= 2;
	cout << a[0] + a[1] + a[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N, A[1000000], cnt;

void Out(const vector<int> G) {
	cout << G.size() << endl;
	cout << G.back();
	for (int i = G.size() - 2; i >= 0; i--) {
		cout << ' ' << G[i];
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < N; i++)
		cout << A[i] << endl;
}

void InsertionSort(int g) {
	for (int i = g; i < N; i++) {
		int v = A[i], j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}
void ShellSort(const vector<int> G) {
	cnt = 0;
	for (int i = G.size() - 1; i >= 0; i--) {
		InsertionSort(G[i]);
	}
}

int main()
{
	vector<int> G;
	cin >> N;
	int calc = 1;
	while (calc <= N) {
		G.push_back(calc);
		calc = calc * 3 + 1;
	}
	for (int i = 0; i < N; i++)
		cin >> A[i];
	ShellSort(G);
	Out(G);
	return 0;
}



Measured memory_bytes: 7064