akhauriyash/Code-Regression huggingface dataset:
D, G = map(int, input().split())
p = [None for _ in range(D)]
c = [None for _ in range(D)]
s = [None for _ in range(D)]
for i in range(D):
    p[i], c[i] = map(int, input().split())
    s[i] = 100 * (i + 1) * p[i] + c[i]

INF = 10 ** 9
ans = []
for i in range(2 ** D):
    ii = bin(i)[2:]
    ii = '0' * (D - len(ii)) + ii
    y = 0
    x = 0
    for j in range(D):
        if ii[j] == '1':
            y += s[j]
            x += p[j]
    yy = G - y
    if yy > 0:
        xx = sum(p)
        flag = False
        for j in range(D):
            xt = x
            if ii[j] == '0':
                ss = 100 * (j + 1)
                if (yy + ss - 1) // ss < p[j]:
                    xt += (yy + ss - 1) // ss
                    if xt < xx:
                        xx = xt
                        flag = True
        if flag:
            x = xx
        else:
            x = INF
    ans.append(x)
print(min(ans))


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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 10000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

ll GCD(ll a,ll b){
  if(a < b){
    return GCD(b,a);
  }
  ll r = INF;
  while(r){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main(){
 ll A,B;cin >> A >> B;
 cout << (A / GCD(A,B)) * (B / GCD(A,B)) * GCD(A,B) << endl; 
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val line1 = readLine()!!.trim()
    val (n: Long, k: Long) = line1.split(" ").map {it.toLong()}

    var cur: Long = n % k

    while (true) {
        val next = skill(cur, k)
        if (next > cur) {
            break
        }

        cur = next
    }

    println(cur)
}

fun skill(value: Long, value2: Long): Long {
    val result =  (value2 - value)
    if (result < 0) {
        return - result
    } else {
        return result
    }
}

Measured memory_bytes: 37756
n, w = map(int, input().split())
vw = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(n-1, -1, -1):
  for j in range(w+1):
    if j<vw[i][1]:
      dp[i][j] = dp[i+1][j]
    else:
      dp[i][j] = max(dp[i+1][j], dp[i+1][j-vw[i][1]]+vw[i][0])

print(dp[0][w])


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

int main(){
    int N;
    cin>>N;
    double x=0.0;
    vector<double>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        x+=1/A[i];
    }
    cout << fixed << setprecision(10);
    cout<<1/x<<endl;
}   


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main (String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int sum = 0;
		for (int x = 1 ; x <= a; x++)
		{
			sum += x;
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 9428
#include <stdio.h>

int main(){
  int i,j,N;
  scanf("%d",&N);
  for(i=0;i<14;i++){
    j=N-7*i;
    if(j%4==0&&j>=0){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;




class Main{


	static	ArrayList<Integer> one ;
	static	ArrayList<Integer> two ;
	static	ArrayList<Integer> three ;
	static	ArrayList<Integer> four ;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		int w =sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int min = Math.min(a, b);
		int max = Math.max(a, b);
		
		if(max <= min + w){
			System.out.println(0);
		}else{
			System.out.println(max-(min+w));

		}




	}
	
	
	
}

class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




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

sums = [sum(
            [int(c) for c in str(i)]
        )
        for i in range(1, N+1)]
sums = [n for n, s in zip(range(1, N+1), sums) if A <= s <= B]
#print(sums)
print(sum(sums))

Measured memory_bytes: 3444
////基本の者ども
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF =2000000000;
#define MOD 1000000007
//////forども//////////////////////////////////////////
#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 FOR(i,m,n) for(int i = int(m); i < int(n); i++)
#define FOREACH(x,a) for(auto& (x) : (a) )
////////////////////////////////////////////////////////////////
//cinおよびcout拡張
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
/////////////////////////////////////////////////////////////////
//////あまった
#define MP make_pair
#define ALL(v) v.begin(), v.end()
#define pb(a) push_back(a)
///////////////////////////////////////////////////////////


//メモ
	//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
	//vector<intなど> 変数名(要素数,初期値)
	//dfsではvector<vector<int>> g(n);で◎
ll fx(ll k){
    return k*(k+1)/2;
}
void Main(){//本処理はココ
	//入力パート
 	//string ;
 	ll  n,k,ans;
 	cin>>n>>k;
 	ans=0;
 	ll full=fx(n);
 	for(k;k<=n+1;k++){
 	ll up=full-fx(n-k);
 	ll down=fx(k-1);
//  	ans-=fx(n-k+1);/-1;
 	  //  ans;
 	  ans+=up-(down-1);
 	  ans%=MOD;
 	  //  cout<<ans<<endl;
 	}
 //答え出力パート
     cout<<ans;
     cout<<endl;
 }
int main(){//ここは前処理のゾーン
    //COMinit();//nCrするならON
    //Prime();//素数ならコレをon//PRIME_MAXとかisPrimeもいじろう
    //string a,b;
    //ll n,a;
    std::cout << std::fixed << std::setprecision(15);//浮動小数点絶対殺すマン
  	Main();
}


Measured memory_bytes: 3612
class Eratosthenes():  # エラトステネスの篩
    def __init__(self, N):  # 素数リスト生成 O(n*log(log n))
        self.fact = [i for i in range(N + 1)]
        for i in range(2, int(N ** 0.5) + 1):
            if self.fact[i] < i:
                continue
            for j in range(i ** 2, N + 1, i):
                self.fact[j] = i
        self.prime = set(i for i in range(2, N + 1) if i == self.fact[i])


q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

p = Eratosthenes(10 ** 5).prime
acc = [0]
for i in range(1, 10 ** 5, 2):
    tmp = (i in p) and ((i + 1) // 2 in p)
    acc.append(acc[-1] + tmp)

for l, r in lr:
    ans = acc[r // 2 + 1] - acc[l // 2]
    print(ans)


Measured memory_bytes: 91816
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAllGreen solver = new CAllGreen();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAllGreen {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int d = in.nextInt();
            int g = in.nextInt();
            Pair[] p = new Pair[d];
            for (int i = 0; i < d; i++) {
                p[i] = new Pair(in.nextInt(), in.nextInt());
            }

            int res = Integer.MAX_VALUE;

            // 解きかけの問題はどうせ一つしかない
            // ふたつ解きかけにする状況が必要ないから(得点が大きいほうに寄せていけばいいから)
            //　総合スコアをG点以上にすることは可能である。　という条件から,とりあえずd bitの問題を立てて考えればよさそう.

            // 使っていない残りの問題からひとつ選んで必要な分量だけ…？
            // それならソートしておけばよさそう
            // そしたら使ってないものの中から一番前をとればいい
            // 足りなければfalse

            for (int i = 0; i < Math.pow(2, d); i++) {
                int tmpRes = 0;
                int type = i;
                boolean[] fullSolved = new boolean[d];
                int scoreGotByFullSolve = 0;
                for (int j = 0; j < d; j++) {
                    fullSolved[j] = type % 2 == 1;
                    type /= 2;
                    if (fullSolved[j]) {
                        scoreGotByFullSolve += (j + 1) * 100 * p[j].x + p[j].y;
                        tmpRes += p[j].x;
                    }
                }

            /*
            out.println(Arrays.toString(fullSolved));
            out.println("nowScore : " + scoreGotByFullSolve);
            
             */

                if (scoreGotByFullSolve < g) {
                    // score が足りていないので,falseの中から最大のものを選ぶことにする
                    for (int j = fullSolved.length - 1; j >= 0; j--) {
                        boolean b = fullSolved[j];
                        if (!b && scoreGotByFullSolve + p[j].x * (j + 1) * 100 >= g) {
                            tmpRes += (g - scoreGotByFullSolve + (j + 1) * 100 - 1) / (100 * (j + 1));
                            scoreGotByFullSolve = g;
                            break;
                        }
                    }
                }


                if (scoreGotByFullSolve >= g) {
                    res = Math.min(res, tmpRes);
                }

            }
            out.println(res);
        }

    }

    static class Pair {
        public int x;
        public int y;

        public Pair(int x, int y) {
            this.x = x;
            this.y = y;
        }

    }
}



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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> vis(n,-1);
    vector<int> s(n+1);
    int ord=0;
    vis[0]=ord;
    s[ord]=1;
    int next=a[0]-1;
    while(vis[next] == -1) {
        ord++;
        s[ord]=next+1;
        vis[next]=ord;
        next=a[next]-1;
    }

    int loop = ord+1-vis[next];
    int prel = vis[next];
//    cout << loop << " " <<  prel << "\n";
    if(k<prel) cout << s[k] << "\n";
    else{
        k-=prel;
        k%=loop;
        cout << s[prel+k] << "\n";
    }
    return 0;
}

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

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  vector<int>a(q);
  rep(i,q)cin>>a[i];
  vector<int>h(n,k-q);
  rep(i,q){
    h[a[i]-1]++;
  }
  rep(i,n){
    if(h[i]<=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
}
  

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
		int n;
		scanf("%d",&n);
		int a[n/2+1],i,j;
		long ans=1;int tmp=0;
		for(i=0;i<n/2+1;i++)a[i]=0;
		if(n%2==0)a[n/2]=2;
		for(i=0;i<n;i++){
				scanf("%d",&tmp);
				a[tmp/2]++;
		}
		for(i=0;i<n/2+1;i++){
				if(n%2==0){
						if(a[i]!=2){
								puts("0");
								return 0;
						}
				}
				else{
						if(i!=0&&a[i]!=2){
								puts("0");
								return 0;
						}
				}
		}
		
		for(i=0;i<n/2;i++)ans=(ans*2)%(1000000007);
		printf("%ld\n",ans);
		return 0;
}


Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static final boolean debugMode = false;

	static final long DIV_INF = 1000000007l;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = readInt(sc);
		Set<BigInteger> set = new HashSet<>();

		for (int i = 0; i < n; i++) {
			set.add(new BigInteger(sc.next()));
		}

		BigInteger res = BigInteger.ONE;
		for (BigInteger e : set) {
			res = KrmlUtil.lcm(e, res);
		}

		System.out.println(res.toString());

	}

	

	static int readInt(Scanner sc) {
		return Integer.parseInt(sc.next());
	}

	static Long readLong(Scanner sc) {
		return Long.parseLong(sc.next());
	}

	static void log(String s) {
		if (debugMode) {
			System.out.println(s);
		}
		return;
	}
}

class KrmlUtil {
	// a >= b
		static int gcd(int a, int b) {
			while (true) {
				if (b == 0)
					break;

				int mod = a % b;
				a = b;
				b = mod;
			}
			return a;
		}

		// a >= b
		static int lcm(int a, int b) {
			return a * b / gcd(a, b);
		}

		// a >= b
		static long gcd(long a, long b) {
			while (true) {
				if (b == 0)
					break;

				long mod = a % b;
				a = b;
				b = mod;
			}
			return a;
		}

		// a >= b
		static long lcm(long a, long b) {
			return a * b / gcd(a, b);
		}

		static BigInteger gcd(BigInteger a, BigInteger b) {
			return a.gcd(b);
		}

		static BigInteger lcm(BigInteger a, BigInteger b) {
			return a.divide(a.gcd(b)).multiply(b);
		}
}

class Pair {
	private int x;
	private int y;

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Pair() {

	}

	public Pair(int x, int y) {
		this.x = x;
		this.y = y;
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 60);

int main()
{
  int64_t A, B, Q, x;
  cin >> A >> B >> Q;
  vector<int64_t> S(A), T(B);
  for (int i = 0; i < A; i++)
  {
    cin >> S.at(i);
  }
  for (int i = 0; i < B; i++)
  {
    cin >> T.at(i);
  }
  queue<int64_t> ans;
  for (int i = 0; i < Q; i++)
  {
    cin >> x;
    int64_t sl, tl, sr, tr, d1 = INF, d2 = INF, d3 = INF, d4 = INF;
    auto it_sr = lower_bound(S.begin(), S.end(), x);
    sr = it_sr == S.end() ? -1 : *it_sr;
    sl = it_sr == S.begin() ? -1 : *(it_sr - 1);
    auto it_tr = lower_bound(T.begin(), T.end(), x);
    tr = it_tr == T.end() ? -1 : *it_tr;
    tl = it_tr == T.begin() ? -1 : *(it_tr - 1);
    if (sl != -1 && tl != -1)
      d1 = max(x - sl, x - tl);
    if (sr != -1 && tr != -1)
      d2 = max(sr - x, tr - x);
    if (tl != -1 && sr != -1)
      d3 = (x - tl) + (sr - x) + min((x - tl), (sr - x));
    if (sl != -1 && tr != -1)
      d4 = (x - sl) + (tr - x) + min((x - sl), (tr - x));
    ans.push(min(min(d1, d2), min(d3, d4)));
  }
  while (!ans.empty())
  {
    cout << ans.front() << endl;
    ans.pop();
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 10001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, g[MAX_N], l[MAX_N], a[MAX_N];
map<ll, ll> pf[MAX_N];

ll modpow(ll x, ll n) {
    if (n == 0) return 1;
    return modpow(x * x % mod, n / 2) * (n & 1 ? x : 1) % mod;
}

ll modinv(ll a) {
    return modpow(a, mod - 2);
}

// assert m is prime
inline ll  inverse(ll  a, ll  m) {
    ll  b = m, x = 1, y = 0;
    // extgcd(a, m, x, y)
    while (b) {
        ll  t = a / b;
        swap(a -= t * b, b);
        swap(x -= t * y, y);
    }
    return (x % m + m) % m;
}


vector<ll> fact, inv_fact;
void init_fact(ll n) {
    fact.resize(n);
    fact[0] = 1;
    for (ll i = 1; i < n; i++) {
        fact[i] = i * fact[i - 1] % mod;
    }
    inv_fact.resize(n);
    inv_fact[n - 1] = inverse(fact[n - 1], mod);
    for (ll i = n - 2; i >= 0; i--) {
        inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
    }
}

ll nPr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * inv_fact[n - r] % mod;
}

ll nCr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

ll nHr(ll n, ll r) {
    if (n == 0 && r == 0) return 1;
    return nCr(n + r - 1, r);
}

map<ll, ll> prime_factor(ll a){
    map<ll, ll> ret;
    for(ll p=2; p*p<=a; p++){
        while(a % p == 0){
            a /= p;
            ret[p]++;
        }
    }
    if(a != 1) ret[a] = 1;
    return ret;
}

signed main(){
    cin >> n;
    REP(i, n) cin >> a[i];
    REP(i, n) pf[i] = prime_factor(a[i]);
    map<ll, ll> max_factor;
    REP(i, n) for(auto p: pf[i]) max_factor[p.first] = max(max_factor[p.first], p.second);
    ll l = 1;
    for(auto p: max_factor){
        l *= modpow(p.first, p.second);
        l %= mod;
    }
    // cout << l << endl;
    ll ret = 0;
    REP(i, n){
        ret += l * modinv(a[i]);
        ret %= mod;
    }
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 3968
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define INF 1000000007
using namespace std;
int main(){
  int X,Y,A;
  int W1,W2,H1,H2,N;
  scanf("%d %d %d",&W2,&H2,&N);
  while(N--){
    scanf(" %d %d %d",&X,&Y,&A);
    if(A==1) W1=max(W1,X);
    if(A==2) W2=min(W2,X);
    if(A==3) H1=max(H1,Y);
    if(A==4) H2=min(H2,Y);
  }
  printf("%d\n",(W1<W2&&H1<H2?(W2-W1)*(H2-H1):0));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>

#define inf 2001
using namespace std;

int main() {
	int n, tmp;
	int g[100][100];//与えられるグラフ
	bool used[100] = {}; //訪問済みを１、未訪問を０とする
	used[0] = 1;
	cin >> n;
	vector <int> x;

	//入力を受け取る
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			cin >> tmp;
			g[i][j] = tmp;
		}
	}
	x.push_back(0);
	int s, t, min, minn;
	int d[100] = {};
	while (x.size() != n) {
		min = inf;
		for (int i = 0; i < x.size(); ++i) {
			for (int j = 0; j < n; ++j) {
				if (!used[j] && g[x[i]][j] < min && g[x[i]][j] != -1) {//未訪問　かつ　最小値かつ　つながっている
					s = x[i];
					t = j;
					min = g[s][t];
				}
			}
		}
		x.push_back(t);
		used[t] = 1;
		d[t] = g[s][t];
	}
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += d[i];
	}
	cout << sum << endl;
}


Measured memory_bytes: 3144
package main

import (
	"fmt"
	"math"
)

var (
	n, k int
	h, dp []int
)

func solve(idx int) int {
	if dp[idx] != -1 {
		return dp[idx]
	}

	if idx == 0 {
		dp[idx] = 0
	} else if idx == 1 {
		dp[idx] = int(math.Abs(float64(h[idx] - h[idx-1])))
	} else {
		var ans = int(math.Pow(10, 10))
		for i := 1; i <= k; i++ {
			if idx - i < 0 {
				break
			}
			var cost =  solve(idx - i) + int(math.Abs(float64(h[idx-i]-h[idx])))
			ans = int(math.Min(float64(ans), float64(cost)))
		}

		dp[idx] = ans
	}

	return dp[idx]
}

func main() {
	fmt.Scan(&n, &k)
	h = make([]int, n)
	dp = make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	for i := 0; i < n; i++ {
		dp[i] = -1
	}

	//fmt.Println(h)

	fmt.Println(solve(n - 1))
}

Measured memory_bytes: 17664
import sys
input = sys.stdin.readline
N=int(input())
S=input()
R=S.count("R")
G=S.count("G")
B=S.count("B")
ans=R*G*B
for i in range(N):
    for j in range(i+1,N):
        k=j+j-i
        if k>=N:
            continue
        if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
            ans-=1
print(ans)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int maxn = 1e5 + 10;
int h[maxn];
int n;
int dp[maxn];

int32_t main(){
	scanf("%lld", &n);

	for(int i=0; i<n; i++){
		scanf("%lld", &h[i]);
	}

	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for(int i=2; i<n; i++){
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
	}

	printf("%lld\n", dp[n-1]);

}


Measured memory_bytes: 5356
#include <iostream>
using namespace std;
 int main(){
 string S;
 cin >> S;
 int ans = 700;
 if(S[0] == 'o') ans += 100;
 if(S[1] == 'o') ans += 100;
 if(S[2] == 'o') ans += 100;
 cout << ans << endl;
 }

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

using namespace std;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    for (int i = 0; i < N; ++i) cin >> x[i];
    for (int i = 0; i < M; ++i) cin >> y[i];
    int x_max = *max_element(x.begin(), x.end());
    int y_min = *min_element(y.begin(), y.end());
    for (int z = x_max+1; z <= y_min; ++z) {
        if (z > X && z <= Y) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_map>
#define lol(i,n) for(ll i=0;i<n;i++)
#define Max(a,b) a=max(a,b);
#define Min(a,b) a=min(a,b);
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 110
ll n;
vector<ll> g[N];
class Rad{public:
    ll d[N];
    void dfs(ll x,ll from,ll dis){
	d[x]=dis;
	for(auto y:g[x]){
	    if(y==from)continue;
	    dfs(y,x,dis+1);
	}
    }
    ll Main(ll s){
	dfs(s,-1,0);
	ll maxi=0,pnt=0;
	lol(i,n){
	    if(maxi<d[i]){
		maxi=d[i];
		pnt=i;
	    }
	}
	return pnt;
    }
};

ll dep[N],eo;
class Setdep{public:
    vector<ll> path;
    bool dfs(ll x,ll from,ll pur){
	path.push_back(x);
	if(x==pur)return 1;
	for(auto y:g[x]){
	    if(y==from)continue;
	    if(dfs(y,x,pur))return 1;
	}
	path.pop_back();
	return 0;
    }
    void bfs(ll x,ll from,ll dis){
	dep[x]=dis;
	for(auto y:g[x]){
	    if(y==from)continue;
	    bfs(y,x,dis+1);
	}
    }
    ll Main(ll a,ll b){
	dfs(a,-1,b);
	if(path.size()%2==0){
	    ll x=path[path.size()/2];
	    ll y=path[path.size()/2-1];
	    bfs(x,y,0);
	    bfs(y,x,0);
	    eo=2;
	}
	else{
	    ll x=path[path.size()/2];
	    bfs(x,-1,0);
	    eo=1;
	}
	return (path.size()+1)/2;
    }
};
class Setdep2{public:
    void bfs(ll x,ll from,ll dis){
	dep[x]=dis;
	for(auto y:g[x]){
	    if(y==from)continue;
	    bfs(y,x,dis+1);
	}
    }
    void Main(ll a,ll b){
	if(a==b){
	    bfs(a,-1,0);
	    eo=1;
	}
	else{
	    bfs(a,b,0);
	    bfs(b,a,0);
	    eo=2;
	}
    }
};

ll maxdep;
class Solve{public:
    ll depres,ansres;
    void Main(ll a,ll b){
	Setdep2 sd;
	sd.Main(a,b);
	//ll len=sd.Main(a,b);
	//if(len!=maxdep)return;
	ll ma[N]; lol(i,N)ma[i]=0;
	lol(i,n){
	    ll cnt=0;
	    for(auto x:g[i]){
		if(dep[x]==dep[i]+1)cnt++;
	    }
	    Max(ma[dep[i]],cnt);
	    //cout<<i<<":"<<dep[i]<<endl;
	}
	ll ans=eo;
	for(ll d=0;;d++){
	    if(ma[d]==0){
		depres=d+1;
		ansres=ans;
		break;
	    }
	    ans*=ma[d];
	}
	//cout<<a+1<<" "<<b+1<<":"<<depres<<" "<<ansres<<endl;
	//lol(i,n)cout<<dep[i]<<" ";cout<<endl;
    }
};
int main(){
    cin>>n;
    lol(i,n-1){
	ll a,b;cin>>a>>b;a--,b--;
	g[a].push_back(b);
	g[b].push_back(a);
    }
    Rad rad;
    ll a=rad.Main(0);
    ll b=rad.Main(a);
    Setdep sd;
    maxdep=sd.Main(a,b);
    
    ll maxans=1e9;
    Solve sv;
    lol(i,n)lol(j,n){
	sv.Main(i,j);
	if(maxdep==sv.depres){
	    Min(maxans,sv.ansres);
	}
    }
    cout<<maxdep<<" "<<maxans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, sum, co, ce int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	c := 1
	for i := 0; i < n; i++ {
		sum += a[i]
		if sum*c <= 0 {
			co += Abs(sum) + 1
			sum = c
		}
		c *= -1
	}
	c = -1
	sum = 0
	for i := 0; i < n; i++ {
		sum += a[i]
		if sum*c <= 0 {
			ce += Abs(sum) + 1
			sum = c
		}
		c *= -1
	}
	fmt.Println(Min(co, ce))
}

func Abs(a int) int {
	return int(math.Abs(float64(a)))
}

func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}


Measured memory_bytes: 7552
#include<cstdio>

int main()
{
    int N,l,r;
    scanf("%d",&N);
    int sum = 0;
    for(int i = 0;i < N;i ++)
    {
        scanf("%d %d",&l,&r);
        sum += r-l+1;
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
//define
typedef pair<int,int>pi;
#define int long long
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mod 100000007
#define elif else if
#define str string

signed main(){
  int N,M,O,P=0,c=0,co=0,cou=0;
  double D,Do;
  char C,Ca;
  str S,T;
  cin>>N>>M;
  N==M?cout<<"Yes"<<endl:cout<<"No"<<endl;
}


Measured memory_bytes: 256
L, R = map(int , input().split())

ans = 10 ** 9
for i in range(L, R):
    for j in range(i+1, R+1):
        mod = i * j % 2019
        if ans > mod:
            ans = mod
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

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

int main() {
	int N;
	long K;
	cin >> N >> K;
	long T[100010];
	for(int i=1; i<=100000; ++i) T[i]=0;
	int a, b;
	for(int i=0; i<N; ++i){
	    cin >> a >> b;
	    T[a] += b;
	}
	int p;
	for(p=1; K>T[p]; ++p) K -= T[p];
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 1024
h, w = list(map(int, input().split()))
n = int(input())
a = list(map(int, input().split()))

plate_as_line = []

color = 1
for i in a:
    for j in range(i):
        plate_as_line.append(color)
    color += 1

start_index = 0
end_index = w
line_reversed = False
for i in range(h):
    if line_reversed:
        print(' '.join(map(str, reversed(plate_as_line[start_index:end_index]))))
        line_reversed = False
    else:
        print(' '.join(map(str, plate_as_line[start_index:end_index])))
        line_reversed = True
    start_index += w
    end_index += w

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] forecast = sc.next().toCharArray();
        char[] weather = sc.next().toCharArray();
        int hit = 0;
        for(int i=0; i<forecast.length; i++){
            if(forecast[i]==weather[i]) hit++;
        }
        System.out.println(hit);
    }
}

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

bool cmp(int a, int b)
{
	return a > b;
}

int main()
{
	int n, k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a, a+n, cmp);
	int sum = 0;
	for(int i=0;i<k;i++) sum += a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())
left = []
right = []
rev = False
for i in range(Q):
  l = input().split()
  if l[0] == '1':
    rev = not rev
  else:
    if (l[1] == '1' and not rev) or (l[1] == '2' and rev):
      left.append(l[2])
    else:
      right.append(l[2])
S = ''.join(left[::-1]) + S + ''.join(right)
if rev:
  print(S[::-1])
else:
  print(S)

Measured memory_bytes: 6216
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdlib>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=10000000+5;
const int INF=0x7fffffff;
const int inf=100000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
int main(void)
{
    int n;
    cin>>n;
    int i;
    for(i=1000;i<=10000;i+=1000)
    {
        if(i>=n)
        {
            cout<<i-n<<endl;
            break;
        }
    }
}


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

int n;
string s;
map<string,int> mp;
inline int read(){
	int ret=0,pos=1;char c=getchar();
	while(!isdigit(c) && c!='-' ) c=getchar();
	if(c=='-')	pos=-1,c=getchar();
	while(isdigit(c))ret=(ret<<3)+(ret<<1)+(c&15),c=getchar();
	return pos*ret;
}
int mx;
vector<string> v;
signed main(){
	n=read();
	while(n--){
		cin>>s;mp[s]++;
	}
	for(auto &it : mp){
		int val=it.second;
		if(val>mx){
			v.clear();
			v.push_back(it.first);
			mx=val;
		}
		else if(val==mx)	v.push_back(it.first);
	}
	for(auto it : v) cout<<it<<endl;
}

Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k=0,sum=0;
  cin>>k;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      for(int c=1;c<=k;c++){
        sum += gcd(gcd(a,b), c);
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s;
    for (char i : s) {
        if (i == 'B') {
            if (t.size()) t.pop_back();
        } else t += i;
    }
    cout << t;
}


Measured memory_bytes: 256
want = [0,0,0]
ans = []
N,want[0],want[1],want[2] = map(int,input().split())
L = []
for _ in range(N):
    L.append(int(input()))
table = [0,1,2,-1]
import itertools as it
c = list(it.product(table, repeat=N))
for x in c:
    ABC = [0,0,0,0]
    cnt = -3
    for i in range(len(x)):
        ABC[x[i]] += L[i]
        if x[i] != -1:
            cnt += 1
    t = ABC.pop(-1)
    if 0 in ABC:
        continue
    val = sum(map(lambda x:abs(x[0]-x[1]),list(zip(ABC,want))))
    val += 10*cnt
    ans.append(val)
print(min(ans))

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

lli R, G, B, N;

int main(void){
	cin >> R >> G >> B >> N;
	lli ans = 0;
	rep(r, N+1){
		rep(g, N+1){
			lli b = N-r*R-g*G;
			if(b < 0) continue;
			if(b%B == 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

const int N = 100010;

int n;
int a[N];

long long calc(long long val){
	for(int i = 1; i <= n; ++i){
		val -= val % a[i];			
	}
	return val;
}

int main(){
	if(fopen("1.inp", "r")){
		freopen("1.inp", "r", stdin);
	}

	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", a + i);
	}

	long long low = 1, high = 1e18, ans = 1e18;

	while(low <= high){
		long long mid = (low + high) >> 1;

		if(calc(mid) > 2){
			high = mid - 1;
		}
		else{
			ans = mid;
			low = mid + 1;
		}
	}

	long long s = ans;

	low = 1, high = 1e18, ans = 0;

	while(low <= high){
		long long mid = (low + high) >> 1;

		if(calc(mid) >= 2){
			high = mid - 1;
			ans = mid;
		}
		else{
			low = mid + 1;
		}
	}

	if(calc(ans) != 2) cout << -1;
	else cout << ans << " " << s;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  set<int> st;
  rep(i, 0, 3) {
    VAR(int, n);
    st.insert(n);
  }
  print(st.size());
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> X(N), L(N);
    for(int64_t i=0;i<N;i++) cin >> X[i] >> L[i];

    multimap<int64_t, int64_t> p;

    for(int64_t i=0;i<N;i++) p.emplace(X[i]+L[i] , X[i]-L[i]);

    int64_t tmp = -1100000000;
    int64_t ans = 0;

    for(const auto& i : p){
        if(tmp <= i.second){//次のロボットが、直前の置いておくロボットとぶつからなかった場合
            ans++;
            tmp = i.first;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8064
//##MohK
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
using ld = long double;
using i= int ;
int main()
{
    ll k,s,res=0,z;
    cin>>k>>s;
    for(ll x=0;x<=k;x++){
        for(ll y=0;y<=k;y++){
               z=s-x-y;
               if(z+x+y==s&&x>=0&&y>=0&&z>=0&&x<=k&&y<=k&&z<=k)res++;
        }
    }
    cout<<res<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    V<ll> a(n);
    rep(i,n) cin >> a[i];
    int s = 1+n%2;

    //s個まで飛ばして選べる
    //dp[i][j][k] := i-1番目までを見て、スキップをj回使い、直前の要素を使ったときの最大値
    auto dp = make_vec(n+1, s+1, 2, -LINF);
    dp[0][0][0] = 0;
    rep(i,n) rep(j,s+1)
    {
        int ni = i+1;
        
        //直前の要素をとった
        chmax(dp[ni][j][0], dp[i][j][1]);
        //a[i]をとる
        chmax(dp[ni][j][1], dp[i][j][0] + a[i]);
        //バックレ
        if(j < s) chmax(dp[ni][j+1][0], dp[i][j][0]);
    }
    ll ans = -LINF;
    if(n%2==1) rep2(i,1,s+1) rep(j,2) chmax(ans, dp[n][i][j]);
    else rep(i,s+1) rep(j,2) chmax(ans, dp[n][i][j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 43756
S = input()

cnt = 0

for i in range(len(S)):
    if i % 2 == 0: #奇数
        if S[i] == "L":
            cnt += 1
    if i % 2 == 1:
        if S[i] == "R":
            cnt += 1

if cnt ==0:
    print('Yes')
if cnt !=0 :
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int N,i,w;
  int V[20],C[20];

  scanf("%d\n",&N );
  for ( i = 0; i < N; i++) {
    scanf("%d ",&V[i] );
  }
  printf("\n" );
  for ( i = 0; i < N; i++) {
    scanf("%d ",&C[i] );
  }

  w = 0;

  for ( i = 0; i < N; i++) {
    if(V[i] - C[i] > 0){
      w = w + (V[i] - C[i]);
    }
  }

  printf("%d\n",w);

  return 0;
}


Measured memory_bytes: 128
import math

a, b, x = map(int, input().split())

if a ** 2 * b / 2 <= x:
    print(round(math.degrees(math.atan(2 * (a ** 2 * b - x) / (a ** 3))), 10))
else:
    print(round(180 - 90 - math.degrees(math.atan(2 * x / (b ** 2 * a))), 10))


Measured memory_bytes: 3064
#include <stdio.h>
#define N 100

int main(void){
  int i,j,n,u,k,w;
  int v[N][N];
  scanf("%d",&n);

  for(i =0; i<n ;i++){
    for (j=0 ; j<n; j++){
      v[i][j]=0;
    }
  }

  for(i=0 ;i<n;i++){
    scanf("%d%d",&u,&k);
    for (j=0;j<k;j++){
      scanf("%d",&w);
      v[u-1][w-1]=1;
    }
  }

  for (i =0 ; i <n ;i++){
    for(j=0 ; j<n ; j++){
      if(j) printf(" ");
      printf("%d",v[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2048
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[][][] arr = new int[4][3][10];
    for(int i = 0; i < n; i++) {
      int b = sc.nextInt();
      int f = sc.nextInt();
      int r = sc.nextInt();
      int v = sc.nextInt();
      arr[b - 1][f - 1][r - 1] += v;
    }
    for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 3; j++) {
        for(int k = 0; k < 10; k++) {
          if(k == 9) {
            System.out.println(" " + arr[i][j][k]);
          } else {
            System.out.print(" " + arr[i][j][k]);
          }
        }
      }
      if(i != 3) {
        System.out.println("####################");
      }
    }
  }
}



Measured memory_bytes: 29728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() { 
    ll a[100010][3]={0};
    ll dp[100010][3]={0};
    ll N;
    cin >> N;
    for(int i = 0; i < N; i++){
      for (int j = 0; j<3; j++){
        cin >> a[i][j];
      }
    }

    for(int i = 0; i < N; i++){
      for (int j = 0; j < 3; j++){
        for (int k = 0; k<3; k++){
            if(j!=k){
                chmax(dp[i + 1][j], dp[i][k] + a[i][j]);
            }
        }
      }
    }
    ll maxx = 0;
    for(int i = 0; i < 3; i++){
      maxx = max(maxx, dp[N][i]);
    }
    cout << maxx << endl;
    return 0;
}

Measured memory_bytes: 8292
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define P pair<int, int>
#define PP pair<P, P>
#define mk make_pair
#define fi first
#define se second
#define V vector<int>
#define VV vector<V>
#define pb push_back

using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    V H(N);
    rep(i, N) cin >> H[i];

    int res = 0;
    int cnt = 0;
    int tmaxi = 0;
    for(int i=1; i<N; i++) {
        if(H[i] > H[i-1]) {
            tmaxi = i;
            res = max(res, cnt);
            cnt = 0;
        }
        else {
            cnt++;
        }
    }
    res = max(res, cnt);

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
n,w=map(int,input().split())
weight=[]
value=[]
for i in range(n):
    q,r=map(int,input().split())
    weight.append(q)
    value.append(r)

dp=[[0 for _ in range(100100)] for _ in range(110)]

for i in range(n):
    for j in range(w+1):
        if j-weight[i]>=0:
            dp[i+1][j]=max(dp[i+1][j],dp[i][j-weight[i]]+value[i])
        dp[i+1][j]=max(dp[i+1][j],dp[i][j])

print(dp[n][w])

Measured memory_bytes: 181768
#include <iostream>

using namespace std;


int main() {
    string s,p;
    getline(cin, s);
    getline(cin, p);

    if ((s+s).find(p) == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
n, m, l = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]

c = [[0 for i in range(l)] for i in range(n)]
for i in range(n):
    for j in range(l):
        c[i][j] = sum([(a[i][x] * b[x][j]) for x in range(m)])

for i in range(n):
    print(' '.join(map(str, c[i])))

Measured memory_bytes: 8836
#include<stdio.h>

    int kosuu;
    int shurui;
    int pri[1001]; 
    int i = 0;
    int n,m = 0;
    int a,b = 0;
    int goukei = 0;


int main()
{
    scanf("%d",&kosuu);
    scanf("%d",&shurui);
    
    while(i < kosuu){
        scanf("%d",&pri[i]);
        i++;
    }

    while(kosuu > m){
        while(kosuu > n){
            
            a = pri[n];
            b = pri[n+1];

            if(pri[n] > pri[n+1]){
                pri[n] = b;
                pri[n+1] = a;
            }

            n++;

        }
        n = 0;
        m++;
    }

    i = 0;
    
    while(i <= shurui){
        goukei += pri[i];
        i++;
    }
    
    printf("%d",goukei);
    
    return 0;
}

Measured memory_bytes: 1680
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>

typedef long long ll;
using namespace std;

int main()
{
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		double xa,ya,ra,xb,yb,rb;
		scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
		double dist = sqrt(pow((xa-xb),2.0) + pow((ya-yb),2.0));

		int res=1;
		if(dist > ra + rb){
			res=0;
		}
		else if(dist <= ra+ rb){
			if(ra > dist +rb){
				res=2; 
			}
			else if(rb > dist + ra){
				res=-2;
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 0
void main() {
	auto n = ri;
	auto a = readAs!(int[]);

	auto m = a.reduce!max; // combの第一引数
	auto q = m / 2;
	int r = int.max;
	foreach(i; a) {
		auto b = abs(q - i);
		if(abs(q - r) > b) r = i;
	}
	if(r == m) r = a.reduce!min;
	"%d %d".writefln(m, r);
}

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

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

int main(){
    int k,n;
    cin>>k>>n;
    int a[n];
    vector<int>v;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        v.push_back(a[i]-a[i-1]);
    }
    v.push_back(abs(k-a[n-1]+a[0]));
    sort(v.begin(),v.end());
    v.pop_back();
    int ans=0;
   ans= accumulate(v.begin(),v.end(),ans);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        if(c>=a&&c<=b)
        {
            printf("Yes\n");
        }
        else
            printf("No\n");
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a, b;
	cin>>a>>b;
	if((a + b) % 2 != 0){
		cout<<"IMPOSSIBLE"<<endl;
	}
	else{
		cout<<(a + b) / 2<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
using pair_t = pair< string,vector<int> >;

int main() {
	string word;
	int page;
	vector<pair_t> v;
	while (cin >> word >> page) {
		auto word_pos = find_if(v.begin(),v.end(),[word](pair_t p){return p.first == word;});
		if (word_pos == v.end()) { // if word not exist
			v.push_back({word,{page}});
		} else {
			word_pos->second.push_back(page);
		}
	}
	sort(v.begin(),v.end(),[](pair_t p_1,pair_t p_2){return p_1.first < p_2.first;});
	for (auto i = v.begin();i != v.end();++i) {
		sort(i->second.begin(),i->second.end());
		cout << i->first << endl;
		for_each(i->second.begin(),i->second.end(),[i](int n){cout << n << (n == i->second.back() ? "\n" : " ");});
	}
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
string s,t;
int dp[3010][3010];
void query(int i,int j)
{
    if (i<=0 || j<=0)
        return;
    if (s[i]==t[j])
    {
        query(i-1,j-1);
        cout<<s[i];
    }
    else
        if (dp[i-1][j]>dp[i][j-1])
            query(i-1,j);
        else
            query(i,j-1);

}
int main(){
    cin>>s>>t;
    s=" "+s;
    t=" "+t;
    int n=s.size();
    int m=t.size();
    for (int i=1;i<n;i++)
    {
        for (int j=1;j<m;j++)
        {
            if (s[i]==t[j])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    query(n-1,m-1);
}


Measured memory_bytes: 35840
#include <iostream>
#include<bits/stdc++.h>
#define ll long long 
using namespace std;


int digits(int n){
    int ans = 0;
    while(n != 0){
        n = n / 10;
        ans++;
    }
    return ans;
}

int main() {
	// your code goes here
    int n;
    cin >> n;
    int a = 0;
    for(int i = 1; i <= n; i++){
        if(digits(i) % 2 != 0) a++;
    }
    
    cout << a << endl;
    
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 2000000
#define INF 100000000

//operation of pushing or popping
void maxHeapInsert( int A[], int key );
void heapIncreaseKey( int A[], int, int key );
int  heapExtractMax( int A[] );

//make a max heap 
void swap( int*, int* );
void maxHeapify( int A[], int i );
void buildMaxHeap( int A[] );

//declare sevaral global variables
int n = 0;

int main(){
    int A[N+1], i, j, data;
    char com[10];

    //input and some procedures
    while( 1 ){
	scanf("%s", com);
	if( com[0] == 'i' ){
	    scanf("%d", &data);
	    maxHeapInsert(A, data);
	}
	else if( com[0] == 'e' && com[1] == 'x' ){
	    data = heapExtractMax(A);
	    printf("%d\n", data);
	}
	else break;//when end command was inputted
    }
    return 0;
}

//----------------------------------------------------------------
inline void swap( int* a, int *b ){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
void maxHeapify( int A[], int p ){
    int l, r, largest;

    //initialize
    l = 2*p;
    r = 2*p + 1;
    //compare those values of p , l and r
    largest = p;
    if( A[l] > A[p] && l <= n ) largest = l;
    if( A[r] > A[largest] && r <= n ) largest = r;
    //swap those values
    if( largest != p ){
	swap( &A[largest], &A[p] );
	maxHeapify( A, largest );
    }
    return ;
}
void buildMaxHeap( int A[] ){
    int l, p, r, i, heap_size = N;

    for( i=N/2; i>=1; i-- ) maxHeapify( A, i );
    
    return ;
}

//------------------------------------------------------------------
void maxHeapInsert( int A[], int key ){

    n += 1;
    A[n] = -INF;
    heapIncreaseKey( A, n, key );

    return ;
}

void heapIncreaseKey( int A[], int i, int key ){
    int p = i/2;

    A[i] = key;
    while( i>1 && A[i] > A[p] ){
	swap( &A[i], &A[p] );
	i = p;
	p = p/2;
    }
    return ;
}

//------------------------------------------------------------------
int heapExtractMax( int A[] ){
    int max, heap_size = n;

    max = A[1];
    A[1] = A[heap_size];
    n--;
    maxHeapify( A, 1 );

    return max;
}



Measured memory_bytes: 5612
from collections import Counter
n=int(input())
*v,=map(int,input().split())
odd=Counter(v[::2]).most_common()
odd.append((0,0))
even=Counter(v[1::2]).most_common()
even.append((0,0))
if odd[0][0]==even[0][0]:
    ans=min(n-odd[0][1]-even[1][1],n-odd[1][1]-even[0][1])
else:
    ans=n-odd[0][1]-even[0][1]
print(ans)

Measured memory_bytes: 20572
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

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

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n;
	cin >> n;
	vector<float> a(n);
	repz(i, n)cin >> a[i];
	
	float temp = 0, ans = 0;
	repz(i, n)temp += 1 / a[i];
	ans = 1 / temp;

	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504