akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    ull N, res;
    char tmp;
    string ans;
    cin >> N;
    while (N > 0){
        res = N % 26;
        if (res != 0) tmp = 'a' + res - 1;
        else {
            tmp = 'z';
            res = 26;
        }
        ans += tmp;
        N = (N - res) / 26;
    }
    for (int i = ans.length() -1; i >=0; i--){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3120
def gcd(x, y):
  while(x % y != 0 and y % x != 0):
    if(x > y):
      x = x % y
    else:
      y = y % x
  if(x > y):
    return y
  else:
    return x
  
N = int(input())
A = list()
for i in range(N):
  A.append(int(input()))

ans = 1
for i in range(N):
  gcd_i = gcd(A[i], ans)
  ans = A[i] * ans // gcd_i
  
print(ans)


Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int max =sc.nextInt();
			
			if(max == 0){
				break;
			}
			
			final int n = sc.nextInt();
			final int size = n + 2;
			
			int[] map = new int[size];
			for(int i = 1; i <= n; i++){
				map[i] = sc.nextInt();
			}
			
			//int[][] adj = new int[size][max];
			boolean[][] adj = new boolean[size][size];
			for(int i = 0; i < size; i++){
				for(int j = 0; j < max; j++){
					if(i == size - 1){
						adj[i][i] = true;
						continue;
					}
					final int num = j + 1;
					final int to = Math.min(size - 1, Math.max(0, i + num));
					final int dist = Math.min(size - 1, Math.max(0, to + map[to]));
					
					adj[i][dist] = true;
				}
			}
			
			for(int k = 0; k < size; k++){
				for(int i = 0; i < size; i++){
					for(int j = 0; j < size; j++){
						adj[i][j] = adj[i][j] || (adj[i][k] && adj[k][j]);
					}
				}
			}
			
			boolean flag = true;
			for(int i = 0; i < size; i++){
				//System.out.print(i + " ");
				//System.out.print(adj[0][i] + " ");
				//System.out.println(adj[i][size-1]);
				
				if(adj[0][i] && !adj[i][size-1]){
					System.out.println("NG");
					flag = false;
					break;
				}
			}
			
			if(flag){
				System.out.println("OK");
			}
		}
	}

}

Measured memory_bytes: 52032
//#define _USE_MATH_DEFINES
//#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>
//#include <sstream>
//#include <queue>

using namespace std;


int main(){

	int field[14][14];
	int x, y, s,cntz = 0,max = 0;
	char c;

	for (int i = 0; i < 14; i++){
		for (int j = 0; j < 14; j++){
			field[i][j] = 0;
		}
	}


	while (cin >> x >> c >> y >> c >> s){

		//?°?
		if (s == 1){
			field[x + 2][y + 2]++;
			field[x + 2][y + 1]++;
			field[x + 2][y + 3]++;
			field[x + 1][y + 2]++;
			field[x + 3][y + 2]++;
		}
		//????????§
		if (s == 2 || s == 3){
			for (int i = -1; i <= 1; i++){
				for (int j = -1; j <= 1; j++){
					field[x + 2 + i][y + 2 + j]++;
				}
			}
		}
		//??§
		if (s == 3){
			field[x + 2][y]++;
			field[x + 2][y + 4]++;
			field[x][y + 2]++;
			field[x + 4][y + 2]++;
		}

	}

	for (int i = 2; i < 12; i++){
		for (int j = 2; j < 12; j++){
			if (field[i][j] == 0)cntz++;
			if (field[i][j] > max)max = field[i][j];
		}
	}

	cout << cntz << endl;
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#define N 100 
#define INF 10000


int main(){
 
  int  i,j,k, num, min;
  int  mini, total=0;
  int  M[N][N];
  int  flag[N], e[N];

  /*入力*/  
  scanf("%d", &num);
  
  for(i = 0; i < num; i++){
    for(j = 0; j < num; j++){
      scanf("%d", &M[i][j]);
    }
  }

  /*flag and e の初期化*/ 
  for(i = 0; i < num ; i++){
    flag[i] = 0;
    e[i] = INF;
  }
  e[0] = 0;

   
  /**/
  for(k = 0; k < num - 1; k++){
    min = INF;
    for(i = 0 ; i < num ; i++){
      if(e[i] < min && flag[i] == 0){
	min = e[i];
	mini = i;
      }
    }
      flag[mini] = 1;
 
    /*最小の要素を決める*/
    for(i = 0; i < num; i++){
      if(M[mini][i] < e[i] && M[mini][i] != -1 && flag[i]==0){
	e[i] = M[mini][i];
      }
    }
 
  }
 

  /*辺の重みの総和*/
  for(i = 0; i < num; i++) total += e[i];
  printf("%d\n", total);
 
 
 
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define ABS(a, b) ((a) < (b) ? (b) - (a) : (a) - (b))

int main()
{
    int N;
    cin >> N;
    int A[N+2];
    for(int i = 1; i <= N; ++i) cin >> A[i];
    A[0] = 0, A[N+1] = 0;

    int total = 0;
    for(int i = 0; i <= N; ++i) 
        total += ABS(A[i], A[i+1]);

    for(int i = 1; i <= N; ++i) {
        if(A[i-1] <= A[i+1]) {
            if(A[i] - A[i-1] >= 0 && A[i+1] - A[i] >= 0) {
                cout << total << endl; continue;
            }

            if(A[i] - A[i-1] <= 0 && A[i+1] - A[i] >= 0) {
                cout << total - 2*ABS(A[i-1], A[i]) << endl;
                continue;
            }

            if(A[i] - A[i-1] >= 0 && A[i+1] - A[i] <= 0) {
                cout << total - 2*ABS(A[i], A[i+1]) << endl;
                continue;
            }
        }

        if(A[i-1] >= A[i+1]) {
            if(A[i+1] <= A[i] && A[i] <= A[i-1]) {
                cout << total << endl; continue;
            }

            if(A[i+1] <= A[i] && A[i] >= A[i-1]) {
                cout << total - 2*ABS(A[i], A[i-1]) << endl;
                continue;
            }

            if(A[i+1] >= A[i] && A[i] <= A[i-1]) {
                cout << total - 2*ABS(A[i+1], A[i]) << endl;
                continue;
            }
        }
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  for(int i=0;i<n;i++){
    cout << 'x';
  }
  cout << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 int r =sc.nextInt();
         int D =sc.nextInt();
         int x =sc.nextInt();
      
      for(int i=0; i<10; i++){
      x=r*x-D;
          System.out.println(x);
         
       }
    }
}

Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int dotsCount = int.Parse(input1[0]);
            int dimension = int.Parse(input1[1]);

            List<string[]> dots = new List<string[]>();

            for(int i = 0; i < dotsCount; i++)
            {
                dots.Add(Console.ReadLine().Split(' '));
            }

            int answer = 0;

            for(int i = 0; i < dots.Count; i++)
            {
                for (int j = 0; j < dots.Count; j++)
                {
                    string[] dotsX;
                    string[] dotsY;

                    if (i == j)
                    {
                        continue;
                    }
                    else
                    {
                        dotsX = dots[i];
                        dotsY = dots[j];
                    }

                    double distance = 0;

                    for (int k = 0; k < dimension; k++)
                    {
                        distance += Math.Pow(int.Parse(dotsX[k]) - int.Parse(dotsY[k]), 2);
                    }

                    distance = Math.Sqrt(distance);

                    if (distance - Math.Floor(distance) == 0)
                    {
                        answer++;
                    }
                }
            }

            Console.WriteLine((answer / 2).ToString());
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <string>
int j[3000][3000];
int k[3000][3000];
int main() {
	std::string str1, str2;
	std::cin >> str1;
	std::cin >> str2;
	if (str1[0] == str2[0])
		j[0][0] = 1;
	for (int q = 1; q < str2.size(); q++) {
		if (str1[0] == str2[q] || j[0][q - 1] == 1)
			j[0][q] = 1;
	}
	for (int q = 1; q < str1.size(); q++) {
		if (j[q - 1][0] == 1 || str1[q] == str2[0])
			j[q][0] = 1;
	}
	for (int q = 1; q < str1.size(); q++) {
		for (int w = 1; w < str2.size(); w++) {
			if (str2[w] == str1[q]) {
				j[q][w] = j[q - 1][w - 1] + 1;
				k[q][w] = 1;
			}
			else {
				j[q][w] = j[q - 1][w];
				k[q][w] = 0;
				if (j[q][w - 1] > j[q][w]) {
					j[q][w] = j[q][w - 1];
					k[q][w] = 2;
				}
			}
		}
	}
	char result[3000];
	int count1 = 0;
	int x = str1.size() - 1, y = str2.size() - 1;
	while (y != 0 && x != 0) {
		if (k[x][y] == 1) {
			result[count1++] = str1[x];
			--y;
			--x;
		}
		else if (k[x][y] == 0) {
			--x;
		}
		else {
			--y;
		}
	}
	if (y == 0) {
		if (j[x][y] == 1) {
			result[count1++] = str2[0];
		}
	}
	else {
		if (j[x][y] == 1) {
			result[count1++] = str1[0];
		}
	}
	for (int q = count1 - 1; q >= 0; q--) {
		std::cout << result[q];
	}
	
	return 0;
}

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

using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int t = 0;
    if(n%2!=0){
    	t = n/2 + 1;
	}else{
		t = n/2;
	}
	double ans = 1.0*t/n;
	cout << ans << endl;
    
	return 0;
}


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

int main(){
    long long n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for(long long i = 0; i < n; i++) cin >> h[i];

    vector<long long> dp(n, 1e12);
    dp[0] = 0;

    for(long long i = 0; i < n; i++){
        for(long long j = 1; j <= k; j++) if(i - j >= 0) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int s;cin >> s;
    int a = s/100;
    s%=100;
    bool t=false,ta=false,k=false,ka=false;
    if(0<=a&&a<=99) t=true;
    if(0<=s&&s<=99) ta=true;
    if(1<=s&&s<=12) k=true;
    if(1<=a&&a<=12) ka=true;
    if(t&&ta&&k&&ka) puts("AMBIGUOUS");
    else if(t&&k) puts("YYMM");
    else if(ta&&ka) puts("MMYY");
    else puts("NA");
    return 0;
}


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

int main(int argc, char const *argv[]) {
  int n[32] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  int i;
  cin >> i;

  cout << n[i - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
int main(){
  string s;cin>>s;
  if(s[0]!='A'){cout << "WA" << endl;return 0;}
  bool ans = true;
  bool found = false;
  for(int i=1;i<s.size();i++){
    char c=s[i];
    if('a'<=c && c<='z'){
      continue;
    }else if(c=='C'){
      if(2<=i&&i<=s.size()-2){
        if(!found)found=true;
        else{ans=false;break;}
      }else{ans=false;break;}
    }else{
      ans = false;break;
    }
  }
  cout << (found&&ans?"AC":"WA") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ld> P(N,0.0);
    for(ll i=0;i<N;++i)cin>>P[i];
    //dp[i]は表がi枚出る確率
    vector<ld> dp(N+1,0.0);
    dp[0]=1.0;
    for(ll i=0;i<N;++i){
        for(ll j=N;j>=0;--j){
            if(j-1>=0)
            dp[j]=dp[j]*(1.0-P[i])+dp[j-1]*P[i];
            else 
            dp[j]=dp[j]*(1.0-P[i]);
        }
    }
    ld ans=0;
    for(ll i=0;i<=N;++i){
        if(i>N-i)ans+=dp[i];
    }
    cout << fixed << setprecision(12);
    prt(ans)

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right){ //カードの配列を2分割
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for ( i = 0; i < n1; i++) L[i] = A[left + i];
    for ( i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for (k = left; k < right; k++){
    	if ( L[i].value <= R[j].value )
    		A[k] = L[i++];
    	else
    		A[k] = R[j++];
    	
   }	
}

void mergeSort(struct Card A[], int n, int left, int right){ //部分配列を限界まで2分割
    int mid;
    if (left + 1 < right){
    	mid = (left + right)/2;
    	mergeSort(A, n, left, mid);
    	mergeSort(A, n, mid, right);
    	merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r){ //与えられた配列の,値xがある番地より左側は<=x,右側はx<になるように並び替え
    int i,j;
    struct Card t, x;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++){
    	if (A[j].value <= x.value){
    		i++;
    		t = A[i]; A[i] = A[j]; A[j] = t;
    	}
    }
    t = A[i+1]; A[i+1] = A[r]; A[r] = t;
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r){
    int q;
    if(p < r){
    	q = partition(A,n,p,r);
    	quickSort(A,n,p,q-1);
    	quickSort(A,n,q+1,r);
    }
}

int main(){
    int  n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
    	scanf("%s %d", S, &v);
    	A[i].suit = B[i].suit = S[0];
    	A[i].value = B[i].value = v;
    }
    
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n-1);
    
    for(i = 0; i < n; i++)
    	if(A[i].suit != B[i].suit)stable = 0;
    
    
    if(stable == 1)printf("Stable\n");
    else printf("Not stable\n");
    for (i = 0; i < n; i++)
    	printf("%c %d\n",B[i].suit, B[i].value);
    
    
    return 0;
}


Measured memory_bytes: 4040
fun isKaibun(input: String): Boolean {
    val mid = if(input.length % 2 == 0) { input.length/2 - 1 } else {input.length /2 }
    return (0..mid).map { input[it] == input[input.length - 1 - it] }.all { it }
} 

fun main(args: Array<String>) {
    val S = readLine()!!
    val N = S.length
    if(isKaibun(S) && isKaibun(S.substring(0, ((N - 2)/ 2) + 1)) && isKaibun(S.substring(((N - 1 + 3)/2), N))) { "Yes" } else { "No" }.run(::println)
}

Measured memory_bytes: 33660
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxtotv = 100002;

int n, m;
long long f[maxtotv];

int main() {

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

    cin >> n >> m;

    for (int j = 1000 * n; j > 0; --j)
        f[j] = INT_MAX;

    for (int i = 0; i < n; ++i) {
        int w, v;
        cin >> w >> v;
        for (int j = maxtotv-2; j >= v; --j)
            f[j] = min(f[j], f[j-v] + w);
    }

    int ans = 0;
    for (int j = 1000 * n; j > 0; --j)
        if (f[j] <= m) {
            ans = j;
            break;
        }
	
    cout << ans << endl;
	return 0;
}

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

using namespace std;

//int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};


int main()
{
    ios::sync_with_stdio(false);
    //freopen("inp.in","r",stdin);
    //freopen("outp.out","w",stdout);
    int N;
    cin >> N;
    int ans=-1;
    for(int X=N; X>=1; X--)
    {
        int lol=X*108;
        lol/=100;
        if(lol==N) ans=X;
    }
    if(ans==-1) cout << ":(" << endl;
    else cout << ans << endl;
    return 0;
}


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

using namespace std;

// Prioridade
typedef long long   ll;
typedef pair<ll,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i < (b); i++)
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (((a)*(b))/__gcd((a), (b)))

// fim da Prioridade
int dp[100010];
int h[100010];
int n;
int solve(int i){
	if(i == n-1){
		return 0;
	}
	if(i >= n)
		return INF;
	if(dp[i] != -1){
		return dp[i];
	}
	return dp[i] = min(abs(h[i] - h[i+1]) + solve(i+1),abs(h[i] - h[i+2]) + solve(i+2));
}
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin >> n;
	memset(dp,-1,sizeof dp);
	REP(i,0,n){
		cin >> h[i];
	}
	cout << solve(0) << endl;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     int N,max=0,su=0;
     cin >> N;
     int L[N+10];
     for(int i=0; i<N; i++){
         cin >> L[i];
         max+=L[i];
         if(L[i]>su){
             su=L[i];
         }
     }

    if(max-su>su){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
int x[101];

int main() {
    int N, K;
    scanf("%d%d", &N, &K);
    int ans = 1;
    while(N > 0) {
        if(N / K > 0)
            ans++;
        N = N / K;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int N, T;
    scanf("%d %d", &N, &T);

    int t[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &t[i]);
    }

    int X = 0;
    for (int i = 0; i < N - 1; i++) {
        int x = (t[i + 1] - t[i]);
        if (x > T) {
            x = T;
        }
        for (int j = 0; j < x; j++)
            X++;
    }
    X = X + T;

    printf("%d\n", X);

    return 0;
}

Measured memory_bytes: 896
#include <cstdio>

int n, A[50];

bool solve(int i, int m) {
    if (m == 0) return true;
    if (i >= n) return false;
    bool res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, key;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &A[i]);
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
        scanf("%d", &key);
        bool res = solve(0, key);
        if (res) printf("yes\n");
        else printf("no\n");
    }
}



Measured memory_bytes: 2620
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;
 
vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//abcのbed乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 



ll i,j,k,ii,jj;
ll n,m,num;
ll a,b,c,d,e,f,g,h,w;
ll x[800005],y[800005],z[900005];
char s[500005];
ll len[500];
bool dame;


int main(){	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i]>>y[i];
		//if(abs(x[i]) >= 11 || abs(y[i]) >= 11){
		//	return 0;
		//}
	}
	len[31] = 1;
	for(i=30;i>=0;i--){
		len[i] = len[i+1] * 2;
	}

	a = abs(x[0]) + abs(y[0]);
	for(i=0;i<n;i++){
		if((x[i] + y[i] - a) % 2 == 1){
			dame = true;
		}
	}
	if(dame){
		p(-1);
		return 0;
	}
	if(a%2==0){
		for(i=0;i<n;i++){
			x[i] += 1;
		}
		p(33);
		for(i=0;i<32;i++){
			pe(len[i]);
		}
		p(1);
	}else{
		p(32);
		for(i=0;i<32;i++){
			pe(len[i]);
		}
		el;
	}
	for(i=0;i<n;i++){
		ll posx = 0;
		ll posy = 0;
		for(j=0;j<32;j++){
			ll knum = -1;
			ll ksum = INF;
			ll lenx,leny;
			for(k=0;k<4;k++){
				//どの方向に使うべきかを決める
				lenx = dx[k] * len[j];
				leny = dy[k] * len[j];
				if(ksum > abs(x[i] - (posx + lenx)) + abs(y[i] - (posy + leny))){
					ksum = abs(x[i] - (posx + lenx)) + abs(y[i] - (posy + leny));
					knum = k;
				}
			}
			posx += dx[knum] * len[j];
			posy += dy[knum] * len[j];
			//pe(knum);pe(posx);p(posy);
			pu(dir[knum]);
		}
		if(a%2==0){
			pu("L");
		}
		//pe(posx);p(posy);
		el;
	}
	return 0;
}

Measured memory_bytes: 29440
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#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 << endl; } 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__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

int d[2][100];

void solve(){
  int n;
  cin >> n;
  forn(i, 2){
    forn(j, n){
      int a;
      cin >> a;
      if (i){
        setmax(d[i][j], d[i-1][j] + a);
      } else {
        setmax(d[i][j], a);
      }
      if (j){
        setmax(d[i][j], d[i][j-1] + a);
      } else {
        setmax(d[i][j], a);
      }
    }
  }
  cout << d[1][n-1];
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 


*/

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


int main() {
    int n;
    cin>>n;
    int num[n];
    for (int i = 0; i < n; ++i) {
        cin>>num[i];
    }
    sort(num,num+n);
    int count=1;
    for (int j = 0; j < n-1;j++) {
        if(num[j]!=num[j+1])count++;
    }
    if((n-count)%2==1)count--;
    cout<<count<<endl;
    return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

map<ll, ll> d;
priority_queue< Pll, vector<Pll>, greater<Pll> > que;
map<ll, vector<Pll> > edges;

void dijkstra(ll start){
    d[start] = 0;
    que.push(Pll(0, start));

    while(!que.empty()){
        Pll v = que.top(); que.pop();
        if(d.find(v.second) != d.end() && d[v.second] < v.first) continue;
        for(Pll e: edges[v.second]){
            if(d.find(e.first) == d.end() || d[e.first] > d[v.second] + e.second){
                d[e.first] = d[v.second] + e.second;
                que.push(Pll(d[e.first], e.first));
            }
        }
    }
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    ll u, k, c, v;
    cin >> n;
    rep(n){
        cin >> u >> k;
        repp(j, k){
            cin >> v >> c;
            edges[u].emplace_back(v, c);
        }
    }

    dijkstra(0);
    repp(u, n) cout << u << " " << d[u] << endl;

}



Measured memory_bytes: 12152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String s = in.next();

        if (n % 2 == 1) {
            System.out.println("No");
            return;
        }

        for (int i = 0; i < n / 2; i++) {
            if (s.charAt(i) != s.charAt(i + n / 2)) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct PointDis{
    ll point, dis;
};

static const ll MAX = 100001;
vector<PointDis> G[MAX];
ll dis[MAX];
ll NIL = -1;

void bfs(ll u){
    queue<ll> Q;
    Q.push(u);
    dis[u] = 0;
    ll v;
    while(!Q.empty()){
        v = Q.front();
        Q.pop();
        for (ll i=0;i<G[v].size();i++){
            ll p = G[v][i].point;
            if(dis[p] == NIL){
                dis[p] = dis[v] + G[v][i].dis;
                Q.push(p);
            }
        }
    }
}

int main() {
    

    ll n;
    cin >> n;
    for (ll i = 0;i<n-1;i++){
        ll a,b,c;
        cin >> a >> b >> c;
        PointDis p,q;
        p.point = b;
        p.dis = c;
        q.point = a;
        q.dis = c;
        G[a].push_back(p);
        G[b].push_back(q);
    }
    for (ll i=1;i<=n;i++){
        dis[i] = NIL;
    }
    ll q,k;
    cin >> q >> k;

    bfs(k);

    for (ll i=0;i<q;i++){
        ll x,y;
        cin >> x >> y;
        cout << dis[x] + dis[y] << endl;
    }

}



Measured memory_bytes: 9984
s = int(input())
history = {}

ans = 1
n_tmp = s
while True:
  if history.setdefault(str(n_tmp), 0) > 0:
    break
  else:
    history[str(n_tmp)] = 1
  #
  ans += 1
  if n_tmp % 2 > 0:
    n_tmp = 3 * n_tmp + 1
  else:
    n_tmp = n_tmp // 2
    
print(ans)

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


int main(){

int a,b;
cin >> a >> b;
if((a*b)%2==0)cout << "Even" << endl;
else cout << "Odd" << endl;
return 0;
}




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

int main() {
  int n, k;
  cin >> n >> k;
  
  int ans = 1;
  for(int i=0; i<n; i++) {
    if(ans*2 <= ans+k) ans *= 2;
    else ans += k;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans=0;
  vector<int> A(N);
  vector<int> B(N-1);
  
  rep(i, N-1) cin >> B[i];
  
  rep(i, N){
  	if(i==0) ans += B[0];
    else if(i==N-1) ans += B[N-2];
    else{
    	ans += min(B[i-1], B[i]);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
void main(){
	long k, x;
	readf("%d %d", &k, &x);
	writeln(k*500>=x? "Yes": "No");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2812
h,w=map(int,input().split())
l=[chr(i) for i in range(97, 97+26)]
d={i:j for i,j in zip(l,range(26))}
c=[0]*26
for i in range(h):
    s=input()
    for j in s:
        c[d[j]]+=1
if h%2==0 and w%2==0:
    if all([i%4==0 for i in c]):#偶数×偶数のとき、全てが4の倍数でなければならない
        print("Yes")
    else:print("No")
else:
    k=(h//2)*(w//2)
    if h%2==1 and w%2==1:
        if sum([i%2 for i in c])==1:
            if h==1 or w==1:
                print("Yes") 
            elif sum([i//4 for i in c])>=k:
                print("Yes")
            else:print("No")
        else:
            print("No")
    else:
        if sum([i%2 for i in c])==0:
            if h==1 or w==1:
                print("Yes")
            elif sum([i//4 for i in c])>=k:
                print("Yes")
            else:print("No")
        else:print("No")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <climits>
using namespace std;

int h,map[10][5];
int main(){
    while(scanf("%d",&h),h){
		int ans=0;		
		for(int i=0;i<10;i++)
			for(int j=0;j<5;j++)
				if(i<h)
		 			scanf("%d",&map[h-i-1][j]);
		 		else 
		 			map[i][j]=0;
		bool boo=true;
		while(boo){
			boo=false;
			for(int z=0;z<10;z++){
			for(int i=0;i<h;i++){
				for(int j=0;j<5;j++)
					if(map[i][j]==0){
						for(int k=i+1;k<h;k++){
							map[k-1][j]=map[k][j];
							map[k][j]=0;
						}					
					}
			}
			}
			/*
			for(int i=0;i<h;i++){
				for(int j=0;j<5;j++){
					printf("%d ",map[i][j]);
				}
				printf("\n");
			}
			printf("\n");
			*/
			for(int i=0;i<h;i++){
			 	int a=-1,b=0,t=0;
			 	for(int j=0;j<5;j++){
			 		if(map[i][j]==a){
			 			t++;
			 		}else if(t<3){
			 			a=map[i][j];
			 			b=j;
			 			t=1;
			 		}else break;
			 	}
			 	
			 	if(t>=3){
			 		if(a==0)continue;
			 		boo=true;
			 		ans+=a*t;
			 		//printf("%d %d %d\n%d\n",a,b,t,ans);
			 		for(int j=0;j<t;j++)
			 			map[i][b+j]=0;
			 	}
			 }
		}
		printf("%d\n",ans);
    }
    return 0;
}

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

using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    long long q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    long long q1 = q * 8, h1 = h * 4, s1 = s * 2, d1 = d;
    vector <long long> a(4);
    a[0] = q1, a[1] = h1, a[2] = s1, a[3] = d;
    int mn = 0;
    for (int i = 0; i < 4; ++i)
        if (a[i] < a[mn])
            mn = i;
    long long cnt = 0;
    while (n > 0) {
        if (n >= 2) {
            cnt += (n / 2) * a[mn];
            n = n % 2;
        } else {
            int mn1 = 0;
            for (int i = 0; i < 3; ++i) {
                if (a[i] < a[mn1])
                    mn1 = i;
            }
            cnt += a[mn1] / 2;

            n = 0;
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
X = list(map(int, input().split()))

X.sort()
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        k = bisect_left(X, X[i] + X[j])
        ans += k - j - 1

print(ans)


Measured memory_bytes: 68584
#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 mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
  ll n,x,t;
  cin>>n>>x>>t;
  ll no = (n+x-1)/x;
  no*=t;
  cout<<no<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

int main()
{
 	ios::sync_with_stdio(0);
 	cin.tie(0);
 	int n;
	cin>>n;
	int x[n+1];
	
	for(int i=1; i<=n; i++)	cin>>x[i];
	sort(x+1,x+n+1);
	
	int minv=0,naili=1e9;
	for(int p=x[1]; p<=x[n]; p++)
	{
		minv=0;
		for(int i=1; i<=n; i++)
		{
			minv+=(x[i]-p)*(x[i]-p);
		}
		
		if(minv<naili)
			naili=minv;
	}
	
	cout<<naili<< endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000

int n, s[MAX];

int numsearch(int );

int main()
{
  int i, j, ans, count=0, q, t[MAX];

  scanf("%d", &n);

  for( i=0; i<n; i++){
    scanf("%d", &s[i]);
  }

  scanf("%d", &q);

  for( i=0; i<q; i++){
    scanf("%d", &t[i]);
  }

  for( i=0; i<q; i++){
    if( numsearch(t[i]) == 1 )count++;
  }

  printf("%d\n", count);

  return 0;
}

int numsearch(int num)
{
  int i;

  for( i=0; i<n; i++){
    if( s[i] == num )return 1;
  }

  return 0;
}

Measured memory_bytes: 644
#include <iostream>
#include <string>

int main() {
  std::string str;
  std::cin >> str;
  
  long long sum = 0;
  
  for(char c: str) {
    sum += c-int('0');
  }
  
  std::cout << (sum % 9 == 0 ? "Yes\n": "No\n");
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int sx,sy,tx,ty;

signed main(void) {
    cin>>sx>>sy>>tx>>ty;
    int dx = tx-sx;
    int dy = ty-sy;
    rep(i, dx) {
        cout<<'R';
    }
    rep(i, dy) {
        cout<<'U';
    }
    
    rep(i, dx) {
        cout<<'L';
    }
    rep(i, dy) {
        cout<<'D';
    }
    
    cout<<'D';
    rep(i, dx+1) {
        cout<<'R';
    }
    rep(i, dy+1) {
        cout<<'U';
    }
    cout<<'L';
    
    cout<<'U';
    rep(i, dx+1) {
        cout<<'L';
    }
    rep(i, dy+1) {
        cout<<'D';
    }
    cout<<'R';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	  private static int find(int dest, int[] a, int s, int e) {
		    if (s == e) {
		      return s;
		    }
		    int m = (s + e + 1) / 2;
		    return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);
		  }
	
	static boolean nextPermutation(int[] a){
	    for (int i = a.length - 1; i > 0; --i) {
	        if (a[i - 1] < a[i]) {
	          int swapIndex = find(a[i - 1], a, i, a.length - 1);
	          int temp = a[swapIndex];
	          a[swapIndex] = a[i - 1];
	          a[i - 1] = temp;
	          Arrays.sort(a, i, a.length);
	          return true;
	        }
	      }
	      return false;		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextInt();
		}
		for(int i = 0 ; i < N ; ++i){
			B[i] = sc.nextInt();
		}
		int C[] = new int[N];
		for(int i = 0 ; i < N ; ++i){
			C[i] = i + 1;
		}
		int a = 0;
		int b = 0;
		int cnt = 0;
		do{
//			System.out.println(Arrays.toString(C));
			if(Arrays.equals(A, C)){
				a = cnt;
			}
			if(Arrays.equals(B, C)){
				b = cnt;
			}
			++cnt;
		}while(nextPermutation(C));
		System.out.println(Math.abs(a - b));
	}
}


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

const int INF = (1 << 30) - 1;

struct Unionfind
{
	vector < int > par;

	Unionfind(int n)
	{
		par = vector < int >(n);
		for ( int i = 0; i < n; i++ ) {
			par[i] = i;
		}
	}

	void unite(int x, int y)
	{
		x = root(x), y = root(y);
		if ( x == y ) return;
		par[x] = y;
	}
	
	bool same(int x, int y)
	{
		return ( root(x) == root(y) );
	}

	int root(int n)
	{
		return (par[n] = ( par[n] == n ? n : root(par[n]) ));
	}
};

struct Edge
{
	int a, b, c;
	Edge () {}
	Edge ( int a, int b, int c) : a(a), b(b), c(c) {}
	bool operator < ( const Edge &d ) const
	{
		return ( c < d.c );
	}
};

int main()
{
	int n, m;
	Edge edges[5555];

	while ( cin >> n >> m, n ) {

		for ( int i = 0; i < m; i++ ) {
			cin >> edges[i].a >> edges[i].b >> edges[i].c;
			--edges[i].a, --edges[i].b;
		}
		sort(edges, edges + m);
		int minv = INF;
		for ( int i = 0; i < m - n + 2; i++ ) {
			int cnt = 0, j;
			Unionfind tree(n);
			for ( j = i; j < m && cnt < n - 1; j++ ) {
				if ( !tree.same(edges[j].a, edges[j].b) ) {
					cnt++;
					tree.unite(edges[j].a, edges[j].b);
				}
			}
			if ( cnt == n - 1 ) {
				minv = min(minv, edges[j - 1].c - edges[i].c);
			}
		}

		if ( minv == INF ) {
			cout << -1 << endl;
		} else {
			cout << minv << endl;
		}

	}
	return ( 0 );
}



Measured memory_bytes: 3124
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, m, sum = 0, selected = 0;
    cin >> n >> m;

    vector<int> votes(n);

    for (int i = 0; i < n; i++)
    {
        cin >> votes[i];
        sum += votes[i];
    }

    double min = double(sum)/(4*m);

    for (int vote : votes)
    {
        if (vote >= min) selected++;
    }

    if (selected >= m) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	z := getNextInt(scanner)
	w := getNextInt(scanner)

	aa := make([]int, n)

	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}

	if n == 1 {
		fmt.Println(absint(w - aa[n-1]))
		return
	}

	fmt.Fprintln(writer, maxint(absint(w-aa[n-1]), absint(aa[n-2]-aa[n-1])))

	writer.Flush()
	fmt.Fprintln(writer, z)
}

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

func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <set>
#include <vector>

using namespace std;

const int N = 2e5 + 10;

vector<int> adj[N];
int n;
int ans;

int dfs(int u, int p) {
  int mx = 0, mx2 = 0;
  for (int v : adj[u]) {
    if (v == p) continue;
    int val = dfs(v, u) + 1;
    if (val > mx) {
      mx2 = mx;
      mx = val;
    } else if (val > mx2) {
      mx2 = val;
    }
  }
  ans = max(ans, mx + mx2 + 1);
  return mx;
}

int main() {

  cin >> n;
  for (int i = 0; i+1 < n; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  dfs(1, -1);

  cout << (ans % 3 != 2 ? "First" : "Second") << endl;

  return 0;
}



Measured memory_bytes: 23168
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<stack>
#include<array>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<numeric>
#include<random>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
using namespace std;

bool isAcceptable(int price, vector<int>D) {
	for (int p = price; 0 < p; p /= 10)EACH(i, D)if (p % 10 == i)return false;
	return true;
}

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

	int N, K;
	cin >> N >> K;
	vector<int>D(K);
	rep(i, K)cin >> D[i];
	while (!isAcceptable(N, D))N++;
	cout << N << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back
#define MP make_pair

using namespace std;

int main(){
	lint n,m;
	lint a[50],b[50],c[50],d[50],ans[50],anss[50];
	cin>>n>>m;
	rep(i,0,n){
		cin>>a[i]>>b[i];
	}
	rep(i,0,m){
		cin>>c[i]>>d[i];
	}
	rep(i,0,50){
		ans[i]=10000000000;
	}
	lint e,f;
	rep(i,0,n)rep(j,0,m){
		if(a[i]-c[j]>0)e=a[i]-c[j];
		else e=c[j]-a[i];
		if(b[i]-d[j]>0)f=b[i]-d[j];
		else f=d[j]-b[i];
		if(ans[i]>e+f){
			ans[i]=e+f;
			anss[i]=j+1;
		}
	}
	rep(i,0,n){
	cout<<anss[i]<<endl;
	}
return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 
const long long mod = 1000000007;
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    int ans = 0;
    FOR(i,K,N+1){
        ans+=N*i-(i-1)*i+1;
        ans%=divs;
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 3788
import math

N = int(input())
nums = [int(input()) for _ in range(N)]

def is_prime(num):
    if num < 2:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        for prime in range(2, num_sqrt + 1):
            if num % prime == 0:
                return False
                break
        return True

print(len([n for n in nums if is_prime(n)]))



Measured memory_bytes: 6020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    int a,b;
    cin >> a >> b;
    if(a == 1 && b == 2) cout << 3 << endl;
    else if(a == 1 && b == 3) cout << 2 << endl;
    else if(a == 2 && b == 1) cout << 3 << endl;
    else if(a == 2 && b == 3) cout << 1 << endl;
    else if(a == 3 && b == 1) cout << 2 << endl;
    else if(a == 3 && b == 2) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, now, ans = 0, tmp, r = 1;
  scanf("%lld%lld", &n, &k);
  ll a[n], b[n];
  now = k;
  for(i = 0; i < n; ++i) scanf("%lld%lld", &a[i], &b[i]);
  while( 1 ) {
    tmp = 0;
    for(i = 0; i < n; ++i) if((now | a[i]) == now) tmp += b[i];
    if(ans < tmp) ans = tmp;
    while(!(r & now) && r <= k) now += r, r <<= 1;
    now -= r;
    if(r > k) break;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <cstdio>
#define mod 1000000007
using namespace std;
char s[1000006];
int f[1000006], last[3];
int main(){
	scanf("%s", s + 1);
	int n = strlen(s + 1), c = 0;
	bool flag = false;
	for (int i = 2; i <= n; ++ i)
		if (s[i] == s[i - 1]){
			flag = true;
			break;
		}
	if (! flag){
		cout << 1 << endl;
		return 0;
	}
	last[1] = n + 1, last[2] = n + 1;
	f[0] = 1;
	for (int i = 1; i <= n; ++ i){
		(c += s[i] == 'a' ? 1 : 2) %= 3;
		if (c == 0 && i < n)
			f[i] = 1;
		(f[i] += f[last[(c + 1) % 3]]) %= mod;
		(f[i] += f[last[(c + 2) % 3]]) %= mod;
		last[c] = i;
	}
	cout << f[n] << endl;
}


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

int main() {
  int num;
  int asum = 0;
  int bsum = 0;
  cin >> num;
  vector<int> vec(num);
  
  for(int i = 0; i < num; i++) cin >> vec.at(i);
  
  sort(vec.begin(),vec.end(),greater<int>());
  for(int i = 0; i < num; i++){
    if(i % 2 == 0) asum += vec.at(i);
    else bsum += vec.at(i);
  }

  cout << asum - bsum;
}


Measured memory_bytes: 256