akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
class BinomialCoefficient {
int pow(int x, int p) {
    int ans = 1;
    while(p) {
        if(p % 2) ans = ((long long)ans * x) % prime;
        x = ((long long)x * x) % prime;
        p /= 2;
    }
    return ans;
}
public:
    int prime;
    vector <int> f, inv_f;
    BinomialCoefficient(int maxN, int prime = 1e9 + 7) {
        this->prime = prime;
        f.assign(maxN + 1, 1);
        inv_f.assign(maxN + 1, 1);
        inv_f[0] = pow(1, prime - 2);
        for(int i = 1; i <= maxN; i++) {
            f[i] = (long long)f[i - 1] * i % prime;
            inv_f[i] = pow(f[i], prime - 2);
        }
    }
    int choose(int N, int K) {
        return (((long long)f[N] * inv_f[N - K] % prime) * inv_f[K]) % prime;
    }
};
 
const int MOD = 1e9 + 7;struct ModularInt{int n;ModularInt(int n_=0):n(n_){}};
ModularInt operator-(ModularInt a){return -a.n+MOD*(a.n!=0);}
ModularInt operator+(ModularInt a,ModularInt b){int x=a.n+b.n;return x-(x>=MOD)*MOD;}
ModularInt operator-(ModularInt a,ModularInt b){int x=a.n-b.n;return x+(x<0)*MOD;}
ModularInt operator*(ModularInt a,ModularInt b){return (long long)a.n*b.n%MOD;}
ModularInt &operator+=(ModularInt &a,ModularInt b){return a=a+b;}
ModularInt &operator-=(ModularInt &a,ModularInt b){return a=a-b;}
ModularInt &operator*=(ModularInt &a,ModularInt b){return a=a*b;}
istream &operator>>(istream &i,ModularInt &a){return i>>a.n;}
ostream &operator<<(ostream &o,ModularInt a){return o<<a.n;}
int N, M, K;
 
BinomialCoefficient binomialCoefficient(200005, MOD);
 
ModularInt solve(int n, int m, int k) {
    ModularInt bc = binomialCoefficient.choose(n * m - 2, k - 2);
    ModularInt ans = 0;
    for(int d = 1; d < m; d++) {
        ans += (ModularInt)d * n * n * (m - d) * bc;
    }
    return ans;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> N >> M >> K;
    cout << solve(N, M, K) + solve(M, N, K) << endl;
}


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

int main(){
  vector< vector<int> > c(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c.at(i).at(j);
    }
  }
  vector<int> a(3),b(3);
  a.at(0)=0;
  for(int i=0;i<3;i++){
    b.at(i)=c.at(0).at(i)-a.at(0);
  }
  for(int i=1;i<3;i++){
    a.at(i)=c.at(i).at(0)-b.at(0);
  }
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      if(c.at(i).at(j)!=a.at(i)+b.at(j)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner (System.in);
		
		int red = in.nextInt(),gre = in.nextInt(),blue = in.nextInt(),k = in.nextInt();
		
		
		while(k-->0) {
		if(red> gre ||gre == red) {
			gre = gre * 2;
			
		}
		else if(gre>blue || gre == blue){
			blue*=2;
		}
		
		}
		
		if(red<gre && gre<blue) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
			
			

	}
}


Measured memory_bytes: 26988
import System.IO
import Data.List
import Data.Char
import Debug.Trace

f :: String -> Bool
f s = do
  let a1 = head s == 'A'
  let b2 = findIndices ('C' ==) s
  let a2 = length b2 == 1
  let b3 = tail $ map snd $ filter (\e -> head b2 /= fst e) $ zip [0..] s
  let a3 = all isLower b3
  let a4 = all (\i -> 2 <= i && i <= (length s) - 2) b2
  and [a1, a2, a3, a4]

main = do
  s <- getLine
  --let s = "AtCoder"
  --print $ length $ s
  putStrLn $ if f s then "AC" else "WA"
  --print $ f s


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<vector<char>>  A(3,vector<char>(3));
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> A.at(i).at(j);
        }
    }
 cout << A.at(0).at(0) << A.at(1).at(1) << A.at(2).at(2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return 0
int main(){
    LL N,M;cin >> N>>M;
    if(N==1&&M==1){
        COUT(1);
        rt;
    }
    if(N==2&&M==1){
        COUT(0);
        rt;
    }
    if(N==1&&M==2){
        COUT(0);
        rt;
    }
    if(N==1){
        COUT(M-2);
        rt;
    }
    if(M==1){
        COUT(N-2);
        rt;
    }
    if(N==2&&M==2){
        COUT(0);
        rt;
    }
    if(N==2){
        COUT(0);
        rt;
    }
    if(M==2){
        COUT(0);
        rt;
    }
    COUT((M-2)*(N-2));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

int main(){
	int n, a[100010], b[100010];
	cin >> n;
	int max = -1, maxindex = -1;
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i];
		if(a[i] > max){
			max = a[i];
			maxindex = i;
		}
	}
	cout << max + b[maxindex] << endl;
	return 0;
}

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

int main(void){
    int n;
    int a;
    string s;
    cin >>n >> s;
    for(int i = 0;i < s.size();i++){
        a = (s[i]-'A' + n);
        if(a >= 26)a -= 26;
        cout << (char)(a+'A');
    }
    
    
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

money = 10**20

for i in range(2**n):
    cnt = 0
    b = a[:]
    max_b = b[0]
    for j in range(1, n):
        max_b = max(max_b, b[j])
        if i >> j & 1:
            cnt += max_b - b[j] + 1
            b[j] = max_b + 1
            max_b = b[j]
    col = 1
    m = b[0]
    for j in range(1, n):
        if b[j] > m:
            col += 1
            m = b[j]
    if col >= k:
        money = min(money, cnt)

print(money)

Measured memory_bytes: 80064
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val reS = s.reversed()
//    1 0
//    2 0
//    3 1
//    4 1
//    5 2
//    6 2
//    7 3
    var ans = 0
    for (i in 0 ..((s.length - 1) / 2)) {
        if (s[i] != reS[i]) {
            ans++
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 35552
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		int q = scanner.nextInt();
		int[] st = new int[n];
		for (int i = 0; i < n; i++)
			st[i] = scanner.nextInt();
		int[] s = Arrays.copyOf(st, n);
		Arrays.sort(s);
		PriorityQueue<Integer> list = new PriorityQueue<Integer>();
		while (q-- > 0) {
			char query = scanner.next().charAt(0);
			int x = scanner.nextInt();
			if (query == 'A') {
				list.add(st[x - 1]);
			} else if (query == 'R') {
				list.remove(st[x - 1]);
			} else {
				int r = INF;
				int l = 0;
				while (r != l) {
					int mid = (r + l) / 2;
					int pre = 0;
					int BAN = 0;
					PriorityQueue<Integer> tmp = new PriorityQueue<Integer>();
					tmp.addAll(list);
					while (!tmp.isEmpty()) {
						int i = tmp.poll();
						int p = lower(s, i - mid);
						BAN += Math.max(p - pre, 0);
						pre = upper(s, i);
					}
					BAN += n - pre;
					if (BAN <= x)
						r = mid;
					else
						l = mid + 1;
				}
				System.out.println(l != INF ? l : "NA");
			}
		}
	}

	private int lower(int[] s, int i) {
		int p = Arrays.binarySearch(s, i);
		if (p < 0) {
			p = p * -1 - 1;
		} else {
			for (int j = p - 1; j >= 0; j--) {
				if (s[j] != i)
					break;
				p--;
			}
		}
		return p;
	}

	private int upper(int[] s, int i) {
		int pre = Arrays.binarySearch(s, i);
		for (int j = pre + 1; j < n; j++) {
			if (s[j] != i)
				break;
			pre++;
		}

		return pre + 1;
	}

	int INF = 1000000001;
	int n;
}

Measured memory_bytes: 297476
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a[325];
void init()
{
    for(int i=0;i<=320;i++)
    a[i]=i*i;
}
int main()
{
    init();
    int x,y;
    scanf("%d%d",&x,&y);
    int t=y;
    while(t>0)
    {
        t/=10;
        x*=10;
    }
    x+=y;
    int judge=0;
    for(int i=0;i<=320;i++)
    if(a[i]==x) judge=1;
    if(judge) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 128
N = int(input())
D = []
for i, a in enumerate(map(int, input().split())):
    D.append((a<<11) + i)
D.sort(reverse=True)
dp = [0]*(N+1)
for i, d in enumerate(D,start=1):
    x, a = d%(1<<11),d>>11
    for j in reversed(range(0, i+1)):
        res1 = dp[j-1]+a*(x-(j-1))*(j-1>=0)
        res2 = dp[j]+a*(N-(i-j)-x)*(j<=i-1)
        if res1>=res2: dp[j] = res1
        else: dp[j] = res2
print(max(dp))

Measured memory_bytes: 69016
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b = MAP()
print(ceil((a+b)/2))


Measured memory_bytes: 3888
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	char x,y;
	cin>>x>>y;
	if(x>y)cout<<">";
	else if(x<y) cout<<"<";
	else cout<<"=";
}//2^10 all samples except none. find sum for all possible options;

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int gcd(int n,int m){
    if(m==0){
        return n;
    }else{
        return gcd(m,n%m);
    }
}

int main(){
    int w,h,c;
    cin >> w >> h >> c;
    if(h<w)swap(h,w);
    int n=gcd(w,h);
    cout << c*(w/n)*(h/n) << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
const int  M = 1e9 + 7;
int n;
double dp[301][301][301];

double f(int x, int y, int z)
{
	if(x < 0 || y < 0 || z < 0)
		return 0;
	if(x == 0 && y == 0 && z == 0)
		return 0;
	if(dp[x][y][z] > 0)
		return dp[x][y][z];
	double p0 = (n - (x+y+z))/(1.0 *n);
	double p1 = x/(1.0 *n);
	double p2 = y/(1.0 *n);
	double p3 = z/(1.0*n);

	//return (1 + p1 * f(x-1, y, z) + p2*f(x+1, y-1, z) + p3*f(x, y+1, z-1))/(1.0*(1.0-p0));
	return dp[x][y][z] = (n + x*f(x-1, y, z) + y*f(x+1, y-1, z) + z*f(x, y+1, z-1))/(x+y+z);
}

int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int i, j, wt, m;
	
	cin >> n;
	int ones = 0, twos = 0, threes = 0;
	for(i = 0; i < n; i++)
	{
		cin >> m;
		if(m == 1) ones++;
		else if(m == 2) twos++;
		else threes++;
	}
	cout << setprecision(10) << f(ones, twos, threes);
}


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

int main(){
  int h, w, k, ans = 0;
  cin >> h >> w >> k;
  vector<vector<char>> vec(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  for(int i = 0; i < (1 << h); i++){
    bitset<6> bi(i);
    for(int j = 0; j < (1 << w); j++){
      bitset<6> bj(j);
      int sum = 0;
      for(int o = 0; o < h; o++){
        if(bi.test(o)) continue;
        for(int p = 0; p < w; p++){
          if(bj.test(p)) continue;
          if(vec.at(o).at(p) == '#') sum++;
        }
      }
      if(sum == k) ans++;
    }
  }
  
  cout << ans << endl;
}

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

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

    int X;
    cin >> X;

    int pnt = 0;
    for (int i = 1;; ++i) {
        pnt += i;
        if (pnt >= X) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b, c;
  cin >> a >> b >> c;
  cout << a+b+c-max({a, b, c}) << endl;

  return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n;
    let dn: number[][];
    let ans;
    // init
    n = Number(input.shift());
    dn = new Array(n);
    for (let nx = 0; nx < n; nx++) {
        dn[nx] = input[nx].split(" ").map(x => Number(x));
    }
    // solve
    ans = "No";
    let cnt = 0;
    for (let nx = 0; nx < n; nx++) {
        if (dn[nx][0] == dn[nx][1]) {
            cnt++;
            if (3 <= cnt) {
                ans = "Yes";
                break;
            }
        } else {
            cnt = 0;
        }
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29684
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int Maxn = 100010;
typedef long long ll;
int n,a,b;
int main()
{
    cin>>n>>a>>b;
    if(n * a < b)
        cout<<n*a<<endl;
    else
        cout<<b<<endl;
    return 0;
}

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


int main() {
  int N;
  int p1, p2, p3, p4;
  vector<char> op(3);         //演算子の+と-を1と-1で保存
  cin >> N;
  vector<int> order = {-1, 1};

  p4 = N / 1000;
  p3 = (N - p4 * 1000) / 100;
  p2 = (N - p4 * 1000 - p3 * 100) / 10;
  p1 = N % 10;

  for (int i : order){
    for (int j : order){
      for(int k : order){
        if( p4  + p3 * i + p2 * j + p1 * k == 7){
          if(i == 1)  op.at(0) = '+';
          else if(i == -1) op.at(0) = '-';
          if(j == 1)  op.at(1) = '+';
          else if(j == -1) op.at(1) = '-';
          if(k == 1) op.at(2) = '+';
          else if(k == -1) op.at(2) = '-';
        }
      }
    }
  }
  
  cout << p4 << op.at(0) << p3 << op.at(1) << p2 << op.at(2) << p1 << "=7" << endl;

}


  

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main(){
	int k,s;
	cin>>k>>s;
	int x,y,z;
	int ans=0;
	for(int i=0;i<=k;i++){
		x=i;
		int u=s-x;
		for(int j=0;j<=k;j++){
			y=j;
			z=u-j;
			if(z<=k&&z>=0){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

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

int main()
{
	long N,A[5],B[5],ans=0;
	int i;
	cin >> N;
	for(i=0;i<5;i++){
		cin >> A[i];
		B[i] = N/A[i];
		if(N%A[i]!=0){
			B[i]++;
		}
		if(B[i]>ans){
			ans=B[i];
		}
	}
	cout<<ans+4;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int H,N;
    cin >> H >> N;
    vector<pii>input(N);
    for(auto& p : input)
        cin >> p.first >> p.second;
    vector<vector<int>>dp(N + 1,vector<int>(2 * H,INF));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < H; ++j){
            if(dp[i][j] == INF) continue;
            cmin(dp[i + 1][j], dp[i][j]);
            int magic = input[i].second;
            int atk = input[i].first;
            if(atk + j > H ) {
                cmin(dp[i][H],dp[i][j] + magic);
                cmin(dp[i+1][H],dp[i][j] + magic);
            } else {
                cmin(dp[i][atk + j],dp[i][j] + magic);
                cmin(dp[i+1][atk + j], dp[i][j] + magic);
            }
        }
    }
    int ans = INF;
    rep(i,N)cmin(ans, dp[i][H]);
    cout << ans << endl;
}


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

using namespace std;

#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define VIN(VECTOR,n)


lli abs2(lli a){
	return a>=0?a:-a;
}

lli min2(lli a,lli b){
	return a<=b?a:b;
}

lli max2(lli a,lli b){
	return a>=b?a:b;
}


lli heightCalc(lli h,lli x,lli cx,lli y,lli cy){
	return max2(h-abs2(x-cx)-abs2(y-cy),0);
}

int main(){

	lli n;
	vector<lli> x,y,h;
	cin >>n;
	lli maxH=0;
	lli minH=100000000000;
	REP(i,n){
		lli tmpX,tmpY,tmpH;
		cin>>tmpX>>tmpY>>tmpH;
		x.push_back(tmpX);
		y.push_back(tmpY);
		h.push_back(tmpH);
		maxH = max2(maxH,tmpH);
		minH = min2(minH,tmpH);
	}

	lli flag=0;
	lli ansH,ansX,ansY;
	for(ansH = max2(minH-300,0);ansH <= maxH+500;ansH++){
	for(ansX = 0;ansX<=100;ansX++){
	for(ansY = 0;ansY<=100;ansY++){
		flag=0;
	for(lli i = 0;i<n;i++){
		if(h[i] != heightCalc(ansH,ansX,x[i],ansY,y[i])){
			flag=1;
			break;
		}
	}
	if(flag==0)goto END;
	}
	}
	}

END:
	if(flag==0)cout<<ansX<<" "<<ansY<<" "<<ansH<<endl;
	return 0;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
long long m[100],c[10000],prime[200];
int main(){
	long long n,p;
	int count=0,i=2;
	while(true){
		bool t=true;
		for(int j=2;j*j<=i;j++){
			if(i%j==0)
				t=false;
		}
		if(t==true){
			prime[count]=i;
			count++;
		}
		if(count==200)
			break;
		i++;
	}
	while(true){
		cin>>n>>p;
		if(n==-1&&p==-1)
			break;
		for(int i=0;i<p*p;i++){
			c[i]=1000000;
		}
		if(n==0)
			n++;
		int i=n+1,count=0;
		while(true){
			bool t=true;
			for(int j=0;j<200;j++){
				if(i!=prime[j]&&i%prime[j]==0)
					t=false;
			}
			if(t==true){
				m[count]=i;
				count++;
			}
			if(count==p)
				break;
			if(i%2==1)
				i+=2;
			else
			i++;
		}
		for(int i=0;i<p;i++){
			for(int j=0;j<=i;j++){
				c[i*p+j]=m[i]+m[j];
			}
		}
		sort(c,c+p*p);
		cout<<c[p-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int l[100];

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	n *= 2;
	for (size_t i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l, l + n);
	int sum = 0;
	for (int i = n-2; i >= 0; i -= 2) {
		sum += l[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static final int MOD = 1000000007;
	static final int HALF = (MOD + 1) / 2;

	static int add(int a, int b) {
		int res = a + b;
		return res >= MOD ? res - MOD : res;
	}

	static int mul(int a, int b) {
		int res = (int) ((long) a * b % MOD);
		return res < 0 ? res + MOD : res;
	}

	static void solve() throws Exception {
		int n = scanInt();
		int q = scanInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanInt();
		}
		int v[][] = new int[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				v[i][j] = a[i] < a[j] ? 1 : 0;
			}
		}
		for (int qq = 0; qq < q; qq++) {
			int x = scanInt() - 1;
			int y = scanInt() - 1;
			for (int i = 0; i < n; i++) {
				if (i != x && i != y) {
					v[i][x] = v[i][y] = mul(v[i][x] + v[i][y], HALF);
					v[x][i] = v[y][i] = mul(v[x][i] + v[y][i], HALF);
				}
			}
			v[x][y] = v[y][x] = mul(v[x][y] + v[y][x], HALF);
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				ans = add(ans, v[i][j]);
			}
		}
		for (int i = 0; i < q; i++) {
			ans = add(ans, ans);
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 89600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define all(c) c.begin(),c.end()
#define sz(c) ((int)c.size())
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;

int depth(string line) {
    int r = 0;
    rep(i, 0, sz(line)) {
        if (line[i] == '.') r++;
        else break;
    }
    return r;
}

signed main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;

        vector<string> s(n);
        rep(i, 0, n) cin >> s[i];

        map<int, stack<int>> elem;
        
        // d --> d - 1 
        auto prop = [&](int d) {
            stack<int> buf;
            while (elem[d].size()) {
                int x = elem[d].top(); elem[d].pop();
                if (x >= 0) buf.push(x);
                else if (x == -1) {
                    int sum = 0;
                    while (buf.size()) {
                        sum += buf.top();
                        buf.pop();
                    }
                    elem[d - 1].push(sum);
                } else {
                    int prd = 1;
                    while (buf.size()) {
                        prd *= buf.top();
                        buf.pop();
                    }
                    elem[d - 1].push(prd);
                }
            }
        };

        int d = 0;
        rep(i, 0, n) {
            int t = depth(s[i]);
            while (t < d) {
                prop(d);
                d--;
            }

            d = t;
            if (s[i][t] == '+') {
                elem[t + 1].push(-1);
            } else if (s[i][t] == '*') {
                elem[t + 1].push(-2);
            } else {
                int num = s[i][t] - '0';
                elem[t].push(num);
            }
        }
        while (d > 0) {
            prop(d);
            d--;
        }
        cout << elem[0].top() << endl;
    }
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int x;
  cin >> x;
  
  cout << "Christmas";
  REP(i,25-x) cout << " Eve";
  cout << endl;

}


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

 
int main() {
	string s;
  	cin >> s;
  	if(s[2]==s[3] && s[4] == s[5]){
      cout << "Yes" << endl;
    }
  	else{ 
      cout << "No" << endl;
    }
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long lint;
using namespace std;
 
int main(){
  int n;
  cin>>n;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int m=1e9+7;
int main(){
    int n;
    cin>>n;
    vector<double>dp(n+1,0.0);
    dp[0]=1.0;
    
    for(int i=1;i<=n;i++){
         double p;
         cin>>p;
         
         for(int j=i;j>=0;j--){
          //    cout<<i<<" "<<j<<" "<<dp[j-1]*p<<" "<<dp[j]*(i-p)<<endl;
              dp[j]=(j==0?0:dp[j-1]*p)+dp[j]*(1-p);
              
         }
    }
    double ans=0.0000000;
    for(int i=n/2+1;i<=n;i++){
         ans+=dp[i];
     //    cout<<dp[i]<<endl;
    }
    printf("%.10lf\n",ans);
}

Measured memory_bytes: 3824
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B
--import Debug.Trace

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- map read.words <$> getLine :: IO [Int]
  let as' = (group.sort) as
      las' = length as'
  if las' > 3 then putStrLn "No"
    else if las' == 1 && ((head (as'!!0)) `xor` (head (as'!!0)) == (head (as'!!0))) then putStrLn "Yes"
      else if las' == 2 && ((length (as'!!0) == 2*(length $ as'!!1) && head (as'!!1) `xor` head (as'!!0) == head (as'!!0)) || ((length (as'!!1) == 2*(length $ as'!!0)) && head (as'!!0) `xor` head (as'!!1) == head (as'!!1))) then putStrLn "Yes"
        else if las' == 3 && length (as'!!0) == length (as'!!1) && length (as'!!1) == length (as'!!2) && head (as'!!0) `xor` head (as'!!1) == head (as'!!2) then putStrLn "Yes"
          else putStrLn "No"


Measured memory_bytes: 35324
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

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

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

    ll n, m;
    cin >> n >> m;

    vector <ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }

    ll l = 1;
    for (int i = 0; i < n; i++) {
        l = lcm(l, a[i]);
        if (l > m * 2) {
            cout << 0 << '\n';
            return 0;
        }
    }

    for (int i = 0; i < n; i++) {
        if ((l / a[i]) % 2 == 0) {
            cout << 0 << '\n';
            return 0;
        }
    }

    cout << m / l - m / (l * 2) << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
const int MAX_N = (1<<18)-1;

vector<ll> x, dat[MAX_N];

void init(int k, int l, int r)
{
    if (r - l == 1) {
        dat[k].push_back(x[l]);
    } else {
        int lch = k * 2 + 1, rch = k * 2 + 2;
        init(lch, l, (l + r) / 2);
        init(rch, (l + r) / 2, r);
        dat[k].resize(r - l);

        merge(dat[lch].begin(), dat[lch].end(),
              dat[rch].begin(), dat[rch].end(),
              dat[k].begin());
    }
}

int query(int i, int j, ll x, int k, int l, int r)
{
    if (j <= l || r <= i) {
        return 0;
    } else if (i <= l && r <= j) {
        return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
    } else {
        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }
}

int main()
{
    ll D, Q, l, r, e;
    scanf("%lld", &D);
    x.resize(D);
    for (int i = 0; i < D; i++) {
        scanf("%lld", &x[i]);
    }    
    
    init(0, 0, D);
    
    scanf("%lld", &Q);
    while (Q--) {
        scanf("%lld %lld %lld", &l, &r, &e);
        l--; r--;
        ll a = min(x[l], x[r]) - e, b = max(x[l], x[r]) + e;        
        printf("%lld\n", query(l, r+1, a-1, 0, 0, D) +
                         (r - l + 1) - query(l, r+1, b, 0, 0, D));
    }
    return 0;
}

Measured memory_bytes: 27152
N, P = map(int, input().split())
A = list(map(int, input().split()))
def comb(x, y):
  m = c = 1
  for i in range(y):
    m *= x-i
    c *= y-i
  return m//c
even = odd = 0
for a in A:
  if a%2 == 0:
    even += 1
  else:
    odd += 1
ans = 0
for i in range(P, odd+1, 2):
  ans += comb(odd, i)
print(pow(2, even) * ans)


Measured memory_bytes: 61824
import math, re

a, b, c = [int(n) for n in re.split(r"\s+", input().strip())]
h = b * math.sin(c * math.pi / 180)
S = a * h / 2
L = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(c * math.pi / 180)) + a + b
print("%f %f %f" % (S, L, h))



Measured memory_bytes: 6660
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
ll k;
ll Frog_Problem(ll n, ll a[], ll dp[]) {
    if (n <= 0) {
        return 0;
    }
    if (dp[n] != -1) {
        return dp[n];
    }
    ll ans = INT_MAX;
    for (int i = 1; i <= 2; i++) {
        if (n - i >= 0) {
            ans = min(ans, abs(a[n] - a[n - i]) + Frog_Problem(n - i, a, dp));
        }
    }
    return dp[n] = ans;
}
int main() {
    fio;
    ll n;
    cin >> n;
    //cin >> k;
    ll a[n];
    ll dp[n];
    memset(dp, -1, sizeof(dp));
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << Frog_Problem(n - 1, a, dp);
    return 0;
}

Measured memory_bytes: 12900
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>


#define MOD 1000000007
#define INTMAX 0x7fffffff
#define INTMIN 0x80000000
#define LLMAX 0x7fffffffffffffffLL
#define LLMIN 0x8000000000000000LL

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

using namespace std;
using ll = long long;

#define NMAX 100000

int h[NMAX];
int N, A, B;

bool check(int T) {
	ll count = 0;
	rep(i, N) {
		int h_ex = h[i] - B * T;
		if (h_ex <= 0){
			continue;
		}
		count += (h_ex + A - B - 1) / (A - B);
	}
	return count <= T;
}

int main(){
	cin >> N >> A >> B;
	int h_max = 0;
	rep(i, N) {
		cin >> h[i];
		if (h[i] > h_max) {
			h_max = h[i];
		}
	}
	
	int Tmin = 1;
	int Tmax = h_max / B + 1;
	while (Tmax > Tmin) {
		int Tmid = (Tmin + Tmax) / 2;

		if (check(Tmid)) {
			Tmax = Tmid;
		} else {
			Tmin = Tmid + 1;
		}
	}

	cout << Tmin << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define pb(x) push_back((x))
typedef long long ll;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=1e5+5;
int n,m,dep[N],s,t,flg,S[N],k[N],stk[N],tp;
ll ans;
vector<int> E[N];

inline void Dfs(int u,int pa){
    for(int v:E[u]){
	if(v==pa)continue;
	if(dep[v]){flg=(dep[u]==dep[v]);s=u,t=v;continue;}
	dep[v]=dep[u]*-1;Dfs(v,u);
    }
}
inline void Cal(int u,int pa){
    for(int v:E[u]){
	if(v==pa||(u==s&&v==t)||(v==s&&u==t))continue;
	Cal(v,u);
	S[u]+=S[v];k[u]+=k[v];
    }
}

int main(){
    //freopen("in.in","r",stdin);
    n=read(),m=read();
    REP(i,1,m){int u=read(),v=read();E[u].pb(v),E[v].pb(u);}
    dep[1]=1;Dfs(1,0);
    int sum=0;
    REP(i,1,n)sum+=(S[i]=dep[i]);
    if(m==n-1){if(sum)return puts("-1"),0;}
    else if((flg&&(sum&1))||(!flg&&sum))return puts("-1"),0;
    if(m==n){
	if(flg){
	    S[s]-=sum/2,S[t]-=sum/2;
	    ans+=abs(sum/2);
	}
	else k[s]=1,k[t]=-1;
    }
    Cal(1,0);
    REP(i,1,n)
	if(!k[i])ans+=abs(S[i]);
	else if(~k[i])stk[++tp]=-S[i];
	else stk[++tp]=S[i];
    stk[++tp]=0;
    sort(stk+1,stk+tp+1);
    int x=stk[(tp+1)>>1];
    REP(i,1,tp)ans+=abs(stk[i]-x);
    printf("%lld\n",ans);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;++i) cin >> A.at(i);
  int ans=0;
  for(int i=0;i<N;i++){
    while(A.at(i) % 2 == 0){
      A.at(i)=A.at(i)/2;
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())
ans=10**19
for i in range(n):
  for j in range(i,n):
    for k in range(j,n):
      for l in range(k,n):
        xl=min(x[i],x[j],x[k],x[l])
        xr=max(x[i],x[j],x[k],x[l])
        yl=min(y[i],y[j],y[k],y[l])
        yh=max(y[i],y[j],y[k],y[l])
        cnt=0
        for c in range(n):
          cnt+=xl<=x[c]<=xr and yl<=y[c]<=yh
        if cnt>=m:ans=min(ans,(xr-xl)*(yh-yl))
print(ans)

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    vector<ll> a(3, 0);
    for(int i = 0; i < n; i++) {
        if(s[i] == 'R') a[0]++;
        if(s[i] == 'G') a[1]++;
        if(s[i] == 'B') a[2]++;
    }
    ans = a[0]*a[1]*a[2];
    for(int j = 0; j < n; j++) {
        for(int i = 0; i < j; i++) {
            int k = j+j-i;
            if(k < n) {
                if(s[i] == s[j]) continue;
                if(s[j] == s[k]) continue;
                if(s[k] == s[i]) continue;
                ans--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()
prev = 'e'
flag = 0

count = 0
        
for i in range(n):
    if s[i] == 'L':
        if prev == 'R':
            if k == 0:
                pass
            elif flag == 0:
                flag = 1
            else:
                count += 2
                k -= 1
                flag = 0
        elif prev == 'L':
            count += 1
    else:
        if prev == 'L':
            if k == 0:
                pass
            elif flag == 0:
                flag = 1
            else:
                count += 2
                k -= 1
                flag = 0
        elif prev == 'R':
            count += 1
    if i == n - 1:
        if flag == 1:
            count += 1
    prev = s[i]
    
print(count)

Measured memory_bytes: 3316
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.monstersBattleRoyale();
    }

    private void monstersBattleRoyale() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = Integer.parseInt(scan.next());
            int[] a = IntStream.range(0, n).map(i -> Integer.parseInt(scan.next())).sorted().toArray();
            System.out.println(gcdAll(a, 0));
        }
    }

    private int gcdAll(int[] a, int n) {
        if (n == a.length - 2) {
            return gcd(a[n], a[n + 1]);
        }
        return gcd(a[n], gcdAll(a, n + 1));
    }

    private int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        if (a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        return gcd(b, a % b);
    }

    private void foodsLovedByEveryone() {
        try (Scanner scan = new Scanner(System.in)) {
            int n = Integer.parseInt(scan.next());
            int m = Integer.parseInt(scan.next());
            List<List<Integer>> lovedFoods = IntStream.range(0, n).boxed().map(
                    i -> {
                        int j = Integer.parseInt(scan.next());
                        return IntStream.range(0, j).map(l -> Integer.parseInt(scan.next())).boxed().collect(Collectors.toList());
                    })
                    .collect(Collectors.toList());

            System.out.println(
                    IntStream.rangeClosed(1, m)
                            .mapToObj(i -> lovedFoods.stream().filter(j -> j.contains(i)).count()).filter(i -> i >= n).count());
        }
    }

    private void bPlusMinusA() {
        try (Scanner scan = new Scanner(System.in)) {
            int a = Integer.parseInt(scan.next());
            int b = Integer.parseInt(scan.next());
            if (b % a == 0) {
                System.out.println(a + b);
            } else {
                System.out.println(b - a);
            }
        }
    }
}


Measured memory_bytes: 66316
#include <algorithm>
#include <array>
#include <deque>
#include <functional>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int n;
    float m;
    cin >> n >> m;
    float a[n], all_vote = 0, ans_num = 0;
    REP(i, n) {
        cin >> a[i];
        all_vote += a[i];
    }
    REP(i, n) {
        if (a[i] >= all_vote / (4 * m))
            ans_num++;
    }
    if (ans_num >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n;
    int t;
    int c[100];
    int ti[100];
    int i;
    int num=100000;
    int a=0;

    scanf("%d", &n);
    scanf("%d", &t);
    for (i = 0; i < n; i++) {
        scanf("%d", &c[i]);
        scanf("%d", &ti[i]);
    }
    for (i = 0; i < n; i++) {
        if (ti[i] <= t) {
            a++;
            if (c[i] <=num) {
                num = c[i];
            }
        }
    }

   
    if (a != 0 ) {
        printf("%d",num);
    }
    else {
        printf("TLE");
   }
    return 0;
}




Measured memory_bytes: 128
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
//#define MOD 1000000007
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll sum = 0;
    rep(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    ll x = a[0];
    ll y = sum - x;
    ll mi = abs(x - y);
    for(ll i = 1; i < N - 1; i++) {
        x += a[i];
        y = sum - x;
        mi = min(mi, abs(x-y));
    }
    print(mi);
    return 0;
}

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

int main(){
  int N,M;
  std::cin >> N >> M;

  std::vector<std::vector<int>> a_arr(N+1), b_arr(N+1);

  for(int i = 0; i < M; i++){
    int a,b;
    std::cin >> a >> b;
    a_arr[a].push_back(i);
    b_arr[b].push_back(i);
  }

  std::unordered_set<int> solved;
  std::vector<int> current;
  int ans = 0;
  for(int i = 0; i < N+1; i++){
    for(auto&& b: b_arr[i]){
      if(solved.count(b) == 0){
        for(auto&& c: current){
          solved.insert(c);
        }
        current.clear();
        ans++;
      }
    }
    for(auto&& a: a_arr[i]){
      current.push_back(a);
    }
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 14496
#include <stdio.h>

int main() {
	int m, f, r ;
	char grade;
	grade = 'x';
	for (int i = 0; i < 50; i++) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 || f == -1) {
			grade = 'F';
		}
		else if (m + f >= 80) {
			grade = 'A';
		}
		else if (m + f >= 65 && m + f < 80) {
			grade = 'B';
		}
		else if (m + f >= 50 && m + f < 65) {
			grade = 'C';
		}
		else if (m + f >= 30 && m + f < 50) {
			grade = 'D';
			if (r >= 50) {
				grade = 'C';
			}
		}
		else if (m + f < 30) {
			grade = 'F';
		}
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		printf("%c\n", grade);
	}
}


Measured memory_bytes: 2768
S=input()
a=int(S[0])
b=int(S[1])
c=int(S[2])
d=int(S[3])
if (a+b+c+d)==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif (a+b+c-d)==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif (a+b-c+d)==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif (a+b-c-d)==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif (a-b+c+d)==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif (a-b+c-d)==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif (a-b-c+d)==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif (a-b-c-d)==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  for(int i=1;i<=c;i++){
    if(c%i==0&&a<=i&&i<=b){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  ll sum = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) sum += a[i];

  vector<ll> div;
  for (ll i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      div.push_back(i);
      if (sum / i != i) {
        div.push_back(sum / i);
      }
    }
  }
  ll ans = 1;
  vector<ll> rem(n);
  for (auto &d : div) {
    for (int i = 0; i < n; i++) rem[i] = a[i] % d;
    sort(rem.begin(), rem.end());
    int bj = n - 1;
    ll c = 0;
    for (int i = 0; i < bj; i++) {
      c += rem[i];
      while (i < bj && rem[bj] + rem[i] > d) {
        rem[i] -= d - rem[bj];
        rem[bj] = d;
        bj--;
      }
      if (i < bj) {
        rem[bj] += rem[i];
        rem[i] = 0;
      }
    }
    bool ok = true;
    for (int i = 0; i < n; i++)
      if (rem[i] % d != 0) ok = false;
    if (ok && c <= k) {
      ans = max(ans, d);
    }
  }
  cout << ans << endl;

  return 0;
}


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

d={}
for i in range(N):
    if i-A[i]>0:
        if str(i-A[i]) in d:
            d[str(i-A[i])]+=1
        else:
            d[str(i-A[i])]=1

ans=0
for j in range(N):
    if str(j+A[j]) in d:
        ans+=d[str(j+A[j])]
print(ans)

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

int main() {
	vector<int> nums(3);
	cin >> nums.at(0) >> nums.at(1) >> nums.at(2);
	sort(nums.begin(), nums.end());

	cout << nums.at(0) << ' ' << nums.at(1) << ' ' << nums.at(2) << endl;

}


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

# Nが三角数の場合はYes
M = (8 * N + 1)**0.5

if M.is_integer():
    M = (int(M) - 1) // 2
    print('Yes')
    print(M + 1)
    setNum = [[] for _ in range(N + 1)]
    for s in range(1, M + 2):
        ans = [M]
        V = set()
        for i in range(1, N + 1):
            if len(ans) > M:
                break
            if len(setNum[i]) >= 2:
                continue
            elif len(setNum[i]) == 0:
                ans.append(i)
                setNum[i].append(s)
            elif not setNum[i][0] in V:
                ans.append(i)
                setNum[i].append(s)
                V.add(setNum[i][0])
        print(*ans)
else:
    print('No')


Measured memory_bytes: 65312
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

void rec(int d, Int val, vector<Int> &all) {
    all.push_back(val);

    if (d == 10) {
        return;
    }

    for (int i = -1; i <= 1; i++) {
        int add = (val % 10) + i;

        if (0 <= add && add <= 9) {
            rec(d + 1, val * 10 + add, all);
        }
    }
}

int main() {
    int K;
    cin >> K;
    vector<Int> all;
    for (int v = 1; v < 10; v++) {
        rec(1, v, all);
    }
    sort(all.begin(), all.end());

    cout << all[K - 1] << endl;

    return 0;
}

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

int main(){
  char b;
  cin >> b;
  if (b=='A') {
    b = 'T';
  } else if (b=='T') {
    b = 'A';
  } else if (b=='G') {
    b = 'C';
  } else if (b=='C') {
    b = 'G';
  }
  cout << b << endl;
}

Measured memory_bytes: 256