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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

constexpr int MAX = 1e6 + 10;

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, cnt = 0;
  bool ans[MAX] = {true};
  cin >> n;
  vector<int> x(n);
  arep(i, x) cin >> i;
  sort(all(x));
  // arep(i, x) cout << i << ' ';

  rep(i, 0, n) {
    if (ans[x[i]] == false) {
      if (x[i] != x[i + 1]) ++cnt;
      for (int j = x[i]; j <= MAX; j += x[i]) ans[j] = true;
    }
  }

  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 5836
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

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

# ans = 0
# for i in range(1,L+1):
#     for j in range(1,L-i+1):
#         k = L-i-j
#         ans = max(ans,i*j*k)

ans = (L/3)**3
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 3060
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    int ans = 1;
    for (int i = 0; i < n; i++) {
      ans = Math.min(ans * 2, ans + k);
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23252
A,B,C=map(int, input().split())
odd=[]
even=[]
for x in [A,B,C]:
    if x%2==0:
        even.append(x)
    else:
        odd.append(x)
cnt = 0
ns = []
if len(even) == 2:
    for x in even:
        cnt = 1
        ns.append(x+1)
else:
    ns.extend(even)
if len(odd) == 2:
    for x in odd:
        cnt = 1
        ns.append(x+1)
else:
    ns.extend(odd)

ns.sort()
max_v = max(ns)
for x in ns:
    cnt += (max_v-x) // 2

print(cnt)

Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		var k = Console.ReadLine().ToLong();
		
		for(int i = 0; i < Math.Min(k, s.Length); i++)
		{
			if(s[i]-'0' != 1)
			{
				Console.WriteLine(s[i]);
				return;
			}
		}
		Console.WriteLine(1);
		
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b;
    cin >> a >> b;
    
    int x[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};

    cout << (x[a] == x[b] ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$chars = str_split(trim(fgets(STDIN)));
$k = trim(fgets(STDIN));

$kth = $chars[$k - 1];
foreach ($chars as $char) {
	if ($char === $kth) {
    	echo $char;
    } else {
    	echo '*';
    }
}
echo PHP_EOL;

Measured memory_bytes: 4856
#include "stdio.h"

int N, D, X;

int main(int argc, char* argv[])
{
	int ans=0;
	int i;
	int a;

	scanf("%d%d%d", &N, &D, &X);

	ans += X;
	for(i=0;i<N;i++){
		scanf("%d", &a);
		ans += (D-1)/a + 1;
	}


	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 128
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);
#define asc(A) sort(A.begin(),A.end())
#define dsc(A) sort(A.begin(),A.end(),greater<ll>())
#define input(A,N) for(ll i=0;i<N;i++) cin>>A[i];
int main()
{
    fasino
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    #endif
    ll s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else
        cout<<"safe";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A.at(i);
    
    char x = '=';
    int ans = 1;
    for(int i = 0; i < N-1; i++) {
        if(x=='=') {
            if(A.at(i)<A.at(i+1)) x = '<';
            if(A.at(i)>A.at(i+1)) x = '>';
        }
        if(x=='<') {
            if(A.at(i)<=A.at(i+1)) continue;
            else {
                x = '=';
                ans++;
            }
        }
        if(x=='>') {
            if(A.at(i)>=A.at(i+1)) continue;
            else {
                x = '=';
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int s; cin >> s;
    vector<int> a(s+1, 0);
    FOR(i, 3, s+1) {
        ll cnt = 1;
        FOR(j, 3, i) {
            // debug(i, j);
            cnt += a[i-j]%MOD;
        }
        a[i] = cnt%MOD;
    }
    // debug(a);
    cout << a.back() << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
//        System.out.println("S＝");
        int S = Integer.parseInt(scan.next());
//        System.out.println("W＝");
        int W = Integer.parseInt(scan.next());

        if (S <= W) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}


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

int main(){
  long long N;
  cin>>N;
  long long A[N];
  long long B[N];
  for(long long i=0;i<N;i++){
    cin>>A[i];
    B[i]=A[i]-(i+1);
  }
  
  long long T=0;
  sort(B,B+N);
  if(N%2==0){
    T=(B[N/2]+B[N/2-1])/2;
  }
  else T=B[(N-1)/2];
    
  long long ans=0;
  long long minans=10e18;
  for(long long i=T-2;i<=T+2;i++){
    ans=0;
    for(long long j=0;j<N;j++){
      ans+=abs(A[j]-(j+i));
      //cout<<abs(A[j]-(j+i));
    }
    //cout<<i<<" "<<ans<<"#"<<endl;
    minans=min(ans,minans);
  }
  cout<<setprecision(18)<<minans<<endl;
  return 0;
}


Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	rep(i,n) cin>>a[i];

	if(n==2){
		cout<<max(a[0],a[1])<<endl;
	}

	//nが偶数の時
	if(n%2==0 && n!=2){
		ll dp0[n+10][2],dp1[n+10],which=max(a[n-1],a[n-2]),MAX=-INF;
		rep(i,n+10) dp1[i]=-INF;
		rep(i,n+10) rep(j,2) dp0[i][j]=-INF;

		dp0[0][0]=a[0];
		dp1[1]=a[1];

		//0start
		for(ll i=0;i<n-2;i++){
			for(ll j=0;j<2;j++){
				if(dp0[i][j]==-INF) continue;
				if(i+2<n) chmax(dp0[i+2][j],dp0[i][j]+a[i+2]);
				if(i+3<n && j+1<2) chmax(dp0[i+3][j+1],dp0[i][j]+a[i+3]);
			}
		}
		MAX=max(dp0[n-2][0],dp0[n-1][1]);

		//1start
		for(ll i=1;i<n;i++){
			if(i+2<n){
				if(dp1[i]==-INF) continue;
				chmax(dp1[i+2],dp1[i]+a[i+2]);
			}
		}
		MAX=max(MAX,dp1[n-1]);

		cout<<MAX<<endl;
	}

	//nが奇数の時
	if(n%2==1){
		ll dp0[n+10][3],dp1[n+10][2],dp2[n+10],MAX=-INF;
		rep(i,n+10) rep(j,3) dp0[i][j]=-INF;
		rep(i,n+10) rep(j,2) dp1[i][j]=-INF;
		rep(i,n+10) dp2[i]=-INF;

		dp0[0][0]=a[0];
		dp1[1][0]=a[1];
		dp2[2]=a[2];

		//2start
		for(ll i=2;i<n;i++){
			if(dp2[i]==-INF) continue;
			if(i+2<n) chmax(dp2[i+2],dp2[i]+a[i+2]);
		}
		MAX=max(MAX,dp2[n-1]);
		
		//1start
		for(ll i=1;i<n;i++){
			for(ll j=0;j<2;j++){//j:2個飛ばしを使った回数(1回しか使ってはならない)
				if(dp1[i][j]==-INF) continue;
				if(i+2<n) chmax(dp1[i+2][j],dp1[i][j]+a[i+2]);
				if(i+3<n && j+1<2) chmax(dp1[i+3][j+1],dp1[i][j]+a[i+3]);
			}
		}
		MAX=max(MAX,max(dp1[n-2][0],dp1[n-1][1]));
		
		//0start
		for(ll i=0;i<n;i++){
			for(ll j=0;j<3;j++){//j:2個飛ばしは2回まで、3個飛ばしは1回まで
				if(dp0[i][j]==-INF) continue;
				if(i+2<n) chmax(dp0[i+2][j],dp0[i][j]+a[i+2]);
				if(i+3<n && j+1<3) chmax(dp0[i+3][j+1],dp0[i][j]+a[i+3]);
				if(i+4<n && j+2<3) chmax(dp0[i+4][j+2],dp0[i][j]+a[i+4]);
			}
		}
		MAX=max(MAX,max(dp0[n-3][0],max(dp0[n-2][1],dp0[n-1][2])));
	
		cout<<MAX<<endl;
	}

	return 0;
}

Measured memory_bytes: 14308
#include <stdio.h>
#include <string.h>

typedef struct {
	char name[30];
	int score;
} TEAM;
	
	
int main(void)
{
	int n, i, j, f = 0;
	int win, lose, draw;
	TEAM team[10], temp;
	

	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%s %d %d %d", team[i].name, &win, &lose, &draw);
			team[i].score = win * 3 + draw;
		}
		
		for (i = 0; i < n; i++){
			for (j = n - 1; j > i; j--){
				if (team[j].score > team[j-1].score){
					strcpy(temp.name, team[j-1].name);
					temp.score = team[j-1].score;
					
					strcpy(team[j-1].name, team[j].name);
					team[j-1].score = team[j].score;
					
					strcpy(team[j].name, temp.name);
					team[j].score = temp.score;
				}
			}
		}
		if (f == 1){
			puts("");
		}
		for (i = 0; i < n; i++){
			printf("%s,%d\n", team[i].name, team[i].score);	
			f = 1;
		}
	}
	
	return (0);
}

Measured memory_bytes: 620
import itertools
import math
n,d = map(int,input().split(" "))
points = []
for i in range(n):
    points.append([int(e) for e in input().split(" ")])

all_pattern = list(itertools.combinations(points,2))
result = 0

for i in all_pattern:
    a = i[0]
    b = i[1]
    tmp = 0
    for j,e in enumerate(a):
        tmp += (e - b[j])**2
    if math.sqrt(tmp).is_integer():
        result += 1

print(result)

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

int main(){
  int n;
  cin >> n;
  set<int> s;
  vector<int> c(n,0);
  rep(i,n){
    int a;
    cin >> a;
    s.insert(a);
    c[a]++;
  }
  if(s.size() > 2) cout << "No" << endl;
  else if (s.size() == 1) {
    int p = *s.begin();
    if(n == p+1 || n >= 2*p) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    int p = *s.begin(); s.erase(p);
    int q = *(s.begin());
    if(q - p != 1) cout << "No" << endl;
    else {
      if(c[p] < q && c[q] >= (q-c[p])*2) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
  return 0;
}

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

int main()
{
    int p[4] = {0, 0, 0, 0};
    rep(i, 3)
    {
        int a, b;
        cin >> a >> b;
        p[a - 1]++;
        p[b - 1]++;
    }
    rep(i, 4)
    {
        if (p[i] == 3)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Prime Number II
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int N = 50000;
		int overN = 0;
		int underN = 0;
		boolean[] prims = new boolean[N + 1];

		for (int i = 2; i < N / 2 + 1; i++) {
			if (!prims[i]) {
				for (int j = 2; j < N / i + 1; j++) {
					prims[i * j] = true;
				}
			}
		}
		for (int i = N + 1; ; i++) {
			int count = 0;
			for (int j = 2; j < i; j++) {
				if (i % j == 0) {
					count++;
				}
			}
			if (count == 0) {
				overN = i;
				break;
			}
		}
		for (int i = N; ; i--) {
			if (!prims[i]) {
				underN = i;
				break;
			}
		}

		int primU = 0, primL = 0;
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line);
			//U
			if (n >= underN) {
				primU = overN;
			} else {
				for (int i = n + 1; ; i++) {
					if (!prims[i]) {
						primU = i;
						break;
					}
				}
			}
			//L
			for (int i = n - 1; ; i--) {
				if (!prims[i]) {
					primL = i;
					break;
				}
			}
			System.out.println(primL + " " + primU);
		}
	}
}

Measured memory_bytes: 20088
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

string t,s;
int S,T;

bool match(int k){
  for(int i=0;i<T;i++){
    if(t[i]!=s[i+k]&&s[i+k]!='?'){
      return false;
    }
  } 
  return true;
}

string construct(int k){
  string ans=s; 
  for(int i=0;i<T;i++){
    ans[k+i]=t[i];
  }
  for(int i=0;i<S;i++){
    if(ans[i]=='?'){ans[i]='a';}
  }
  return ans;
}

int main() {
  cin>>s>>t;
  S=s.size(),T=t.size();
  vector<string>table;
  //table.push_back("000");
  if(S<T){cout<<"UNRESTORABLE"<<endl;return 0;}
  bool ok=false;
  for(int i=0;i<=S-T;i++){
    if(match(i)){ok=true;table.push_back(construct(i));}
  }
  if(!ok){cout<<"UNRESTORABLE"<<endl;return 0;}
  sort(table.begin(),table.end());
  cout<<table[0]<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>


int main(){

    int i=0;

    char a [300000];

    scanf("%s",&a);

    for(i=0;i<300000;i++){

        if(a[i]=='?'){
            if(a[i-1]=='P'){
                a[i]='D';
            }else if(a[i+1]=='D'){
                a[i]='P';
            }else{
                a[i]='D';
            }
        }
        
    }
    printf("%s",a);



    return 0;




}

Measured memory_bytes: 1932
#include <iostream>
#include <string>
using namespace std;
int N, K;
string S;

void input() {
    cin >> N >> K;
    cin >> S;
}
string solve() {
    S.at(K-1)+=32;
    return S;
}
int main() {
    input();
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i , n) for(int i=0;i<n;i++)



class DICE{
	int tmp , tmp2;
	public:
	int s[6];
	void turnE();
	void turnN();
	void turnS();
	void turnW();
	void turnR();
	void turnL();
	void SetT(int a , int b);
	void SetS(int a);
	bool CheckDICE(int a0 ,int a1 , int a2, int a3, int a4 , int a5);
} ;

void DICE::turnE(){
	tmp=s[0];
	s[0]=s[3];
	s[3]=s[5];
	s[5]=s[2];
	s[2]=tmp;
}

void DICE::turnN(){
	tmp=s[0];
	s[0]=s[1];
	s[1]=s[5];
	s[5]=s[4];
	s[4]=tmp;
}

void DICE::turnS(){
	tmp=s[0];
	s[0]=s[4];
	s[4]=s[5];
	s[5]=s[1];
	s[1]=tmp;
}

void DICE::turnW(){
	tmp=s[0];
	s[0]=s[2];
	s[2]=s[5];
	s[5]=s[3];
	s[3]=tmp;
}

void DICE::turnR(){
	tmp=s[1];
	s[1]=s[2];
	s[2]=s[4];
	s[4]=s[3];
	s[3]=tmp;
}

void DICE::turnL(){
	tmp=s[1];
	s[1]=s[3];
	s[3]=s[4];
	s[4]=s[2];
	s[2]=tmp;
}

void DICE::SetS(int a){
	if(s[2]==a) {
		turnR();
	} else if (s[3]==a){
		turnL();
	} else if (s[4]==a){
		turnR();
		turnR();
	}
}

void DICE::SetT(int a , int b){ 
	tmp=a;
	tmp2=b;
	rep(i ,6){
		if(s[i]==a){
			switch(i){
				case 0:
					SetS(b);
					break;
				case 1:
					turnN();
					SetS(b);
					break;
				case 2:
					turnW();
					SetS(b);
					break;
				case 3:
					turnE();
					SetS(b);
					break;
				case 4:
					turnS();
					SetS(b);
					break;
				case 5:
					turnN();
					turnN();
					SetS(b);
					break;
			}
		}
	}	
}

bool DICE::CheckDICE(int a0 ,int a1 ,int a2 , int a3 , int a4 , int a5){
	bool b=true;
	int i,j,k;
	
	int c[6]={0};
	for(k=0;k<6;k++){
		for(j=0;j<6;j++){
			if(s[k]==s[j]) c[k]++;
		}
	}
	for(k=0;k<6;k++){
		if(c[k]==5) {
			b=true; 
			return b;
		} 
	}
	
	for(i=0 ; i<6 ; i++){
		if(s[i]==a0) break;
	}
	switch (i){
		case 0:
			break;
		case 1:
			turnN();
			break;
		case 2:
			turnW();
			break;
		case 3:
			turnE();
			break;
		case 4:
			turnS();
			break;
		case 5:
			turnN();
			turnN();
			break;
		case 6:
			b=false;
			return b;
	}
	for(i=1 ; i<6 ; i++){
		if(s[i]==a1){ 
			if(i==1){
				if( s[2]!=a2 || s[3]!=a3 || s[4]!=a4 || s[5]!=a5) {b=false; break;}
			} else if(i==2){
				turnR();
				if( s[2]!=a2 || s[3]!=a3 || s[4]!=a4 || s[5]!=a5) {b=false; break;}
			} else if(i==3){
				turnL();
				if( s[2]!=a2 || s[3]!=a3 || s[4]!=a4 || s[5]!=a5) {b=false; break;}
			} else if(i==4){
				turnL();
				turnL();
				if( s[2]!=a2 || s[3]!=a3 || s[4]!=a4 || s[5]!=a5) {b=false; break;}
			} else if (i==5){
				b=false;
				break;
			}
		} else if (s[i]==a5 && i!=5) {b=false; break;}
		else if (s[i]!=a1 && s[i]!=a2 && s[i]!=a3 && s[i]!=a4 && s[i]!=a5) {b=false ; break;}
		
	}
	return b;
}

int main(){
	int n ,i, j;
	cin>>n;
	DICE* d = new DICE [n];
	for(i=0 ; i<n ; i++){
		cin >> d[i].s[0] >>d[i].s[1] >> d[i].s[2] >> d[i].s[3] >> d[i].s[4] >> d[i].s[5];
	}
	for(i=0 ; i<n ; i++){
		for (j=i+1 ; j<n ; j++){
			if(d[i].CheckDICE(d[j].s[0] , d[j].s[1] , d[j].s[2] , d[j].s[3] , d[j].s[4] , d[j].s[5])) goto skip;
		}
	}
	skip:
	if (i==n){
		cout << "Yes" << endl; 
	} else {
		cout << "No" << endl;
	}
	delete [] d;
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

int N, x, a[100000];

int main(void){
	cin >> N >> x;
	for(int i = 0; i < N; i++) cin >> a[i];

	ll res = 0;
	if(a[0] > x){
		res += a[0] - x;
		a[0] = x;
	}
	if(a[N-1] > x){
		res += a[N-1] - x;
		a[N-1] = x;
	}

	for(int i = 0; i < N-1; i++){
		if(a[i] + a[i+1] > x){
			res += a[i] + a[i+1] - x;
			a[i+1] = x - a[i];
		}
	}

	cout << res << '\n';

	return 0;
}


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

# define ll long long 
# define VI vector<int>
# define VLL vector<ll>
# define PII pair<int,int> 
# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ld long double
const int MxN = 200001 ; 
# define FOR(i,a,b) for(int i = a ; i < b ; ++i)
# define RFOR(i,a,b) for(int i = a ; i >= b ; --i)
const int MOD = 1e9 + 7 ; 

/* VARIABLES */
int n , d ; 
/* END OF VARIABLES */



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

	cin >> n  >> d ; 
	int cnt = 0 ; 
	ld x , y  ; 
	FOR(i,0,n) {
		cin >> x >> y ; 
		ld dis = sqrt((double) x*x + y*y ); 
		//cout << dis ; 
		if(dis <= d) 
			cnt ++;
	}
	cout << cnt ; 
	

	
	
	return 0 ; 
}



Measured memory_bytes: 3828
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n,k;
    int ans=0;
    scanf("%d%d",&n,&k);
    int ball[400];
    for(int i=1;i<=n;i++){
        scanf("%d",&ball[i]);
    }
    for(int i=1;i<=n;i++){
        if(ball[i]<=k/2){
            ans+=ball[i]*2;
        }
        else{
            ans+=(k-ball[i])*2;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
h,w,d = gets.chomp.split().map(&:to_i)
a=[]
h.times do
  a.push gets.chomp.split().map(&:to_i)
end
q = gets.chomp.to_i
l,r=q.times.map{gets.split.map(&:to_i)}.transpose

pos = Array.new(h*w+1)
h.times do |i|
  w.times do |j|
    pos[a[i][j]] = [i,j]
  end
end

costs = Array.new(h*w+1, 0)
(1..(pos.size-d-1)).each do |i|
  ini = costs[i-d] || 0
  costs[i] = ini + (pos[i][0] - pos[i+d][0]).abs + (pos[i][1] - pos[i+d][1]).abs
end
#p costs
#p [l,r]

l.zip(r).each do |l,r|
  puts costs[r-d] - costs[l-d]
end


Measured memory_bytes: 27388
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
const int MAX=1000000;

int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int m,n;
   m=min(a,b);
   n=min(c,d);
   cout<<m+n<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	var m [1000]bool
	for _, v := range s {
		m[v] = true
	}

	if m['a'] && m['b'] && m['c'] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1768
using System;

class Program
{
    private static readonly Scanner sc = new Scanner();
    private const int INF = 1010101010;
    static void Main(string[] args)
    {
        long n = sc.Long;
        long nf = (long)Math.Floor(Math.Sqrt(n));
        while (n % nf != 0)
            nf--;
        long al = n / nf;
        Console.WriteLine(al.ToString().Length);
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Console.ReadLine().Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int own;
    int kinds;
    int *consume;
    int count=0;
    int min_consume=1000;

//    printf("Input the number of kinds of donuts:");
    scanf("%d",&kinds);
  //  printf("Input the amount of the basis of sweets:");
    scanf("%d",&own);

    consume=(int *)malloc(kinds*sizeof(int));
    int i;

    for(i=0;i<kinds;i++){
        scanf("%d",&consume[i]);
        count++;
        own-=consume[i];
        if(consume[i]<min_consume){
            min_consume=consume[i];
        }
    }
    count+=own/min_consume;
    printf("%d",count);
    return 0;
}

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

#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define pb(x) push_back(x)

ll mod = 1e9 + 7;

ll p(ll num, ll power){
  ll ans = 1;
  for(int i=1;i<=power;++i){
    ans *= num;
    ans %= mod;
  }
  return ans%mod;
}

int main() {
  ll n;cin>>n;
  cout<<(p(10,n)%mod - 2*p(9,n)%mod + p(8,n)%mod + mod)%mod;

}

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

int main() {
	int n, a, b;
	cin >> a >> b;
	if (a == b) {
		cout << "Draw" << endl;
	} else {
		if (a == 1){
			a *= 1000;
		} else if (b == 1){
			b *= 1000;
		}
		if (a > b){
			cout << "Alice" << endl;
		} else {
			cout << "Bob" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n+1];
		arr[0] = -1;
		for(int i = 1; i < n+1; i++) {
			arr[i] = sc.nextInt();
		}
//		System.out.println(Arrays.toString(arr));
		String ans = "Yes";
		for (int i = 1; i < n; i++) {
			if (arr[i] <= arr[i+1] - 1) {
				arr[i+1]--;
			}
			else if (arr[i] <= arr[i+1]) {
				continue;
			}
			else {
				ans = "No";
				break;
			}
		}
//		System.out.println(Arrays.toString(arr));
		System.out.println(ans);
	}
}


Measured memory_bytes: 50608
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
  ll ar[n];
  rep(i,0,n) cin>>ar[i];
  m=ar[0];
  rep(i,1,n)
  {
    if(ar[i]>=m) {m=ar[i];continue;}
    k+=(m-ar[i]);
  }
  cout<<k;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
static const long long MOD=1000000007;

int main(){
  long long F[1001];
  for(int i=0;i<1001;i++) F[i]=0;
  long long N;
  cin>>N;
  
  for(long long i=1;i<=N;i++){
    long long temp=i;
    while(temp>1){
      for(int j=2;j<=temp;j++){
        if(temp%j==0){
          F[j]++;
          temp=temp/j;
          j--;
        }
        
      }
    }
  }
  long long ans=1;
  for(long long i=1;i<N+1;i++){
    if(F[i]>0){
      ans=ans*(F[i]+1)%MOD;
    }
  }
  
  cout<<setprecision(18)<<ans<<endl;
  return 0;
}


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

int main(){

    int a, b, tmpmax = 0, tmpmin = 0, tmpdif = 0;

    vector<int> v;
    while(cin>>a>>b,a||b){

        map<int,int> mp;
        mp[a] = 1;
        v.resize(b,0);

        for(int i=b-1;i>=0;i--){
            v[i]=a%10;
            a/=10;
        }
        for(int i=2;;i++){
            tmpmax = 0;
            tmpmin = 0;
            tmpdif = 0;
            sort(v.begin(),v.end(),greater<int>());
            for(int j=0;j<b;j++){
                tmpmax=tmpmax*10+v[j];

            }
            //cout << tmpmax;
            sort(v.begin(),v.end());
            for(int j=0;j<b;j++){
                tmpmin=tmpmin*10+v[j];

            }
          //  cout << " " << tmpmin << endl;
            tmpdif = tmpmax-tmpmin;
            if(mp[tmpdif]!=0){
                cout << mp[tmpdif]-1 << " " << tmpdif<<" " << i - mp[tmpdif] << endl;
                break;
            }else{
                mp[tmpdif] = i;
                
                for(int j=b-1;j>=0;j--){
                    v[j]=(tmpdif)%10;
                    tmpdif/=10;
               //     cout << v[j];
                }
                //cout << endl;
            }
        }

    }
}


Measured memory_bytes: 3156
input = gets.chomp.split.map!(&:to_i)
dekiru = 1
(0..input[0]).each{ |i|
  (0..input[0] - i).each{ |j|
    if (10000 * i + 5000 * j + 1000 * (input[0] - i - j)) == input[1] then
      printf("%d %d %d", i, j, input[0] - i - j)
      dekiru = 0
      break
    end
  }
  if dekiru == 0
    break
  end
}
if dekiru == 1
  puts "-1 -1 -1"
end

Measured memory_bytes: 1788
import java.util.Scanner;

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

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();

        System.out.printf("%d %d\n",a*b,2*(a+b));
        stdIn.close();
    }    
}


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

#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 1 << 21

int prim(vector<vector<int> > &graph, int n){

    vector<int> parent(n, NIL);
    vector<int> cost(n, INF);
    vector<int> color(n, WHITE);

    cost[0] = 0;
    while(1){
        int minv = INF;
        int u = NIL;
        rep(i, n){
            if(cost[i] < minv && color[i] != BLACK){
                minv = cost[i];
                u = i;
            }
        }
        if(u == NIL) break;

        color[u] = BLACK;
        rep(j, n){
            if(color[j] != BLACK && graph[u][j] != NIL){
                if(cost[j] > graph[u][j]){
                    cost[j] = graph[u][j];
                    parent[j] = u;
                    color[j] = GRAY;
                }
            }
        }
    }

    int sum = 0;
    rep(i, n){
        if(parent[i] != NIL){
            sum += graph[i][parent[i]];
        }
    }
    return sum;
}

int main() {

    int n;
    cin >> n;
    vector<vector<int> > graph(n, vector<int>(n));
    rep(i, n){
        rep(j, n){
            cin >> graph[i][j];
        }
    }

    cout << prim(graph, n) << endl;

    return 0;
} 


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
struct S{
    int num,Ai;
}a[100010];
bool cmp(S A,S B){
    return A.Ai<B.Ai;
}
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)   cin>>a[i].Ai,a[i].num=i;
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)   cout<<a[i].num<<" ";
    return 0;
}


Measured memory_bytes: 4256
s=input().rstrip()
win,lose=0,0
if s[0] == 'p':
  lose += 1
countg,countp=1,0
for i in range(1,len(s)):
  if s[i] =='g' and (countp +1 <= countg):
    win += 1
    countp += 1
  elif s[i] =='g':
    countg += 1
  elif s[i] =='p' and (countp +1 <= countg):
    countp += 1
  else:
    countg += 1
    lose += 1
print(win-lose)

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

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a + b) > (c + d)) { cout << "Left"; }
	else if ((a + b) < (c + d)) { cout << "Right"; }
	else if ((a + b) == (c + d)) { cout << "Balanced"; }
    return 0;
}



Measured memory_bytes: 256
from sys import stdin
input = stdin.readline
from time import time
from random import randint
from copy import deepcopy

start_time = time()

def calcScore(t, s, c):
    scores = [0]*26
    lasts = [0]*26
    for i in range(1, len(t)):
        scores[t[i]] += s[i][t[i]]
        dif = i - lasts[t[i]]
        scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
        lasts[t[i]] = i
    for i in range(26):
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2
    return scores

def greedy(c, s):
    day_lim = len(s)
    socres = [0]*26
    t = [0]*day_lim
    lasts = [0]*26
    for i in range(1, day_lim):
        pls = [v for v in socres]
        mns = [v for v in socres]
        for j in range(26):
            pls[j] += s[i][j]
            mns[j] -= c[j] * (i - lasts[j])
        sum_mns = sum(mns)
        pt = sum_mns - mns[0] + pls[0]
        idx = 0
        for j in range(1, 26):
            tmp = sum_mns - mns[j] + pls[j]
            if pt < tmp:
                pt = tmp
                idx = j
        t[i] = idx
        lasts[idx] = i
        for j in range(26):
            if j == idx:
                socres[j] = pls[j]
            else:
                socres[j] = mns[j]
    return socres, t

D = int(input())
c = list(map(int, input().split()))
s = [[0]*26 for _ in range(D+1)]
for i in range(1, D+1):
    s[i] = list(map(int, input().split()))

scores, t = greedy(c, s)
sum_score = sum(scores)

while time() - start_time < 1.8:
    tmp_t = deepcopy(t)
    for _ in range(5):
        tmp_t[randint(1, D)] = randint(0, 25)
    tmp_scores = calcScore(tmp_t, s, c)
    sum_tmp_score = sum(tmp_scores)
    if sum_score < sum_tmp_score:
        sum_score = sum_tmp_score
        t = tmp_t
        scores = tmp_scores

for v in t[1:]:
    print(v+1)


Measured memory_bytes: 89456
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    count = [0]*(n)

    for i in range(1, n):
        for j in range(i, n, i):
            count[j] += 1
    
    ans = sum(count)
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 81164
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
int main() {
	int N, x[5], s[5], m, t;
	scanf("%d", &N);
	vector<int> a(N);
	rep(i, 0, N)scanf("%d", &a[i]);
	sort(all(a));
	x[0] = a[0], x[4] = a[N - 1];
	while (1) {
		m = 1 << 30;
		rep(i, 1, 4) {
			x[i] = (x[4] - x[0]) * (i + 1) / 4 + x[0];
			s[i] = 0;
			rep(i2, 0, N) {
				s[i] += (x[i] - a[i2]) * (x[i] - a[i2]);
			}
			if (m > s[i])m = s[i], t = i;
			//printf("i:%d x:%d s:%d\n", i,x[i], s[i]);
		}
		//printf("t:%d\n", t);
		x[0] = x[t - 1], x[4] = x[t + 1];
		if (x[4] - x[0] <= 1)break;
	}
	printf("%d\n", s[1]);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pitsu(){
    ll a,b;
    cin>>a>>b;
    if(a>b)swap(a,b);
    ll ans=a-1;
    if(a==b)return ans*2;
    ll l=0,r=b;
    while(r-l>1){
        ll mid=(l+r)/2;
        ll m=(mid+a)/2;
        ll mul=m*(a+mid-m);
        if(a*b-1>=mul)l=mid;
        else r=mid;
    }
    return ans+l-1;
}
int main(){
  int t;
  cin>>t;
  while(t--)cout<<pitsu()<<"\n";
}

Measured memory_bytes: 256
import math
n, p = map(int,raw_input().split())

arr = map(int,raw_input().split())

odd = 0
even = 0

for i in range(n):
	if arr[i] %2 == 0 :
		even += 1
	else :
		odd += 1

def P(n, r):
	return math.factorial(n)//math.factorial(n-r)

def C(n, r):
	return P(n, r)//math.factorial(r)

oddnum = 0
for i in range(1,odd+1,2):
	oddnum += C(odd,i)

if p == 1:
	print oddnum * 2**even
else :
	print 2**n-(oddnum*2**even)

Measured memory_bytes: 2692
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BChooseIntegers {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c;
	    in >> a >> b >> c;
	    int m = a%b;
	    set<int> used;
	    bool res = false;
	    int ind = 1;
	    while(true){
	        int mm = m*ind%b;
            if(used.find(mm) != used.end()) break;
	        used.insert(mm);
            ind++;
	        if(mm == c){
	            res = true;
	            break;
	        }
	    }

	    ans2(res, out);
	}
};


int main() {
	BChooseIntegers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,K;
    scanf("%lld",&n);
    vector<ll> a(n);
    for(ll& x: a)
        scanf("%lld", &x);
    const ll MAX  = 1e18 ;   
    vector<vector<ll> > dp(n+1, vector<ll> (n+1,MAX) );
    vector<ll> pre(n+1);
    for(int i = 1; i<=n;i++)
        pre[i] = pre[i-1] + a[i-1];
    
    
    for(int l = 1; l<=n; l++)
        for(int i =1; i<=n -l +1; i++)
        {
            int j = i + l-1;
            if(l==1)
                    dp[i][j] = 0;
            else if (l==2)
                    dp[i][j] = a[i-1] + a[j-1];
            else 
                    for(int x = i; x<j; x++)
                            dp[i][j] = min(dp[i][j], dp[i][x] + dp[x+1][j] +pre[j] - pre[i-1]);
        }
    
    cout<<dp[1][n]<<"\n";

}

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

using namespace std;

int main(void)
{
	int n;
	cin>>n;
	vector<string>s;
	int i;
	string w;
	for(i = 0; i < n; i++){
		cin>>w;
		s.push_back(w);
	}
	sort(s.begin(),s.end());
	
	int max,max_kouho;
	max = 0;
	int ans_num[n];
	for(i = 0; i < n; i++){
		ans_num[i] = 1;
	}
	
	for(i = 1; i < n; i++){
		max_kouho = 1;
		if(s[i] == s[i-1]){
			ans_num[i] = ans_num[i-1] + 1;
		}
	}
	for(i = 0; i < n; i++){
		//printf("i = %d, ans_num[i] = %d\n",i,ans_num[i]);
		if(max < ans_num[i]) max = ans_num[i];
	}
	
	//cout<<"\n\n"<<endl;
	for(i = 0; i < n; i++){
		if(max == ans_num[i]){
			cout<<s[i]<<endl;
		}
	}
	
	return 0;
}




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

int x, y;

signed main () {
  cin >> x >> y;
  int res = 0;
  while (x <= y) {
    res += 1;
    x *= 2.0;
  }
  cout << fixed << setprecision(0) << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;

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

int main() {
  ll a, b;

  cin >> a >> b;
  cout << (a % 2 && b % 2 ? "Yes" : "No") << endl;
}

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

// > NUM_MAX*digit(100000)
#define BUF_SIZE 800000

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define NUM_MAX 100000
#define DIVISOR 1000000007

int main(void) {
    int n = get_int();
    int stack[3] = {0};
    int arr[NUM_MAX];
    int i, j;
    fget_array(arr, n);

    uint64_t ans = 1;
    for(i = 0; i < n; i++) {
        int c = arr[i];
        int cnt = 0;
        for(j = 0; j < 3; j++) {
            if(stack[j] == c) {
                if(!cnt) stack[j]++;
                cnt++;
            }
        }
        ans = (ans * (uint64_t)cnt)%DIVISOR;
    }
    // ans should be DIVISOR < INT_MAX
    printf("%d\n", (int)ans);
    return 0;
}

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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define OF(i,a,b) for (int (i) = (a)-1; (i) >= (b); --(i))
#define SZ(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/

int H, W;
char gr[1005][1005];


int main() {
    scanf ("%d %d", &H, &W);
    FO (i,1,H+1) {
        FO (p,1,W+1) {
            scanf (" %c", &gr[i][p]);
        }
    }
    FO (i,1,H+1) {
        FO (p,1,W+1) {
            if (i == H) printf (".");
            else if (i == 1 || p % 2 == 1 || gr[i][p] == '#') printf ("#");
            else printf (".");
        }
        printf ("\n");
    }
    printf ("\n");
    FO (i,1,H+1) {
        FO (p,1,W+1) {
            if (i == 1) printf (".");
            else if (i == H || p % 2 == 0 || gr[i][p] == '#') printf ("#");
            else printf (".");
        }
        printf ("\n");
    }
    return 0;
}



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

int main()
{
while(1){
 char stra[10], strb[10];
 int hit=0,bro=0;
 cin>>stra>>strb;

 if(stra[0]=='0'&&stra[1]=='\0'){break;}

 for(int i=0;i<4;i++){
  if(stra[i]==strb[i]){
	hit++;
	}
  for(int j=0;j<4;j++){
	if(stra[i]==strb[j]){
		bro++;
		}
	}
 }
bro=bro-hit;
cout<<hit<<' '<<bro<<'\n';

}

return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000005;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    queue<ll> que;
    int K;
    cin >> K;
    for (int i = 1; i < 10; i++) {
        que.push(i);
    }
    ll n;
    int cnt = 0;
    while (que.size()) {
        cnt++;
        n = que.front();
        que.pop();
        if (cnt == K) {
            break;
        }
        int m = n % 10;
        for (int i = m - 1; i <= m + 1; i++) {
            if (i >= 0 && i <= 9) {
                que.push(n * 10 + i);
            }
        }
    }
    cout << n << endl;
}

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

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

    // 素数である
    return true;
}

int main(){
    int n;
    cin>>n;
    int l,r;
    int sum[100001]={};
    for(int i=3;i<100000;i+=2){
        sum[i]=sum[i-2];
        if(IsPrime(i)&&IsPrime((i+1)/2)) sum[i]++;
    }

    for(int i=0;i<n;i++){
        cin>>l>>r;
        //cerr<<sum[r]<<" "<<sum[max(1,l-2)]<<endl;
        cout<<sum[r]-sum[max(1,l-2)]<<endl;
    }


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define sz(x) ((int)x.size())

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> dp(100005, 0);
    int n, w;
    cin >> n >> w;
    while(n--)
    {
        int wi, vi;
        cin >> wi >> vi;
        for(int i = 100005-1; i >= 0; i--)
            if(i+wi < 100005)
                dp[i+wi] = max(dp[i+wi], dp[i]+vi);
    }
    int mx = 0;
    for(int i = 0; i <= w; i++)
        mx = max(mx, dp[i]);
    cout << mx << endl;
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll M = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> is;
ll power(ll x,ll y){
    if(y==0)
    return 1;
    ll res=power(x,y/2);
    res=(res*res)%M;
    if(y&(ll)1)
    res=(res*x)%M;
    return res;
}
void solve(){
    ll n;
    cin>>n;
    cout<<n/2+n%2<<endl;
    
}
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
    return 0;
}

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

def gcd(a,b):
  if b>a:
    a,b=b,a
  while a%b!=0:
    a,b=b,a%b
  return b

def lcd(a,b):
  return a*b//gcd(a,b)

print(lcd(A,B))

Measured memory_bytes: 3060
N,M = map(int ,input().split())

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

all_reputation = sum(A)

over_quater_item = [i for i in A if i >=  all_reputation/(4*M)]

if len(over_quater_item) >= M:
    print('Yes')
else:
    print('No') 


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

int main(){
	ll n,y;
	cin >> n >> y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			int k = n-i-j;
			if(k<0)continue;
			if(10000*i+5000*j+1000*k==y){
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 100+5;

LL F[N][2];

int main() {
	int n, p;
	cin >> n >> p;
	F[0][0] = 1;
	for(int i=1;i<=n;++i) {
		F[i][0] = F[i-1][0], F[i][1] = F[i-1][1];
		int x; cin >> x; x &= 1;
		for(int j=0;j<=1;++j) 
			F[i][(j+x)&1] += F[i-1][j];
	}
	cout << F[n][p] << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[100010] = {};
int main(){
	int i,n,m;
	cin >> n >> m;
	for(i=0;i<m;i++){
		int l,r; cin >> l >> r;
		a[l]++; a[r+1]--;
	}
	for(i=1;i<=n;i++){
		a[i] += a[i-1];
	}
	int ans = 0;
	for(i=0;i<=n;i++){
		if(a[i]==m){
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640