akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
int  main()
{
	int n; cin >> n;
	string s,t; cin >> s >> t;

	rep(i, n)
	{
		cout << s[i];
		cout << t[i];
	}
	cout << endl;
	return (0);
}

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


int main(){

    int n,m;
    cin>>n>>m;
    long a[50],b[50],c[50],d[50];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<m;i++){
        cin>>c[i]>>d[i];
    }

    for(int i=0;i<n;i++){
        int num=1;
        long min=abs(a[i]-c[0])+abs(b[i]-d[0]);
        for(int j=1;j<m;j++){
            long aa=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(aa<min){
                num=j+1;
                min=aa;
            }
        }
            cout<<num<<endl;
    }


    exit(0);

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int width,height;
int map[50][50];
char input_map[50][51];
 
int main(void) {
    int i,j,k;
    int black,white;
    while(1) {
        scanf("%d%d",&width,&height);
        if(width==0 && height==0)break;
        memset(map,0,sizeof(map));
        for(i=0;i<height;i++) {
            scanf("%s",input_map[i]);
            for(j=0;j<width;j++) {
                if(input_map[i][j]=='B')map[i][j]=5;
                else if(input_map[i][j]=='W')map[i][j]=6;
            }
        }
        for(k=0;k<width*height;k++) {
            for(i=0;i<height;i++) {
                for(j=0;j<width;j++) {
                    if((map[i][j] & 4)==0) {
                        if(i>0)map[i][j]|=map[i-1][j]&3;
                        if(j>0)map[i][j]|=map[i][j-1]&3;
                        if(i<height-1)map[i][j]|=map[i+1][j]&3;
                        if(j<width-1)map[i][j]|=map[i][j+1]&3;
                    }
                }
            }
        }
        black=white=0;
        for(i=0;i<height;i++) {
            for(j=0;j<width;j++) {
                if(map[i][j]==1)black++;
                else if(map[i][j]==2)white++;
            }
        }
        printf("%d %d\n",black,white);
    }
    return 0;
}

Measured memory_bytes: 1052
import java.util.Scanner;

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

        int x = Integer.parseInt(strX);
        int y = Integer.parseInt(strY);

        int answer = divisor(x, y);

        System.out.println(answer);
        scan.close();
    }

    static int divisor(int x, int y) {
        if (y > x) {
            return divisor(y, x);
        }
        while (y != 0) {
            int remainder = x % y;
            x = y;
            y = remainder;
        }
        return x;
    }
}


Measured memory_bytes: 26120
N=int(input())
a=list(map(int,input().split()))
b=[]
b2=[]
if N%2==0:
  for i in range(0,N,2):
    b.append(str(a[N-i-1]))
    b2.append(str(a[i]))
  ans=b+b2
else:
  for i in range(N):
    if i%2==0:
      b.append(str(a[N-1-i]))
    else:
      b2.append(str(a[i]))
  ans=b+b2
print(' '.join(ans))

Measured memory_bytes: 33808
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pa;
int main(){
    priority_queue<pa,vector<pa>,greater<pa> > que;
    int n,a;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        que.push(pa(a,i));
    }
    while(!que.empty()){
        printf("%d ", que.top().second);
        que.pop();
    }
    return 0;
}

Measured memory_bytes: 1780
#include <cstdio>
using namespace std;
const long long mod=1000000007,NR=1145140;
long long n,k,ans,a[NR];
long long power(long long x,long long y)
{
	if(y==0)
	{
		return 1;
	}
	long long tmp=power(x,y>>1),ans=(tmp*tmp)%mod;
	if(y&1)
	{
		ans=(ans*x)%mod;
	}
	return ans;
}
long long c(long long n,long long k)
{
	return (a[n]*power((a[k]*a[n-k])%mod,mod-2))%mod;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	a[0]=1;
	for(long long i=1;i<2*n;i++)
	{
		a[i]=(a[i-1]*i)%mod;
	}
	ans=c(2*n-1,n);
	for(long long i=1;i<n-k;i++)
	{
		ans=(ans-((c(n,i)*c(n-1,i-1))%mod))%mod;
	}
	printf("%lld",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 4224
# D - Handstand

# 逆立ちしている人が連続する区間のインデックスを保存する
# 指示1回あたり2つの区間を繋ぐことができる
# 連続したK+1個の区間を順に選んで繋ぎ、最も逆立ち区間が長くなる場合を探す。端から繋ぐ場合は例外処理

N, K = map(int, input().split())
S = input()

if len(set(S)) == 1:
    print(N)
    exit()

handstand_range_idx = []
range_start_idx = 0
for idx in range(1,N):
    if (S[idx-1] == "1" and S[idx] == "0"):
        range_end_idx = idx - 1
        handstand_range_idx.append([range_start_idx, range_end_idx])
    elif idx == N-1 and S[idx] == "1":
        range_end_idx = idx
        handstand_range_idx.append([range_start_idx, range_end_idx])
    elif S[idx-1] == "0" and S[idx] == "1":
        range_start_idx = idx

ans = 0
try:
    ans = max(handstand_range_idx[K-1][1]+1, (N-1) - handstand_range_idx[-K][0] + 1)
except IndexError: # 逆立ち区間の数が操作回数よりも少ない場合
    print(N)
    exit()

for first_link_range_idx in range(len(handstand_range_idx)):
    try:
        ans = max(ans, handstand_range_idx[first_link_range_idx + K][1] - handstand_range_idx[first_link_range_idx][0] + 1)
    except IndexError:
        pass

print(ans)

Measured memory_bytes: 11380
s = input()
l = len(s)
c = (l-1)//2

count = 0
check = 0
for i in range(0,c-1):
  if s[i] == s[l-i-1]:
    count = count + 1
    
if count == c-1:
  check = check + 1

count1 = 0  
for j in range(0, c-1):
  if s[j] == s[c-j-1]:
    count1 = count1 + 1

if count1 == c-1:
  check = check + 1

if check == 2:
  print('Yes')
else:
  print('No')


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

int main(void){
    char a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    if(c==d&&e==f)cout<<"Yes\n";
    else cout<<"No\n";
    
    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 n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        for (int i = 0 ; i < m ; i++) {
            a[i] = sc.nextInt();
        }
        int mod = 1000000007;
        long[] sum = new long[n + 2];
        sum[1] = 1;
        for (int i = 2 ; i < n + 2 ; i++) {
            sum[i] =   (long) sum[i - 1] + sum[i - 2];
            sum[i] %= mod;
        }
        if (m == 0) {
            System.out.println(sum[n + 1]);
            return;
        }
        for (int i = 0 ; i < m - 1 ; i++) {
            if (a[i + 1] - a[i] == 1) {
                System.out.println(0);
                return;
            }
        }
        long ans = 1l;
        int [] b = new int[m + 1];

        if (m == 1) {
            b[0] = a[0];
            b[1] = n - a[0];
        } else {
            b[0] = a[0];
            b[m] = n - a[m - 1];
            for (int i = 1 ; i < m ; i++) {
                if (a[i] - a[i - 1] == 0) {
                    b[i] = 1;
                } else {
                    b[i] = a[i] - a[i - 1] - 1;
                }
            }
        }
        for (int i = 0 ; i < m + 1 ; i++) {
            ans *= sum[b[i]] % mod;
            ans %= mod;
        }
        System.out.println(ans % mod);
    }

}


Measured memory_bytes: 48020
A=input()
B=input()

if A==B:
  print("EQUAL")
elif len(A)>len(B):
  print("GREATER")
elif len(A)<len(B):
  print("LESS")
else:
  ans=True
  for i in range(len(A)):
    if int(A[i]) > int(B[i]):
      break
    elif int(A[i]) < int(B[i]):
      ans=False
      break
    else:
      continue
  if ans:
    print("GREATER")
  else:
    print("LESS")

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int n = read();
  int ans = 1;
  FOR(i, 1, n + 1) {
    ans *= i;
    ans %= mod;
  }
  print(ans);
}


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

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a+b)*c/2<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
 
typedef long long ll;
 
using namespace std; 
 
#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)

int main() {
    int n, cnt = 0;
    cin >> n;
    vector<ll> a(n);
    REP(i, 0, n) {
        cin >> a[i];
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            cnt ++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 384
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let n = input!(usize);
    let a_lst = input!(i64; n);

    let mut sunuke: i64 = 0;
    let mut arai: i64 = a_lst.iter().sum();
    let mut min: i64 = i64::max_value();

    for &a in a_lst.iter().take(n-1) {
        sunuke += a;
        arai -= a;
        if (sunuke - arai).abs() < min {
            min = (sunuke - arai).abs();
        }
    }
    println!("{}", min);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k % 2) cout << b - a << endl;
	else cout << a - b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <malloc.h>
typedef struct {
    int N;
    int E;
    int W;
    int S;
    int D;
    int Z;
} Dice;

int search(int d,int s,Dice *a){
    if(d == a->D){
        if(s == a->S)
            return a->E;
        if(s == a->E)
            return a->N;
        if(s == a->N)
            return a->W;
        if(s == a->W)
            return a->S;
    } else if(d == a->S){
        if(s == a->W)
            return a->Z;
        if(s == a->Z)
            return a->E;
        if(s == a->E)
            return a->D;
        if(s == a->D)
            return a->W;
    } else if(d == a->E){
        if(s == a->S)
            return a->Z;
        if(s == a->Z)
            return a->N;
        if(s == a->N)
            return a->D;
        if(s == a->D)
            return a->S;       
    } else if(d == a->W){
        if(s == a->S)
            return a->D;
        if(s == a->D)
            return a->N;
        if(s == a->N)
            return a->Z;
        if(s == a->Z)
            return a->S;
    } else if(d == a->N){
        if(s == a->W)
            return a->D;
        if(s == a->D)
            return a->E;
        if(s == a->E)
            return a->Z;
        if(s == a->Z)
            return a->W;
    } else if(d == a->Z){
        if(s == a->S)
            return a->W;
        if(s == a->W)
            return a->N;
        if(s == a->N)
            return a->E;
        if(s == a->E)
            return a->S;
    }
}

int main(void){
    Dice *a = (Dice *) malloc(sizeof(Dice));
    int n,s,d;
    int i;
    scanf("%d %d %d %d %d %d\n",&a->D,&a->S,&a->E,&a->W,&a->N,&a->Z);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&d,&s);
        printf("%d\n",search(d,s,a));    
    }
    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

class tree{
public:
    void putparent(int n);
    void putleft(int n);
    void putright(int n);
    int getparent();
    string gettype();
    int getleft();
    int getright();
    int getdegree();
    tree();
private:
    int parent;
    int left;
    int right;
};

typedef struct tree Tree;

tree::tree()
{
    parent = -1;
    left = -1;
    right = -1;
}

void tree::putparent(int n)
{
    parent = n;
    return;
}

void tree::putleft(int n)
{
    left = n;
    return;
}

void tree::putright(int n)
{
    right = n;
    return;
}

int tree::getparent()
{
    return parent;
}

string tree::gettype()
{
    if(getparent() == -1) return "root";
    else if(getleft() == -1 && getright() == -1) return "leaf";
    else return "internal node";
}

int tree::getleft()
{
    return left;
}

int tree::getright()
{
    return right;
}

void preorder(Tree a[], int n)
{
    cout << " " << n;
    if(a[n].getleft() != -1) preorder(a, a[n].getleft());
    if(a[n].getright() != -1) preorder(a, a[n].getright());
    return;
}

void inorder(Tree a[], int n)
{
    if(n == -1) return;
    inorder(a, a[n].getleft());
    cout << " " << n;
    inorder(a, a[n].getright());
}

void postorder(Tree a[], int n)
{
    if(n == -1) return;
    postorder(a, a[n].getleft());
    postorder(a, a[n].getright());
    cout << " " << n;
}

int getroot(Tree a[], int n)
{
    if(a[n].getparent() == -1) return n;
    else return getroot(a, a[n].getparent());
}



int main()
{
    int n;
    cin >> n;
    Tree t[25];
    int id, l, r;
    for(int i = 0; i < n; i++){
        cin >> id >> l >> r;
        t[id].putleft(l);
        t[id].putright(r);
        if(l != -1) t[l].putparent(id);
        if(r != -1) t[r].putparent(id);
    }
    int root = getroot(t, 0);
    cout << "Preorder" << endl;
    preorder(t, root);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(t, root);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(t, root);
    cout << endl;
    return 0;
}

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

int main(){
	int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int x = x2-x1, y = y2-y1;
    cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x;
    return 0;

}

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

ll gcd(ll a,ll b){
    if(a<b)return gcd(b,a);
    if(a%b==0)return b;
    return gcd(b ,a%b);
}
int main(){
    int n;cin >> n;
    ll ans = 0;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        ans += a-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)

int main(){
	int n, m;
	cin >> n >> m;
	vector<bool> v(n+1, true);
	vector<ll> d(n+1, 0);
	for(int i=0; i<m; i++){
		int a;
		cin >> a;
		v[a]=false;
	}
	d[0]=1;
	if(v[1]) d[1]=d[0];
	for(int i=2; i<=n; i++){
		if(!v[i-1] && !v[i-2]) d[i]=0;
		else if(!v[i-1]) d[i]=d[i-2];
		else if(!v[i-2]) d[i]=d[i-1];
		else d[i]=(d[i-1]+d[i-2])%mod;
	}
	cout << d[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    // Your code here!
    long long N;
    scanf("%lld",&N);
    
    long long  A;
    long long min = 1000000001, max=0;
    for(int i = 0; i < N; i++){
        scanf("%lld",&A);
        if(min > A) min = A;
        if(max < A) max = A;
    }
    long long ans = max-min;
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#define ll long long
using namespace std;

ll N, M;
vector<int> A, B;
vector<vector<int>> G;
vector<int> color;
bool bipartite = true;

void dfs(int v, int cur = 0)
{
  color[v] = cur;
  for (int next_v : G[v])
  {
    if (color[next_v] == cur)
    {
      bipartite = false;
      continue;
    }
    if (color[next_v] == -1)
    {
      color[next_v] = 1 - cur;
      dfs(next_v, 1 - cur);
      continue;
    }
  }
}

int main()
{
  cin >> N >> M;
  A.resize(M);
  B.resize(M);
  for (int i = 0; i < M; i++)
  {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }

  G.assign(N, {});
  for (int i = 0; i < M; i++)
  {
    G[A[i]].push_back(B[i]);
    G[B[i]].push_back(A[i]);
  }

  color.resize(N, -1);

  dfs(0);

  ll color_0 = 0, color_1 = 0;
  for (int i = 0; i < N; i++)
  {
    if (color[i] == 0)
    {
      color_0++;
    }
    else if (color[i] == 1)
    {
      color_1++;
    }
    else
    {
      cout << "SWW" << endl;
    }
  }

  if (bipartite)
  {
    cout << color_0 * color_1 - M << endl;
  }
  else
  {
    cout << N * (N - 1) / 2 - M << endl;
  }
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X;
  bool H=false;
  cin>>X;
  for(long long A=-200;A<200;A++){
    for(long long B=-200;B<200;B++){
      long long N=A*A*A*A*A;
      long long M=B*B*B*B*B;
      if(N-M==X&&N+M<=100000000){
        cout<<A<<" "<<B<<endl;
        H=true;
        break;
      }
    }
    if(H==true){
      break;
    }
  }
}


Measured memory_bytes: 3616
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			String S = sc.next();
			char[] s = S.toCharArray();
			
			long ret=0;
			long b = 0;
			
			for(int i=0;i<s.length;i++) {
				if(s[i]=='B') {
					b++;
				}
				if(s[i]=='W') {
					ret+=b;
				}
			}
			
			
			System.out.println(ret);
		}	
	}

Measured memory_bytes: 26800
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<assert.h>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<P> points;
Int n, x;
Int b[216000];
Int l[216000];
Int u[216000];
Int val = 0;
bool ok(Int score){
    Int all = score / x;
    Int part = score % x;
    for(int i = 0;i < n;i++){
        Int V = 0;
        if(i < all) V += points[all].first - (points[i].first - (i?points[i-1].first:0)) ;
        else V += all?points[all-1].first:0;
        int id = points[i].second;
        V += l[id] * min(b[id], part);
        V += u[id] * max(0LL, part - b[id]);
        if(V >=val)return true;
    }
    return false;
}

int main(){
    cin >> n >> x;
    for(int i = 0;i < n;i++){
        cin >> b[i] >> l[i] >> u[i];
        val += b[i] * l[i];
        points.push_back(P(b[i] * l[i] + u[i] * (x-b[i]),i));
    }
    sort(points.rbegin(), points.rend());
    for(int i = 1;i < n;i++){
        points[i].first += points[i-1].first;
    }
    Int bottom = 0, top = n*x;
    while(top - bottom > 1){
        Int mid = (top + bottom) / 2;
        if(ok(mid))top = mid;
        else bottom = mid;
    }
    if(ok(0))top = 0;
    cout << top << endl;
    return 0;
}

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

int main(){
    int d;
    cin >> d;
    
    vector<int> c(26);
    for (int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    
    vector<vector<int>> vec(d, vector<int>(26));
    for (int i = 0; i < d; i++) {
        int maxpoint = 0;
        int maxc = 0;
        for (int j = 0; j < 26; j++) {
            cin >> vec[i][j];
            maxpoint = max(maxpoint,vec[i][j]);
            if (maxpoint == vec[i][j]) {
                maxc = j + 1;
            }
        }
        cout << maxc << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3680
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int main()
{
  int n;
  cin >> n;
  map<int, int> M;
  for (int i=0; i<n; i++) {
    int c;
    cin >> c;
    M[i+1] = c;
  }
  int res = 0;
  for (int i=0; i<n; i++)
    if (M[M[i+1]] == i+1) res ++;
  cout << res / 2 << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<string.h>
using namespace std;

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


class state{
public:
	int rx,ry,lx,ly;
	state(int lx,int ly,int rx,int ry):lx(lx),ly(ly),rx(rx),ry(ry){}
};

int w,h;

bool in(int x,int y)
{
	if(x<0 || x>=w || y<0 || y>=h) return false;
	return true;
}

bool done[50][50][50][50];
		


int main(){
	while(cin>>w>>h && w!=0){
		vector<string> L(h),R(h);
		int flx,fly,frx,fry;
		for(int i=0;i<h;i++){
			cin>>L[i]>>R[i];
			for(int k=0;k<L[i].size();k++){
				if(L[i][k]=='L'){flx=k;fly=i;}
				if(R[i][k]=='R'){frx=k;fry=i;}
			}
		}
		memset(done,false,sizeof(done));
		queue<state> Q;
		Q.push(state(flx,fly,frx,fry));
		bool ok=false;
		while(!Q.empty()){
			state t=Q.front(); Q.pop();
			if(L[t.ly][t.lx]=='%' && R[t.ry][t.rx]=='%'){cout<<"Yes"<<endl;ok=true;break;}
			if(L[t.ly][t.lx]=='%' || R[t.ry][t.rx]=='%') continue;
			if(done[t.lx][t.ly][t.rx][t.ry]) continue;
			done[t.lx][t.ly][t.rx][t.ry]=true;

			for(int r=0;r<4;r++){
				int nlx=t.lx+dx[r],nly=t.ly-dy[r];
				if(!in(nlx,nly) || L[nly][nlx]=='#'){nlx=t.lx;nly=t.ly;}

				int nrx=t.rx+dx[(r+2)%4],nry=t.ry+dy[(r+2)%4];
				if(!in(nrx,nry) || R[nry][nrx]=='#'){nrx=t.rx;nry=t.ry;}
				Q.push(state(nlx,nly,nrx,nry));
			}
		}
		if(!ok)
			cout<<"No"<<endl;
	}
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (b == 0)
    {
        return a;
    }

    return gcd(b, a % b);
}

int main()
{
    ll N, M;
    string S, T;
    cin >> N >> M;
    cin >> S;
    cin >> T;

    bool flag = true;
    REP(i, N)
    {
        if ((M * i) % N == 0)
        {
            ll j = (M * i) / N;
            if (S[i] != T[j])
            {
                flag = false;
                break;
            }
        }
    }
    ll ans = flag ? (M * N) / gcd(M, N) : -1;

    cout << ans << endl;
}


Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n);
    FOR(i,0,n)cin>>v[i];
    sortAlr(v);
    ll x = 0;
    FOR(i,0,n)x+=v[i];
    if(v[m-1]*4*m<x)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
a,b,c,k = gets.chomp.split.map(&:to_i)

if k <= a
  puts k
elsif k <= a + b
  puts a
else
  puts a - (k - a - b)
end


Measured memory_bytes: 14716
package main

import "fmt"

func main() {
	k, j := 0, 0
	fmt.Scanf("%d", &k)
	if k%2 == 0 {
		fmt.Println("-1")
		return
	}
	for i := 1; i < 10000000; i++ {
		j = j*10 + 7
		if j%k == 0 {
			fmt.Println(i)
			return
		}
		j = j % k

	}
	fmt.Println("-1")
}


Measured memory_bytes: 1860
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
using ll = long long;
const ll INF=1e15;
#define F first
#define S second
#define I XH[i]


ll N,D,A,now=0,res=0,t;
pair<ll,ll>XH[200005];
queue<pair<ll,ll> >P;
int main() {
	
	cin>>N>>D>>A;
	for(ll i=0;i<N;i++){
		cin>>I.F>>I.S;
	}
	sort(XH,XH+N);
	for(ll i=0;i<N;i++){
		while(!P.empty()&&P.front().F<I.F){
			now-=P.front().S;
			P.pop();
		}

		I.S-=now;
		
		if(I.S>0){
			t=(I.S+A-1)/A;
			res+=t;
			P.push({I.F+2*D,t*A});
			now+=t*A;
		}
	}
	cout<<res;
} 


Measured memory_bytes: 4992
#include <cassert>
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int main(void) {
  int a, p;
  cin >> a >> p;
  p += a * 3;
  cout << p / 2 << endl;
  
    
  return 0;
}


Measured memory_bytes: 256
def f(n) :
    if n % 2 == 0 :
        return int(n / 2)
    else :
        return 3 * n + 1

s = int(input())

li = [s]
i = 1
while True :
    a_i = f(li[i - 1])
    if a_i in li :
        print(i + 1)
        exit()
    li.append(a_i)
    i += 1


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans = a + b + c - max(a,max(b,c));
  ans += max(a,max(b,c)) * (int)pow(2,k);
  //cout << max(a,max(b,c)) * (int)pow(2,k) << endl;

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


Measured memory_bytes: 256
from math import floor, ceil

H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
else:
    even_col = ceil(H / 2)
    even_row = ceil(W / 2)
    odd_col = floor(H / 2)
    odd_row = floor(W / 2)
    print(even_col * even_row + odd_col * odd_row)


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

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int res = 0;
    for(int i=1; i<n-1; i++){
        int a=p[i-1], b=p[i], c=p[i+1];
        if(((b >= a) && (c > b)) || ((b >= c) && (a > b))){
            res += 1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    ll ans = 0;
    int n = s.size();
    REP (x, 1<<(n-1)) {
        ll acc = 0;
        REP (i,n) {
            acc *= 10;
            acc += s[i] - '0';
            if ((x&(1<<i)) == 0) {
                ans += acc;
                acc = 0;
            }
        }
        ans += acc;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int m, f, r, p;

	while (1) {

		scanf("%d %d %d", &m, &f, &r);

		if (m == -1 && f == -1 && r == -1)
			break;

		p = m + f;

		if (m == -1 || f == -1) {
			printf("F");
		}

		else if (80 <= p) {
			printf("A");
		}

		else if (65 <= p && p < 80) {
			printf("B");
		}

		else if (50 <= p && p < 65) {
			printf("C");
		}

		else if (p < 30) {
			printf("F");
		}

		else if (30 <= p && p < 50 && r < 50) {
			printf("D");
		}
		
		else if (30 <= p && p < 50 && 50 <= r) {
			printf("C");
		}

		printf("\n");
	}

	return(0);

}


Measured memory_bytes: 2044
n,l=map(int,input().split())
if l>=0:
    print((n-1)*l+n*(n-1)//2)
elif l<0 and l+n-1>=0:
    print(n*(2*l+n-1)//2)
else:
    print(n*(2*l+n-1)//2-(l+n-1))

Measured memory_bytes: 3060
n, d = map(int, input().split())
ar = []
count = 0
for i in range(n):
  ar.append(list(map(int, input().split())))
  
for i in range(n):
  for j in range(n):
    s = 0
    if i == j:
      break
    else:
      for k in range(d):
        s += (ar[i][k] - ar[j][k])**2
      f = s**(1/2)
      if f.is_integer(): 
        count +=1
print(count)

Measured memory_bytes: 9456
n = input()
if (n[-1] == "2")or(n[-1] == "4")or(n[-1] == "5")or(n[-1] == "7")or(n[-1] == "9") :
    print("hon")
elif (n[-1] == "0")or(n[-1] == "1")or(n[-1] == "6")or(n[-1] == "8"):
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def solve():
    N = int(input())
    P = list(map(int, input().split()))
    count = 0
    for i in range(1, N - 1):
        pack = [P[i - 1], P[i], P[i + 1]]
        if P[i] != max(pack) and P[i] != min(pack):
            count += 1
    return count


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
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 pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
int lcm(int a, int b){
  return a*(b/__gcd(a,b));
}
int findTrailingZeros(int n) 
{ 
    int count = 0; 
  
    for (int i = 5; n / i >= 1; i *= 5) 
        count += n / i; 
  
    return count; 
}

signed main(){

  ios::sync_with_stdio(false);cin.tie(0);

  int n;
  cin >> n;
  int x = n;
  int ans ;
  n = n/2;
  if(x%2 == 0){
    ans = findTrailingZeros(2*n - n);// - findTrailingZeros(n);
  }
  else
  {
   ans = 0;

  }
  cout << ans << '\n';
  
}


Measured memory_bytes: 256
import queue


def dijkstra(n, graph, start):
    dist = [0 if i == start else float('inf') for i in range(n)]
    que = queue.PriorityQueue()
    que.put((0, start))

    while not que.empty():
        p = que.get()
        d, now = p[0], p[1]

        if dist[now] < d:
            continue

        for e in graph[now]:
            if dist[e[0]] <= d + e[1]:
                continue

            dist[e[0]] = dist[now] + e[1]
            que.put((dist[e[0]], e[0]))

    return dist


def main():
    n, m, s = map(int, input().split())
    graph = [[] for _ in range(n)]

    for _ in range(m):
        data = list(map(int, input().split()))

        graph[data[0]].append([data[1], data[2]])

    dist = dijkstra(n, graph, s)

    for d in dist:
        if d == float("inf"):
            print("INF")
        else:
            print(d)

    return


if __name__ == '__main__':
    main()



Measured memory_bytes: 100708
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
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; }

int main() {
    string s, t; cin >> s >> t;

    vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1, 0));
    vector<vector<int>> prev(dp);
    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < t.length(); j++) {
            if (chmax(dp[i + 1][j + 1], dp[i][j + 1])) {
                prev[i + 1][j + 1] = 0;
            }
            if (chmax(dp[i + 1][j + 1], dp[i + 1][j])) {
                prev[i + 1][j + 1] = 1;
            }
            if (s[i] == t[j] && chmax(dp[i + 1][j + 1], dp[i][j] + 1)) {
                prev[i + 1][j + 1] = 2;
            }
        }
    }
    string res = "";
    int i = s.length(), j = t.length();
    while (i > 0 && j > 0) {
        if (prev[i][j] == 0) i--;
        if (prev[i][j] == 1) j--;
        if (prev[i][j] == 2) i--, j--, res += s[i];
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  rep(i,n){
    if((i+1)%3!=0 && (i+1)%5!=0){
      ans += i+1;
    }
  }
  cout << ans << endl;
}


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

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

using namespace std;

int main(){
	string s[2];
	cin>>s[0]>>s[1];
	cout<<(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0]?"YES":"NO")<<'\n';
	return 0;
}


Measured memory_bytes: 256
<?php
$n = fgets(STDIN);
$array = array_fill(0, $n, 0);
$results = explode(" ", fgets(STDIN));
$answer = 0;
$i=0;
$test = [[]];
foreach($results as $result){
	if(end($test[$i]) >= $result ){
		$test[]=[$result];
		$i+=1;
	}else{
		$test[$i][] = $result;
	}
}
$count = count($test);

for($i=0; $i<$count; $i++){
	$answer+=end($test[$i]);
	if(!($i==$count-1)){
	$minus = end($test[$i]) - $test[$i+1][0];
	$num = $minus > 0 ? $test[$i+1][0] : end($test[$i]);
	$answer -= $num;
	}
}
echo $answer ."\n";


?>

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int N = 1e7+1;
vector<bool> primes(N);
void soe()
{
	for(int i=2;i<=N;i++){
		primes[i] = true;
	}
	for(int i=2;i*i<=N;i++){
		if(primes[i]){
			for(int p=i*i;p<=N;p+=i){
				primes[p] = false;
			}
		}
	}
	//cout << "primes[2]:" << primes[2] << "\n";
}
bool is_square(int n)
{
	int temp = sqrt(n);
	return temp*temp == n;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	soe();
	int n;
	cin >> n;
	ll ans = 1;
	for(int i=2;i <= n;i++){
		int temp = i;
		ll tmp = 1;
		for(int j=2;;j++){
			if(!primes[j])
				continue;
			if(j*j*j > temp)
				break;
			ll count = 1;
			while(temp%j == 0){
				temp /= j;
				count++;
			}
			//cout << "count:" << count << "\n";
			tmp *= count;
		}
		//cout << "primes[2]:" << primes[2] << "\n";
		//cout << "temp:" << temp << "\n";
		if(primes[temp])
			tmp *= 2LL;
		else if(is_square(temp) && primes[sqrt(temp)])
			tmp *= 3LL;
		else if(temp != 1)
			tmp *= 4LL;
		//cout << "No of divisors of :" << i << " are " << tmp << "\n";
	//	cout << "tmp:" << tmp << "\n";
		//cout << "ans:" << ans << "\n";
		ans += (ll)i * tmp;
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){
    string s, t;

    cin >> s >> t;

    if(s.length() < t.length()){
        //printf("aaaa\n");
        printf("UNRESTORABLE\n");
        return 0;
    }
    string ans = s;
    string min_ans = s;

    for(int i = 0; i < s.length(); i++){
        min_ans[i] = 'z';
    }

    int j;

    bool flag = false;

    //printf("s-t %lu\n", s.length() - t.length() + 1);

    for(int i = 0; i < s.length() - t.length() + 1; i++){
        j = 0;
        while(1){
            if(s[i+j] == t[j]){
                //printf("s[i+j] %c t[j] %c\n", s[i+j], t[j]);
                j++;
                if(j == t.length()){
                    break;
                }
            }
            else if(s[i+j] == '?'){
                //printf("s[i+j] %c t[j] %c\n", s[i+j], t[j]);
                //printf("j %d\n", j);
                j++;
                if(j == t.length()){
                    break;
                }
            }
            else{
                //printf("s[i+j] %c t[j] %c\n", s[i+j], t[j]);
                break;
            }
        }
        //printf("j %d t.length() %lu\n", j, t.length());

        if(j == t.length()){
            //printf("flag ture\n");
            flag = true;
            int f = 0;
            for(int k = 0; k < s.length(); k++){
                if(i <= k and k <= i+j-1){
                    ans[k] = t[f];
                    f++;
                }
                else{
                    if(s[k] != '?'){
                        ans[k] = s[k];
                    }
                    else{
                        ans[k] = 'a';
                    }
                    
                }
            }

           // printf("ans %s\n", ans.c_str());
            //printf("min ans %s\n", min_ans.c_str());

            //printf("ans.length %lu min_ans.length() %lu\n", ans.length(), min_ans.length());

            if(ans > min_ans){
                //printf("compare\n");
            }
            else if(ans == min_ans){
                //printf("equal\n");
            }
            else{
                //printf("ans is early\n");
                min_ans = ans;
            }
        }

    }

    if(flag == false){
        //printf("%s\n", min_ans.c_str());
        printf("UNRESTORABLE\n");
    }
    else{
        printf("%s\n", min_ans.c_str());
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for line in stdin:
    number, weight, height = line.split(',')
    if 25.0 <= float(weight) / (float(height) ** 2):
        print(number)

Measured memory_bytes: 4288
main = do
  li <- getLine
  let [a,b,c] = map read $ words li
  let ans = compute a b c
  putStrLn (if ans then "YES" else "NO")

{-
Aの倍数を任意個選んで足した結果は結局Aの倍数nA (n>=1)
nA `mod` B == C
とできるかを判定するのに、nはどこまで探せばよいか。
(B+k)A `mod` B = (AB + kA) `mod` B = kA `mod` B
なので、1からB-1までで十分とわかる。
-}

compute :: Int -> Int -> Int -> Bool
compute a b c = or [ k * a `mod` b == c | k <- [1..b-1] ]


Measured memory_bytes: 508
# 貪欲+山登り(日付をランダムに2つ選んで更新)
import time
import random

d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = []
L = [-1 for j in range(26)]
for i in range(d):
    max_diff = -10**7
    arg_max = 0
    for j in range(26):
        memo = L[j]
        L[j] = i
        diff = S[i][j] - sum([C[k] * (i - L[k]) for k in range(26)])
        if diff > max_diff:
            max_diff = diff
            arg_max = j
        L[j] = memo
    T.append(arg_max)
    L[arg_max] = i


def calc_score(T):
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    score = 0
    for i in range(d):
        score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        score -= C[j] * (dd - X[j])
    return score


score = calc_score(T)
start = time.time()
cnt = 0
while True:
    now = time.time()
    if now - start > 1.8:
        break
    i0, i1 = tuple(random.sample(range(d), 2))
    arg_max = (0, 0)
    max_diff = 0
    for j0 in range(26):
        for j1 in range(26):
            memo = (T[i0], T[i1])
            T[i0], T[i1] = j0, j1
            new_score = calc_score(T)
            if new_score - score > max_diff:
                max_diff = new_score - score
                arg_max = (j0, j1)
            T[i0], T[i1] = memo
    if max_diff > 0:
        T[i0], T[i1] = arg_max
        score += max_diff
    cnt += 1

for t in T:
    print(t + 1)


Measured memory_bytes: 86980
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;
    cin >> r;
    cout << fixed << setprecision(6);
    cout << 2*r*M_PI << endl;
    return 0;
}


Measured memory_bytes: 3796
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int i,n,k;
	cin>>n>>k;
	int a=1;
	for(i=1;i<=n;i++)
	{
		if(a<=k) a*=2;
		else a+=k;
	}
	printf("%d\n",a);
}

Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
use std::io::BufReader;

fn main() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let hwk: Vec<usize> = x
        .trim_end()
        .split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
    let h = hwk[0];
    let w = hwk[1];
    let k = hwk[2];
    let mut b: [[i32; 6]; 6] = Default::default();
    let lines = BufReader::new(io::stdin()).split(b'\n').into_iter();
    for (row, line) in b.iter_mut().zip(lines) {
        for (cell, x) in row.iter_mut().zip(line.unwrap()) {
            if x == b'#' {
                *cell = 1;
            }
        }
    }
    let mut ans = 0;
    for i in 0..1 << h {
        // 行を消すパターン
        for j in 0..1 << w {
            //　列を消すパターン
            let mut cnt = k as i32;
            for r in 0..h {
                if (i >> r) & 1 == 0 {
                    // 第rビットがゼロ
                    for c in 0..w {
                        if (j >> c) & 1 == 0 {
                            // 第cビットがゼロ
                            cnt -= b[r][c];
                        }
                        if cnt < 0 {
                            break;
                        }
                    }
                }
            }
            // println!("{}", cnt);
            if cnt == 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,a,b;
  cin >> x >> a >> b;
  int syoumi=b-a;
  if(syoumi<=0){
    cout << "delicious" << endl;
  } else if(x+1>syoumi && syoumi>=0){
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}


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

void Main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i<N; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    S[i] = s;
  }

  sort(S.begin(), S.end());
  lint ans = 0;
  lint x = 1;
  for (int i=1; i<N; ++i) {
    if (S[i-1] == S[i]) {
      ++x;
    } else {
      ans += x * (x - 1) / 2;
      x = 1;
    }
  }
  cout << ans + x * (x - 1) / 2 << "\n";
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  Main();
}


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

int main(){
      int X,A,B;cin >> X >> A >> B;
      if(B-A <= 0){
            cout << "delicious" << endl;
      }else if(B-A <= X){
            cout << "safe" << endl;
      }else{
            cout << "dangerous" << endl;
      }
}


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

using namespace std;

int main() {
    double PI=2*asin(1);
    double a,b,x;
    cin>>a>>b>>x;
    cout<<fixed<<setprecision(18);
    double half = (a*a*b)/2;
    if(x>=half){
        double ang=2*a*a*b - 2*x;
        ang=ang/(a*a*a);
        cout<<atan(ang)*180/PI;
    }
    else{
        double ang = (2*x)/(a*b*b);
        ang=atan(ang);
        ang=ang*180/PI;
        ang=90-ang;
        cout<<ang;
        
    }
}

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

int main(){
  int D;
  cin >> D;
  
  if(D == 25){
    cout << "Christmas" << endl;
  }else if(D == 24){
    cout << "Christmas Eve" << endl;
  }else if(D == 23){
    cout << "Christmas Eve Eve" << endl;
  }else{
    cout << "Christmas Eve Eve Eve" << endl;
  }

  return 0;
}

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

#ifndef ONLINE_JUDGE
#include "myfile.h"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


void solve() {
	int n;
	cin >> n;
	cout << (1000 - (n % 1000)) % 1000 << endl;


}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117

"""
import sys
from sys import stdin
input = stdin.readline


def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])


def main(args):
    n = int(input())
    m = int(input())
    dp = [[float('inf')]*(n+1) for _ in range(n+1)]
    for i in range(n+1):
        dp[i][i] = 0
    for _ in range(m):
        a, b, c, d = [int(x) for x in input().split(',')]
        dp[a][b] = c
        dp[b][a] = d
    s, g, V, P = [int(x) for x in input().split(',')]
    # print(dp)
    warshallFloyd(n+1, dp)
    # print(dp)

    print(V - dp[s][g] - dp[g][s] - P)



if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7788