akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

using namespace std;

int main() {
   
    int H, W;
    while (1) {
        scanf("%d %d", &H, &W);

        if (H == 0 && W == 0) {
            break;
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (i % 2 == j % 2) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }

        printf("\n");
    }

    return 0;
}


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

int main()
{
	long long x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	
	priority_queue<pair<long long,long long> > h;
	while(a--)
	{
		long long w;
		cin>>w;
		h.push(make_pair(w,1));
	}
	while(b--)
	{
		long long w;
		cin>>w;
		h.push(make_pair(w,2));
	}
	while(c--)
	{
		long long w;
		cin>>w;
		h.push(make_pair(w,3));
	}
	long long z=x+y,ans=0;
	while(z)
	{
		pair<long long,long long> f=h.top();
		h.pop();
		if(f.second==3)
		{
			ans+=f.first;
			z--;
		}
		if(f.second==1 && x)
		{
			ans+=f.first;
			z--;
			x--;
		}
		if(f.second==2 && y)
		{
			ans+=f.first;
			z--;
			y--;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10348
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n').map((el,ind,arr)=>toIntArr(el.split(' ')));
	var n = input[0][0];
	var m = input[0][1];
	var foods = [];
	foods.length = m+1;
	foods.fill(0);
	for(var i = 1; i < n+1; i++){
		for(var j = 1; j < m+1; j++){
			foods[input[i][j]]++;
		}
	}
	var ans = 0;
	for(var i =1; i < m+1; i++){
		if(foods[i]===n)ans++;
	}
	console.log(ans);
	return 0;
}



Measured memory_bytes: 7500
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

S = list(input())
S = sorted(S)
if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4200
#include <iostream>
#include <cstdio>
#include <algorithm>
#define inf 10000000000000
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const int maxN = 1005;
const int maxM = 2005;
int N, M, root[maxN];
ll X;
struct edge{
	int u, v;ll val;
}G[maxM], tmp[maxM];
bool cmp(const edge& e1, const edge& e2) {
	return e1.val < e2.val;
}
int get_root(int v) {
	if(v != root[v]) {
		int rt = get_root(root[v]);
		root[v] = rt; v = rt;
	}
	return v;
}
ll kruskal(int n, int m, int& tm) {
	tm = 0;
	ll ans = 0; int tot = 1;
	for(int i = 1; i <= m; ++i) {
		int u = G[i].u, v = G[i].v;
		int rt1 = get_root(u), rt2 = get_root(v);
		if(rt1 != rt2) root[rt1] = rt2, tot++, ans += G[i].val;
		else tmp[++tm] = G[i];
	}
	if(tot < n) return inf;
	return ans;
}
void init() {
	for(int i = 1; i <= N; ++i) root[i] = i;
}
ll qpow(ll num, ll k) {
	ll ans = 1;
	while(k) {
		if(k & 1) ans = (ans * num) % mod;
		k = k >> 1; num = (num * num) % mod;
	}
	return ans;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d%lld", &N, &M, &X);
	for(int i = 1; i <= M; ++i) scanf("%d%d%lld", &G[i].u, &G[i].v, &G[i].val);
	sort(G + 1, G + 1 + M, cmp);
	init();
	int tm; 
	ll minn = kruskal(N, M, tm);
	//cout << minn << endl;
	if(minn > X) {
		printf("0\n"); return 0;
	} else if(minn == X) {
		//cout << "&&&&&" << endl;
		int tot = 0;
		for(int i = 1; i <= M; ++i) {
			init(); root[G[i].u] = G[i].v;
			if(kruskal(N - 1, M, tm) + G[i].val == X) tot++;
		}
		printf("%lld\n", (((qpow(2, tot) - 2) % mod + mod) % mod) * qpow(2, M - tot) % mod);
	} else {
		int tot1 = 0, tot2 = 0;
		for(int i = 1; i <= M; ++i) {
			init(); root[G[i].u] = G[i].v;
			ll tt;
			if((tt = (kruskal(N - 1, M, tm) + G[i].val)) < X) tot1++;
			else if(tt == X) tot2++;
		}
		//cout << tot1 << ' ' << tot2 << endl;
		printf("%lld\n", 2 * ((qpow(2, tot2) + mod - 1) % mod) % mod * qpow(2, M - tot1 - tot2) % mod);
	}
	return 0;	
}

Measured memory_bytes: 256
import itertools
H,W,K=map(int,input().split())
 
C=[]
 
for i in range(H):
  C.append(input())
 
ans=0
for i in range(H+1):
  for j in range(W+1):
    for n in itertools.combinations(list(range(H)),i):
      for m in itertools.combinations(list(range(W)),j):
        count = 0
        for a in n:
          for b in m:
            if(C[a][b]=="#"):count+=1
        if(count == K):
          ans += 1
print(ans)

Measured memory_bytes: 9128
#include<iostream>
#include<vector>
#include<climits>
#include<queue>
using namespace std;

struct edge{
    int from, to, cost;
};

int main(){
    int n, m, p;
    cin >> n >> m >> p;
    vector<edge> v;
    vector<int> fwd[n], rev[n];
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        v.push_back(edge({--a, --b, -(c-p)}));
        fwd[a].push_back(b);
        rev[b].push_back(a);
    }
    vector<bool> a(n, 0), b(n, 0);
    a[0] = b[n-1] = true;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int x = q.front();  q.pop();
        for(int y : fwd[x]){
            if(!a[y]){
                a[y] = true;
                q.push(y);
            }
        }
    }
    q.push(n-1);
    while(!q.empty()){
        int x = q.front();  q.pop();
        for(int y : rev[x]){
            if(!b[y]){
                b[y] = true;
                q.push(y);
            }
        }
    }

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < n-1; i++){
        for(int j = 0; j < m; j++){
            int from = v[j].from, to = v[j].to;
            if(dp[from] != INT_MAX && dp[from]+v[j].cost < dp[to]){
                dp[to] = dp[from]+v[j].cost;
            }
        }
    }
    bool valid = true;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            int from = v[j].from, to = v[j].to;
            if(dp[from] != INT_MAX && dp[from]+v[j].cost < dp[to]){
                dp[to] = dp[from]+v[j].cost;
                if(a[to] && b[to])   valid = false;
            }
        }
    }

    if(valid){
        cout << max(0, -dp[n-1]) << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  int H, W;
  string above, str, below;
  cin >> H >> W;

  if (H == 1) {
    cin >> str;
    for (int w = 0; w < W; w++) {
      if (str.at(w) == '.') {
        int cnt = 0;
        if (w != 0) {
          if (str.at(w - 1) == '#') cnt++;
        }
        if (w != (W - 1)) {
          if (str.at(w + 1) == '#') cnt++;
        }
        cout << cnt;
      } else {
        cout << '#';
      }
    }
    cout << endl;
  } else {
    cin >> str >> below;
    for (int w = 0; w < W; w++) {
      if (str.at(w) == '.') {
        int cnt = 0;
        if (below.at(w) == '#') cnt++;
        if (w != 0) {
          if (str.at(w - 1) == '#') cnt++;
          if (below.at(w - 1) == '#') cnt++;
        }
        if (w != (W - 1)) {
          if (str.at(w + 1) == '#') cnt++;
          if (below.at(w + 1) == '#') cnt++;
        }
        cout << cnt;
      } else {
        cout << '#';
      }
    }
    cout << endl;
    for (int h = 1; h < H - 1; h++) {
      above = str;
      str = below;
      cin >> below;
      for (int w = 0; w < W; w++) {
        if (str.at(w) == '.') {
          int cnt = 0;
          if (above.at(w) == '#') cnt++;
          if (below.at(w) == '#') cnt++;
          if (w != 0) {
            if (above.at(w - 1) == '#') cnt++;
            if (str.at(w - 1) == '#') cnt++;
            if (below.at(w - 1) == '#') cnt++;
          }
          if (w != (W - 1)) {
            if (above.at(w + 1) == '#') cnt++;
            if (str.at(w + 1) == '#') cnt++;
            if (below.at(w + 1) == '#') cnt++;
          }
          cout << cnt;
        } else {
          cout << '#';
        }
      }
      cout << endl;
    }
    above = str;
    str = below;
    for (int w = 0; w < W; w++) {
      if (str.at(w) == '.') {
        int cnt = 0;
        if (above.at(w) == '#') cnt++;
        if (w != 0) {
          if (above.at(w - 1) == '#') cnt++;
          if (str.at(w - 1) == '#') cnt++;
        }
        if (w != (W - 1)) {
          if (above.at(w + 1) == '#') cnt++;
          if (str.at(w + 1) == '#') cnt++;
        }
        cout << cnt;
      } else {
        cout << '#';
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
g = [[]*(n*(n-1)//2) for _ in range(n*(n-1)//2)]
chk = set([])
cnt = 0
d = {}
st = set([])

for i in range(n):
  a = [int(i) for i in readline().split()]
  for j in range(n-2):
    A,b = min(a[j],i+1),max(a[j],i+1)
    p,q = min(a[j+1],i+1),max(a[j+1],i+1)    
    if not b*1000+A in chk:
      d[b*1000+A] = cnt
      cnt += 1
      chk.add(b*1000+A)
    if not q*1000+p in chk:
      d[q*1000+p] = cnt
      cnt += 1
      chk.add(q*1000+p)
    g[d[b*1000+A]].append(d[q*1000+p])
    if j == 0:
      st.add(d[b*1000+A])

# あとは頂点VのグラフをdfsしてLongest pathの長さを求める
# -1: unchecked, -2: checked and uncalculated
dp=[-1]*(n*(n-1)//2)
#flag=True
def dfs(v):
    #global flag
    dp[v]=-2
    length=0
    for nv in g[v]:
        if(dp[nv]==-2):
            print(-1)
            exit()
        if(dp[nv]==-1):
            dfs(nv)
        length=max(length,dp[nv]+1)
    dp[v]=length
            
st = list(st)
a = []
pp = 0
for i in st:dfs(i)
print(max(dp)+1)


Measured memory_bytes: 188912
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  int k;cin>>k;
  
  ll m = 0;
  ll gc = 0;
  rep(i,n){
    ll a;cin>>a;
    gc = gcd(gc,a);
    chmax(m,a);
  }

  if(m >= k && k % gc == 0)print("POSSIBLE");
  else print("IMPOSSIBLE");

  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
  int h;
  int a;
  
  cin >> h;
  cin >> a;
  
  int num = h / a;
  if (h % a == 0) {
    cout << num << endl;
  } else {
    cout << num + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
a = input()
a = a.replace("A","*")
a = a.replace("C","*")
a = a.replace("G","*")
a = a.replace("T","*")
if (a.find("**********")!=-1):
    print("10")
elif(a.find("*********")!=-1):
    print("9")
elif(a.find("********")!=-1):
    print("8")
elif(a.find("*******")!=-1):
    print("7")
elif(a.find("******")!=-1):
    print("6")
elif(a.find("*****")!=-1):
    print("5")
elif(a.find("****")!=-1):
    print("4")
elif(a.find("***")!=-1):
    print("3")
elif(a.find("**")!=-1):
    print("2")
elif(a.find("*")!=-1):
    print("1")
else:
    print("0")

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

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

Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<functional>
#include<cassert>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;

int main(void) {
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	int a, b;
	int d, r;
	double f;

	scanf("%d %d", &a, &b);

	d = a / b;
	r = a % b;
	f = 1.0 * a / b;
	
	printf("%d %d %f\n", d, r, f);

	return 0;
}

Measured memory_bytes: 2752
import java.util.HashMap;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
//			while(sc.hasNextLine()){
//
//				String s = sc.nextLine();
//				if(s.equals("")) break;
//
//				int JOI=0;
//				int IOI=0;
//				for(int i=0;i<s.length();i++) {
//					if(s.indexOf("JOI",i)!=-1) {
//						JOI++;
//						i=s.indexOf("JOI",i)+1;
//					}
//				}
//
//				for(int i=0;i<s.length();i++) {
//					if(s.indexOf("IOI",i)!=-1) {
//						IOI++;
//						i=s.indexOf("IOI",i)+1;
//					}
//				}
//
//				System.out.println(JOI);
//				System.out.println(IOI);
//			}
//		}
//	}
////	black	00	00	00
////	blue	00	00	ff
////	lime	00	ff	00
////	aqua	00	ff	ff
////	red	ff	00	00
////	fuchsia	ff	00	ff
////	yellow	ff	ff	00
////	white	ff	ff	ff
//	static int[][] rgb = {
//			{0x00,0x00,0x00},
//			{0x00,0x00,0xff},
////			lime	00	ff	00
////			aqua	00	ff	ff
////			red	ff	00	00
////			fuchsia	ff	00	ff
////			yellow	ff	ff	00
////			white	ff	ff	ff
//
//	};
	//m n

		String s = sc.nextLine();
		String [] t = s.split(" ");
		String max = "";
		HashMap<String,Integer> count = new HashMap<>();
		for(String ss : t) {
			if(ss.length()>max.length()) {
				max = ss;
			}
			Integer n = count.get(ss);
			if(n == null) {
				count.put(ss, 1);
			}
			else {
				count.put(ss, n+1);
			}
		}
		String m="";
		int max2=0;
		for(String key: count.keySet()) {
			
			
			if(count.get(key)>max2) {
				max2=count.get(key);
				m=key;
			}
		}
		System.out.println(m+" "+max);
	}

	}
}



Measured memory_bytes: 26004
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeSet<Point> reds = new TreeSet<>(new Comparator<Point>() {
		public int compare(Point p1, Point p2) {
			if (p1.x == p2.x) {
				return p1.y - p2.y;
			} else {
				return p1.x - p2.x;
			}
		}
		});
		for (int i = 0; i < n; i++) {
			reds.add(new Point(sc.nextInt(), sc.nextInt()));
		}
		PriorityQueue<Point> blues = new PriorityQueue<>(new Comparator<Point>() {
		public int compare(Point p1, Point p2) {
			if (p1.x == p2.x) {
				return p1.y - p2.y;
			} else {
				return p1.x - p2.x;
			}
		}
		});
		for (int i = 0; i < n; i++) {
			blues.add(new Point(sc.nextInt(), sc.nextInt()));
		}
		int count = 0;
		while (blues.size() > 0) {
			Point p =blues.poll();
			NavigableSet<Point> set = reds.headSet(p, false);
			if (set == null) {
				continue;
			}
			TreeSet<Point> searchSet = new TreeSet<Point>(new Comparator<Point>() {
			public int compare(Point p1, Point p2) {
				if (p1.y == p2.y) {
					return p1.x - p2.x;
				} else {
					return p1.y - p2.y;
				}
			}
			});
			searchSet.addAll(set);
			Point x = searchSet.lower(p);
			if (x == null) {
				continue;
			}
			reds.remove(x);
			count++;
		}
		System.out.println(count);
	}
	
	static class Point {
		int x;
		int y;
		
		public Point(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		public String toString() {
			return "x:" + x +" y:" + y;
		}
	}
}


Measured memory_bytes: 22740
# input
n = int(input())
H = list(map(int, input().split()))

# exe
cnt = 0
max_cnt = 0
for i in range(len(H)-1) : 
    if H[i] >= H[i+1] : 
        cnt += 1
    else : 
        max_cnt = max(max_cnt, cnt)
        cnt = 0
        
    if i == len(H) -2 : 
        max_cnt = max(max_cnt, cnt)

# # confirm
# print(n)
# print(H)

# output
print(max_cnt)

Measured memory_bytes: 14224
n, a, b, c = [int(_) for _ in input().split()]
l = [int(input()) for _ in range(n)] + [0 for _ in range(8-n)]
ans = 1e9
for i in range(4**8):
    quas = format(i, '016b')
    d = [0, 0, 0, 0]
    m = 0
    for j in range(8):
        t = int(quas[2*j:2*(j+1)], 2)
        if d[t] != 0 and l[j] != 0 and t != 3 : m += 10
        d[t] += l[j]
    if not 0 in d[:3] : ans = min(ans, m + abs(a-d[0]) + abs(b-d[1]) + abs(c-d[2]))
print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);

		// ??????????????°??????????????????
		int n = scan.nextInt();

		// ????????¨??±??????????????????????????????????????°?????£?¨?
		int taroPoint = 0;
		int hanakoPoint = 0;

		// ??????????????°?????°???????????????
		for (int i = 0; i < n; i++) {

			// ??????????????????????????????
			String taroCade = scan.next();
			String hanakoCade = scan.next();

			// ?????????????????????????????§??????????????????????????????????????????compareTo()???????????????(??? ???????????????????¨????)
			int temp = taroCade.compareTo(hanakoCade);

			// temp???0????????§???????????????????°?????????§??????????????????????????????
			if (temp > 0) {
				taroPoint += 3;
			} else if (temp == 0) {
				taroPoint += 1;
				hanakoPoint += 1;
			} else if (temp < 0) {
				hanakoPoint += 3;
			}
		}
		// ???????????¨???
		System.out.println(taroPoint + " " + hanakoPoint);
	}

}

Measured memory_bytes: 29392
// Problem : F - Strivore
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[3000007];
void fact(ll n)
{
    // memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
string s;
// string s=bitset<64>(n).to_string();
int main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
	ll n;
	cin>>n;
	
	cin>>s;
	fact(3000005);
	ll ans=0;
	ll length=s.size();
	// cout<<ncr(0,0)<<endl;
	for(int i=0;i<=n;i++)
	{
		ans+=((power(25,i)*ncr(length+i-1,length-1))%mod*power(26,n-i))%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 27576
N=int(input())
s=str(N)
if s[-1]=="3":
  print("bon")
elif s[-1]=="0":
  print("pon")
elif s[-1]=="1":
  print("pon")
elif s[-1]=="6":
  print("pon")
elif s[-1]=="8":
  print("pon")
else:
  print("hon")

Measured memory_bytes: 9188
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>

int main()
{
    int n;
    long long a;
    long long ans;
    std::cin >> n;
    ans = 0;
    for(int i=0;i<n;i++){
        std::cin >> a;
        while (a%2==0){
            ans++;
            a = a/2;
        }
    }
    std::cout << ans << std::endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/


Measured memory_bytes: 256
def chk(a,b):
    for (i,j) in zip(a,b):
        if i!=j and i!="?":
            return False
    return True

s=input()
t=input()
n=len(t)
l=[]
for i in range(len(s)-n+1):
    if chk(s[i:i+n],t):
        l.extend([s[:i]+t+s[i+n:]])
if not l:
    print("UNRESTORABLE")
else:
    l=sorted(l)
    print(l[0].replace("?","a"))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100+7;
int m[MAXN][MAXN];
queue<int> q;
int d[MAXN];
bool v[MAXN];
int n;
void bfs(int start) {
    d[start] = 0;
    v[start] = true;
    q.push(start);
    int u = 1;
    while(!q.empty()) {
        int x = q.front();
        int i;
        for(i = 1; i <= n; i++) {
            if(m[x][i]==1 && v[i] == false) {
                v[i] = true;
                d[i] = d[x]+1;
                q.push(i);
            }
        }
        q.pop();
    }
}
int main() {
    scanf("%d", &n);
    memset(m, 0, sizeof(m));
    memset(d, -1, sizeof(d));
    memset(v, false, sizeof(v));

    int i;
    for(i = 0; i < n; i++) {
        int num;
        int k;
        scanf("%d", &num);
        scanf("%d", &k);
        int j;
        for(j = 0; j < k; j++) {
            int id;
            scanf("%d", &id);
            m[num][id] = 1;
        }
    }
    bfs(1);
    for(i = 1; i <= n; i++){
        printf("%d %d\n", i, d[i]);
    }
    return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
string T;
int S[202020];
//vector<string> S[2020];

struct SuffixArray {
	int N; vector<int> rank,lcp,sa; string S;
	
	SuffixArray(string S) : S(S){
		int i,h=0; vector<int> tmp,tr;
		N=S.size(); rank.resize(N+1); sa.resize(N+1); tmp.resize(N+1);
		FOR(i,N+1) sa[i]=i, rank[i]=i==N?-1:S[i];
		
		for(int k=1; k<=N; k<<=1) {
			auto pred2 = [k,this](int& a,int &b)->bool{ return (((a+k<=N)?rank[a+k]:-1)<((b+k<=N)?rank[b+k]:-1));};
			auto pred = [pred2,k,this](int& a,int &b)->bool{ return (rank[a]!=rank[b])?(rank[a]<rank[b]):pred2(a,b);};
			int x=0;
			if(k!=1) for(i=1;i<N+1;i++) if(rank[sa[i]]!=rank[sa[x]]) sort(sa.begin()+x,sa.begin()+i,pred2), x=i;
			sort(sa.begin()+x,sa.end(),pred);
			FOR(i,N+1) tmp[sa[i]]=(i==0)?0:tmp[sa[i-1]]+pred(sa[i-1],sa[i]);
			swap(rank,tmp);
		}
		lcp.resize(N+1); tr.resize(N+1);
		FOR(i,N+1) tr[sa[i]]=i;
		FOR(i,N) {
			int j=sa[tr[i]-1];
			for(h=max(h-1,0);i+h<N && j+h<N; h++) if(S[j+h]!=S[i+h]) break;
			lcp[tr[i]-1]=h;
		}
	}
};


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	N=T.size();
	
	SuffixArray sa(T);
	FOR(i,N) {
		int L=0,R=N-i;
		L=sa.lcp[sa.rank[i]-1]+1;
		S[L]++;
		S[R+1]--;
	}
	
	int ma=0;
	for(i=1;i<=N;i++) {
		S[i]+=S[i-1];
		ma=max(ma,S[i]);
	}
	cout<<ma<<endl;
	
	/*
	if(N>1000) return;
	int ma=0;
	for(i=1;i<=N;i++) {
		for(x=0;x+i<=N;x++) S[i].push_back(T.substr(x,i));
		sort(ALL(S[i]));
		S[i].erase(unique(ALL(S[i])),S[i].end());
		ma=max(ma,(int)S[i].size());
	}
	*/
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 2512
#include <iostream>
#include <string>
typedef long long int ll;

using namespace std;

int main() {
  int d,n;
  cin>>d>>n;
  if(d==0&& n!=100){cout<<n;}
  if(d==0&& n==100){cout<<n+1;}
  if(d==1&& n!=100){cout<<n*100;}
  if(d==1&& n==100){cout<<10100;}
  if(d==2&& n!=100){cout<<n*10000;}
  if(d==2&& n==100){cout<<1010000;}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll num = 0;
    while (A >= B) {
        B *= 2;
        num++;
    }
    while (B >= C) {
        C *= 2;
        num++;
    }
    yesno(num <= K);
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, k, x, y;
    cin >> n >> k >> x >> y;
    if(n <= k){
        cout << x * n << endl;
    }else{
        cout << x * k + y * (n - k) << endl;
    }
    return 0;
}


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

int main(){
  int A, B;
  cin >> A >> B;

  if(A%3==0 || B%3==0 || (A+B)%3==0){
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}


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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    string s;
    int ans = 0;
    cin >> s;
    rep(i, s.size()) {
        if (s.at(i) == '1') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int K;
string S;

int main(){
    
  cin>>K>>S;
  if( S.size() > K ){
    REP( i, K )cout<<S[i];
    puts("...");
  }
  else{
    cout<<S<<endl;
  }
    return 0;
}



Measured memory_bytes: 3108
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
res = 0
MOD = 10**9+7
nCk_2 = dict()
fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2,N+1):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD
def comb(n, k):
    return (fac[n]*((finv[k]*finv[n-k])%MOD))%MOD
s = [1,-1]
for m in range(2):
    for i in range(K-1,N):
        res = (res + s[m]*A[i]*comb(i,K-1))%MOD
    A = sorted(A, reverse=True)
print(res)


Measured memory_bytes: 20416
data = gets.chomp.split(" ").map(&:to_i)

loop do
  data[2] = data[2] - data[1]
  if data[2]<=0
    puts "Yes"
    break
  end
  data[0] = data[0] - data[3]
  if data[0]<=0
    puts "No"
    break
  end
end

Measured memory_bytes: 14308
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll nl, nm;

int c[575], s[575], f[575];

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

  int n;
  cin >> n;
  REP(i, n-1) cin >> c[i] >> s[i] >> f[i];

  REP(num, n){
    ll ans = 0LL;
    //num番目からスタート
    FOR(j, num, n-1){
      if(ans > s[j]){
	ll t = s[j];
	while(t < ans){
	  t += f[j];	  
	}
	ans = t + c[j];
      }      
      else ans = s[j] + c[j];
    }
    cout << ans << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    string s;
    int ans=INF;
    cin >> s;
    
    rep(i,s.size()-1){
        if(s[i]!=s[i+1]){
            ans=min(max(i+1,(int)s.size()-(i+1)),ans);
        }
    }
    if(ans==INF)ans=s.size();
    cout << ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

struct SegmentTree{
  ll n;
  vll tree;

  SegmentTree(ll len){
    n=1;
    while(len>n)
      n*=2;

    tree.assign(2*n-1, 0);
  }

  void update(ll index, ll value){
    index += n-1;
    tree[index] += value;

    while(index>0){
      index=(index-1)/2;
      tree[index] = tree[index*2+1]+tree[index*2+2];
    }
  }


  //[a, b)
  ll query(ll a, ll b){
    return query(a,b,0,0,n);
  }

  ll query(ll a, ll b, ll index, ll l, ll r){
    if(b<=l || r<=a)
      return 0;

    if(a<=l && r<=b)
      return tree[index];

    ll value_l = query(a,b,2*index+1,l,(l+r)/2);
    ll value_r = query(a,b,2*index+2,(l+r)/2,r);
    return value_l+value_r;
  }

  ll lower_bound(ll m){
    ll ok=n;
    ll ng=0;
    while(ok-ng>1){
      ll mid=(ok+ng)/2;
      if(m<=query(0,mid))
        ok=mid;
      else
        ng=mid;
    }

    return ok-1;
  }
};


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

  ll q;
  cin>>q;

  vll g(q),a(q),b(q);
  vll as;
  REP(i,q){
    cin>>g[i];
    if(g[i]==1){
      cin>>a[i]>>b[i];
      as.push_back(a[i]);
    }
  }

  SORT_UNIQUE(as);
  ll sz=as.size();
  map<ll,ll> m;
  REP(i,sz)m[as[i]]=i;

  SegmentTree stsum(sz);
  SegmentTree stnum(sz);
  ll all=0;
  ll bsum=0;
  REP(i,q){
    if(g[i]==1){
      ll id=m[a[i]];
      stsum.update(id,a[i]);
      stnum.update(id,1);
      all++;
      bsum+=b[i];
    }
    else{
      ll ans=bsum;
      ll idx=stnum.lower_bound((all+1)/2);
      ans-=stsum.query(0,idx);
      ans+=as[idx]*stnum.query(0,idx);

      ans+=stsum.query(idx+1,sz);
      ans-=as[idx]*stnum.query(idx+1,sz);
      cout<<as[idx]<<" "<<ans<<endl;
    }
  }




}



Measured memory_bytes: 18420
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	int N, K,i,x=1;
	cin >> N >> K;

	for (i = 0; i < N; i++) {
		if (x * 2 >= x + K) {
			x = x + K;
		}
		else if (x * 2 < x + K) {
			x = x * 2;
		}
	}


	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
ll comb(ll, ll);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int a, b;
    cin >> a >> b;

    if (a % 2 == 1 && b % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

ll comb(ll a, ll b) {
    if (a < b) {
        return 0;
    }

    ll v[a + 1][a + 1] = {};

    rep(i, a + 1) {
        v[i][0] = 1;
        v[i][i] = 1;
    }

    repd(k, 2, a + 1) {
        repd(j, 1, k) { v[k][j] = v[k - 1][j - 1] + v[k - 1][j]; }
    }

    return v[a][b];
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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

int main(void){
  int n;
  cin >> n;
  double a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  double ave = 0;
  for(int i = 0; i < n; i++) ave += a[i];
  ave /= n;
  double min = fabs(ave - a[0]);
  int ans = 0;
  double temp;
  for(int i = 1; i < n; i++){
    temp = fabs(ave - a[i]);
    if(temp < min){
      min = temp;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, D;
    // 空白文字で区切られた数字を 3 つ取得
    std::cin >> N >> D;
    int i; // 人の数
    
    i = N/(2*D+1);
    if (N%(2*D+1)==0) {
        cout << i << endl;
    }else{
        cout << i+1 << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define N 1000002
int n,x,a[N];
ll va[N];
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),va[i]=a[i];
	ll ans=1e18;
	for(int i=0;i<n;i++)
	{
		ll tsu=1ll*i*x;
		for(int j=1;j<=n;j++)
		{
			int fr=j-i;if(fr<1)fr+=n;
			va[j]=min(va[j],1ll*a[fr]);
			tsu+=va[j];
		}
		ans=min(ans,tsu);
	}
	printf("%lld\n",ans);
}


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

int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = max(0LL, C-(A-B));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long n,Y;
  cin >> n >> Y;
  long x,y,z;
  for(long i=0;i<=Y/10000;i++){
    long k=Y;
    k-=i*10000;
    for(long j=0;j<=k/5000;j++){
      if(i*10000+j*5000+(n-j-i)*1000==Y){
        cout << i <<" "<<j<<" "<<n-j-i;
        return 0;
      }
    }
  }
  cout << -1 <<" "<<-1<<" "<<-1;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		// get numbers
		Scanner sc = new Scanner(System.in);     
        String str = sc.next();

        // output
        System.out.println(str.substring(0, 5)+ " " + str.substring(6, 13)+ " " +str.substring(14));
        sc.close();
	}
}

Measured memory_bytes: 25172
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<double,double> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
bool d[101][101];
vector<P> p;
int n;
int cal(double x1,double y1,double x2,double y2,double x,double y)
{
	double a,b;
	a=(y-y1)*(x1-x2);
	b=(y1-y2)*(x-x1);
	if(a>b)
	{
		return 1;
	}
	else if(a<b)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}
bool check(int a,int b)
{
	int k;
	bool f=true;
	for(int i=0;i<n;i++)
	{
		if(a==i||b==i)continue;
		if(f)
		{
			k=cal(p[a].fi,p[a].sec,p[b].fi,p[b].sec,p[i].fi,p[i].sec);
			f=false;
		}
		else
		{
			if(k!=cal(p[a].fi,p[a].sec,p[b].fi,p[b].sec,p[i].fi,p[i].sec))
			{
				return false;
			}
		}
	}
	return true;
}

int main()
{
	while(1)
	{
		cin >> n;
		if(n==0)break;
		p.clear();
		memset(d,false,sizeof(d));
		for(int i=0;i<n;i++)
		{
			P s;
			scanf("%lf,%lf",&s.fi,&s.sec);
			p.pb(s);
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i==j)continue;
				if(check(i,j))
				{
					d[i][j]=true;
				}
			}
		}
		int count=0;
		for(int i=0;i<n;i++)
		{
			bool flag=true;
			for(int j=0;j<n;j++)
			{
				if(d[i][j])
				{
					flag=false;
					break;
				}
			}
			if(flag)count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

int main() {
    int n, m;
    long long ans = 0, M = 1e9+7;
    cin >> n >> m;
    if(abs(n-m) <= 1){
        long long f = 1;
        ans = 1;
        for(int i=1;i<=max(n, m);i++){
            f = (f * i) % M;
            if(i == n)ans = (ans * f) % M;
            if(i == m)ans = (ans * f) % M;
        }
        if(n == m){
            ans = (ans * 2) % M;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	bool remains[100];
	for(int i = 0; i < 100; i++)
	{
		remains[i] = false;
	}
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	for(int i = (c + a) / a;; i++)
	{
		if((a * i - c) % b == 0)
		{
			printf("YES\n");
			return 0;
		}
		else
		{
			if(remains[(a * i - c) % b])
			{
				break;
			}
			else
			{
				remains[(a * i - c) % b] = true;
			}
		}
	}
	printf("NO\n");
	return 0;
}

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

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

int rand (int a){
	return a=a*a/100-a*a/1000000*10000;
}

int main(){
	int d,l;
	
	cin>>d;
	for(int i=1;i<=d;i++){
		cin>>l;
		cout<<"Case "<<i<<":"<<endl;
		for(int j=0;j<10;j++){
			l=rand(l);
			cout<<l<<endl;
		}
	}
}	

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

using namespace std;
string s;
char a;
int num_p,num_e,ans,t,temp,p,q,r;
int ix[150];
bool flag,flagp,flagq,flagr,flaga,flagb,flagc;

void check(int x,int y,int z);

int main(){
	while(cin >> s){
		num_p=s.find('+');
		num_e=s.find('=');
		a=48;
		int i=0;
		flag=false;
		flaga=flagb=flagc=false;
		for(int j=0;j<10;j++){
			a=48+j;
			while( ( ix[i] =s.find('X') ) >=0 ){
				if(ix[i]==0)flaga=true;
				if(ix[i]==num_p+1)flagb=true;
				if(ix[i]==num_e+1)flagc=true;
				s[ix[i++]]=a;
			}
			if(j==0&&((flaga&&(s.size()-num_e-2))||(flagb&&(num_e-num_p-2))||(flagc&&(num_p-1))))continue;
			for(int k=0;k<i;k++){
				s[ix[k]]=a;
			}
			check(num_p-1,num_e-1,s.size()-1);
			if(flag){
				ans=a-'0';
				cout<< ans <<endl;
				break;
			}
			
			if(j==9){
				cout << "NA" << endl;
			}
		}
		
	}
	return 0;
}

void check(int x,int y,int z){
	t=0;
	flagp=flagq=flagr=false;
	while(1){
		p=(s[x]-'0')*(!flagp);
		q=(s[y]-'0')*(!flagq);
		r=(s[z]-'0')*(!flagr);
		temp=p+q+t;
		//cout <<temp << endl;
		if(temp%10!=r)return;
		t=temp/10;
		if(x==0&&y==num_p+1&&z==num_e+1)break;
		if(x==0)flagp=true;
		if(x>0)x--;
		if(y==num_p+1)flagq=true;
		if(y>num_p+1)y--;
		if(z==num_e+1)flagr=true;
		if(z>num_e+1)z--;

	}
	flag=true;
	return;
}

Measured memory_bytes: 3112
#include <stdio.h>

int main()
{
        int A, B, C;
        scanf("%d", &A);
        scanf("%d", &B);
        scanf("%d", &C);

        if(A == B && B == C) {
                printf("Yes\n");
        } else {
                printf("No\n");
        }

        return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long X;
cin>>X;
long long ans;
ans=1000*(X/500)+5*((X%500)/5);
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
k=[]
s=[]
for _ in range(m):
  k_=list(map(int,input().split()))
  k.append(k_[0])
  s.append(k_[1:])
p=list(map(int,input().split()))
#print(s)
#print(p)
#print(k)
ans=0
for i in range(2**n):
  sw=str(bin(i)).replace('b','00000000000')#右からi番目が1->スイッチiがON
  f=True
  for j in range(m):# m個の電気に対して
    n_on=0
    for sj in s[j]:
      if sw[-sj]=='1':
        n_on+=1
    if n_on%2!=p[j]: # j個目の電気がNG
      f=False
      break
  if f==True:
    ans+=1
    #print(sw)
print(ans)

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

using pint = pair<int,int>;

int n, m;

vector<int> a;
vector<pint> cb;

int main() {
    cin >> n >> m;

    a.resize(n);

    for (int i = 0; i < n; ++i) cin >> a.at(i);

    sort(a.begin(), a.begin()+n);

    cb.resize(m);

    for (int i = 0; i < m; ++i) cin >> cb.at(i).second >> cb.at(i).first;

    sort(cb.begin(), cb.begin()+m);
    reverse(cb.begin(), cb.begin()+m);

    int l = 0, r;
    for (int i = 0; i < m; ++i)
    {
        r = min(l + cb.at(i).second, n);

        for (int j = l; j < r; ++j)
        {
            if (a.at(j) >= cb.at(i).first) {
                r = j;
                break;
            }
            a.at(j) = cb.at(i).first;
        }
        l = r;

        if (r == n) break;
    }

    long int ans;
    for (int i = 0; i < n; ++i)
    {
        ans = ans + a.at(i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1408
from collections import deque


N = int(input())
AS = [int(i) for i in input().split()]

b = deque()

x = 0 if len(AS) % 2 == 0 else 1

for i, a in enumerate(AS):
  if i % 2 == x:
    b.append(str(a))
  else:
    b.appendleft(str(a))

print(' '.join(list(b)))


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

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
    int a,b;
    cin>>a>>b;
    if(a<b){
        rep(i,b)cout<<a;
    } else{rep(i,a)cout<<b;}

    cout<<endl;
}

Measured memory_bytes: 256
all = [[[0]*10 for q in range(3)] for w in range (4)]
a = int(input())
for m in range(a):
    s,d,f,g = map(int, input().split(' '))
    all[s-1][d-1][f-1] = all[s-1][d-1][f-1] + g
for i in range(4):
    for j in range(3):
        for n in range(10):
            print(' ' + str(all[i][j][n]),end='')
        print()
    if i == 0 or i == 1 or i == 2:
        print('####################')


Measured memory_bytes: 5624