akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

ll moddividing(ll x,ll y){
    vector<ll> vec(30);
    rep(i,30){
        vec[i] = y;
        y = y * y % 1000000007;
    }
    ll c = x;
    c = c * vec[0] % 1000000007;
    c = c * vec[2] % 1000000007;
    c = c * vec[9] % 1000000007;
    c = c * vec[11] % 1000000007;
    c = c * vec[14] % 1000000007;
    c = c * vec[15] % 1000000007;
    c = c * vec[17] % 1000000007;
    c = c * vec[19] % 1000000007;
    c = c * vec[20] % 1000000007;
    c = c * vec[23] % 1000000007;
    c = c * vec[24] % 1000000007;
    c = c * vec[25] % 1000000007;
    c = c * vec[27] % 1000000007;
    c = c * vec[28] % 1000000007;
    c = c * vec[29] % 1000000007;
    return c;
}

int main(){
    ll N, M;
    cin >> N >> M;
    map<ll,ll> mp;
    vector<bool> isdivisor(50001, true);
    isdivisor[1] = false;
    for (ll i = 2; i <= 50000; i++){
        if (isdivisor[i]){
            for (ll j = 2; i * j <= 50000; j++){
                isdivisor[i * j] = false;
            }
        }
    }
    for (ll i = 2; i <= 50000; i++){
        if (isdivisor[i]){
            while(true){
                if (M % i != 0){
                    break;
                }
                mp[i]++;
                M /= i;
            }
        }
    }
    if (M != 1){
        mp[M]++;
    }
    ll ans = 1;
    
    vector<ll> factorial(200000);
    factorial[0] = 1;
    for (ll i = 1; i < 200000; i++){
        factorial[i] = (factorial[i - 1] * i) % 1000000007;
    }
    for (map<ll,ll>::iterator itr = mp.begin(); itr != mp.end(); itr++){
        ans = (ans * moddividing(factorial[N + itr->second - 1], (factorial[N - 1] * factorial[itr->second]) % 1000000007))% 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4804
n = int(input())
l = list(map(int, input().split()))

l.sort()
ans = 0

for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1, n):
      if (l[i] != l[j] and l[i] != l[k] and l[j] != l[k]) and (l[i] + l[j] > l[k]):
        ans += 1
    
print(ans)

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

int main() {
    string S, T;
    cin >> S;
    T = "ATGC";

    int ans = 0;
    int now = 0;
    for (int i=0; i<S.size(); i++) {
        bool isATGC = false;
        for(int j=0; j<T.size(); j++) {
            if (S[i]==T[j]) isATGC = true;
        }
        if (isATGC) {
            now++;
            ans = max(now, ans);
        } else {
            now = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int main(){string s,t="keyence";cin>>s;for(int i=0;i<=7;i++){string a=t.substr(0,i),b=t.substr(i,7-i);if(a==s.substr(0,i)&&b==s.substr(s.size()-7+i,7-i)){cout<<"YES";return 0;}}cout<<"NO";}


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

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(int i=1;i<=n-1;i++){
    ans+=(n-1)/i;
  }
  cout<<ans;
  
  }


Measured memory_bytes: 3620
// Vicfred
// https://atcoder.jp/contests/abc128/tasks/abc128_b
// implementation, sorting
use std::io;
use std::cmp::Ordering;

#[derive(Eq,PartialEq)]
struct Restaurant {
    name: String,
    score: i64,
    index: i64,
}

impl PartialOrd for Restaurant {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        if self.name == other.name {
            Some(self.score.cmp(&other.score).reverse())
        } else {
            Some(self.name.cmp(&other.name))
        }
    }
}

impl Ord for Restaurant {
    fn cmp(&self, other: &Restaurant) -> Ordering {
        if self.name == other.name {
            self.score.cmp(&other.score).reverse()
        } else {
            self.name.cmp(&other.name)
        }
    }
}

impl Restaurant {
    fn new(name: String, score: i64, index: i64) -> Self {
        Self{name, score, index}
    }
}

fn main() {
    let mut n = String::new();

    io::stdin()
        .read_line(&mut n)
        .unwrap();

    let n = n.trim().parse::<i64>().unwrap();

    let mut restaurants = Vec::<Restaurant>::new();
    for idx in 1..n+1 {
        let mut line = String::new();

        io::stdin()
            .read_line(&mut line)
            .unwrap();

        let words: Vec<&str> =
            line
            .split_whitespace()
            .collect();

        let name = words[0].to_string();
        let score: i64 = words[1].parse().unwrap();

        restaurants.push(Restaurant::new(name, score, idx));
    }
    restaurants.sort();

    for item in restaurants {
        println!("{}", item.index);
    }
}



Measured memory_bytes: 2128
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 10000
#include<math.h>
int bingo[3][3]={0};
int N;
int b[11]={0};
int rem[BUFSIZE]={0};
int rem2[BUFSIZE]={0};
int search(int a){
	if(b[a]==0){
		return 0;
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(bingo[i][j] == b[a]){
				bingo[i][j]=0;
			}
			
		}
	}
	
		search(a+1);
}
int count=0;
int shotgun(int a,int b){
	if(count==2){
		return 0;
	}
	count++;
	for(a=0;a<3;a++){	
		for(b=0;b<3;b++){
			rem[b]=bingo[a][b];
			rem2[b]=bingo[b][a];
			if(b==2){
				if(rem[0]==0 && rem[1]==0 && rem[2]==0){
					printf("Yes");
					exit(0);
				}
				if(rem2[0]==0 && rem2[1]==0 && rem2[2]==0){
					printf("Yes");
					exit(0);
				}
			}	
		}
	}
}

int naname(){

	if(bingo[0][0]==0 && bingo[1][1]==0 && bingo[2][2]==0){
		printf("Yes");
		exit(0);
	}
	if(bingo[0][2]==0 && bingo[1][1]==0 && bingo[2][0]==0){
		printf("Yes");
		exit(0);
	}
	return 0;
	
}
int main(void){
	for(int i = 0; i<3;i++){
		for(int j = 0;j<3;j++){
			scanf(" %d",&bingo[i][j]);
		}
	}
	scanf(" %d",&N);
	
	for(int i=0;i<N;i++){
		scanf(" %d",&b[i]);
	}
	search(0);
	
	shotgun(0,0);
	
	naname();
	
	printf("No");
}





Measured memory_bytes: 128
N=int(input())

D={(x//10,x%10):0 for x in range(100)}
for i in range(1,N+1):
    if i<10:
        D[(i,i)]=1
    else:
        Q=int(str(i)[0])
        R=i%10
        D[(Q,R)]+=1

S=0
for x in range(1,10):
    for y in range(1,10):
        S+=D[(x,y)]*D[(y,x)]

print(S)


Measured memory_bytes: 40428
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	ll N,M;
	cin>>N>>M;
	if(N>M){
		swap(N,M);
	}
	ll ansa=1,ansb=1;
	for(int i=1;i<=N;i++){
		ansa=ansa*i%MOD;
	}
	for(int i=1;i<=M;i++){
		ansb=ansb*i%MOD;
	}
	if(N==M)
		cout << 2*ansa%MOD*ansb%MOD << endl;
	else if(M-N==1)
		cout<<ansa*ansb%MOD<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N_ 101000
using namespace std;
char p[3010], q[3010], res[3010];
int D[3010][3010], n, m;
int main() {
	int i, j, x, y;
	scanf("%s", p + 1);
	scanf("%s", q + 1);
	for (i = 1; p[i]; i++);
	n = i - 1;
	for (i = 1; q[i]; i++);
	m = i - 1;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			D[i][j] = max(D[i - 1][j], D[i][j - 1]);
			if (p[i] == q[j])D[i][j] = max(D[i][j], D[i - 1][j - 1] + 1);
		}
	}
	x = n, y = m;
	int c = D[x][y];
	while (x&&y) {
		if (p[x] == q[y]) {
			res[--c] = p[x];
			x--, y--;
		}
		else if (D[x][y] == D[x - 1][y])x--;
		else y--;
	}
	printf("%s\n", res);
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
int D,N,start,t,k=1,cnt=1;
int main(){
	scanf("%d %d",&D,&N);
	while(D--) k*=100; t=k;
	while(cnt<N){
		t+=k; cnt++;
		if(!((t/k)%100)) cnt--;
	}
	printf("%d",t);
}

Measured memory_bytes: 764
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;
 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N + 1);
  rep(i, N) {
    cin >> a.at(i + 1); 
  }
  
  int c = 1;
  int result = 0;
  
  rep(i, N) {
    if (c == 2) {
      cout << result;
      return 0;
    }
    c = a[c];
    result++;
  }
  cout << -1;
  return 0;
}

Measured memory_bytes: 768
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        new Main().run();
    }
 
    private void run() throws NumberFormatException, IOException {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
            nodes[i] = new Node();
        }
        for (int i = 0; i < n; i++) {
            int v = scanner.nextInt();
            int left = scanner.nextInt();
            int right = scanner.nextInt();
            nodes[v].left = left;
            nodes[v].right = right;
            if (left != -1)
                nodes[left].p = v;
            if (right != -1)
                nodes[right].p = v;
        }
 
        int root = 0;
        for (int i = 0; i < n; i++) {
            if (nodes[i].p == -1) {
                root = i;
            }
        }
        System.out.println("Preorder");
        preParse(root, nodes);
        System.out.println();
        System.out.println("Inorder");
        inParse(root, nodes);
        System.out.println();
        System.out.println("Postorder");
        postParse(root, nodes);
        System.out.println();
    }
 
    private void postParse(int id, Node[] nodes) {
        if (id == -1) //
            return;
        postParse(nodes[id].left, nodes);
        postParse(nodes[id].right, nodes);
        System.out.print(" " + id);
    }
 
    private void inParse(int id, Node[] nodes) {
        if (id == -1)
            return;
        inParse(nodes[id].left, nodes);
        System.out.print(" " + id);
        inParse(nodes[id].right, nodes);
    }
 
    private void preParse(int id, Node[] nodes) {
        if (id == -1)
            return;
        System.out.print(" " + id);
        preParse(nodes[id].left, nodes);
        preParse(nodes[id].right, nodes);
    }
 
    class Node {
        int p = -1, left, right;
    }
}

Measured memory_bytes: 26204
#include<bits/stdc++.h>
using namespace std;
int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx, dy = ty - sy;

    for(int i = 0; i < dy; i++) cout << "U";
    for(int i = 0; i < dx; i++) cout << "R";

    for(int i = 0; i < dy; i++) cout << "D";
    for(int i = 0; i < dx; i++) cout << "L";

    cout << "L";
    for(int i = 0; i < dy + 1; i++) cout << "U";
    for(int i = 0; i < dx + 1; i++) cout << "R";
    cout << "D";

    cout << "R";
    for(int i = 0; i < dy + 1; i++) cout << "D";
    for(int i = 0; i < dx + 1; i++) cout << "L";
    cout << "U";

    cout << endl;
}

Measured memory_bytes: 256
from itertools import permutations, combinations

def main():
    n = int(input())
    x_l = [] ; y_l = []
    for _ in range(n):
        tmp_x, tmp_y = map(int, input().split())
        x_l.append(tmp_x) ; y_l.append(tmp_y)
    cnt = 0
    total_dist = 0
    for c in permutations(range(n)):
        # c の中から２辺の数繰り返す
        for i in range(n-1):
            dist = ((x_l[c[i]] - x_l[c[i+1]])**2 + (y_l[c[i]] - y_l[c[i+1]])**2)**(1/2)
            total_dist += dist
        cnt += 1

    print(total_dist/cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
const int inf=0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);
    ll a,b,x;cin>>a>>b>>x;
    int sum=a/x;
    if(a%x==0) sum--;
    cout<<1ll*b/x-sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;

int main()
{
	ll n, sum = 0;
	cin >> n;
	sum += 1000 * (n / 500);
	n %= 500;
	sum += 5 * (n / 5);
	cout << sum << endl;
}

Measured memory_bytes: 256
function Main(input) {
  var lfArgs = input.split('\n');
  var n = parseInt(lfArgs[0]);
  var hs = lfArgs[1].split(' ');
  var max = parseInt(hs[0]);
  var count = 1;
  for (var i = 1; i < n; i++) {
    if (max <= parseInt(hs[i])) {
      max = hs[i];
      count++;
    }
  }
  console.log(count);


}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int MXN=100005;

map<int,bool>PrimList(int MX)
{
	map<int,bool>res;
	for(int i=2;i<=MX;i++)
	{
		res[i]=true;
		for(int j=2;j*j<=i;j++)
		{
			if(i%j==0)
			{
				res[i]=false;
				continue;
			}
		}
	}
	return res;
}

int main()
{
	int Q;

	map<int,bool> pri=PrimList(MXN);
	vector<int> alist;
	alist.push_back(0);
	for(int i=1;i<MXN;i++)
	{
		if(i%2==1&&pri[i]&&pri[(i+1)/2])
		{
			alist.push_back(alist[i-1]+1);
		}
		else
		{
			alist.push_back(alist[i-1]);
		}
	}

	cin>>Q;
	for(int i=0;i<Q;i++)
	{
		int l,r;
		cin>>l>>r;
		cout<<alist[r]-alist[l-1]<<endl;
	}

}

Measured memory_bytes: 5880
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    cnt=0
    for a,b in S:
        if a==b:
            cnt+=1
        else:
            cnt=0
        if cnt==3:
            print("Yes")
            return
    print("No")



if __name__ == "__main__":
    main()

Measured memory_bytes: 72756
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}

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

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll l = lcm(C, D);
    ll b = B - (B / C + B / D - B / l);
    A--;
    ll a = A - (A / C + A / D - A / l);
    cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 256
# input
S = input()
Q = int(input())
Query = []
for _ in range(Q):
    Query.append(input())

# process
t = True
hlist = []
flist = []
for q in Query:
    if q == "1":
        t = not t
    else:
        _, f, c = q.split()
        if f == "1":
            if t:
                hlist.append(c)
            else:
                flist.append(c)
        else:
            if t:
                flist.append(c)
            else:
                hlist.append(c)

# output
ans = "".join(hlist[::-1]) + S + "".join(flist)
if t:
    print(ans)
else:
    print("".join(list(ans)[::-1]))


Measured memory_bytes: 20984
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let x: u64 = itr.next().unwrap().parse().unwrap();
    let ans = x / 11 * 2;
    let rem = x % 11;
    if rem > 6 {
        println!("{}", ans + 2)
    } else if rem > 0 {
        println!("{}", ans + 1)
    } else {
println!("{}", ans);
}
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k=nxtl(),q=nxtl();
    vector <ll> d(k);
    generate(all(d),nxtl);
    

    while(q--)
    {
        ll n=nxtl(),x=nxtl(),m=nxtl();
        vector <ll> d1(k);
        for(int i=0;i<k;i++)
            d1[i]=d[i]%m;
        ll sum=0;
        for(int i=0;i<k;i++)
            sum+=d1[i];
        ll final=x+sum*((n-1)/k);
        for(int i=0;i<=(n-1)%k-1;i++)
            final+=d1[i];
        ll test=final/m-(x/m);
        //cout<<test<<endl;
        for(int i=0;i<k;i++)
            if(d1[i]==0)
            {
                test+=(n-1)/k;
                if((n-1)%k-1>=i)
                    test++;
            }
        cout<<n-1-test<<"\n";

    }


    return 0;   
}


 
 


Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      string s;
      cin >> s;//.at(0) >> s.at(1) >> s.at(2) >> s.at(3);
      //sort(s.begin(),s.end());
      if(s.size()==2) cout << s << endl;
      else cout << s.at(2) << s.at(1) << s.at(0) << endl;
      return 0;
    }

Measured memory_bytes: 256
N = int(input())
ans =0
cout =0
for i in range(N):
    d1,d2 = list(map(int,input().split()))
    if d1==d2:
        ans +=1
        if ans ==3:
            cout =1
    else:
        ans =0
if cout==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, p = 1, *a = (int *)calloc(11, sizeof(int));
	
	while(cin >> n){
		if(n == 0){
			p--;
			cout << a[p] << endl;
		} else {
			a[p] = n;
			p++;
		}
	}
	
	free(a);
	return 0;
}

Measured memory_bytes: 0
import heapq
while True:
  n,m,l=map(int,raw_input().split())
  if n==0: break
  v={}
  for i in xrange(n):
    v[i] = []                                                                                                                                    # count attacked
  cost=[[10**9]*(l+1) for _ in xrange(n)]
  cost[0][l] = 0
  for _ in xrange(m):
    a,b,d,e=map(int,raw_input().split())
    a-=1
    b-=1
    v[a].append((b,d,e))
    v[b].append((a,d,e))
  q=[]
  heapq.heappush(q,(0,l))
  while len(q)>0:
    t = heapq.heappop(q)
    for x in v[t[0]]:
      # hit
      if cost[x[0]][t[1]] > cost[t[0]][t[1]]+x[2]:
        cost[x[0]][t[1]] = cost[t[0]][t[1]]+x[2]
        q.append((x[0], t[1]))
      # guard
      if t[1]-x[1]>=0 and cost[x[0]][t[1]-x[1]] > cost[t[0]][t[1]]:
        cost[x[0]][t[1]-x[1]] = cost[t[0]][t[1]]
        q.append((x[0], t[1]-x[1]))
  print min(cost[n-1])

Measured memory_bytes: 9556
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        for (int x = 1; x <= 10000; x++) {
            int i = scanner.nextInt();
            if (i == 0) {
                break;
            }
            System.out.println("Case " + x + ": " + i);
        }
    }
}


Measured memory_bytes: 41900
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int A, B;
    cin >> A >> B;

    vector<vector<int>> ans(100, vector<int>(100, 0));
    int i = 1;
    int j = 1;
    bool makeBlock = false;
    while (A > 1) {
        makeBlock = true;
        ans[3 * i - 3][3 * j - 3] = 1;
        ans[3 * i - 3][3 * j - 2] = 1;
        ans[3 * i - 3][3 * j - 1] = 1;

        ans[3 * i - 2][3 * j - 3] = 1;
        ans[3 * i - 2][3 * j - 2] = 0;
        ans[3 * i - 2][3 * j - 1] = 1;

        ans[3 * i - 1][3 * j - 3] = 1;
        ans[3 * i - 1][3 * j - 2] = 1;
        ans[3 * i - 1][3 * j - 1] = 1;
        --A;
        ++j;
        if (3 * j - 1 > 98) {
            j = 1;
            ++i;
        }
    }
    if (makeBlock) {
        --B;
    }
    i = 0;
    j = 0;
    while (B > 0) {
        ans[99 - i][99 - j] = 1;
        --B;
        j += 2;
        if (99 - j < 0) {
            j = 0;
            i += 2;
        }
    }

    cout << 100 << " " << 100 << endl;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            cout << (ans[i][j] == 1 ? '#' : '.');
        }
        cout << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

const int N_CONTEST = 26;

struct Contest {
    int day;
    vector<int> complain;
    vector<vector<int>> satisfy;

    Contest() {
        cin >> day;

        complain.resize(N_CONTEST+1);
        for ( int c = 1; c <= N_CONTEST; c++ )
            cin >> complain.at(c);

        satisfy.resize(day+1);
        for ( int d = 1; d <= day; d++ ) {
            satisfy.at(d).resize(N_CONTEST+1);
            for ( int c = 1; c <= N_CONTEST; c++ )
                cin >> satisfy.at(d).at(c);
        }
    }

    void dump() {
        printf("----- Dump contents of struct Contest -----\n"
               "%d\n", day);
        for ( int c = 1; c <= N_CONTEST; c++ )
            printf("%d ", complain.at(c));
        printf("\n");
        for ( int d = 1; d <= day; d++ ) {
            for ( int c = 1; c <= N_CONTEST; c++ )
                printf("%d ", satisfy.at(d).at(c));
            printf("\n");
        }
        printf("----- Dump done -----\n");
    }
};

static int calc_score (Contest contests, int day, vector<int> &last, int contest) {
    long long score = contests.satisfy.at(day).at(contest);

    for ( int c = 1; c <= N_CONTEST; c++ ) {
        if ( c == contest ) {
            continue;
        }
        score -= (long long)contests.complain.at(c) * (day - last.at(c));
    }

    /* 13 日後までコンテストを開催しない場合のスコアで比較する */
    for ( int d = day+1; d <= min(day+13, contests.day); d++ ) {
        for ( int c = 1; c <= N_CONTEST; c++ ) {
            score -= (long long)contests.complain.at(c) * (d - last.at(c));
        }
    }

    return score;
}

static int calc_greedy_ans (Contest contests, int day, vector<int> &last) {
    int max_score = INT_MIN;
    int ans_c = 1;

    for ( int c = 1; c <= N_CONTEST; c++ ) {
        int score = calc_score(contests, day, last, c);

        if ( score > max_score ) {
            max_score = score;
            ans_c = c;
        }
    }
    last.at(ans_c) = day;

    return ans_c;
}

static void dump_ans (Contest contests) {
    vector<int> last(N_CONTEST+1, 0);

    for ( int d = 1; d <= contests.day; d++ ) {
        int c = calc_greedy_ans(contests, d, last);
        cout << c << endl;
    }
}

int main (void) {
    Contest contests;

    dump_ans(contests);

    return 0;
}



Measured memory_bytes: 3772
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    S = input().strip()
    ALF = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"

    Ans = ""
    for Si in S:
        index = ord(Si)-ord("A") + N
        Ans += ALF[index]

    print(Ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    ll num_0 = X / D;
    if(num_0>K){
        cout << X - K * D <<endl;
    }else{
        ll left_k = K - num_0;
        if(left_k%2){
            cout << abs((X % D) - D) <<endl;
        }else{
            cout << X % D <<endl;
        }
    }
}

int main(){
    Main();
}

Measured memory_bytes: 3100
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
aaa = get_nums_l()

sum_ = sum(aaa)

x = 0
for i in range(1, n, 2):
    x += aaa[i] * 2

ans = [0] * n
ans[0] = sum_ - x

for i in range(1,n):
    ans[i] = (aaa[i-1] - ans[i-1]//2) * 2

print(*ans)

Measured memory_bytes: 69084
#include <bits/stdc++.h>
#define endl '\n'

#define double long double

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);
const double dinf = (double)1e17;
const double eps = 0.00000000000001;
const double PI = acos(-1);

struct point
{
	double x, y;
	point() {x = 0; y = 0;}
	point(double _x, double _y)
	{
		x = _x;
		y = _y;
	}
};

bool cmp(point a, point b)
{
	if(a.x == b.x) return a.y < b.y;
	return a.x < b.x;
}

double slope(point a, point b)
{
	double deltax = b.x - a.x;
	double deltay = b.y - a.y;
	if(max(-deltax, deltax) < eps) return (((deltax < 0) ? (-1) : 1) * deltay < 0) ? (-dinf) : (dinf);

	return deltay / deltax; 
}

struct convex_hull
{
	vector<point> st;
	convex_hull() {st.clear();}

	void compute_hull(vector<point> vec)
	{
		sort(vec.begin(), vec.end(), cmp);

		for(int i = 0; i < (int)vec.size(); i++)
		{
			while(st.size() >= 2 && slope(st[st.size() - 2], vec[i]) >= slope(st[st.size() - 2], st[st.size() - 1])) 
				st.pop_back();
			st.push_back(vec[i]);
		}

		st.pop_back();
		int k = st.size();

		for(int i = vec.size() - 1; i >= 0; i--)
		{
			while(st.size() - k >= 2 && slope(vec[i], st[st.size() - 2]) >= slope(st[st.size() - 1], st[st.size() - 2]))
				st.pop_back();
			st.push_back(vec[i]);
		}

		st.pop_back();
	}
};

int n;
int64_t x[MAXN], y[MAXN];

vector<point> li;
map<pair<double, double>, int> idx;

void read()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
		li.push_back(point(x[i], y[i]));
		idx[{x[i], y[i]}] = i;
	}
}

convex_hull ch;
double ans[MAXN];

point mns(point a, point b) { return point(a.x - b.x, a.y - b.y); }

double ang(point l, point mid, point r)
{
	l = mns(l, mid);
	r = mns(r, mid);

	double f = atan2(l.y, l.x), s = atan2(r.y, r.x);
	if(s < 0) s += 2 * PI;
	if(f < 0) f += 2 * PI;

	double ret = s - f;
	if(f > s) ret = 2 * PI - f + s;

	chkmin(ret, 2 * PI - ret);
	return ret;
}

void solve()
{
	ch.compute_hull(li);

	double sum = 2 * PI;
	for(int i = 0; i < (int)ch.st.size(); i++)
	{
		int prv = (i - 1 + ch.st.size()) % ch.st.size();
		int nxt = (i + 1 + ch.st.size()) % ch.st.size();

		double angle = PI - ang(ch.st[prv], ch.st[i], ch.st[nxt]);
		ans[idx[make_pair(ch.st[i].x, ch.st[i].y)]] += angle;
	}

	for(int i = 0; i < n; i++)
		cout << setprecision(9) << fixed << (ans[i] / sum) << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 4352
N,K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K):
    lis = [0] * (N+1)
    for j in range(N):
        lis[min(N,j+A[j]+1)] -= 1
        lis[max(0, j-A[j])] += 1
    cnt = 0
    for j in range(N):
        cnt += lis[j]
        A[j] = cnt

    cnt2 = 0
    for j in range(N):
        if A[j] == N:
            cnt2 += 1
    if cnt2 == N:
        break
    #print(lis)
print(' '.join(map(str,A)))


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  ll res = 0;
  if (n == 1 && m == 1) {
    res = 1;
  } else if (n == 1 || m == 1) {
    ll edge = max(0, n - 2) + max(0, m - 2);
    ll mid = 0;
    res = edge + mid;
  } else {
    ll edge = 0;
    ll mid = (ll) max(0, n - 2) * max(0, m - 2);
    res = edge + mid;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
void Iswap(int *a,int *b){
  int t=*a;
  *a=*b;
  *b=t;
}
void Fswap(double *a,double *b){
  double t=*a;
  *a=*b;
  *b=t;
}
void Lswap(ll *a,ll *b){
  ll t=*a;
  *a=*b;
  *b=t;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int main(void){
  int n,m;
  scanf("%d %d",&n,&m);
  int a[n];
  double sum=0;
  FOR(i,n){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  qsort(a,n,sizeof(int),dsort);
  char s[2][4]={"Yes","No"};
  PRS(s[a[m-1]<sum/(m*4.0)]);
  return 0;
}

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

using namespace std;

int main(void){
    string N;
    int thisR=0, thisL=0, ans[100009], mv, latestR, i;
    bool lastR = true;
    cin >> N;
    for(i = 0; i < N.length(); i++){
        ans[i] = 0;
        if(N[i] == 'R'){
            thisR++;
            if(lastR == false){
                mv = ((thisL+1)/2);
                ans[latestR+1] += mv;
                ans[latestR] += (thisL - mv);
                thisL = 0;
                lastR = true;
            }
        }
        else{
            thisL++;
            if(lastR == true){
                mv = ((thisR+1)/2);
                ans[i-1] += mv;
                ans[i] += (thisR-mv);
                thisR = 0;
                lastR = false;
                latestR = (i-1);
            }
        }
    }
    mv = ((thisL+1)/2);
    ans[latestR+1] += mv;
    ans[latestR] += (thisL - mv);
    for(i = 0; i < (N.length()-1); i++){
        cout << ans[i] << " ";
    }
    cout << ans[i] << endl;
    return 0;
}


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

int main(){
  int P,Q,R;
  cin >> P >> Q >> R;
  int time1 = P+Q;
  int time2 = P+R;
  int time3 = Q+R;
  cout << min(time3,min(time1, time2));
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S, T;
	cin >> S >> T;
	cout << T << S << endl;
}


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

int main(){
  int n,x,y,u,v,l,r,mid;
  long long s[10100],p;
  for(int i=0;i<=10001;i++)s[i] = i*i;

  while(scanf("%lld%d",&p,&n),(p||n)){
    x = n; y = u = v = 1;

    for(int i=1;i<=n;i++){
      if(s[n]<p*s[i]){
	if(s[u]*s[i]<s[n]*s[v]){u = n; v = i;}
	continue;
      }
      l = 1, r = n+1;
      while(r-l>1){
	mid = (l+r)/2;
	if(s[mid]<p*s[i])l = mid;
	else r = mid;
      }
      if(s[u]*s[i]<s[l]*s[v] && s[l]<p*s[i]){u = l; v = i;}
      if(s[x]*s[i]>s[r]*s[y] && s[r]>p*s[i]){x = r; y = i;}
    }

    printf("%d/%d %d/%d\n",x,y,u,v);
  }
}

Measured memory_bytes: 1264
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort()

total_pay = 0
for ab in AB:
    M -= ab[1]
    total_pay += ab[1] * ab[0]
    if M < 0:
        total_pay += ab[0] * M
        break
    else:
        pass
        
print(int(total_pay))

Measured memory_bytes: 17000
#include <bits/stdc++.h>
#define rep(i,n) for (int i =0;i<n;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int r,c;
vector <string> s;
vector <vector<int>> m;
queue <P> q;
int di[] = {1,0};
int dj[] = {0,1};
int INF = 1001001001;


void update(int i,int j,int d,char p){
  if(s[i][j]=='#'&&p=='.')d++;
  if(m[i][j]>d){
    m[i][j]=d;
    q.push(P(i,j));
  }
  return;
}

void bfs(){
  update(0,0,0,'.');
  while(!q.empty()){
    int ni=q.front().first;
    int nj=q.front().second;
    int dist =m[ni][nj];
    q.pop();
    rep(i,2){
      int ti = ni + di[i];
      int tj = nj + dj[i];
      if(ti>=r||tj>=c)continue;
      update(ti,tj,dist,s[ni][nj]);
    }
  }
  return;
}

int main(){
  cin >> r >> c;
  vector <string> s0(r);
  vector <vector<int>> m0(r,vector<int>(c,INF));
  rep(i,r)cin >> s0[i];
  s=s0;
  m=m0;
  bfs();
  cout << m[r-1][c-1]<< endl; 
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define MAX_N 1000000039
using namespace std;
struct card
{
    ll lw,rw;
};
card num[200039];
ll lmax=-1,rmax=-1,lmin=MAX_N,rmin=MAX_N,rankmax,rankmin,smax,smin=MAX_N,stpmin=MAX_N;
bool cmp(card a,card b)
{
    return a.rw<b.rw;
}
void exc(int k)
{
    int stp;
    stp=num[k].rw;
    num[k].rw=num[k].lw;
    num[k].lw=stp;
}
int main()
{
    ll ans,stp,stpans,n,a,b,c;
    scanf("%lld",&n);
    for(a=1;a<=n;a++)
    {
        scanf("%lld%lld",&b,&c);
        num[a].lw=max(b,c);
        num[a].rw=min(b,c);
        if(num[a].lw>=lmax)
        {
            lmax=num[a].lw;
            rankmax=a;
        }
        if(num[a].rw<=rmin)
        {
            rmin=num[a].rw;
            rankmin=a;
        }
        lmin=min(lmin,num[a].lw);
        rmax=max(rmax,num[a].rw);
    }
    ans=(lmax-lmin)*(rmax-rmin);
    stp=lmax-rmin;
    if(rankmax!=rankmin)
    {
        sort(num+1,num+1+n,cmp);
        for(a=1;a<=n;a++)
        {
            if(num[a].lw==lmax)
            {
                rankmax=a;
                break;
            }
        }
        exc(1);
        if(num[1].rw<=num[2].rw)
        {
            smin=num[1].rw;
            rankmin=1;
        }
        else   
        {
            smin=num[2].rw;
            rankmin=2;
        }
        smax=max(num[1].rw,num[n].rw);
        ans=min(ans,stp*(smax-smin));
        for(a=2;a<=n;a++)
        {
            if(a!=rankmax)
            {
                exc(a);
            }
            if(a==rankmin)
            {
                if(num[a].rw>num[a+1].rw)
                {
                    smin=num[a+1].rw;
                    rankmin=a+1;
                }
                else
                {
                    smin=num[a].rw;
                    rankmin=a;
                }
            }
            stpmin=min(stpmin,num[a-1].rw);
            if(stpmin<=smin)
            {
                smin=stpmin;
                rankmin=1;
            }
            smax=max(smax,num[a].rw);
            ans=min(ans,stp*(smax-smin));
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 3328
import sys
input = sys.stdin.readline  #文字列入力では注意！

N,W = map(int,input().split())
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    w,v = map(int,input().split())
    for j in range(W+1):
        if j+w <= W:
            dp[i+1][j+w] = dp[i][j]+v
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])

print(dp[N][W])


Measured memory_bytes: 120556
n, m, x = [int(i) for i in input().split(' ')]

from itertools import combinations
a = []
for i in range(n):
    a.append([int(i) for i in input().split(' ')])
min_cost = float('inf')
for i in range(1, n + 1):
    for opt in combinations(range(n), i):
        curr_cost = 0
        curr_skills = [0] * m
        for to_take in opt:
            curr_cost += a[to_take][0]
            for j in range(1, m + 1):
                curr_skills[j - 1] += a[to_take][j]
        found = True
        for j in range(m):
            if curr_skills[j] < x:
                found = False
        if found:
            min_cost = min(min_cost, curr_cost)
print(min_cost if min_cost != float('inf') else -1)

Measured memory_bytes: 9132
using System;

class Program
{
	private static int m;
	private static int cnt;
	private static int[] g;

	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());

		int[] array = new int[n];
		for(int i=0; i<n; i++)
		{
			array[i] = int.Parse(Console.ReadLine());
		}

		ShellSort(array, n);
		Console.WriteLine(m);
		for(int i=0; i<m; i++)
		{ 
			Console.Write((i>0 ? " " : "") + g[i]);
		}
		Console.WriteLine();
		Console.WriteLine(cnt);
		for(int i=0; i<n; i++)
		{
			Console.WriteLine(array[i]);
		}
	}

	static void InsertionSort(int[] array, int n, int g)
	{
		for(int i=g; i<n; i++)
		{
			int v = array[i];
			int j = i - g;
			for(; j>=0 && array[j]>v; )
			{
				array[j+g] = array[j];
				j -= g;
				cnt ++;
			}
			array[j+g] = v;
		}
	}

	static void ShellSort(int[] array, int n)
	{
		cnt = 0;
		m = 0;
		for(int i=0; ; )
		{
			i = i*3 + 1;
			if(i > n)
			{
				break;
			}
			m++;
		}

		g = new int[m];
		for(int i=m-1; i>=0; i--)
		{
			if(i == m-1)
			{
				g[i] = 1;
			}
			else
			{
				g[i] = g[i+1]*3 + 1;
			}
		}
		for(int i=0; i<m; i++)
		{
			InsertionSort(array, n, g[i]);
		}
	}
}

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

int main(){
	ll a,b,v,w;
	cin>>a>>v;
	cin>>b>>w;
	ll t;
	cin>>t;
	if(b>a){
		if( a+(v*t) >= b+(w*t)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}else{
		if( a-v*t <= b-w*t){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
}
	

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

int main(){
  int a, b;
  while((cin >> a >> b), a, b){
    int n1=0, n2=0, n3=0;
    a = b-a;
    n3 = a/1000;
    a %= 1000;
    n2 = a/500;
    a %= 500;
    n1 = a/100;
    cout << n1 << " " << n2 << " " << n3 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
# 最初と最後を保存すれば10*10ぶんもてばよくて単純に探索するというだけのことなのに1時間以上椅子を温めただけだった
n = int(input())
table = [[0 for _ in range(10)] for _ in range(10)]
for i in range(n + 1):
    f, l = i // (1 * 10**(len(str(i)) - 1)), i % 10
    table[f][l] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += table[i][j] * table[j][i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <fstream>

using namespace std;

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var nx = Console.ReadLine().Split(' ');
        var N = int.Parse(nx[0]);
        var X = int.Parse(nx[1]);

        var min = int.MaxValue;
        var ans = 0;
        for (int i = 0; i < N; i++)
        {
            var m = int.Parse(Console.ReadLine());
            min = Math.Min(min, m);
            X -= m;
            ans++;
        }

        while (min <= X)
        {
            X -= min;
            ans++;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
long long gcd(long long a, long long b) {
    // O(log min(a,b))
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}


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

    int n;
    cin >> n;

    cout << (n / 2) * ((n + 1) / 2) << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int num[3];
  int k;
  for(int i=0;i<3;i++) cin >> num[i];
  cin >> k;
  sort(num, num+3);
  cout << num[0] + num[1] + num[2]*pow(2, k) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    int arr[n];
    vi v;
    cin>>arr[0];
    for(int i =1;i<n;i++){
        cin>>arr[i];
        v.pb(arr[i]-arr[i-1]);
    }
    int ans = 0;
    for(int i =0;i <v.size();i++){
        if( v[i]*a < b){
            ans = ans + v[i]*a;
        }
        else{
            ans = ans + b;
        }


    }
    cout<<ans<<endl;








}














Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s;
    cin>>s;
    int i=0;
    int c=0;
    int m=0;
    while(i<s.size())
    {
        if(s[i]=='R')
        {
            c++;
            m=max(m,c);
        }
        else if(s[i]=='S')
        {
            c=0;
            //m=max(m,c);
        }
        i++;
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 3612
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        //入力準備
        Scanner sc = new Scanner(System.in);
        
        double r = sc.nextDouble();
        
        System.out.print(String.format("%.6f",r*r*Math.PI));
        System.out.print(" ");
        System.out.println(String.format("%.6f",2*r*Math.PI));
        
    }
}



Measured memory_bytes: 28428