akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		vector<string> inputs;
		REP(i, n) {
			string a;
			cin >> a;
			inputs.push_back(a);
		}
		REP(i, n) {
			for (int q = inputs[i].length() - 1; q >= 0; --q) {
				if (inputs[i][q] == '.') {
					inputs[i][q] = '+';
					break;
				}
			}
		}
		REP(i, n) {
			REP(q, inputs[i].length()) {
				if (inputs[i][q] == '+') {
					int ok = 0;
					for (int t = i + 1; t < n; ++t) {
						if (q >= inputs[t].length()) break;
						if (inputs[t][q] == '+') {
							ok = 1;
							break;
						}
						if (inputs[t][q] != '.') {
							break;
						}
					}
					if (ok == 0) continue;
					for (int t = i + 1; t < n; ++t) {
						if (q >= inputs[t].length()) break;
						if (inputs[t][q] == '+') {
							ok = 1;
							break;
						}
						inputs[t][q] = '|';
					}
				}
			}
		}

		REP(i, n) {
			REP(q, inputs[i].length()) {
				if (inputs[i][q] == '.') inputs[i][q] = ' ';
			}
		}
		REP(i, n) {
			cout << inputs[i] << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3424
# sys.stdin.readline()
import sys
input = sys.stdin.readline

n=int(input())
num=list(map(int,input().split()))
ido=0
ans=[0]
for i in range(n-1):
    if num[i]>=num[i+1] and i==n-2:
        ans.append(ido+1)
    elif num[i]>=num[i+1]:
        ido=ido+1
    elif num[i]<num[i+1]:
        ans.append(ido+0)
        ido=0

print(max(ans))


Measured memory_bytes: 14252
using System;
class ProgramB
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int x = int.Parse(input[1]);

            string[] input_L = Console.ReadLine().Split(' ');

            int count = 1;
            int Lx = 0;

            for(int i = 0; i < n;i++)
            {
                Lx += int.Parse(input_L[i]);

                if (Lx <= x)
                    count++;
                else
                    break;
            }

            Console.WriteLine(count);
        }
    }

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
const int N = 1003;

int n, m, t, s;

int a[N][N];

void rec(int x, int y)
{
    if (x == n)
    {
        for (int i = 0; i < n; ++i)
        {
            int q[2] = {};
            for (int j = 0; j < m; ++j)
            {
                q[a[i][j]]++;
            }
            if (min(q[0], q[1]) != t)
                return;
        }
        for (int j = 0; j < m; ++j)
        {
            int q[2] = {};
            for (int i = 0; i < n; ++i)
            {
                q[a[i][j]]++;
            }
            if (min(q[0], q[1]) != s)
                return;
        }
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
                printf("%d", a[i][j]);
            printf("\n");
        }
        exit(0);
    }
    a[x][y] = 0;
    if (y == m - 1)
        rec(x + 1, 0);
    else
        rec(x, y + 1);
    a[x][y] = 1;
    if (y == m - 1)
        rec(x + 1, 0);
    else
        rec(x, y + 1);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d%d%d%d", &n, &m, &t, &s);
    for (int i = 0; i < n; ++i)
    {
        if (i < s)
        {
            for (int j = 0; j < m; ++j)
            {
                if (j < t)
                    printf("1");
                else
                    printf("0");
            }
        }
        else
        {
            for (int j = 0; j < m; ++j)
            {
                if (j < t)
                    printf("0");
                else
                    printf("1");
            }
        }
        printf("\n");
    }
    return 0;
    rec(0, 0);
    printf("-1\n");
    return 0;
}


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

typedef long long hyper;

hyper W[100000];
int n, k;

int value(hyper P)
{
    hyper sum = 0;
    int v = 0, t = 1; // v: baggages, t: tracks.

    while(1){
        sum = sum + W[v];
        if(sum > P){
            sum = 0; t++;   // to the next track.
        }else{ v++; }       // to the new baggage.
        if(v == n || t > k) break;
    };

    return v;   // return possible ...
}

hyper solve()
{
    hyper left, right, mid;
    left = 0;
    right = 100000 * 10000;

    while(right - left > 1){

        mid = (left + right) / 2;

        if(value(mid) < n){ left = mid; }
        else{ right = mid; }
    };

    return right;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> W[i];

    cout << solve() << endl;

    return 0;
}

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

int main(){
	int a,b,c,d=0;
	cin >> a >> b >> c;

	for(int x=a; x<=b;x++){
		if( c%x == 0 ){
			d++;
		}
	}

	cout << d << "\n";
	return 0;
	
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	string s; cin >> s;
	int index_a,index_z;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {
			index_a = i;
			break;
		}
	}
	for (int i = s.length()-1; i >= 0; i--) {
		if (s[i] == 'Z') {
			index_z = i;
			break;
		}
	}
	cout << index_z - index_a + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val xy = (0 until n).map { sc.next().toDouble() to sc.next() }
    println(problem119b(n, xy))
}

fun problem119b(n: Int, xy: List<Pair<Double, String>>): Double {
    val BTC = 380000.0
    var sum = 0.0
    for (i in 0 until n) {
        val xyi = xy[i]
        if (xyi.second == "BTC") {
            sum += xyi.first * BTC
        } else {
            sum += xyi.first
        }
    }
    return sum
}

Measured memory_bytes: 31392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vector<ll>a(n);

  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<n; i++) a[i]-=i+1;
  sort(a.begin(),a.end());
  ll stand = n/2;
  ll standard = a[stand];
  
  ll ans=0;
  for(int i=0; i<n; i++){
    a[i]-=standard;
    if(a[i]<0) a[i]*=-1;
    ans+=a[i];
  }
  
  cout << ans << endl;
  
}
  
  


Measured memory_bytes: 1792
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

h,w,a,b = map(int,input().split())
if a > w // 2 or b > h // 2:
    print('No')
    exit()
l = [0] * (w - a) + [1] * a
for i in range(h):
    for j in l:
        p = j ^ (i < b)
        print(p, end = '')
    print()


Measured memory_bytes: 121812
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	vector<int> T(N),V(N);
	for(int i=0;i<N;i++) cin >> T[i];
	for(int i=0;i<N;i++) cin >> V[i];
	
	vector<int> H(N+1);
	int Inf = (int) 1e9;
	for(int i=1;i<N;i++) H[i] = Inf;
	for(int i=0;i<N;i++){
		H[i] = min(H[i], V[i]);
		H[i+1] = min(H[i+1], H[i] + T[i]);
		H[i+1] = min(H[i+1], V[i]);
	}
	for(int i=N;i>0;i--){
		H[i] = min(H[i], V[i - 1]);
		H[i-1] = min(H[i-1], H[i] + T[i-1]);
		H[i-1] = min(H[i-1], V[i - 1]);
	}
//for(int i=0;i<N+1;i++) cout << H[i] << " "; cout << endl;	
	double tot = 0;
	for(int i=0;i<N;i++){
		int l = V[i] - H[i];
		int r = V[i] - H[i + 1];
		if(l + r > T[i]){
			double t0 = -1.0 * (double) (H[i] - T[i] - H[i+1]) / 2.0;
			tot += t0 * (H[i] + H[i] + t0) / 2.0;
			tot += (T[i] - t0) * (H[i + 1] + H[i + 1] + (T[i] - t0)) / 2.0;
		} else {
			tot += V[i] * (T[i] - l - r);
			tot += (double) l * (H[i] + H[i] + l) / 2.0;
			tot += (double) r * (H[i + 1] + H[i + 1] + r) / 2.0;
		}
//cout << "tot: " << tot << endl;
	}
	
	//cout << tot << endl;
	printf("%.12f\n", tot);
	
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	ll N, A, B; cin >> N >> A >> B;
	ll sum = A + B;
	ll num,ans=0;
	num = (ll)N / sum;
	ll temp=N%(A+B);
	ll matubi;
	matubi = max((ll)0, temp - A);
	ans = N-B * num - matubi;
	cout << ans << endl;
}

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

int main() {
	// your code goes here
	int n;
	int arr[100100];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	sort(arr,arr+n);
	bool found = false;
	int curr = 0;
	long long pertama = 0;
	long long kedua = 0;
	long long sisi = 0;
	for(int i=n-1;i>=1;i--){
		//printf("%d\n",i);
		if(arr[i]==arr[i-1]){
			//printf("%d %d\n",arr[i],arr[i-1]);
			if(pertama!=0){
				kedua = arr[i];
				break;
			}
			else{
				pertama = arr[i];	
				i--;
			}
			
		}
		
	}
	long long ans = pertama*kedua;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=a*min(n,b-1)/b;
    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 998244353

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

ll dp[2020][2020];
ll sum;
int K, N;

void init()
{
	cin >> K >> N;
	rep(i, K) {
		dp[N-1][i] = 1;
	}
	rrep(i, N-1) {
		ll a = 0;
		rrep(j, K) {
			a += dp[i+1][j];
			a %= MOD;
			dp[i][j] = a;
		}
	}
	rep(i, K) {
		sum += dp[0][i];
		sum %= MOD;
	}
}

struct comb {
#define MOD_COMB MOD
	vector<ll> fact;
	vector<ll> facti;
	comb(int n) {
		init(n);
	}
	void init(int n) {
		fact.resize(n);
		facti.resize(n);
		fact[0] = 1;
		for (int i = 1; i < n; i++) {
			fact[i] = fact[i-1] * i % MOD_COMB;
		}
		facti[n-1] = po(fact[n-1], MOD_COMB - 2);
		for (int i = n-2; i >= 0; i--) {
			facti[i] = facti[i+1] * (i + 1) % MOD_COMB;
		}
	}
	ll nCr(int a, int b) {
		return (fact[a] * facti[b] % MOD_COMB) * facti[a-b] % MOD_COMB;
	}
private:
	ll po(ll next, int cnt) {
		ll res = 1;
		if (cnt == 0) return 1;
		if (cnt & 1) res = res * next % MOD_COMB;
		return res * po(next * next % MOD_COMB, cnt >> 1) % MOD_COMB;
	}
};

void solve()
{
	vector<ll> res;
	comb co(2020);
	if (K == 1) {
		cout << 0 << endl;
		return;
	}
	int i = 0;
	reps(cnt, 3, K+3) {
		ll hugo = 1;
		ll ans = 0;
		rep(j, i+1) {
			ans += hugo * co.nCr(i+1, j+1) * dp[j*2+1][0];
			ans %= MOD;
			hugo *= -1;
		}
		res.PB(ans);
		res.PB(ans);
		cnt++;
		i++;
	}
	if (K%2) res.pop_back();
	rep(i, res.size()) {
		cout << (sum - res[i] + MOD) % MOD << endl;
	}
	rrep(i, res.size()-1) {
		cout << (sum - res[i] + MOD) % MOD << endl;
	}
}





Measured memory_bytes: 31872
A,B,M = list(map(int,input().split()))
listA = list(map(int,input().split()))
listB = list(map(int,input().split()))
listC = set([])
for i in range(M):
    M = list(map(int,input().split()))
    listC.add(listA[M[0]-1]+listB[M[1]-1]-M[2])
D = min(listC)
E = min(listA) + min(listB)
print(min(D,E))

Measured memory_bytes: 18736
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = in.nextInt(), x = in.nextInt() - 1, y = in.nextInt() - 1, b[] = new int[n];
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++) {
                int t = Math.min(j - i, Math.abs(i - x) + Math.abs(j - y) + 1);
                b[t]++;
            }
        for (int j = 1; j < n; j++)
            out.println(b[j]);
        out.flush();

    }
}


Measured memory_bytes: 24020
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

typedef db T;
struct P{
    T x,y;
    P(){} P(T x,T y):x(x),y(y){}
    P operator - (const P&b) const {return P(x-b.x,y-b.y);}
    P operator + (const P&b) const {return P(x+b.x,y+b.y);}
    P operator * (const T&k) const {return P(x*k,y*k);}
    T operator * (const P&b) const {return x*b.x+y*b.y;}
    void read() {scanf("%lf%lf",&x,&y);}
};
T norm(P a){return a.x*a.x+a.y*a.y;}
P proj(P p,P a,P b){return (b-a)*((p-a)*(b-a)/norm(b-a))+a;}
P reflect(P p,P a,P b){return proj(p,a,b)*2-p;}

int main(){
    P p,a,b;
    a.read();b.read();
    int Q;scanf("%d",&Q);
    rep(i,0,Q){
        p.read();
        P q=reflect(p,a,b);
        printf("%.10f %.10f\n",q.x,q.y);
    }
    return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LONG_LONG_MAX    9223372036854775807LL
#define LONG_LONG_MIN    (-LONG_LONG_MAX-1)
vector<vector<long long>> dpsum,dpcost; // dp(i,j) ways when i children and ith children get j candies
vector<int>v;



void solve(){
    int n;cin>>n;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    dpsum.resize(n,vector<long long>(n,-1));
    dpcost.resize(n,vector<long long>(n,-1));
    for(int i=0;i<n;i++){
        dpsum[i][i]=v[i];
        dpcost[i][i]=0;
    }
    for(int d=1;d<n;d++){
        for(int i=0;i<n-d;i++){
            int j = i+d;
            dpcost[i][j]=LONG_LONG_MAX;
            dpsum[i][j] = dpsum[i][j-1]+v[j];
            for(int k=i;k<j;k++){
                dpcost[i][j] = min(dpcost[i][j],dpcost[i][k]+dpcost[k+1][j]+dpsum[i][j]);
            }
        }
    }
    cout<<dpcost[0][n-1]<<"\n";
}

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

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

vi solve_naive(int k, int n){
	vector<vi> v;
	function<void(vi)> rec = [&](vi cur){
		if(cur.size()) v.pb(cur);
		if(cur.size() < n) for(int i = 1; i <= k; i++){
			cur.pb(i);
			rec(cur);
			cur.pop_back();
		}
	};
	rec(vi(0));
	sort(all(v));
	//for(vi i : v) cerr<<i; cerr<<endl;
	return v[(v.size() + 1) / 2 - 1];
}
vi solve(int k, int n){
	vi ans;
	if(k % 2 == 0){
		rep(i, n) ans.pb(i ? k : k / 2);
		return ans;
	}
	
	rep(i, n) ans.pb((k + 1) / 2);
	
	int ofs = n / 2;
	while(ofs){
		if(ans.back()-- == 1) ans.pop_back();
		else while(ans.size() < n) ans.pb(k);
		ofs--;
	}
	
	while(ans.back() == 0) ans.pop_back();
	return ans;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	if(0){
		for(int k = 1; k <= 7; k++) for(int n = 1; n <= 7; n++){
			dbg(k, n);
			dbg(solve_naive(k, n));
			dbg(solve(k, n));
		}
		exit(0);
	}
	
	int k, n; cin >> k >> n;
	vi ans = solve(k, n);
	rep(i, ans.size()) cout << ans[i] << (i==n-1?"\n":" ");
	return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>

int main(int argc,char* argv[]){
  int len[10];
  int v_1,v_2,i;
  int sum;
  double time;

  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&len[0],&len[1],&len[2],&len[3],&len[4],&len[5],&len[6],&len[7],&len[8],&len[9],&v_1,&v_2) != EOF){
    sum = 0;
    for(i = 0;i < 10;i++){
      sum += len[i];
    }

    time = (double)(sum)/(v_1 + v_2);
    
    sum = 0;
    for(i = 0;i < 10;i++){
      sum += len[i];
      if(sum >= (v_1 * time)){
	printf("%d\n",i+1);
	break;
      }
    }
    
  }
  
  return 0;
  
}

Measured memory_bytes: 0
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=1000000, INF=20000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

string s[10];
int h,w,k;
int dp1[10][10],dp[10][1000];
void pre()
{
    rep(i,0,h)
    rep(j,0,w)
    dp[i][j]=s[i][j]-'0';
    for(int i=0;i<w;i++)
    {
        for(int j=1;j<h;j++)
        dp[j][i]+=dp[j-1][i];
    }
    return;
}
int fun(vector <int> &v)
{
    int res=0,l=v.size();
    int cur[l-1];
    fill(cur, 0);
    /**if(l==2)
    {rep(i,0,l)cout<<v[i]<<" ";
    cout<<"\n";}**/
    for(int i=0;i<w;i++)
    {
        int f=0;
        for(int j=0;j<l-1;j++)
        {
            int a=v[j]+1,b=v[j+1];
            int ad=dp[b][i];
            if(a)
            ad-=dp[a-1][i];
            if(ad>k)
            return INF;
            cur[j]+=ad;
            if(cur[j]>k)
            f=1;
        }
        if(f==1)
        {
            res++;
            rep(j,0,l-1)
            for(int j=0;j<l-1;j++)
        {
            int a=v[j]+1,b=v[j+1];
            int ad=dp[b][i];
            if(a)
            ad-=dp[a-1][i];
            cur[j]=ad;
        }
        }
    }
    return res;
}
int32_t main()
{
    IOS;
    cin>>h>>w>>k;
    for(int i=0;i<h;i++)
    cin>>s[i];
    pre();
    //print2d(dp,h-1,w-1);
    fill(dp1, -1);
    int ans=INF;
    for(int i=0;i<(1 << (h-1));i++)
    {
        vi v;
        v.pb(-1);
        for(int j=0;j<h-1;j++)
        {
            if(i&(1 << j))
            v.pb(j);
        }
        v.pb(h-1);
        int cur=fun(v);
        //cout<<i<<" "<<cur<<"\n";
        ans=min(ans, cur+setbits(i));
    }
    cout<<ans;
}

Measured memory_bytes: 3672
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            cnt++;
        }
    }
    int cnt1=0;
    for(int i=0;i<cnt;i++)
    {
        if(s[i]=='W')
        {
            cnt1++;
        }

    }
    cout<<cnt1<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll dp[44][444][444];
//40*400*400
//2^6*10^5
//6*10^6

int main(){
	ll n, ma, mb, ans=INF;
	cin>>n>>ma>>mb;
	vector<ll> a(n),b(n),c(n);
	rep(i,n){
		cin>>a[i]>>b[i]>>c[i];
	}
	//dpで考える.ここで変数は
	//番号と2の値とvalueであるので
	//3次元dp
	//最小値を出したいのでINFで初期化.
	rep(i,n+2){
		rep(j,411){
			rep(k,411){
				dp[i][j][k]=INF;
			}		
		}
	}
		
	//何も持たない時のvalueは0
	dp[0][0][0]=0;
	rep(i,n){
		rep(j,401){
			rep(k,401){
				//iを加えない場合.足さないでコストが下がるのか.
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
				//iを加える場合.足してコストが下がるのか.
				dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
			}
		}
	}
	FOR(i,1,n+2){
		FOR(j,1,401){
			FOR(k,1,401){
				if(j*mb-k*ma==0){
					ans=min(ans,dp[i][j][k]);
				}
			}
		}
	}


	if(ans==INF){
		cout<<-1<<endl;
	}else{
		cout<<ans<<endl;
	}


	return 0;
}














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

long long N, M;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> >  >AB;
priority_queue<long long> Q;


int main(){
	cin >> N >> M;

	for(long long i = 0; i < N; i++){
		long long a, b;
		cin >> a >> b;
		AB.push(make_pair(a, b));
	}

	long long ans = 0;
	for(long long i = 1; i <= M; i++){
		while(!AB.empty()){
			long long day = AB.top().first;
			long long money = AB.top().second;
			if(day > i){
				break;
			}
			AB.pop();
			Q.push(money);
		}
		if(!Q.empty()){
			ans += Q.top();
			Q.pop();
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3568
#include <vector>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
bool is_prime(int n, int k = 3)
{
    if(n < k * k) { return true; }
     
    if(n % k == 0) { return false; }
     
    return is_prime(n, k + 2);
}
 
int main()
{
    vector<int> prime = {2};
     
    for(int i = 3; i < 101300; i += 2)
    {
        if(is_prime(i))
        {
            prime.push_back(i);
        }
    }
     
    int n, m;
     
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &m);
         
        if(n == -1 && m == -1) { break; }
         
        int ptr = distance(prime.begin(), lower_bound(prime.begin(), prime.end(), n + 1));
         
        vector<int> c;
        
        for(int i = ptr + m - 1; i >= ptr; i--)
        {
            for(int j = ptr + m - 1; j >= i; j--)
            {
                c.push_back(prime[i] + prime[j]);
            }
        }
        
        sort(c.begin(), c.end());
         
        printf("%d\n", c[m - 1]);
    }
     
    return 0;
}

Measured memory_bytes: 3392
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

ll A[1010], B[1010], C[1010];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    for (int i = 0; i < X; ++i)
    {
        cin >> A[i];
    }

    for (int i = 0; i < Y; ++i)
    {
        cin >> B[i];
    }
    for (int i = 0; i < Z; ++i)
    {
        cin >> C[i];
    }

    sort(A, A + X);
    sort(B, B + Y);
    sort(C, C + Z);

    vector<ll> v;
    for (int i = 0; i < X; ++i)
    {
        for (int j = 0; j < Y; ++j)
        {
            v.push_back(A[i] + B[j]);
        }
    }
    sort(v.begin(), v.end(), greater<ll>());
    vector<ll> v1;
    for (int i = 0; i < min((int)v.size(), K); ++i)
    {
        v1.push_back(v[i]);
    }

    vector<ll> v2;
    for (int i = 0; i < Z; ++i)
    {
        for (int j = 0; j < v1.size(); ++j)
        {
            v2.push_back(C[i] + v1[j]);
        }
    }

    vector<ll> ans;
    sort(v2.begin(), v2.end(), greater<ll>());

    for (int i = 0; i < K; ++i)
    {
        ans.push_back(v2[i]);
    }

    for (int i = 0; i < K; ++i)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 43268
BLACK = "0"
WHITE = "1"
S = input()
even_black = 0
even_white = 0
odd_black = 0
odd_white = 0

for i in range(len(S)):
  if i%2 == 0:
    even_black += S[i]==BLACK
    even_white += S[i]==WHITE
  else:
    odd_black += S[i]==BLACK
    odd_white += S[i]==WHITE
if even_black+odd_white < even_white+odd_black:
  print("{}" .format(even_black+odd_white))
else:
  print("{}" .format(even_white+odd_black))



Measured memory_bytes: 3188
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e5+69, INF=2e9+6969;

int n,ans;
long double d,x,y;

int main()
{
	//  scanf("%d", &n);
	cin >> n >> d;
	d*=d;
	for(int i=0;i<n;i++)
	{
		cin >> x >> y;
		x = x*x;
		y = y*y;
		x = x + y;
		//  x = sqrt(x);
		if(d >= x) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3796
#include <cstdio>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <climits>

class Node {
 public:
  explicit Node(uint32_t id):
      id_(id) {}

  uint32_t id() const {return id_;}
  
  void AddEdge(uint32_t edge) {
    to_edge_.push_back(edge);
  }

  const std::vector<uint32_t>& to_edges() const {
    return to_edge_;
  }

  int edge_cunt() const {
    return to_edge_.size();
  }

 private:
  uint32_t id_;
  std::vector<uint32_t> to_edge_;
};

class Graph {
 public:
  using GraphNodeMap = std::unordered_map<uint32_t, Node*>;

  void AddOrUpdateNode(uint32_t id, uint32_t to) {
    Node* from = nullptr;
    if (node_map_.count(id) > 0) {
      from = node_map_.find(id)->second;
    } else {
      from = new Node(id);
      node_map_.insert({id, from});
    }

    Node* toNode = nullptr;
    if (node_map_.count(to) == 0) {
      toNode = new Node(to);
      node_map_.insert({to, toNode});
    } else {
      toNode = node_map_.find(to)->second;
    }

    toNode->AddEdge(id);
    from->AddEdge(to);
  }

  uint32_t FindBridge() const {
    uint32_t bridge_count = 0;
    std::unordered_set<std::string> erased_edge_set;
    for (const auto &node_pair: node_map_) {
      auto node = node_pair.second;
      for (const auto &edge: node->to_edges()) {
        std::pair<uint32_t, uint32_t> ignore_route {node->id(), edge};
        std::unordered_set<uint32_t> visited_set;
        char edge_key[10];
        sprintf(edge_key, "%u_%u", node->id() > edge? edge: node->id(), node->id() > edge? node->id(): edge);
        if (erased_edge_set.count(edge_key) == 0) {
          erased_edge_set.insert(std::string(edge_key));
        } else {
          continue;
        }
        DoFindBridge(node_map_.find(1)->second, &bridge_count, &visited_set, ignore_route);
        if (visited_set.size() != node_map_.size()) {
          bridge_count++;
        }
      }
    }

    return bridge_count;
  }

 private:
  void DoFindBridge(const Node* node, uint32_t* bridge_count, std::unordered_set<uint32_t>* visited_set, const std::pair<uint32_t, uint32_t>& ignore_pair) const {
    visited_set->insert(node->id());
    for (const auto& next_id: node->to_edges()) {
      if (visited_set->count(next_id) == 0) {
        if ((ignore_pair.first == node->id() &&
             ignore_pair.second == next_id) ||
            (ignore_pair.second == node->id() &&
             ignore_pair.first == next_id)) {
          continue;
        }
        DoFindBridge(node_map_.find(next_id)->second, bridge_count, visited_set, ignore_pair);
      }
    }
  }

  GraphNodeMap node_map_;
};


int main() {
  int n = 0;
  int m = 0;
  scanf("%d %d", &n, &m);
  Graph graph;
  for (int i = 0; i < m; i++) {
    uint32_t id;
    uint32_t to;
    scanf("%u %u", &id, &to);
    graph.AddOrUpdateNode(id, to);
  }

  printf("%u\n", graph.FindBridge());
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
    int n,a,b,i,max,x;
    scanf("%d",&n);
	max=0;
    for(i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        if(max<=b){
            if(max<b){
                x=a;
                max=b;
            }
			else if(x>a)x=a; 
		}
    }
    printf("%d %d\n",x,max);
    return 0;
}

Measured memory_bytes: 1028
def solve():
    N, M = map(int, input().split())
    K = [0 for _ in range(N)]
    A = [[] for _ in range(N)]
    for i in range(N):
        K[i], *A[i] = map(int, input().split())
    
    ans = M
    for i in range(1, M+1):
        for j in range(N):
            if i not in A[j]:
                ans -= 1
                break
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[10],i;
    for(i=0;i<10;i++)cin>>a[i];
    sort(a,a+10);
    for(i=9;i>6;i--)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 1180
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

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

bool dfs(int rest, size_t s_idx, size_t t_idx, string &s, string &t) {
	if(s_idx == s.size() && t_idx == t.size()) return true;
	if(s_idx == s.size()) return t.size() - t_idx <= rest;
	if(t_idx == t.size()) return s.size() - s_idx <= rest;

	if(s[s_idx] == t[t_idx]) return dfs(rest, s_idx + 1, t_idx + 1, s, t);

	if(rest == 0) return false;
	if(dfs(rest - 1, s_idx + 1, t_idx, s, t)) return true; // delete
	if(dfs(rest - 1, s_idx, t_idx + 1, s, t)) return true; // insert
	if(dfs(rest - 1, s_idx + 1, t_idx + 1, s, t)) return true; // replace

	// swap
	if(s_idx + 1 < s.size() && t_idx + 1 < t.size() && s[s_idx] == t[t_idx + 1] && s[s_idx + 1] == t[t_idx]) {
		if(dfs(rest - 1, s_idx + 2, t_idx + 2, s, t)) return true;
	}

	if(rest == 2) { // delete and swap
		if(s_idx + 2 < s.size() && s[s_idx + 2] == t[t_idx]) {
			swap(s[s_idx], s[s_idx + 2]);
			const bool ok = dfs(rest - 2, s_idx + 2, t_idx + 1, s, t);
			swap(s[s_idx], s[s_idx + 2]);
			if(ok) return true;
		}

		if(t_idx + 2 < t.size() && s[s_idx] == t[t_idx + 2]) {
			swap(t[t_idx], t[t_idx + 2]);
			const bool ok = dfs(rest - 2, s_idx + 1, t_idx + 2, s, t);
			swap(t[t_idx], t[t_idx + 2]);
			if(ok) return true;
		}
	}

	return false;
}

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

	for(int n; cin >> n && n;) {
		int d;
		cin >> d;

		vector<string> name(n);
		for(auto &e : name) cin >> e;

		vector<string> ans;
		rep(i, n) {
			rep(j, i) {
				if(dfs(d, 0, 0, name[i], name[j])) {
					if(name[i] < name[j]) {
						ans.emplace_back(name[i] + "," + name[j]);
					}
					else {
						ans.emplace_back(name[j] + "," + name[i]);
					}
				}
			}
		}

		sort(ALL(ans));
		for(const auto &s : ans) {
			cout << s << endl;
		}
		cout << ans.size() << endl;
	}

	return EXIT_SUCCESS;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll a[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
            1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  ll K;
  scanf("%lld", &K);

  cout << a[K - 1] << endl;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb push_back
#define emp emplace_back
#define ppb pop_back
#define len(v) int(v.size())
#define all(v) (v).begin(),(v).end()
#define ri(x) scanf("%d",&(x))
#define rii(x,y) scanf("%d %d",&(x),&(y))
#define riii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rl(x) scanf("%lld",&(x))
#define rll(x,y) scanf("%lld %lld",&(x),&(y))
#define rlll(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
using namespace std; 
typedef unsigned int uint; typedef long long ll;
typedef unsigned long long ull; typedef pair<int, int> pii;
typedef pair<ll,ll> pll; typedef long double ld;
void fastio(){ ios_base::sync_with_stdio(false); cin.tie(0);}
template<typename T> T __lcm(T a, T b){return (a*b)/__gcd(a,b);}
template<typename T> T fpow(T a, T b, T p) {
	a %= p; T res = 1; while (b > 0) { 
	if (b & 1) res = res * a % p;
	a = a * a % p; b >>= 1;} return res;}
template<typename T> T binpow(T a, T b) {
		T res = 1; while (b > 0) {if (b & 1) res = res * a;
		a = a * a; b >>= 1;} return res;}
const long double PI = acos(-1);
const long long MOD = 1000000000 +7;
const int maxn = 100, maxw = 1e5;

int n, cap;
int w[maxn];
ll v[maxn];
ll dp[maxn+5][maxw+5];

ll solve(int curn, int curw){
	if (curn == 0) return 0;
	if(curw>cap) return 0;
	if (dp[curn][curw] != -1) return dp[curn][curw];
	if (curw+w[curn-1]<=cap) dp[curn][curw] = v[curn-1] + solve(curn-1, curw+w[curn-1]);
	dp[curn][curw] = max(dp[curn][curw], solve(curn-1, curw));
	return dp[curn][curw];
}

int main() {
	rii(n, cap);
	memset(dp, -1, sizeof(dp));
	forn(i, n) ri(w[i]), rl(v[i]);
	printf("%lld\n", solve(n, 0));
	
	return 0;
}

Measured memory_bytes: 82304
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int r;
    cin >> r;
    if (r < 1200) {
        P("ABC");
    }
    else if (r < 2800) {
        P("ARC");
    }
    else {
        P("AGC");
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long n; cin >> n;
  while (n--) {
    s = (char)('a' + (int)(n % 26)) + s;
    n /= 26;
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
typedef pair<int,int> pii;
typedef long long ll;

int n,a[100005],tmp;

void solve(){
	for (int i=1; ; i++){
		tmp = i*i + i + 4;
		if (tmp > n) return;
		for (int j=1; ; j++){
			tmp = i*i + j*j + 2 + i*j + i + j;
			if (tmp > n) break;
			for (int k=1; ; k++){
				tmp = i*i + j*j + k*k + i*j + j*k + i*k;
				if (tmp <= n) {
					a[tmp]++;
				}
				else {
					break;
				}
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	
	cin >> n;
	solve();
	for (int i=1;i<=n;i++){
		cout << a[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n;
  cin >> n;
  vector<P> B(n), R(n);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    R[i] = make_pair(b, a);
  }
  rep(j, n) {
    int c, d;
    cin >> c >> d;
    B[j] = make_pair(c, d);
  }
  sort(all(R));
  reverse(all(R));
  sort(all(B));
  vector<int> Mi(n, -1);
  vector<int> Mj(n, -1);
  auto f = [&](int i, int j) {
    return R[i].second < B[j].first
           && R[i].first < B[j].second && Mi[i] < 0
           && Mj[j] < 0;
  };
  rep(i, n) rep(j, n) if(f(i, j)) Mi[i] = j, Mj[j] = i;
  int ans = 0;
  rep(i, n) if(Mi[i] >= 0) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,q,m[100],date[50][100],i,j,k,cnt,max,result;
  while(1){
    max=0;
    cin >> n >> q;
    if(n==0&&q==0) break;
    for(i=0;i<n;i++){
      cin >> m[i];
      for(j=0;j<m[i];j++){
	cin >> date[i][j];
      }
    }
    
    for(i=1;i<100;i++){
      cnt=0;
      for(j=0;j<n;j++){
        for(k=0;k<m[j];k++){
          if(i==date[j][k]){
	    cnt++;
	    break;
	  }
	}
      }
      if(cnt>max){
	max=cnt;
        result=i;
      }
    }
    if(max>=q) cout << result << endl;
    else cout << 0 << endl;
  }
  return 0;
}

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

int main() {
  long A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  long ans = 1e9;
  for (int i = 0; i <= max(X, Y); i++) {
    long cost = i * C * 2;
    long x = i;
    long y = i;
    if (x < X) cost += A * (X - x);
    if (y < Y) cost += B * (Y - y);
    ans = min(ans, cost);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    char a,b;
    cin>>a>>b;
    if(a==b)cout<<'H'<<endl;
    else cout<<'D'<<endl;
}

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

int main(){
  int N ; 
  cin >> N ; 
  vector<int> h(N) ; 
  vector<int> dp(N) ; 
  for(int i = 0 ; i < N ; i++) cin >> h.at(i) ; 
  
  for(int i = 1 ; i < N ; i++){
    if(i -2 >= 0){
      dp.at(i) = min(dp.at(i-1)+abs(h.at(i-1)-h.at(i)),dp.at(i-2)+abs(h.at(i-2)-h.at(i)));
    }
    else dp.at(i) = dp.at(i-1)+ abs(h.at(i-1) - h.at(i)) ;
  }
                                 
                                 
  int ans = dp.at(N-1) ; 
  
  cout << ans <<endl ; 

                                 
}

Measured memory_bytes: 4048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC023A {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            long[] sums = new long[N];
            long sum = 0;
            for(int i = 0; i < N; i++) {
                sum += input[i];
                sums[i] = sum;
            }
            Array.Sort(sums);
            long ans = 0;
            int nowre = 0;
            long nownum = sums[0];
            if(nownum == 0) {
                ans++;
            }
            for(int i = 1; i < N; i++) {
                if(sums[i] == nownum) {
                    nowre++;
                    ans += nowre;
                } else {
                    nowre = 0;
                    nownum = sums[i];
                }
                if(sums[i] == 0) {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int n, m;
vector<int> G[MAX];
int cnt[2];

bool is_bipartite_graph(std::vector<int> checkGraph[], int size, int now = 0, int prev = -1, int c = 0) {
    static int color[MAX];      // must declare {const int MAX;}
    static bool isFirst = true;
    if (isFirst) {
        memset(color, -1, sizeof(color));
        isFirst = false;
    }
    if (color[now] == -1) {

        cnt[c]++;

        color[now] = c;
        bool ret = true;
        for (int e : checkGraph[now]) {
            if (e != prev) {
                ret &= is_bipartite_graph(checkGraph, size, e, now, c ^ 1);
            }
        }
        return ret;
    } else {
        return color[now] == c;
    }
}



int main(void) {
    scanf("%d%d", &n, &m);
    REP(i, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--;b--;
        G[a].EB(b);
        G[b].EB(a);
    }
    if (is_bipartite_graph(G, n)) {
        cout << 1ll * cnt[0] * cnt[1] - m << endl;
    } else {
        cout << 1ll * n * (n - 1) / 2 - m << endl;
    }
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
 
const int N = 2e3 + 5;
int G[N][N], e[N][N], p[N][N], h[N][N], s[N][N];
char ss[N];
 
int read () {
	int x = 0, f = 0; char c = getchar ();
	while (!isdigit (c)) f |= (c == '-'), c = getchar ();
	while (isdigit (c)) x = x * 10 + c - '0', c = getchar ();
	return f ? -x : x;
}
 
int main () {
//	freopen ("duty.in" ,"r", stdin);
//	freopen ("duty.out", "w", stdout);
	int n = read (), m = read (), Q = read ();
	for (int i = 1; i <= n; i++) {
		scanf ("%s", ss + 1);
		for (int j = 1; j <= m; j++) {
			G[i][j] = ss[j] - '0';
			if (G[i][j]) {
				p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + 1;
				e[i][j] = e[i - 1][j] + e[i][j - 1] - e[i - 1][j - 1] + (G[i - 1][j] == 1) + (G[i][j - 1] == 1);
				h[i][j] = h[i][j - 1] + (G[i][j - 1] == 1);
				s[i][j] = s[i - 1][j] + (G[i - 1][j] == 1);
			} else {
				p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1];
				e[i][j] = e[i - 1][j] + e[i][j - 1] - e[i - 1][j - 1];
				h[i][j] = h[i][j - 1], s[i][j] = s[i - 1][j];
			}
		}
	}
	
	while (Q--) {
		int a1 = read (), b1 = read (), a2 = read (), b2 = read ();
		int sww1 = p[a2][b2] + p[a1 - 1][b1 - 1] - p[a2][b1 - 1] - p[a1 - 1][b2];
		int sww2 = e[a2][b2] + e[a1][b1] - e[a2][b1] - e[a1][b2];
		int sww3 = s[a2][b1] - s[a1][b1] + h[a1][b2] - h[a1][b1];
		printf ("%d\n", sww1 - sww2 - sww3);
	}
	return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>

int main(void){

         long long int a, b, temp, sum, GCD, LCM;

        while(scanf("%lld %lld",&a,&b) !=EOF)
        {

            if(a<b)
            {
                temp = a;
                a = b;
                b = temp;
            }

            sum = a * b;

            while( b != 0)
            {
                a = a % b;
                temp = a;
                a = b;
                b = temp;
            }

            printf("%lld %lld\n", a, sum/a);
        }
        return 0;
}

Measured memory_bytes: 1812