akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT
 
using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;
 
template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
 
int n;
int m;
int a, b, ab, na, nb;
 
int main () {
    cin >> a >> b >> ab >> na >> nb;
    int ans = 1e9;
    for (int t = 0; t <= max (na, nb); t++)
        ans = min (ans, 2 * t * ab + max (0, na - t) * a + max (0, nb - t) * b);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// B - Bite Eating

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int main(){
	int N, L;
	cin >> N >> L;

	int sum = 0;
	int min_abs = 999999;
	int selected_apples_taste = -1;
	for (int i=L; i<L+N; i++) {
		sum += i;
		if (abs(i) < min_abs) {
			min_abs = min(min_abs, abs(i));
			selected_apples_taste = i;
		}

	}

	int ans = sum - selected_apples_taste;

	cout << ans << endl;

	return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  int R[N];
  rep(i, N) R[i] = 0;
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    R[x]++;
    R[y]++;
  }
  rep(i, N) cout << R[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
int a,b,c,i;
for(i=1;i<10000;i++){
scanf("%d %d",&a,&b);
if(a==0&&b==0)break;
if(a>b){
	c=a;
	a=b;
	b=c;
}

printf("%d %d\n",a,b);

}
return 0;

}


Measured memory_bytes: 2700
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    X = ii()
    ans = 0
    ans += X//500 * 1000
    X %= 500
    ans += X//5 * 5
    print(ans)


main()







Measured memory_bytes: 5676
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x;
  for(x = nil->next;x!=nil;x=x->next){
  if(x->key==key)return x;
  }
  return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){


  t->next->prev=t->prev;
  t->prev->next=t->next;

  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if (t==nil)return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t=listSearch(key);
  if(t==NULL)return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;


}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

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

bool p(int y){
    for(int i=2;i*i<=y;i++){
            if(y%i==0) return false;
    }
    return true;
}

int main(void){
    int x;
    cin >> x;
    for(int y=x;;y++){
        if(p(y)){
            cout << y << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a>b){
		cout << "a" << " > " << "b" << endl;
	}
	else if(a==b){
		cout << "a" << " == " << "b" << endl;
	}
	else{
		cout << "a" << " < " << "b" << endl;
	}
}


Measured memory_bytes: 3120
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static class Walk implements Comparable<Walk>{
		int pos;
		double dist;
		int bit;
		
		public Walk(int pos, double dist, int bit) {
			super();
			this.pos = pos;
			this.dist = dist;
			this.bit = bit;
		}
		
		@Override
		public int compareTo(Walk arg0) {
			return this.dist < arg0.dist ? -1 : this.dist > arg0.dist ? 1 : 0;
		}
	}
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		final int bit_size = 1 << 8;
		final int size = 30;
		boolean[][] is_visited = new boolean[size][bit_size];
		int[][] adj = new int[size][size];
		
		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			final int p = sc.nextInt();
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			
			if(n == 0 && m == 0 && p == 0 && a == 0 && b == 0){
				break;
			}
			
			for(int i = 0; i < m; i++){
				final int init_size = 1 << n;
				for(int j = 0; j < init_size; j++){
					is_visited[i][j] = false;
				}
				
				for(int j = 0; j < m; j++){
					adj[i][j] = Integer.MAX_VALUE;
				}
			}
			
			int[] tickets = new int[n];
			for(int i = 0; i < n; i++){
				tickets[i] = sc.nextInt();
			}
			
			for(int i = 0; i < p; i++){
				final int start = sc.nextInt();
				final int end = sc.nextInt();
				final int dist = sc.nextInt();
				
				adj[start - 1][end - 1] = adj[end - 1][start - 1] = dist;
			}
			
			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			queue.add(new Walk(a - 1, 0, 0));
			
			boolean flag = false;
			while(!queue.isEmpty()){
				Walk walk = queue.poll();
				
				//System.out.println(walk.pos + " " + walk.dist);
				
				if(is_visited[walk.pos][walk.bit]){
					continue;
				}else{
					is_visited[walk.pos][walk.bit] = true;
				}
				
				if(walk.pos == b - 1){
					System.out.println(walk.dist);
					flag = true;
					break;
				}
				
				for(int ticket = 0; ticket < n; ticket++){
					if((walk.bit & (1 << ticket)) == 0){
						final int new_bit = walk.bit | (1 << ticket);
						
						for(int to = 0; to < m; to++){
							//System.out.println(to);
							if(adj[walk.pos][to] != Integer.MAX_VALUE && !is_visited[to][new_bit]){
								queue.add(new Walk(to, walk.dist + (adj[walk.pos][to] / (double)(tickets[ticket])), new_bit));
							}
						}
					}
				}
			}
			
			if(!flag){
				System.out.println("Impossible");
			}
			
		}
		
	}

}

Measured memory_bytes: 70736
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n>=30){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		// your code goes here
	}
}

Measured memory_bytes: 35600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	int N; // num of Tenbodai
	int M; // num of roads
	std::vector<int> H; // height of Tenbodai 
	std::vector<int> A;
	std::vector<int> B;
	std::vector<int> otherPeaks;
	
	std::cin >> N >> M;

	H.resize(N);
	A.resize(M);
	B.resize(M);
	otherPeaks.resize(N);
	std::for_each(otherPeaks.begin(), otherPeaks.end(), [](int& i) {i = -1; });

	for (int i = 0; i < N; i++)
	{
		std::cin >> H[i];
	}
	for (int i = 0; i < M; i++)
	{
		std::cin >> A[i] >> B[i];

		if (otherPeaks[A[i] - 1] < H[B[i] - 1])
		{
			otherPeaks[A[i] - 1] = H[B[i] - 1];
		}
		if (otherPeaks[B[i] - 1] < H[A[i] - 1])
		{
			otherPeaks[B[i] - 1] = H[A[i] - 1];
		}
	}

	int answer = 0;
	for (int i = 0; i < N; i++)
	{
		if (otherPeaks[i] == -1)
		{
			answer++;
		}
		else if (otherPeaks[i] < H[i])
		{
			answer++;
		}
	}

	std::cout << answer;

	return 0;
}


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

using namespace std;

string a, b;

string solve(){
	if(a.length() > b.length()) return "GREATER";
	if(a.length() < b.length()) return "LESS";
	if(a > b) return "GREATER";
	if(a < b) return "LESS";
	return "EQUAL";
}

int main(){
	cin >> a >> b;
	cout << solve() << endl;
	return 0;
}

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

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

int main(){
int map[3][3];
rep(i,3) {rep(j,3){
	cin >> map[i][j];
}}

int a[3], b[3];
a[0] = 0;

rep(i,3) b[i] = map[0][i];
rep(i,3) a[i] = map[i][0] - b[0];

rep(i,3){ rep(j,3) {
	if(map[i][j] != a[i] + b[j]) {cout << "No" <<endl; return 0;}
}}

cout << "Yes" <<endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> a,b;
  bool f=1;
  int tmp=0;
  for(auto itr=s.begin();itr !=s.end();itr++)
  {
    if(*itr=='F'){tmp++;}
    else {
      if(f){a.push_back(tmp);}
      else{b.push_back(tmp);}
      f=!f;
    tmp=0;
  }

  }
  if(f){a.push_back(tmp);}
  else{b.push_back(tmp);}
  x-=a[0];
  x=abs(x);
  y=abs(y);
  a.erase(a.begin());
  int suma=0,sumb=0;
  for(auto itr=a.begin();itr !=a.end();itr++)
  {
    suma+=*itr;
  }
  for(auto itr=b.begin();itr !=b.end();itr++)
  {
    sumb+=*itr;
  }
  int flag=0;
  if((suma-x)%2 or (sumb-y)%2){flag=0;}
  else
  {
    if(suma<x or sumb<y){flag=-2;}
    x=(suma-x)/2;
    y=(sumb-y)/2;
    vector<int> dpx(8001),dpy(8001);
    //for(int i=0;i<8001;i++){dpx[i]=0;dpy[i]=0;}
    dpx[0]=1;dpx[suma]=1;
    dpy[0]=1;dpy[sumb]=1;
    for(auto itr1=a.begin();itr1 !=a.end();itr1++)
    {
      for(int i=x;i>-1;i--)
      {
        if(dpx[i]==1){dpx[i+*itr1]=1;}
      }
      if(dpx[x]!=0){flag+=1;break;}

    }
    if(a.size()==0 and x==0){flag+=1;}
    for(auto itr2=b.begin();itr2 !=b.end();itr2++)
    {
      for(int i=y;i>-1;i--)
      {
        if(dpy[i]==1){dpy[i+*itr2]=1;}
      }
      if(dpy[y]!=0){flag+=1;break;}
    }
    if(b.size()==0 and x==0){flag+=1;}
  }
  cout<<yn(flag>=2)<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e4+7;

int MAX=1000100;
vector<vector<int> >trie(MAX,vector<int>(26));
vector<int>leaf(MAX);

int sz=1;
void add_string(string s){
    int v=0;
    for(auto c:s){
        if(!trie[v][c-'a']){
            trie[v][c-'a']=sz;
            sz++;
        }
        v=trie[v][c-'a'];
    }
    leaf[v]=1;
}

signed main(){
    int n;cin>>n;
    vector<string>a(n);
    rep(i,n){
        cin>>a[i];
        reverse(all(a[i]));
        add_string(a[i]);
    }
    int ans=0;
    rep(i,n){
        string s;
        s=a[i];
        vector<int>cnt(26);
        for(auto c:s){
            cnt[c-'a']++;
        }
        int v=0;
        rep(j,s.size()){
            rep(x,26){
                if(cnt[x]&&trie[v][x]){
                    ans+=leaf[trie[v][x]];
                }
            }
            cnt[s[j]-'a']--;
            v=trie[v][s[j]-'a'];
        }
        ans--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 146304
from sys import stdin
import itertools
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    s1=[0]*n
    s2=[0]*n
    for i in range(n):
        if i==0:
            s1[i]=a[i]
        else:
            s1[i]+=s1[i-1]+a[i]

    for i in range(n-1,-1,-1):
        if i==n-1:
            s2[i]=a[i]
        else:
            s2[i]+=s2[i+1]+a[i]

    ans=float("inf")
    for i in range(n-1):
        ans=min(ans,abs(s1[i]-s2[i+1]))

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 30456
def A():
    temp = [int(i) for i in input().split()]
    print(max(0, temp[0]-2*temp[1]))

def B():
    N = int(input())
    T = [int(i) for i in input().split()]
    s = 0
    for i in range(N):
        for j in range(i):
            s += T[i]*T[j]
    print(s)

B()

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    string S, T;
    cin >> S >> T;

    if (S == T) {
        cout << "Yes\n";
    }
    else if (S.size() != T.size()) {
        cout << "No\n";
    }
    else {
        int n = S.size();
        bool ok;
        for (int i = 0; i < n; i++) {
            ok = true;
            for (int j = 0; j < n; j++) {
                if (S[j] != T[(j + i) % n]) {
                    ok = false;
                    break;
                }
            }
            if (ok) break;
        }
        cout << (ok ? "Yes" : "No") << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long LL;
const int N=200005;
LL t1[N*4],t2[N*4];
void pushup(int k){
	t1[k]=min(t1[k<<1],t1[k<<1|1]);
	t2[k]=min(t2[k<<1],t2[k<<1|1]);
}
void build(int k,int l,int r,int x){
	if (l==r){
		t1[k]=t2[k]=x==l?0:1ll*N*N;
		t1[k]-=l;t2[k]+=l;
		return;
	}
	int mid=(l+r)>>1;
	build(k<<1,l,mid,x);
	build(k<<1|1,mid+1,r,x);
	pushup(k);
}
void modify(int k,int l,int r,int x,LL y){
	if (l==r){
		t1[k]=min(t1[k],y-l);
		t2[k]=min(t2[k],y+l);
		return;
	}
	int mid=(l+r)>>1;
	if (x<=mid) modify(k<<1,l,mid,x,y);
		else modify(k<<1|1,mid+1,r,x,y);
	pushup(k);
}
LL query1(int k,int l,int r,int x){
	if (r<=x) return t1[k];
	int mid=(l+r)>>1;
	LL y=query1(k<<1,l,mid,x);
	if (x>mid) y=min(y,query1(k<<1|1,mid+1,r,x));
	return y;
}
LL query2(int k,int l,int r,int x){
	if (x<=l) return t2[k];
	int mid=(l+r)>>1;
	LL y=query2(k<<1|1,mid+1,r,x);
	if (x<=mid) y=min(y,query2(k<<1,l,mid,x));
	return y;
}
LL query(int k,int l,int r){
	if (l==r) return t1[k]+l;
	int mid=(l+r)>>1;
	return min(query(k<<1,l,mid),query(k<<1|1,mid+1,r));
}
int main(){
	int n,q,A,B;LL delta=0;
	scanf("%d%d%d%d\n",&n,&q,&A,&B);
	build(1,1,n,A);
	for (int i=1;i<=q;i++){
		scanf("%d",&A);
		modify(1,1,n,B,min(query1(1,1,n,A)+A,query2(1,1,n,A)-A)-abs(A-B));
		delta+=abs(A-B);B=A;
	}
	printf("%lld\n",delta+query(1,1,n));
}

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

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

typedef long long ll;

ll GCD( ll a,ll b){
    if( a < b ) swap( a, b );
    ll r = a % b;
    if( r == 0 ) return b;
	else
        return GCD( b, r );
}

//*******************
//エントリーポイント
//*******************
int main( void ) {
    ll a, b;
    cin >> a >> b;
    cout << GCD( a, b ) << endl;
    return 0;
}



Measured memory_bytes: 3116
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var l = mutableListOf<Int>()
    for (i in 0 until n) l.add(readLine()!!.toInt())
    l = l.sorted().toMutableList()
    println(n + ((m - l.sum()) / l[0] ))
}

Measured memory_bytes: 37932
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	while(true){
		cin>>n;
		if(n==-1)
			break;
		if(n==0)
			cout<<"0"<<endl;
		else{
		int c=1024*1024;
		bool first=true;
		while(true){
			if(n/c>0){
				first=false;
				cout<<n/c;
				n%=c;
			}
			else if(first==false)
				cout<<"0";
			if(c==1)
				break;
			c/=4;
		}
		cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
using System;

class Program {

    static void Main() {
        string input = Console.ReadLine();

        int a = int.Parse(input.Split(' ')[0]);
        int b = int.Parse(input.Split(' ')[1]);
        int c = int.Parse(input.Split(' ')[2]);

        Console.WriteLine(a<=c && c<=b ? "Yes" : "No");
    }
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    rep(i, n + 1) {
        if (floor((double)i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

long long gcd(long long a, long long b){
	if(b > a) swap(a, b);
	long long tmp;
	while(b != 0){
		tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}

//累乗 O(log N)
long long power(long long x, long long N){
	if(N == 0) return 1LL;
	if(N == 1) return x;
	long long tmp = power(x, N/2);
	if(N%2 == 0) return tmp * tmp % MOD;
	else return tmp * tmp % MOD * x % MOD;
}

//逆元 O(log x)
long long inverse(long long x){
	return power(x, MOD-2);
}

int N;
ll A[10000];
ll so[1000000] ={};
signed main(){
	cin >> N;
	rep(i, N) cin >> A[i];

	ll g = A[0];
	for(int i=1; i<N; i++) g = gcd(g, A[i]);
	rep(i, N) A[i] /= g;

	rep(i, N){
		ll a = A[i];
		for(ll j=2; j<=sqrt(A[i]); j++){
			ll c = 0;
			while(a%j == 0){
				c++;
				a /= j;
			}
			so[j] = max(so[j], c);
		}
		if(a > 1){
			so[a] = max(so[a], 1LL);
		}
	}

	ll sum = 1;
	for(ll i=2; i<1000000; i++){
		rep(j, so[i]){
			sum *= i;
			sum %= MOD;
		}
	}

	ll ans = 0;
	rep(i, N){
		ans += sum * inverse(A[i]);
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 6656
n = int(input())
array = [[0, 0] for i in range(n)]
for i in range(n):
    array[i] = list(map(int, input().split()))
array.sort(key=lambda x:(x[1], x[0]))
time = 0
flag = True
for el in array:
    a, b = el[0], el[1]
    time += a
    if time > b:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 66196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    auto ab = make_vec<int>(100005, 0);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        ab[a].push_back(b);
    }
    priority_queue<int> pq;
    ll ans = 0;
    for (int i = 1; i <= m; ++i) {
        for (int x : ab[i]) pq.push(x);
        if (sz(pq) > 0) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8560
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import Text.Printf

readInt = ( readLn :: IO Int )
getInts = map ( read :: String -> Int ) . words <$> getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= putStrLn . map head . words


Measured memory_bytes: 508
def dfs(now, l):
    if now == n:
        for ll in l[1:]:
            if ll < x:
                return inf
        return l[0]
    else:
        add_l = []
        for i, j in zip(l, book[now]):
            add = i + j
            add_l.append(add)
        return min(dfs(now + 1, add_l), dfs(now + 1, l))


inf = 1001001001
n, m, x = map(int, input().split())

book = []
su = 0
for i in range(n):
    tmp = list(map(int, input().split()))
    su += tmp[0]
    book.append(tmp)

first = [0 for _ in range(m + 1)]
ans = dfs(0, first)
if ans == inf:
    print(-1)
else:
    print(ans)


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

int main() {
  int n;
  cin >> n;
  long long s=1;
  //long long x;
  long long a[100000+10];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) {
    if (a[i] == 0){
      s=0;
    }
  }
  for(int i=0; i<n; i++){
    if(log10(s+0.0)+log10(a[i]+0.0) > 18 | s*a[i] > 1000000000000000000){
      s = -1;
      break;
    }
    s *= a[i];
  } 

  cout << s;
}


Measured memory_bytes: 4664
import Control.Monad

import Data.Ord
import Data.List
import Data.Function
import Data.Maybe

import qualified Data.ByteString.Char8 as BS

import Debug.Trace

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInt
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
  [a,b,k] <- getIntList
  traceShowM (a,b,k)
  print $ head . drop (k-1) $ factors a b

factors a b = factors' a b (min a b)
  where
    factors' a b n
      | n == 1 = [1]
      | a `mod` n == 0 && b `mod` n == 0 = traceShow n $ n : factors' a b (n-1)
      | otherwise = factors' a b (n-1)


Measured memory_bytes: 508
#include <stdio.h>

int main (void)
{
	int n, i, v, j, k;
	scanf("%d", &n);
	
	int a[n];
	for(i = 0; i < n; i++){scanf("%d", &a[i]);}
	for(k=0; k < n;k++){
			if(k!=n-1){printf("%d ", a[k]);}
			else printf("%d", a[k]);
		}
	printf("\n");
	for(i = 1; i <= n-1; i++){
		v = a[i];
		j = i-1;
		while(j>=0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for(k=0; k < n;k++){
			if(k!=n-1){printf("%d ", a[k]);}
			else printf("%d", a[k]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2144
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int1,input()))
    X=0
    c=0
    f=False
    if not 1 in a:
        for i in range(N):
            a[i]//=2
        f=True
    for i in range(N):
        if c==0:
            X^=a[i]%2
        K=N-1-i
        while K>0 and K%2==0:
            c+=1
            K//=2
        K=i+1
        while K>0 and K%2==0:
            c-=1
            K//=2
    if X==1:
        print(1*(f+1))
    else:
        print(0)

if __name__ == '__main__':
    main()


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

S = set()
for i in range(K):
    a = A+i
    if A <= a <= B:
        S.add(a)
    b = B-i
    if A <= b <= B:
        S.add(b)

l = list(S)
l.sort()
for s in l:
    print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int  long long  
void solve(){
	int k;cin>>k;
    string s,t;
    cin>>s;int n=s.length();
    if(n>k){
    	for (int i = 0; i < k; ++i)
    	{
    		t+=s[i];
    	}
    	cout<<t+"..."<<endl;
    }
    else  cout<<s<<endl;  
}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
 #ifndef ONLINE_JUDGE
      freopen("input.txt",  "r",  stdin);
      freopen("output.txt", "w", stdout);
 #endif
 
     cout << setprecision(9) << fixed;
     clock_t z = clock();
 
     int t=1; 
     // cin >> t;
     while (t--) solve();
 
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
 
     return 0;
}



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

const int INF = (int)1e9;

namespace math {
    const int N = (int)1.01e7;

    char ispr[N];
    vector<int> pr;

    void init() {
        memset(ispr, 1, sizeof(ispr));
        ispr[1] = 0;
        for (int i = 2; i < N; i++) {
            if (!ispr[i]) continue;
            pr.push_back(i);
            for (int j = i + i; j < N; j += i) ispr[j] = 0;
        }
    }

    bool isPrime(int x) {
        if (x < N) return ispr[x];
        for (int i = 0; i < (int)pr.size() && 1LL * pr[i] * pr[i] <= x; i++) {
            if (x % pr[i] == 0) {
                return 0;
            }
        }
        return 1;
    }
}

using namespace math;

void upd(int &x, int y) {
    x = min(x, y);
}

int fastsolve(vector<int> x) {
    int n = x.size();

    vector<int> vv;
    vv.push_back(x[0]);
    for (int i = 0; i + 1 < n; i++) {
        if (x[i + 1] != x[i] + 1) {
            vv.push_back(x[i] + 1);
            vv.push_back(x[i + 1]);
        }
    }
    vv.push_back(x.back() + 1);

    vector<vector<int> > vct(2);
    for (int x : vv) {
        vct[x % 2].push_back(x);
    }
    vector<vector<int> > e(vct[0].size());
    for (int i = 0; i < (int)vct[0].size(); i++) {
        for (int j = 0; j < (int)vct[1].size(); j++) {
            if (isPrime(abs(vct[0][i] - vct[1][j]))) {
                e[i].push_back(j);
            }
        }
    }


    vector<char> vis;
    vector<int> mt(vct[1].size(), -1);
    function<bool(int)> dfs = [&](int v) {
        if (vis[v]) return false;
        vis[v] = 1;
        for (int to : e[v]) {
            if (mt[to] == -1 || dfs(mt[to])) {
                mt[to] = v;
                return true;
            }
        }
        return false;
    };
    int mat = 0;
    for (int i = 0; i < (int)vct[0].size(); i++) {
        vis.assign(vct[0].size(), 0);
        mat += dfs(i);
    }
    int c0 = vct[0].size() - mat;
    int c1 = vct[1].size() - mat;

    int ans = 0;
    ans += mat;
    ans += c0 / 2 * 2;
    ans += c1 / 2 * 2;
    ans += c0 % 2 * (c1 % 2) * 3;

    return ans;
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif
    init();

    int n;
    while (cin >> n) {
        vector<int> x(n);
        for (int i = 0; i < n; i++) cin >> x[i];

        cout << fastsolve(x) << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


Measured memory_bytes: 16240
using System;
class Program
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
        double n = inp[0];
        double m = inp[1];
        double d = inp[2];
        double p = d == 0 ? n : (n - d) * 2;
        Console.WriteLine(p * (m - 1) / Math.Pow(n, 2));
    }
}


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

public class Main{

	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String[] line=new String[n];
		char s[][]=new char[n][10];

		for(int i=0;i<n;i++){
			s[i]=sc.next().toCharArray();
			Arrays.sort(s[i]);
		}

		for(int i=0;i<n;i++){
			line[i]=String.valueOf(s[i]);
		}

		int count=0;
		long usagi=0;


		Arrays.sort(line);


		for(int i=0;i<n-1;i++){
			if(line[i].equals(line[i+1])){
				count++;
				usagi+=count;
			}else{
				count=0;
			}
		}


		System.out.println(usagi);

	}
}


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

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int a1, a2, a3; cin>>a1>>a2>>a3;
    if (a1+a2+a3>=22) cout<<"bust";
    else cout<<"win";
    return 0;
}

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

int main(){
    long long int X, K, D;
    cin >> X >> K >> D;
    long long int first = X;
    long long int k = 0;
    //cout << X/D << endl;
    for(int i=0;i<K;i++){
        if(abs(X) >= D){
            if(X > 0){
                k = X/D;
                X %= D;
                if(k > K){
                    X = first - D*K;
                    break;
                }
                
            }else
            {
                k = abs(X)/D;
                X = -(abs(X)%D);
                if(k > K){
                    X = first + D*K;
                    break;
                }
            }
        
        }
            if((K - k)%2 == 1){
                if(X > 0){
                    X -= D;
                    break;
                }else if(X <= 0){
                    X += D;
                    break;
                }
            }else
            {
                break;
            }
        
    }

    cout << abs(X) << endl;
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k; cin >> n >> k;
    cout << (ll)(k * pow(k-1, n-1)) << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		boolean ans = true;
		if (w.length() % 2 == 1) {
			ans = false;
		}
		for(int i = 0; i < w.length(); i++) {
			char x = w.charAt(i);
			int count = (int) w.chars().filter(ch -> ch == x).count();
			if (count % 2 == 1) {
				ans = false;
			}
		}
		System.out.println(ans ? "Yes" : "No");
	}
}



Measured memory_bytes: 35936
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
	ll N; SCLLD(N);
	vector<ll> a;
	vector<ll> b;
	ll ans = 0;
	REP(i,N){
		ll A; SCD(A);
		a.PB(A);
	}
	REP(i,N){
		ll B; SCD(B);
		b.PB(B);
	}

		
	for (ll p = 1;p <= 268435456;p = 2*p){
		vector<ll> pa,pb;
		REP(i,N){
			pb.PB(b[i] % (2*p));
		}

		sort(pb.begin(),pb.end());
		ll count = 0;

		REP(i,N){
			auto it1 = lower_bound(pb.begin(),pb.end(),2*p-a[i]%(2*p));
			auto it2 = lower_bound(pb.begin(),pb.end(),p-a[i]%(2*p));
			auto it3 = lower_bound(pb.begin(),pb.end(),4*p-a[i]%(2*p));
			auto it4 = lower_bound(pb.begin(),pb.end(),3*p-a[i]%(2*p));
			
			count += (ll)((it1 - pb.begin()) - (ll)(it2 - pb.begin()));
			count += (ll)((it3 - pb.begin()) - (ll)(it4 - pb.begin()));
		}
		//printf("count = %d\n",count);
		if (count % 2 == 1) ans += p;
	}

	PRINTLLD(ans);
	return 0;
}

Measured memory_bytes: 7028
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vi a(n);
	int x = 0;
	REP(i, n) {
		cin >> a[i];
		x ^= a[i];
	}
	REP(i, n) {
		cout << (x ^ a[i]) << " ";
	}
	return 0;
}
 


Measured memory_bytes: 4016
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    H = il()
    height, ret = 0, 0
    for h in H:
        if height <= h:
            height = h
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10100
N, M = gets.strip.split(/ /).collect{|n| n.to_i}

$branches = {}
$branches_r = {}
(N - 1 + M).times{
	a, b = gets.strip.split(/ /).collect{|n| n.to_i}
	if l = $branches[a]
		l << b
	else
		$branches[a] = [b]
	end
	if l = $branches_r[b]
		l << a
	else
		$branches_r[b] = [a]
	end
}

def find_root
	n = 1
	while l = $branches_r[n]
		n = l[0]
	end
	n
end

def tsort
	l = []
	s = [find_root]
	delete_counts = (N + 1).times.collect{0}
	while n = s.pop
		l << n
		if list = $branches[n]
			list.each{|j|
				if list2 = $branches_r[j]
					delete_counts[j] += 1
					if list2.length - delete_counts[j] == 0
						s << j
					end
				end
			}
		end
	end
	l
end

#p tsort

index_list = []
tsort.each_with_index{|n, i|
	index_list[n] = i
}

(1..N).each{|n|
	if index_list[n] == 0
		puts "0"
	else
		puts $branches_r[n].collect{|x| [index_list[x], x]}.max[1]
	end
}




Measured memory_bytes: 32952
#include<iostream>
#include<algorithm>
#include<cmath>
#include <iomanip>

using namespace std;


int main()
{
  int q;
  cin>>q;
  for(;q--;)
    {
      string s;
      cin>>s;
      bool bit[32];
      int bitcnt=0;

      for(int i=7;i>=0;i--)
	{
	  int tmp;
	  if(s[i]>='0' &&s[i]<='9')
	    tmp=s[i]-'0';
	  else
	    tmp=10+(s[i]-'a');	  
	  for(int j=0;j<4;j++)
	    {
	      if((1&tmp)>0)
		bit[bitcnt]=true;
	      else 
		bit[bitcnt]=false;
	      tmp>>=1;
	      bitcnt++;
	    }
	}
      /*      for(int i=31;i>=0;i--)
	cout<<bit[i];
      */
      if(bit[31])
	cout<<"-";
      long double ans=0;
      for(int i=7;i<31;i++)
	{
	  if(bit[i])
	    ans+=pow(2,i-7);
	}
      //      cout<<ans;
      //      ans=0;
      // double ans2=0;
      bool flag=true;
      for(int i=6;i>=0;i--)
	{
	  if(bit[i])
	    {
	      ans+=pow(0.5,6-i+1);
	      flag=false;
	    }
	}
      /*      while(ans2!=(int)ans2)
	{
	  ans2*=10;
	  }*/
      //std::cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
      cout<<setprecision(15)<<ans;
      if(flag)
	cout<<".0";
      //      else      
      cout<<endl;
    }
}

Measured memory_bytes: 1332
x = int(input())
n = 10 * x
primes = [True] * n
for i in range(2, n):
    if primes[i]:
        for j in range(i * i, n, i):
            primes[j] = False

for i in range(x, n):
    if primes[i]:
        print(i)
        exit()


Measured memory_bytes: 16664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,a[200010],x=0,ans=0;
  cin>>n;
  fr(i,n) cin>>a[i];
  ll s=0,t=0;
  while(t<n){
    if(x&a[t]) x^=a[s++];
    else{
      ans+=t-s+1;
      x^=a[t++];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

typedef long long ll;

int main()
{
    int N;

    std::cin >> N;

    std::vector<std::pair<ll, ll>> points;
    points.resize(N);
    std::map<std::pair<ll, ll>, ll> pointCost;

    for(int i=0; i<N; ++i)
        std::cin >> points[i].first >> points[i].second;

    std::sort(points.begin(), points.end());
    ll ans = 0;
    for(int i=0; i<N; ++i)
    {
        for(int j=i+1; j<N; ++j)
        {
            ll x = points[j].first - points[i].first;
            ll y = points[j].second - points[i].second;
            pointCost[{x,y}]++;
            ans = std::max(ans, pointCost[{x,y}]);
        }
    }

    std::cout << N - ans << std::endl;


    return 0;
}


Measured memory_bytes: 384
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int solve(int N, int K) {
    if(N == 1) return 0;

    int ub = INF, lb = -1;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        // mid 回で塗る

        int W = N + (mid - 1);
        if((W + K - 1) / K <= mid) {
            ub = mid;
        }
        else {
            lb = mid;
        }
    }
    return ub;
}
 
signed main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);

    int idx = -1;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        if(A[i] == 1) idx = i;
    }

    int ans = INF;
    for(int i=max(0LL, idx-K+1); i<=idx; i++) {
        int rl = i, rr = max(0LL, N - (i + K));

        // printf("i = %lld, rl = %lld, rr = %lld\n", i, rl, rr);

        int pl = solve(rl + 1, K);
        int pr = solve(rr + 1, K);
        chmin(ans, pl + pr + 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

	

int main()
{
	string S;
	cin >> S;
	int count_0 = 0;
	int count_1 = 0;
	int N = S.size();
	if(N%2==0)
	{
		for(int i=0;i<N/2;i++)
		{
			int n,m;
			n = S[2*i] - '0';
			if(n!=0){	count_0 = count_0 + 1;}
			m = S[2*i+1] - '0';
			if(m!=1){	count_0 = count_0 + 1;}
		}
		for(int i=0;i<N/2;i++)
		{
			int n,m;
			n = S[2*i] - '0';
			if(n-1!=0){	count_1 = count_1 + 1;}
			m = S[2*i+1] - '0';
			if(m-0!=0){	count_1 = count_1 + 1;}
		}
		if(count_0>=count_1)
		{
			cout << count_1 << endl;
		}
		else
		{
			cout << count_0 << endl;
		}
	}
	else if(N%2==1)
	{
		for(int i=0;i<(N-1)/2;i++)
		{
			int n,m;
			n = S[2*i] - '0';
			if(n-0!=0){	count_0 = count_0 + 1;}
			m = S[2*i+1] - '0';
			if(m-1!=0){	count_0 = count_0 + 1;}
		}
		int x = S[N-1] - '0';
		if(x!=0){	count_0 = count_0 + 1;}

		for(int i=0;i<(N-1)/2;i++)
		{
			int n,m;
			n = S[2*i] - '0';
			if(n-1!=0){	count_1 = count_1 + 1;}
			m = S[2*i+1] - '0';
			if(m-0!=0){	count_1 = count_1 + 1;}
		}
		if(x!=1){	count_1 = count_1 + 1;}
		
		if(count_0>=count_1)
		{
			cout << count_1 << endl;
		}
		else
		{
			cout << count_0<< endl;
		}
	}
		
		
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	int n,a,b,ma = 0,mb = 0;
	cin >> n;
	for (int i = 0; i < n;i++) {
		cin >> a >> b;
		if (a > ma) {
			ma = a;
			mb = b;
		}
	}
	cout << ma+mb << endl;
	
	

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int n,tmp;
  int ans;
 
  while(1){
    scanf("%d",&n);
    if(!n)break;
 
    ans = 0;
 
    tmp = 5;
    while(tmp <= n){
      ans += n/tmp;
      tmp *= 5;
    }
 
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 2036
S = input()
judge = False
if S[0] == "A":
    if list(S[2:len(S)-1]).count("C") == 1:
        S = S.lstrip("A")
        S = S.replace("C", "")
        if S.islower():
            judge =True
if judge:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>

void roll(std::vector<int> &v, char c) {
    if (c == 'E') {
        char tmp = v[0];
        v[0] = v[3];
        v[3] = v[5];
        v[5] = v[2];
        v[2] = tmp;
    } else if (c == 'S') {
        char tmp = v[0];
        v[0] = v[4];
        v[4] = v[5];
        v[5] = v[1];
        v[1] = tmp;
    } else if (c == 'N') {
        char tmp = v[0];
        v[0] = v[1];
        v[1] = v[5];
        v[5] = v[4];
        v[4] = tmp;
    } else {
        char tmp = v[0];
        v[0] = v[2];
        v[2] = v[5];
        v[5] = v[3];
        v[3] = tmp;
    }
}

int main(){
    std::vector<int> v(6), v2(6);
    for (int i = 0; i < 6; i++) {
        std::cin >> v[i];
    }
    for (int i = 0; i < 6; i++) {
        std::cin >> v2[i];
    }

    if (v[1] != v2[1]) {
        if (v2[4] == v[1]) roll(v2, 'N');
        while (v2[0] != v[1]) roll(v2, 'E');
        roll(v2, 'S');
    }

    for (int i = 0; i < 4; i++) {
        if (v == v2) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
        roll(v2, 'E');
    }
    std::cout << "No" << std::endl;

    return 0;
}

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

n = min(A, B)
count = 0
for i in range(n, 0, -1):
    if i == 0:
        break
    if A%i == 0 and B%i == 0:
        count = count + 1
        if count == K:
            break
print(i)

Measured memory_bytes: 2940