akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,m;
  cin >> n >> m;
  vector<list<int>> e(n);
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    a--,b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  vector<int> next(n,-1);
  next[0]=0;
  int two[2]={-1,-1};
  list<int>::iterator itr;
  int zerocount=0;
  for(itr=e[0].begin();itr!=e[0].end();itr++){
    two[zerocount]=(*itr);
    next[(*itr)]=0;
    zerocount++;
    if(zerocount==2) break;
  }
  int now=0;
  bool ok;
  for(int i=0;i<zerocount;i++){
    now=two[i];
    while(1){
      ok=false;
      for(itr=e[now].begin();itr!=e[now].end();itr++){
        if(next[(*itr)]==-1){
          // cout << now+1 << (*itr)+1 << endl;
          ok=true;
          break;
        }
      }
      if(!ok){
        next[now]=now;
        break;
      }
      next[now]=(*itr);
      now=(*itr);
    }
  }
  list<int> path;
  path.push_back(0);
  if(zerocount==1){
    now=two[0];
    while(now!=next[now]){
      path.push_back(now);
      now=next[now];
    }
    path.push_back(now);
  }else{
    now=two[0];
    while(now!=next[now]){
      path.push_back(now);
      now=next[now];
    }
    path.push_back(now);
    now=two[1];
    while(now!=next[now]){
      path.push_front(now);
      now=next[now];
    }
    path.push_front(now);
  }
  cout << path.size() << endl;
  for(itr=path.begin();itr!=path.end();){
    cout << (*itr)+1 << flush;
    itr++;
    if(itr!=path.end()) cout << " " << flush;
    else cout << endl;
  }
  return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <string>
#include <stdlib.h>

#define INC(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define DEC(i, a, b) for(int (i) = (a); (i) > (b); --(i))
#define REP(i, n)    INC(i, 0, n)
#define comp(a, b) int comp(const void *(a), const void *(b))

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int abs(int x){
    return x > 0? x : -x;
}

int max(int a, int b){
    return a > b? a : b;
}

int min(int a, int b){
    return a < b? a : b;
}


int main(){
    int N; cin >> N;
    char c = 'C' + N / 999 - (N % 999 == 0? 1 : 0);
    cout << "AB" << c << endl;
    return 0;
}

Measured memory_bytes: 256
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

s = inp()

if s[2] != s[3]:
  print("No")
  exit()
elif s[4] != s[5]:
  print("No")
  exit()

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fir first
#define sec second
#define MAX_N 200000
#define mid ((s+t)>>1)
using namespace std;
typedef long long lnt;
typedef pair<int,int> pii;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m; vector <pii> p[MAX_N+5];
lnt tr[(MAX_N<<2)+5], tag[(MAX_N<<2)+5];
void modify(int v, int s, int t, int l, int r, lnt x) {
	if (s >= l && t <= r) {tr[v] += x, tag[v] += x; return;}
	if (l <= mid) modify(v<<1, s, mid, l, r, x);
	if (r >= mid+1) modify(v<<1|1, mid+1, t, l, r, x);
	tr[v] = max(tr[v<<1], tr[v<<1|1])+tag[v];
}
int main() {
	read(n), read(m);
	for (int i = 1, l, r, c; i <= m; i++)
		read(l), read(r), read(c), p[r].push_back(pii(l, c));
	for (int i = 1; i <= n; i++) {
		modify(1, 1, n, i, i, tr[1]);
		for (pii q : p[i]) modify(1, 1, n, q.fir, i, q.sec);
	}
	return printf("%lld\n", max(tr[1], 0LL)), 0;
}


Measured memory_bytes: 22656
#include<bits/stdc++.h>
#include <iostream>
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(char c='a';c<='z';c++){
		if(s.find(c)==string::npos){
			cout<<c<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}


Measured memory_bytes: 512
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

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

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

		Arrays.sort(ab, (x, y) -> Integer.compare(y[0], x[0]));

		int ans = 0;
		int prev = Integer.MAX_VALUE;

		for (int i = 0; i < M; i++) {
			if (prev < ab[i][1]) {

			} else {
				prev = ab[i][0];
				ans++;
			}
		}

		out.println(ans);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


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

int main()
{
	long long n;
	cin >> n;
	vector<long long> av(n);
	long long suma = 0;
	for (auto& a : av) {
		cin >> a;
		suma += a;
	}

	long long ret = 0;
	for (long long i = 0; i < n - 1; ++i) {
		suma -= av[i];
		long long tempa = suma % 1000000007;
		ret += av[i] * tempa;
		ret %= 1000000007;
	}

	cout << ret << endl;

	return 0;
}

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

int main() {
  int kotae=0;
  for(int i=0;i<5;i++) {
    int x;
    cin >> x;
    if(x-1==i) {
      kotae++;
    } else {
      kotae++;
      break;
    }
  }
  cout << kotae << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int x,y,gx,gy;
int main () {
cin >> x >> y;
if (x==2) {
	gx=1; 
} else if(x==4||x==6||x==9||x==11) {
	gx=2;
} else {
	gx=3;
}
if (y==2) {
	gy=1;
} else if (y==4||y==6||y==9||y==11) {
	gy=2;
} else {
	gy=3;
}
if (gx==gy) {
	cout << "Yes" << endl;
} else {
	cout << "No" << endl;
}
}


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

int main() {
    int a,b  ;
    cin >> a >> b;
    for(int i = 0; i <= 1000; i++) {
        if((int)(i * .08) == a && (int)(i * .1) == b) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  string s; cin>>s; if(s =="SUN") cout<<7;
  if(s =="SAT") cout<<1;
  if(s =="FRI") cout<<2;
  if(s =="THU") cout<<3;
  if(s =="WED") cout<<4;
  if(s =="TUE") cout<<5;
  if(s =="MON") cout<<6;
  return 0;
}


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

    if(h <= sum){
        printf("Yes");
        return 0;
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 512
n=int(raw_input())
A=map(int,raw_input().split())
A.reverse()
[p,q]=[2,2]
for a in A:
    if p%a==0:
        p=p
    else:
        p=a*(p/a+1)
        if p>q:
            print -1
            break
    q=a*(max(q/a,p/a)+1)-1
else:
    print p,q


Measured memory_bytes: 11316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;


int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = min(a * n, b);
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m,*abs=$<.read.split.map(&:to_i)
abs = abs.each_slice(2).to_a

arr = Array.new(n+1,true)
abs.each do |a,b|
  arr[a] = !arr[a]
  arr[b] = !arr[b]
end

ret = arr.all?

puts (ret ? 'YES' : 'NO')



Measured memory_bytes: 22268
#include <stdio.h>
#include <math.h>
int v[4096][150],a[10],i,j,n,s;
int summing(int n,int s){
    int ans=0,i,max=0,min=0,m,k;
    if(n==1){if(s<10 && a[s]==1)return 1; else return 0;}
    else{
        k=(a[0]+a[1]*2+a[2]*4+a[3]*8+a[4]*16+a[5]*32+a[6]*64+a[7]*128+a[8]*256+a[9]*512)*4+(n-1);
        if(n<5 && s<150 && v[k][s]>=0)return v[k][s];
        for(i=0,m=n;m>0 && i<10;i++){if(a[i]==1){min+=m*i;m--;if(s<min)goto answer;}}
        for(i=9,m=n;m>0 && i>=0;i--){if(a[i]==1){max+=m*i;m--;if(s<=max)break;}}if(s>max)goto answer;
        for(i=0;i<10;i++){
            if(a[i]==1 && n*i<=s){
                a[i]=0;
                ans+=summing(n-1,s-n*i);
                a[i]=1;
            }
        }
        answer:
        if(n<5)v[k][s]=ans;
        return ans;
    }
}
int main(void){
    for(i=0;i<10;i++)a[i]=1;
    for(i=0;i<4096;i++){{for(j=0;j<150;j++)v[i][j]=-1;}}
    while(scanf("%d %d",&n,&s)!=EOF){printf("%d\n",summing(n,s));}
    return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 998244353
#define INF 1000000000000000

int main(){
  int N;
  ll K;
  cin>>N>>K;
  vector<ll> A(N);
  ll sum=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  vector<ll> div;
  for(ll i=1;i*i<=sum;i++){
    if(sum%i==0){
      div.push_back(i);
      if(i!=sum/i){
        div.push_back(sum/i);
      }
    }
  }
  sort(div.begin(),div.end());
  reverse(div.begin(),div.end());

  int i=0;
  while(true){
    vector<ll> B(N);
    for(int j=0;j<N;j++){
      B.at(j)=A.at(j)%div.at(i);
    }
    sort(B.begin(),B.end());
    vector<ll> sum1(N+1,0),sum2(N+1,0);
    for(int j=0;j<N;j++){
      sum1.at(j+1)=sum1.at(j)+B.at(j);
      sum2.at(j+1)=sum2.at(j)+(div.at(i)-B.at(j))%div.at(i);
    }

    ll sum=sum1.at(N);
    for(int j=0;j<N;j++){
      sum=min<ll>(sum,max<ll>(sum1.at(j),sum2.at(N)-sum2.at(j)));
    }
    if(sum<=K){
      cout<<div.at(i)<<endl;
      break;
    }
    i++;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
 
using namespace std;
 
int main(){
int height[10000], i=0;
 
while(cin >> height[i++]);
 
partial_sort(height, height+3, height+i, greater<int>());
 
cout << height[0] << endl;
cout << height[1] << endl;
cout << height[2] << endl;
 
return 0;
}

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

struct point {
	int left;
	int down;
	int right;
	int up;
};

void move(point able[5][5], int& x, int& y, int& direction){
	switch(direction){
	case 0: 
		if(able[y][x].down){
			y++;
			direction = 3;
			cout << "D";
		}else if(able[y][x].left){
			x--;
			direction = 0;
			cout << "L";
		}else if(able[y][x].up){
			y--;
			direction = 1;
			cout << "U";
		}else if(able[y][x].right){
			x++;
			direction = 2;
			cout << "R";
		}
		break;
	case 1:
		if(able[y][x].left){
			x--;
			direction = 0;
			cout << "L";
		}else if(able[y][x].up){
			y--;
			direction = 1;
			cout << "U";
		}else if(able[y][x].right){
			x++;
			direction = 2;
			cout << "R";
		}else if(able[y][x].down){
			y++;
			direction = 3;
			cout << "D";
		}
		break;
	case 2:
		if(able[y][x].up){
			y--;
			direction = 1;
			cout << "U";
		}else if(able[y][x].right){
			x++;
			direction = 2;
			cout << "R";
		}else if(able[y][x].down){
			y++;
			direction = 3;
			cout << "D";
		}else if(able[y][x].left){
			x--;
			direction = 0;
			cout << "L";
		}
		break;
	case 3:
		if(able[y][x].right){
			x++;
			direction = 2;
			cout << "R";
		}else if(able[y][x].down){
			y++;
			direction = 3;
			cout << "D";
		}else if(able[y][x].left){
			x--;
			direction = 0;
			cout << "L";
		}else if(able[y][x].up){
			y--;
			direction = 1;
			cout << "U";
		}
	}
}

int main(){
	int direction = 3;
	int x = 0, y = 0;
	point able[5][5];
	char c;
	for(int i = 0; i < 5; i++)
		for(int j = 0; j < 5; j++){
			able[i][j].left = 0;
			able[i][j].right = 0;
			able[i][j].down = 0;
			able[i][j].up = 0;
		}
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < 4; j++){
			cin >> c;
			if(c == '1'){
				able[i][j].right = 1;
				able[i][j+1].left = 1;
			}
		}
		if(i == 4) break;
		for(int j = 0; j < 5; j++){
			cin >> c;
			if(c == '1'){
				able[i][j].down = 1;
				able[i+1][j].up = 1;
			}
		}
	}
	move(able, x, y, direction);
	while(x != 0 || y != 0){
		move(able, x, y, direction);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define rep(i,l,r)  for(int i=l;i<=r;i++)
#define pre(i,r,l)  for(int i=r;i>=l;i--)
#define pii pair<int,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1000005;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}


int main(){
   int a = read(), b = read();
   int c = read(), d = read();
   while(a > 0&& c > 0) {
      if(c - b <= 0) {
        c -= b;
        break;
      }
      else if(a - d <= 0) {
        a -= d;
        break;
      }
      c -= b;
      a -= d;
   }
   //cout << a << ' ' << c << endl;
   if(a <= 0) puts("No");
   else puts("Yes");
}


Measured memory_bytes: 3636
import sys,collections,math,random,fractions,bisect,itertools;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
x,k,d = I()

if abs(x)/d >= k:
    print(abs(x)-k*d)
else:
    if (k - math.floor(x/d))%2 == 0:
        print(abs(x%d))
    else:
        print(abs(x%d-d))

Measured memory_bytes: 83684
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[3] = " \n";
int i, j, k, l, m, n;

int main() {
  string s, p, q;
  int a, b;
  char t;
  cin >> s >> n;
  rep(i,n) {
    cin >> q >> a >> b;
    if (q == "print") {
      REP(j,a,b+1) printf("%c", s[j]);
      printf("\n");
    } else if (q == "reverse") {
      rep(j,(b-a+1)/2) t=s[a+j],s[a+j]=s[b-j],s[b-j]=t;
    } else if (q == "replace") {
      cin >> p;
      s.replace(a, b-a+1, p);
    }
  }

  return 0;
}
  

Measured memory_bytes: 1204
import java.util.*;

public class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int d = sc.nextInt();

	boolean ab = false;
	boolean bc = false;
	

	if(a>=b && a-b<=d) ab = true;

	if(a<=b && b-a<=d) ab = true;

	if(b>=c && b-c<=d) bc = true;

	if(b<=c && c-b<=d) bc = true;


	if(a>=c && a-c<=d){
	    ab =true;
	    bc = true;
	}

	if(a<=c && c-a<=d){
	    ab = true;
	    bc = true;
	}
	if(ab == true && bc == true){

	    System.out.println("Yes");
	}else{
	    System.out.println("No");
	}

					
    }
}


Measured memory_bytes: 23252
#a = int(input())
#b,c = map(int,input().split())
#s = input()
#list_s = list(input())
#list_int = list(map(int,input().split()))

#list = [0 for i in range(n)]
#dp = [[0 for i in range(A)] for j in range(B)]

#list_int 並べて出力 print (' '.join(map(str,ans_li)))
#list_str 並べて出力 print (' '.join(list))

# 2進数 format(10, 'b') # '1010'

# aa=[int(input()) for i in range(n)]

#for i,name in enumerate(list)

''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) #heapqの作成
heapq.heappush(queue,num) #numのpush(値の追加)
pop = heapq.heappop(queue) #numのpop(最小値の出力)
pop = heapq.heappushpop(queue,num) #push -> pop

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7


N,M = map(int,input().split())

AA = [list(input()) for i in range(N)]
BB = [list(input()) for i in range(M)]

d = N - M

def check(x,y):
	for xx in range(0,M):
		for yy in range(0,M):
			if BB[yy][xx] != AA[yy+y][xx+x]:
				return False
	return True


for x in range(d+1):
	for y in range(d+1):
		if check(x,y):
			print('Yes')
			sys.exit()

print('No')


Measured memory_bytes: 3892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 3616
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    char c; cin >> c;
    if('a' <= c && c <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 

#define int             long long

 
void anmol()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
 
//const int N = 1e6 + 5 ;
 //int a[N], nums2[N] , freq[N];


int32_t main(){

  anmol();
    
   int n;
   cin>>n;


   int a[n+1] ={0};

   for(int i =1; i<=n; i++){

      for(int j = i; j<=n; j +=i){


         a[j]++;


      }

   }


    int sum =0;
   for(int i =1; i<=n; i++){
    sum+=a[i]*i;

   } 

   cout<<sum<<endl;
 
}










  
 






   

  
  

   
   





  










 
 





  



 
 
    

  
 
 
 
 
 


 

   

 
 



  
  












 
 





  



 
 
    

  































 
 



  
  












 
 





  



 
 
    

  
 
 
 
 
 


 

   

 
 



  
  












 
 





  



 
 
    

  


Measured memory_bytes: 81780
#include<cstdio>
using namespace std;
const int maxn=1e3+2;
int n,m,k;
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for (int i=0;i<=n;i++)
		for (int j=0;j<=m;j++)
			if (i*(m-j)+j*(n-i)==k){
				printf("Yes");
				return 0;
			}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
void moveE(int dice[6])
{
	int tmp = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[5];
	dice[5] = dice[2];
	dice[2] = tmp;
}
void moveN(int dice[6])
{
	int tmp = dice[0];
	dice[0] = dice[1];
	dice[1] = dice[5];
	dice[5] = dice[4];
	dice[4] = tmp;
}
void moveS(int dice[6])
{
	int tmp = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[5];
	dice[5] = dice[1];
	dice[1] = tmp;
}
void moveW(int dice[6])
{
	int tmp = dice[0];
	dice[0] = dice[2];
	dice[2] = dice[5];
	dice[5] = dice[3];
	dice[3] = tmp;
}
int main()
{
	int dice1[6], dice2[6];
	for (int i = 0; i < 6; i++)
		cin >> dice1[i];
	for (int i = 0; i < 6; i++)
		cin >> dice2[i];
	for(int i = 0;i < 6;i++)
	{
		if(dice2[i] == dice1[0])
		{
			switch(i)
			{
			case 1:
				moveN(dice2);
				break;
			case 2:
				moveE(dice2);
				break;
			case 3:
				moveW(dice2);
				break;
			case 4:
				moveN(dice2);
				break;
			case 5:
				moveN(dice2);
				moveN(dice2);
				break;
			}
		}
	}
	int tmp[4] = { dice2[1],dice2[2],dice2[4],dice2[3] };
	bool isSame = false;
	for(int i = 0;i < 4;i++)
	{
		if(tmp[i] == dice1[1])
		{
			if(tmp[(i + 1) % 4] == dice1[2] && tmp[(i + 2) % 4] == dice1[4] && tmp[(i + 3) % 4] == dice1[3])
			{
				isSame = true;
				break;
			}
		}
	}
	if (isSame)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(S == U){
    cout << A - 1 << " " << B << endl;
  }
  else if(T == U){
    cout << A << " " << B - 1 << endl;
  }
  else{cout << A << " " << B << endl;}
return 0;
}

Measured memory_bytes: 256
def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5 + 1)):
        if n % i == 0:
            return False
    return True

def callIsPrime(input_num):
    while True:
        if is_prime(input_num) == True:
            return input_num
        else:
            input_num += 1

print(callIsPrime(int(input())))


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<tuple<int, int, bool>> P;
  P.reserve(2 * N);
  REP(i, N) {
    int x, y;
    cin >> x >> y;
    P.emplace_back(x, y, true);
  }
  REP(i, N) {
    int x, y;
    cin >> x >> y;
    P.emplace_back(x, y, false);
  }
  sort(P.rbegin(), P.rend());

  set<int> ys;
  int ans = 0;
  for (auto& p : P) {
    int y = get<1>(p);
    bool is_red = get<2>(p);
    if (!is_red) {
      ys.insert(y);
      continue;
    }
    auto it = ys.lower_bound(y);
    if (it == ys.end()) {
      continue;
    }
    ans++;
    ys.erase(it);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500+b*100+c*50 == X:
                ans += 1
print(ans)

Measured memory_bytes: 9196
<?php
  list($a) = explode(" ", trim(fgets(STDIN)));
  list($b) = explode(" ", trim(fgets(STDIN)));
  list($c) = explode(" ", trim(fgets(STDIN)));
  list($d) = explode(" ", trim(fgets(STDIN)));

  echo min($a,$b)+min($c,$d);

Measured memory_bytes: 16188
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] area = new int[2];
    for(int i=0; i<2; i++){
      int width = sc.nextInt();
      int length = sc.nextInt();
      area[i] = width * length;
    }
    if(area[0]<area[1]){
      System.out.println(area[1]);
    }else{
      System.out.println(area[0]);
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int N_MAX = 10;
int main()
{
  int n,d,i,j,k,t,u,res=0;
  int x[N_MAX][N_MAX];
  cin >> n >> d;
  for(i=0;i<n;i++)
    for(j=0;j<d;j++)
      cin >> x[i][j];
  for(i=0;i<n-1;i++)
    for(j=i+1;j<n;j++){
      t=0;
      for(k=0;k<d;k++)
        t+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      u=(int)sqrt(t);
      if(u*u==t) res++;
    }
  cout << res << endl;
  return 0;
}

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

int main(){
    int H,W;
    cin>>H>>W;
    while(H!=0&&W!=0){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<"#"<<flush;
            }
            printf("\n");
        }
        cin>>H>>W;
        printf("\n");
    }
}


Measured memory_bytes: 3032
#include <bits/stdc++.h>
using ll = long long;
int main() {
	int n; std::cin >> n;
	std::map<ll,ll> cnt;
	ll a, sum = 0;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		sum += a;
		cnt[a]++;
	}
	int q; std::cin >> q;
	ll b, c;
	for (int i = 0; i < q; i++) {
		std::cin >> b >> c;
		ll bcnt = cnt[b];
		cnt[b] = 0;
		cnt[c] += bcnt;
		sum = sum - b * bcnt + c * bcnt;
		std::cout << sum << std::endl;
	}
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, x, y);
  rep(t, 101) rep(k, 101) {
    if (t + k == x && 2 * t + 4 * k == y) {
      out("Yes");
      return 0;
    }
  }
  out("No");
}


Measured memory_bytes: 3628
import sys
X = int(input())

MAX = pow(10,4)

for b in range(-MAX,MAX):
  #print(b)
  temp = X+pow(b,5) #これがaの5乗
  if temp < 0:
    continue
  aa = pow(temp,1/5)
  a = round(aa,5)
  #print(a,b)
  if a.is_integer():
    print(int(a),int(b))
    sys.exit()
    
  

Measured memory_bytes: 9440
n=int(input())
a=list(map(int,input().split()))

hat = [0,0,0]

mod = 10**9 + 7

ans=1

for i in range(n):
    tmp=0
    index=0
    for j,k in enumerate(hat):
        if k==a[i]:
            tmp+=1
            index=j

    ans = (ans*tmp)%mod

    hat[index]+=1

print(ans)



Measured memory_bytes: 20892
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ull a,b,x;
	cin >> a >> b >> x;
	cout << ((a==0)?(b/x+1):(b/x-(a-1)/x)) << endl;
}

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

int main(){

    // input
    ll n;
    cin >> n;
    vector<vector<ll>> val(2, vector<ll>(3));
    rep(i, 0, 2) rep(j, 0, 3) cin >> val[i][j];

    rep(k, 0, 2) {
        vector<ll> from = val[k], to = val[(k + 1) % 2];
        vector<ll> dp(n+1);
        rep(i, 0, n+1) dp[i] = i;
        rep(i, 0, 3) {
            ll f = from[i], t = to[i];
            for(ll j = 0; j + f <= n; j++) {
                dp[j + f] = max(dp[j + f], dp[j] + t);
            }
        }
        n = dp[n];
    }

    cout << n << endl;
    return 0;
}

Measured memory_bytes: 198552
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF = (1LL<<60)-1;
const int maxN = 1000001;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    read(arr);
    int ans = 0;
    int temp = arr[0];
    for(int i = 1; i < n; ++i){
        if(arr[i] < temp){
            ans += abs(temp - arr[i]);
        }
        else{
            temp = max(temp, arr[i]);
        }
    }
    cout << ans ;
}

Measured memory_bytes: 5200
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

void dfs(deque<ll> &dq,const vector<vector<ll>> &edge, vector<bool> &close, ll n){
    if(!close[n]){
        close[n] = true;
        for(int i = 0; i < edge[n].size(); i++){
            dfs(dq,edge,close,edge[n][i]);
        }
        dq.push_front(n);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
    cin >> n >> m;

    vector<vector<ll>> edge(n+1);

    for(int i = 0; i < m; i++){
        ll x,y;
        cin >> x >> y;
        edge[x].push_back(y);
    }

    deque<ll> dq;
    vector<bool> close(n+1,false);

    for(int i = 1; i <= n; i++){
        dfs(dq,edge,close,i);
    }

    vector<ll> dp(n+1,0);
    while(!dq.empty()){
        ll p = dq.front();
        dq.pop_front();
        for(int i = 0; i < edge[p].size(); i++){
            dp[edge[p][i]] = max(dp[edge[p][i]],dp[p] + 1);
        }
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans,dp[i]);
    }

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

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

int main() {
    int n,l; cin >> n >> l;
    string s;
    priority_queue<string, vector<string>, greater<string> > q;
    for(int i=0; i<n; i++) {
        cin >> s;
        q.push(s);
    }

    for(int i=0; i<n; i++) {
        cout << q.top();
        q.pop();
    }
    cout << endl;
    return 0;
}

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

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

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

	x < a ? cout << 0 : cout << 10;
	cout << endl;

	return 0;
}

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

using namespace std;

#define mod 1000000007
#define sz(c)  (int) c.size()
#define all(c) c.begin(), c.end()
#define tr(container,it) for(__typeof(container.begin()) it = container.begin();it != container.end(); it++)
#define present(s,x) s.find(x) != s.end()
#define cpresent(c,x) find(all(c),x) != c.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,a,b) for(int i=a; i<b;i++)
#define ini(n) scanf("%d",&n)
#define opn printf("\n")

 
#define TRACE
 
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)    
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif 

typedef pair<int,int> pi;
typedef vector<pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector< vi > vvi;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi , greater<int> >minpq;
typedef priority_queue<pi,vp,greater<pi> > mpq;


int main(){
	//ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n;
	cin>>n;
	rep(i,n);
	int a[100002][3] ; 
	rep(i,n){
		rep(j,3){
			cin>>a[i][j];
		}
	}
	int prev=0;
	int pa=0;
	int pb=0;
	rep(i,n){
		int dis = abs(a[i][1]-pa) + abs(a[i][2]-pb);
		int k= a[i][0]-prev;
		//~ trace2(dis,k);
		if(k%dis !=0 ){
			cout<<"No";
			return 0;
		}
		pa = a[i][1];
		pb = a[i][2];
		prev=a[i][0];
	}
	cout<<"Yes";
	opn;
}

	

	



Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			double[] x = new double[3];
			double[] y = new double[3];
			for(int i=0;i<3;i++){
				x[i] = sc.nextDouble();
				y[i] = sc.nextDouble();
			}
			double xp = sc.nextDouble();
			double yp = sc.nextDouble();
			
			solve(x, y, xp, yp);
			
		}
	}
	
	public void solve(double[] x, double[] y, double xp, double yp) {
		boolean isOk = true;
		int sign = (x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0])<0 ? -1 : 1;
		for(int i=0;i<3;i++){
			double vx = x[(i+1)%3]-x[i];
			double vy = y[(i+1)%3]-y[i];
			
			if(sign * (vx*(yp-y[i]) - vy*(xp-x[i])) < 0)
				isOk = false;
		}
		System.out.println(isOk ? "YES" : "NO");
	}

}

Measured memory_bytes: 23340
import sys
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = list(input())

for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    elif n[i] == '9':
        n[i] = '1'

print(''.join(n))


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    while (cin >> a >> b) {
        if (!a && !b) break;
        if (a > b) cout << b << " " << a;
        else cout << a << " " << b;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2972
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    if ( n == 1 ) {
        cout << 0 << endl ;
        return 0 ;
    }
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
    }
    sort(v.rbegin(), v.rend()) ;
    priority_queue<pair<int,int> > q ;
    q.push(make_pair(v[0], 0)) ;
    int ans = 0 ;
    for(int i = 1; i < n; i++){
        auto top = q.top() ; q.pop() ;
        debug() << imie(top) ;
        ans += top.first ;
        q.push(make_pair(v[i], top.first));
        q.push(make_pair(v[i], top.second));
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 8936
// Enjoy your stay. Code by evima on 2018/09/01

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

long N, K, num[200010];

int main() {
    cin >> N >> K;
    for(int i = 1; i <= N; ++i) ++num[i%K];
    long ans = 0;
    for(long ma = 0; ma < K; ++ma){
        long mb = (K - ma) % K;
        long mc = (K - ma) % K;
        if((mb + mc) % K != 0) continue;
        ans += num[ma] * num[mb] * num[mc];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
from collections import defaultdict

N = int(input())
S = input()

cnt_left = defaultdict(int)
for i in range(2 ** N):
    a, b = "", ""
    for j in range(N):
        if (i >> j) & 1:
            a += S[j]
        else:
            b += S[j]
    cnt_left[(a, b)] += 1

S = S[::-1]
cnt_right = defaultdict(int)
for i in range(2 ** N):
    a, b = "", ""
    for j in range(N):
        if (i >> j) & 1:
            a += S[j]
        else:
            b += S[j]
    cnt_right[(a, b)] += 1
    
answer = 0
for k in cnt_left.keys():
    answer += cnt_left[k] * cnt_right[k]
print(answer)

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

int main() {
  int a,b,c,k;cin>>a>>b>>c>>k;
  int cnt = min(a, k);
  if (k-a-b > 0) cnt -= k-a-b;
  cout<<cnt;
}


Measured memory_bytes: 3676
import java.io.*;
import java.util.*;

public class Main {

        static int max = 0;

        public static void main(String[] args) {

                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();
                int M = scan.nextInt();
                int Q = scan.nextInt();

                int[] a = new int[Q];
                int[] b = new int[Q];
                int[] c = new int[Q];
                int[] d = new int[Q];

                for (int i = 0; i < Q; i++) {
                        a[i] = scan.nextInt();
                        b[i] = scan.nextInt();
                        c[i] = scan.nextInt();
                        d[i] = scan.nextInt();
                }

                int Anumber = 0;
                int count = 0;
                int first = 1;
                int[] A = new int[N];

                Main.Aselect(Anumber, N, Q, a, b, c, d, count, 1, M, A);

                System.out.println(max);


        }


        private static void Aselect(int Anumber, int N, int Q, int[] a, int[] b, int[] c, int[] d, int count, int first, int M, int[] A) {
                if (Anumber == N-1) {
                        for (int j = first; j <= M; j++) {
                                A[Anumber] = j; 

                                for (int i = 0; i < Q; i++) {
                                        if (A[b[i]-1]-A[a[i]-1] == c[i]) {
                                                count += d[i];
                                        }
                                }

                                if (max < count) {
                                        max = count;
                                }

                                count = 0;
                        }
                } else {
                        for (int j = first; j <= M; j++) {
                                A[Anumber] = j;
                                Anumber++;
                                Aselect(Anumber, N, Q, a, b, c, d, count, j, M, A);
                                Anumber--;
                        }
                }
        }

}

Measured memory_bytes: 37524
#include <stdio.h>

int N;
int A[3000];
long long dp[3000][3000];

long long max(long long x, long long y) {
    return x > y ? x : y;
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        dp[i][i] = A[i];
    }
    for (int d = 1; d < N; d++) {
        for (int l = 0; l + d < N; l++) {
            int r = l + d;
            dp[l][r] = max(-dp[l + 1][r] + A[l], -dp[l][r - 1] + A[r]);
        }
    }
    printf("%lld\n", dp[0][N - 1]);
    return 0;
}



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

int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(auto&& w:a)cin>>w;
    int sum=0;
    for(auto&& w:a)sum+=w;
    
    int num=a.size();
    int c=(sum%num>num/2)?(sum/num+1):(sum/num);
    int ans=0;
    for(auto&& w:a)ans+=(w-c)*(w-c);
    cout<<ans<<endl;
 //   cout <<-5/3<<" "<<-5%3<<endl;
}



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

using namespace std;

int n;

vector <float> a(51);

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    sort (a.begin() + 1, a.begin() + n + 1, greater <float>());
    ///for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
    for (int i = n - 1; i >= 1; --i)
    {
        a[i] = (a[i + 1] + a[i]) / 2;
    }
    cout << a[1];
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

ll power(ll a, ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans*=a;
        a*=a;
        n>>=1;
    }
    return ans;
}

ll mx;
ll dp[1001][2][5001];
ll a[1001],c[1001];
ll n,m;

ll f(int x, int id, int mask)
{
    // cout<<x<<endl;
    if(mask==mx) 
    {
        // cout<<"dd\n";
        return 0;
    }
    if(x==m) return 1e18;
    if(dp[x][id][mask]!=-1) return dp[x][id][mask];
    // cout<<"gg\n"<<endl;
    if(id==0) dp[x][id][mask]=min(f(x+1,0,mask),f(x+1,1,mask));
    else dp[x][id][mask]=a[x]+min(f(x+1,0,mask|c[x]),f(x+1,1,mask|c[x]));
    return dp[x][id][mask];
} 

int main()
{
    IOS;
    memset(dp,-1,sizeof dp);
    cin>>n>>m;
    mx=power(2,n)-1;
    repf(i,0,m)
    {
        ll b;
        cin>>a[i]>>b;
        c[i]=0;
        while(b--)
        {
            ll x;
            cin>>x;
            c[i]+=power(2,x-1);
        }
    }
    ll ans=min(f(0,0,0),f(0,1,0));
    if(ans>=1e18) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;  
}

Measured memory_bytes: 78592
import scala.io.StdIn._
object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt

    if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)
      println("hon")
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)
      println("pon")
    else
      println("bon")

  }
}


Measured memory_bytes: 54392
#include<stdio.h>
#define MAX 2000000
#define INF (1<<30)
int h=0;

void maxHeapify(int *Heap,int i){
  int l=2*i;
  int r=2*i+1;
  int largest;
  int tmp;
 
  if(l<=h && Heap[l]>Heap[i]) largest=l;
  else largest=i;
  if(r<=h && Heap[r]>Heap[largest]) largest = r;
  if(largest!=i){
    tmp=Heap[i];
    Heap[i]=Heap[largest];
    Heap[largest]=tmp;
    maxHeapify(Heap,largest);
  }
}
int insert(int x,int *Heap){
  int i,tmp;
  h++;
  Heap[h] =-INF;
  if(x<Heap[h]) return -1;
  Heap[h]=x;
  i=h;
  while(i>1&&Heap[i/2]<Heap[i]){
    tmp=Heap[i/2];
    Heap[i/2]=Heap[i];
    Heap[i]=tmp;
    i/=2;
  }
  return 0;
}
int extract(int *Heap){
  int maxv = Heap[1];
  if(h < 1) return -INF;
  Heap[1] = Heap[h];
  h--;
  maxHeapify(Heap,1);
  return maxv;
}    

int main(){
  int n;
  char c[20];
  int Heap[MAX+2];
  while(1){
    scanf("%s",c);
    if(c[0]=='e'&&c[1]=='n') break;
    if(c[0]=='i'){
      scanf("%d",&n);
      insert(n,Heap);
    }else{
      printf("%d\n",extract(Heap));
    }
  }
  return 0;
}
  

Measured memory_bytes: 5484
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll f(ll num)
{
    if (num < 2) return 1;
    else if (num == 2) return 2;
    else if (num % 2 == 0) return 2; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return i;
        }
    }

    // 素数である
    return num;
}

vector<ll> factorList(ll x) {
  vector<ll> res;
  while (x != 1) {
    res.push_back(f(x));
    x /= f(x);
  }
  return res;
}


int main(){
  ll n;
  cin >> n;
  vector<ll> arr(105);
  repo(i, 100){
    arr[i]=arr[i-1]+i;
  }
  vector<ll> v=factorList(n);
  map<ll, int> mp;
  rep(i, v.size()){
    mp[v[i]]++;
  }
  int ans=0;
  for(auto p: mp){
    int it=upper_bound(arr.begin(), arr.end(), p.second)-arr.begin()-1;
    ans+=it;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
int n,m,x[105],y[105];
char a[105][105];
char c;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
           cin>>a[i][j];
           if(a[i][j]=='#'){
               x[i]=1;
               y[j]=1;
           }
        }
    }
    for(int i=1;i<=n;i++){
        int pd=1;
        for(int j=1;j<=m;j++){
            if(x[i]&&y[j]){
                printf("%c",a[i][j]);
                pd=0;
            }
        }
        if(pd==0)
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC064
{
    class TravelingAtCoDeerProblem
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine().Trim());
            var a = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_));
            WriteLine(a.Max() - a.Min());
        }
    }
}


Measured memory_bytes: 11220
n, y = gets.chomp.split(' ').map(&:to_i)
default_x, default_y, default_z = -1, -1, -1
(0..n).each do |i|
  (0..n-i).each do |j|
    if 10000 * i + 5000 * j + 1000 * ( n - i - j) == y
      default_x, default_y, default_z = i, j, (n - i - j)
    end
  end
end
puts "#{default_x} #{default_y} #{default_z}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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

Measured memory_bytes: 256
def resolve():
    L=list(map(int,input().split()))
    LL=[0]*len(L)
    for i in range(len(L)):
        LL[i]=L[i]%2
    val=0
    if sum(LL)==0 or sum(LL)==3:
        for i in range(len(L)):
            val+=max(L)-L[i]
        val//=2
    elif sum(LL)==1:
        for i in range(len(LL)):
            if LL[i] == 0:
                L[i]+=1
        for i in range(len(L)):
            val += max(L) - L[i]
        val//=2
        val+=1
    else:
        for i in range(len(LL)):
            if LL[i] == 1:
                L[i]+=1
        for i in range(len(L)):
            val += max(L) - L[i]
        val//=2
        val+=1


    print(val)


resolve()

Measured memory_bytes: 38432