akhauriyash/Code-Regression huggingface dataset:
/**
*   @author: Kshitiz Srivastava (Pirate_ksh) @ MNNIT Allahabad
*/
#include<bits/stdc++.h>
using namespace std;
 
// General
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define mod_ 998244353 
#define endl "\n"
#define debug(x) cout<<x<<endl
#define REP(i,n) for(i=0;i<n;++i)
#define FOR(i,x,n) for(i=x;i<n;++i)
 
// Bounds
#define lb(a, x) a.lower_bound(x)
#define ub(a, x) a.upper_bound(x)
#define all(a) a.begin(),a.end()
 
// Vector
#define vi vector <int>
#define pb(v, x) v.push_back(x)
#define vsi vector <set <int> >
 
// Map
#define mii map <int, int>
 
// Set
#define si set <int>
 
// Pair
#define vpii vector<pair < int, int > >
#define pii pair < int, int >
#define F first
#define S second

ll t, i, j, k, n, minimum, maximum;
int a[105];

int dp[100005][2];
int DP(int rem, int plr) {
    if(rem < minimum) return dp[rem][plr] = plr;
    if(dp[rem][plr] != -1) return dp[rem][plr];
    int ans;
    if(plr==0) ans = 0;
    else ans = 1;
    int it;
    REP(it,n) {
        if(rem >= a[it]) {
            if(plr == 0) ans = max(ans , DP(rem-a[it], (plr+1)%2));
            else ans = min(ans, DP(rem-a[it], (plr+1)%2));
        }
    }
    return dp[rem][plr] = ans;
}

int main(){
    io;
    t=1;
    while(t--) { 
        cin >> n >> k;
        REP(i,n) cin >> a[i];
        minimum = *min_element(a, a+n);
        maximum = *max_element(a, a+n);
        memset(dp, -1, sizeof(dp));
        ll des = DP(k, 0);
        if(des == 0) cout << "Second\n";
        else cout << "First\n";
    }
    return 0;
}


Measured memory_bytes: 5760
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    s = []
    n = ii()
    for i in range(n):
        tmp = input()
        s.append(tmp)
    s = list(set(s))
    print(len(s))


main()




Measured memory_bytes: 36480
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    cin >> N;

    int K;
    cin >> K;

    int point = 0;
    double prob = 0;

    for (int i = 1; i <= N; i++)
    {
        point = i;
        double prob_temp = 1;

        while (point < K)
        {
            point *= 2;
            prob_temp *= 0.5;
        }
        prob += prob_temp / N;
    }

    // 出力
    cout << fixed << setprecision(10) << prob << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
vector<vector<int> >mp(2010);
int temp;
int n,k;
void dfs(int v,int deep,int front)
{
//	cout<<v<<" "<<deep<<" "<<front<<endl;
	if(deep>k/2) temp++;
	if(mp[v].size()==1&&mp[v][0]==front) return;
	for(int i=0;i<mp[v].size();i++)
	{
		if(mp[v][i]!=front)
		{
			dfs(mp[v][i],deep+1,v);
		}
	}
}
int main()
{	
	scanf("%d %d",&n,&k);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	int res=inf;
	if(k%2==0)
	{
		for(int i=1;i<=n;i++)//Ã¶¾ÙÖÐÐÄµã i
		{
		//	cout<<"i= "<<i<<endl;
			temp=0;
			dfs(i,0,0);
			res=min(res,temp);
		//	cout<<endl;
		}
	}
	else
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<mp[i].size();j++)
			{
				if(mp[i][j]>i)
				{
				//	cout<<i<<" "<<mp[i][j]<<endl;
					temp=0;
					dfs(i,0,mp[i][j]);
					dfs(mp[i][j],0,i);
					res=min(res,temp);
				}
			}
		}
	}
	printf("%d",res);
} 

Measured memory_bytes: 512
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);

int a,b;
vec<vec<int>> l;
vec<int> m;

int main() {
    fast;
    cin>>a>>b;
    l = vec<vec<int>>(b, vec<int>(a));
    for(int q=0; q<b; q++){
        int k; cin>>k;
        for(int w=0; w<k; w++){
            int i; cin>>i;
            l[q][i-1] = 1;
        }
    }

    m = vec<int>(b);
    for(int q=0; q<b; q++) cin>>m[q];
    ll o  =0, all = 1<<a;
    for(int q=0; q<all; q++){
        int cur = 0;
        vec<int> n(a);
        for(int w=a-1, u=q; w>=0; w--, u/=2) n[w] = u&1;
        for(int w=0; w<b; w++){
            int lam = 0;
            for(int e=0; e<a; e++) if(l[w][e] && n[e]) lam++;
            cur+= lam%2 == m[w];
        }
        o += cur==b;
    }
    cout<<o<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, pair<ll, ll>>> v;
  ll t, x, y;
  for (int i = 0; i < N; i++) {
    cin >> t >> x >> y;
    v.push_back({t, {x, y}});
  }
  pair<ll, ll> cur_pos = {0, 0};
  ll cur_t = 0;
  for (int i = 0; i < N; i++) {
    ll diff_t = v[i].first - cur_t;
    ll diff_p = abs(v[i].second.first - cur_pos.first) +
                abs(v[i].second.second - cur_pos.second);
    if (diff_p <= diff_t && diff_t % 2 == diff_p % 2) {
      cur_t = v[i].first;
      cur_pos = v[i].second;
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 6296
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
#include <tuple>
#include <map>
#include <unordered_map>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int i;
	ll n, m;
	priority_queue<ll> que;
	int index;
	ll answer = 0;
	ll tmp;

	cin >> n >> m;	
	
	for (i = 0; i < n; i++) {
		cin >> tmp;
		que.push(tmp);
	}
	for (i = 0; i < m; i++) {
		tmp = que.top();
		que.pop();
		que.push(tmp / 2);
	}

    while (!que.empty()) {
		answer += que.top();
		que.pop();
	}
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

class city{
public:
  long long int pr, year, order;
  static bool cmp(city *a, city *b){
    return (a->year < b->year);
  }
};

class pre{
public:
  vector<city *> c;
};

void solve(){
  int n, m; cin >> n >> m;
  vector<city> c(m);
  for(int i = 0; i < m; i++) cin >> c[i].pr >> c[i].year;
  vector<pre> p(n);
  for(int i = 0; i < m; i++){
    p[c[i].pr - 1].c.push_back(&c[i]);
  }
  /*for(int i = 0; i < n; i++){
    for(int j = 0; j < p[i].c.size(); j++){
      cout << p[i].c[j]->pr << " " << p[i].c[j]->year << endl;
    }
  }*/
  for(int i = 0; i < n; i++){
    sort(p[i].c.begin(), p[i].c.end(), &city::cmp);
    for(int j = 0; j < p[i].c.size(); j++){
      p[i].c[j]->order = j + 1;
    }
  }
  /*for(int i = 0; i < n; i++){
    for(int j = 0; j < p[i].c.size(); j++){
      cout << p[i].c[j]->pr << " " << p[i].c[j]->year << " " << p[i].c[j]->order << endl;
    }
  }*/
  for(int i = 0; i < m; i++){
    cout << setw(6) << setfill('0') << c[i].pr << setw(6) << setfill('0') << c[i].order << endl;
  }
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 9344
#include <stdio.h>
#include <string.h>

int main(void)
{
	char field[102][102];
	int h, w;
	char come[102][102];
	
	while (1){
		int x, y;
		
		scanf("%d%d", &h, &w);
		
		if (h == 0){
			break;
		}
		
		memset(come, 0, sizeof(come));
		
		for (int i = 0; i < h; i++){
			scanf("%s", field[i]);
		}
		
		
		x = y = 0;
		while (come[y][x] == 0 && field[y][x] != '.'){
			come[y][x] = 1;
			
			switch (field[y][x]){
			  case '>':
			  	x++;
				break;
			  case '<':
			  	x--;
				break;
			  case '^':
			  	y--;
				break;
			  case 'v':
			  	y++;
				break;
			}
		}
		
		
		if (come[y][x] == 1){
			puts("LOOP");
		}
		else {
			printf("%d %d\n", x, y);
		}
	}
	
	return (0);
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> PP;
typedef pair<ll,int> Pli;

//-----------------------------------------------------------------------------

ll n,m;

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

	cin>>n>>m;
	if(n==1&&m==1) cout<<1<<endl;
	else if(n==1) cout<<m-2<<endl;
	else if(m==1) cout<<n-2<<endl;
	else cout<<(m-2)*(n-2)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <utility>
#include <valarray>

using namespace std;

namespace {
    int N;
}

void process(deque<int>& S)
{
    if (S[0] == 0){
        S.pop_front();
        --S[0];
        if (S.size() % 2){
            ++S.back();
        }else{
            S.emplace_back(1);
        }
    }else if (S[0] == 1){
        --S[0];
        ++S[1];
    }else{
        --S[0];
        S.emplace_front(1);
        S.emplace_front(0);
    }
}

int main()
{
    int K;
    scanf("%*d %d\n", &K);
    deque<int> S;
    {
        string str;
        getline(cin, str);
        N = str.size();
        // cout << str << endl;
        int count = 0;
        bool A_flag = true;
        for (int i = 0; i < N; ++i){
            if ((str[i] == 'A') != A_flag){
                S.emplace_back(count);
                count = 0;
                A_flag = !A_flag;
            }
            ++count;
        }
        S.emplace_back(count);
    }
    auto print = [](deque<int>& S){
        bool A_flag = true;
        for (int i = 0; i < S.size(); ++i){
            if (A_flag){
                for (int j = 0; j < S[i]; ++j) putchar('A');
            }else{
                for (int j = 0; j < S[i]; ++j) putchar('B');
            }
            A_flag = !A_flag;
        }
        puts("");
    };
    int count = 0;
    map<deque<int>, int> old_map;
    vector<deque<int>> old_vec;
    // old_map.emplace(S, count);
    // old_vec.emplace_back(S);
    while (count < K){
        process(S);
        ++count;
        // printf("%d ", count);
        // print(S);
        if (count >= N * 2){
            if (old_map.count(S)){
                const int first = old_map[S];
                print(old_vec[((K - N * 2 - first) % (count - N * 2 - first)) + first]);
                return 0;
            }else{
                old_map.emplace(S, count - N * 2);
                old_vec.emplace_back(S);
            }
        }
    }
    print(S);
}


Measured memory_bytes: 5312
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int  n,x;
	cin>>n;
	int ans = 0,odd = 0,even = 0;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x%4==0) ans++;
		else if(x&1) odd++;
		else even++;
	}
	if(even){
		if(ans>=odd)  cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
	}
	else {
		if((1+ans)>=odd)   cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
	}
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a=0;string s;cin>>n>>k>>s;
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1))a++;
  }
  cout<<min(k*2+a,n-1)<<endl;
}


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

int main(void){
    long H, N, S;
    cin >> H;
    N = 0;
    while(H > 0){
        H = H/2;
        N++;
    }
    S = pow(2, N)-1;
    cout << S <<endl;
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');


process.stdin.on('data', function (chunk) {
    let n = chunk.toString() // 文字列化する
        .split("\n") // \nで分割
        .map(x => Number(x));
    // .filter(x => x !== );

    let data = n.slice(0, 4);
    let b = n.slice(4, 6);
    data.sort((a, b) => a - b);
    const e = data.slice(1, 5);
    if (b[0] < b[1]) {
        const ans = e[0] + e[1] + e[2] + b[1];
        console.log(ans);

    } else if (b[0] > b[1]) {
        const ans = e[0] + e[1] + e[2] + b[0];
        console.log(ans);
    } else if(b[0] === b[1]){
        const ans = e[0] + e[1] + e[2] + b[0];
        console.log(ans);
    }


})


Measured memory_bytes: 15320
#include<bits/stdc++.h>
#define ll long long int
const int MOD=1000000007;
using namespace std;
int main()
{
	int n;cin>>n;
	vector<ll> a(n);
	vector<ll> suff(n+1);
	suff[n]=0;
	ll ans=0;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=n-1;i>=0;i--)
	{
		suff[i]=(a[i]+suff[i+1])%MOD;
	}
	for(int i=0;i<n-1;i++)
	{
		ans+=(a[i]*suff[i+1])%MOD;
	}
	cout<<ans%MOD<<"\n";
	
	return 0;
	
}

Measured memory_bytes: 6344
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        if(C>=A-B){
            System.out.println(C - A + B);
        }
        else{
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21844
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	
	int n, i, x, y;
	
	cin>>n;
	vector<int> s, e;
	for(i=0;i<n;i++) {
		cin>>x>>y;
		s.PB(x);
		e.PB(y);
	}

	sort(s.begin(), s.end());
	sort(e.begin(), e.end());
	
	if(n&1) {
		cout<<e[n/2]-s[n/2]+1<<endl;
	} else {
		n--;
		LL x1 = s[n/2] + s[n/2 + 1];
		LL y1 = e[n/2] + e[n/2 + 1];
		//~cout<<x1<<" "<<y1<<endl;
		cout<<y1-x1+1<<endl;
	}
    return 0;
}



Measured memory_bytes: 5084
import java.io.*;
import java.util.*;
 
public class Main {
    static long[][]memo;
    static int[]a;
    static int mod = 998244353;
    static long dp(int idx,int sum){
        if (sum<0)
            return 0;
        if (idx==a.length)
            return sum==0?1:0;
        if (memo[idx][sum]!=-1)
            return memo[idx][sum];
        if (sum==0)
            return memo[idx][sum]=(2l*dp(idx+1,sum))%mod;
        long ans = 2*dp(idx+1,sum);
        ans%=mod;
        ans+=dp(idx+1,sum-a[idx]);
        return memo[idx][sum]=ans%mod;
    }
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int s = sc.nextInt();
        a= new int[n];
        memo = new long[n+1][s+1];
        for (long[]z:memo)Arrays.fill(z,-1);
        int[]pow= new int[n+1];
        pow[0]=1;
        for (int i =1;i<=n;i++){
           pow[i]=(2*pow[i-1])%mod;
        }
        for (int i =0;i<n;i++)a[i]=sc.nextInt();
        long ans=0;
        pw.println(dp(0,s));
        pw.flush();
    }
    static long gcd(long a,long b){
        if (a==0)
            return b;
        return gcd(b%a,a);
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;
 
        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }
 
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
 
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        public String nextLine() throws IOException {
            return br.readLine();
        }
 
        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }
 
        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
    bool memo[100001];
    REP(i, N) {
        memo[i] = true;
    }

    REP(i, M) {
        if(H[A[i]-1] < H[B[i]-1]) {
            memo[A[i]-1] = false;
        } else if(H[B[i]-1] < H[A[i]-1]) {
            memo[B[i]-1] = false;
        } else {
            memo[A[i]-1] = false;
            memo[B[i]-1] = false;
        }
    }

    int ans = 0;
    REP(i, N) {
        ans += memo[i];
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}



Measured memory_bytes: 5660
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<P> a(m);
    REP(i, m) cin >> a[i].first >> a[i].second;
    sort(all(a), greater<P>());
    int cut = n+1;
    int ans = 0;
    for(auto &p : a){
        if(cut < p.second) continue;
        ans++;
        cut = p.first;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
N = int(input())
h = list(map(int, input().split()))
list = [0 for _ in range(N)]
list[0] = 0
list[1] = abs(h[1]-h[0])
for i in range(2, N):
  list[i] = min(abs(h[i] - h[i-1]) + list[i-1], abs(h[i] - h[i-2]) + list[i-2])
print(list[N-1])

Measured memory_bytes: 52720
X = int(input())

if 400<=X<=599:
  print(8)
elif 600<=X<=799:
  print(7)
elif 800<=X<=999:
  print(6)
elif 1000<=X<=1199:
  print(5)
elif 1200<=X<=1399:
  print(4)
elif 1400<=X<=1599:
  print(3)
elif 1600<=X<=1799:
  print(2)
elif 1800<=X:
  print(1)

Measured memory_bytes: 61608
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;

long long f[100010];


int main()
{
    int n,w;scanf("%d%d",&n,&w);
    // f[i][j]= f[i-1][j] / f[i-1][j-w[i]]+v[i];
    for (int i=0;i<n;++i){
        int ww,vv;scanf("%d%d",&ww,&vv);
        for (int j=w;j>=ww;--j)
            if (f[j-ww]+vv>f[j])
                f[j]=f[j-ww]+vv;
    }
    printf("%lld\n",f[w]);

}











Measured memory_bytes: 896
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,1,-1,0,1,-1,0};
int main(){
    int n;cin>>n;
    int a[110];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [0] * 45
    for v in a:
        d = 0
        while True:
            bt = v >> d
            if bt != 0:
                ls[d] += bt & 1
                d += 1
            else:
                break
    t = 0
    for i in range(44, -1, -1):
        if n / 2 >= ls[i]:
            t += 2 ** i
            if t > k:
                t -= 2 ** i
    ans = 0
    for v in a:
        ans += v ^ t
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 63628
#include <bits/stdc++.h>
 
using namespace std;
 
#define ff              first
#define ss              second
#define ar              array
#define ll              long long
#define ld              long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define f1(i,n)         for(int i=1;i<=n;i++)
#define fl(i,n)         for(int i=n-1;i>=0;i--)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int> 
#define cout1(a)          cout << a << endl;
#define cout2(a, b)       cout << a << " " << b << endl;
#define cout3(a, b, c)    cout << a << " " << b << " " << c << endl;
#define cout4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl;
#define cin1(a)           cin >> a;
#define cin2(a, b)        cin >> a >> b;
#define cin3(a, b, c)     cin >> a >> b >> c;
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d;
#define check             cout << "check" << endl;
#define all(c)            (c).begin(),(c).end() 

void pv(vector<int>amount)
{
	for (auto i = amount.begin(); i != amount.end(); i++)
		cout << *i << " ";
	cout << endl;
}
void pv(vector<ll>amount)
{
	for (auto i = amount.begin(); i != amount.end(); i++)
		cout << *i << " ";
	cout << endl;
}
void pv(vector<double>amount)
{
	for (auto i = amount.begin(); i != amount.end(); i++)
		cout << *i << " ";
	cout << endl;
}
void pv(vector<string>amount)
{
	for (auto i = amount.begin(); i != amount.end(); i++)
		cout << *i << " ";
	cout << endl;
}
void pv(vector<bool>amount)
{
	for (auto i = amount.begin(); i != amount.end(); i++)
		cout << *i << " ";
	cout << endl;
}

class hitler
{	
	public:
		hitler()
		{
			cout1("DoneDone");
		}
		~hitler()
		{
			cout1("Crash");
		}
		void fun()
		{
			cout1("enter");
		}
	protected:
		int age=10;	
};

class mein:hitler
{
	public:
		mein()
		{
			cout1("Donebhai");
		}
		~mein()
		{
			cout1("Blast");
		}
		void printage(void)
		{
			cout1(age);
		}
};
ll sum=0;
int n;


int main()
{   ll k;
    cin>>n>>k;
    vi vec(n+1);
    f1(i,n)
    {
        cin>>vec[i];
    }
    vi dp(n+1,INT_MAX);

    dp[1] = 0;
    ll c;
	//dp[2] = abs(vec[2] - vec[1]);
    for(int i=2;i<=n;i++)
    {   
        if(i-1<k)
        {
            c=i-1;
        }
        else
        {
            c=k;
        }
        
        f1(j,c)
        {   
            if(dp[i]> dp[i-j]+abs(vec[i]-vec[i-j]))
                dp[i]=dp[i-j]+abs(vec[i]-vec[i-j]);
        }
    }
    cout1(dp[n]);
    
	

}
 

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

int main(){
    char instr[4];
    int a,b,c,d;
    char pm[4];
    int i,j,k,l;
    int ans;

    cin >> instr ;
    a = instr[0]-'0';
    b = instr[1]-'0';
    c = instr[2]-'0';
    d = instr[3]-'0';

    for(i=0;i<2;i++){
        for(j=0;j<2;j++){
            for(k=0;k<2;k++){
                ans = a+b*pow(-1,i)+c*pow(-1,j)+d*pow(-1,k); 
          //      cout << i << j << k << " "<< ans << endl;
              //  cout << pow(-1,i)<<endl;
                if(ans == 7) break;      
            }
            if(ans == 7) break;       
        } 
        if(ans == 7) break;      
    }
    if(i==0) pm[0]='+';
    else pm[0]='-';

    if(j==0) pm[1]='+';
    else pm[1]='-';

    if(k==0) pm[2]='+';
    else pm[2]='-';
    
    if(ans == 7) 
        cout << a << pm[0]<<b<<pm[1]<<c<<pm[2] <<d << "=7" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int A, B, C, D;
	int min_money;
	min_money = 0;
	cin >> A >> B >> C >> D;
	if (A >= B) {
		min_money += B;
	}
	else {
		min_money += A;
	}
	if (C >= D) {
		min_money += D;
	}
	else {
		min_money += C;
	}
	cout << min_money << endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define inp(a) for(auto& i : a) cin >> i;
#define out(a) for(auto i : a){cout << i << ' ';}cout << endl;
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
#define LOCAL
#define int long long
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;

int solve(int mx){
	int cnt = 0 ;
	while(mx){
		cnt++ ;
		mx /= 10 ;	
	}
	return cnt ;
}

int32_t main(){_
	int n,k ;
	cin >> n ;
	int mx = -INF ;
	for(int i = (int)(sqrt(n)) ; i > 0 ; i--){
		if(n%i == 0){
			mx = max({mx , solve(i), solve(n/i)}) ;
			break ;
		}
	}
	cout << mx << endl ;
}


Measured memory_bytes: 256
N, x, M = [int(a) for a in input().split()]

# Let g(i) = x ^ (2^i) mod M
g = [x] + [0] * M
ginv = [-1] * (M + 1)
ginv[x] = 0
partSum = [x] + [0] * (M + 1)     # partSum[-1] = 0 となるようにダミーを追加

for i in range(1, M + 1):
    g[i] = g[i - 1] * g[i - 1] % M
    if ginv[g[i]] >= 0:  # detected cycle
        iStart = ginv[g[i]]
        cycleSum = partSum[i - 1] - partSum[iStart - 1]
        cycleLen = i - iStart

        numCycle = (N - 1 - (i - 1)) // cycleLen
        remCycle = (N - 1 - (i - 1)) % cycleLen
        ans = partSum[i - 1] + cycleSum * numCycle + partSum[iStart + remCycle - 1] - partSum[iStart - 1]
        break
    else:
        ginv[g[i]] = i
        partSum[i] = partSum[i - 1] + g[i]

print(ans)

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

int main(){

  int n;
  while( cin >> n, n ) {
    map<string, int> d;
    for(int i=0; i<n; i++) {
      string s;
      int p;
      cin >> s >> p;
      d[s] = p;
    }

    int m;
    cin >> m;
    for(int i=0; i<m; i++) {
      string s;
      int k, cost = 0;
      cin >> s >> k;
      for(int i=0; i<k; i++) {
	string q;
	cin >> q;
	cost += d[q];
      }

      if( d[s] > cost ) {
	d[s] = cost;
      }
    }

    string s;
    cin >> s;
    cout << d[s] << endl;
  }
}

Measured memory_bytes: 1224
s = gets.chomp.split("")
size = s.size
count = 0
if size % 2 == 0
    until s == []
        if s.pop != s.shift
            count += 1
        end
    end
else
    until s.size == 1
        if s.pop != s.shift
            count += 1
        end
    end 
end
puts count

Measured memory_bytes: 14308
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

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


	printf("%d", (a + b)%24);


}

Measured memory_bytes: 128
from collections import defaultdict

H,W,N = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

Cells = defaultdict(int)
Count = [(H-2)*(W-2)] + [0 for _ in range(9)]

for a,b in AB:
  a -= 1
  b -= 1
  for i in range(-1,2):
    for j in range(-1,2):
      if 1 <= a+i <= H-2 and 1 <= b+j <= W-2:
        Count[Cells[(a+i,b+j)]] -= 1
        Count[Cells[(a+i,b+j)]+1] += 1
      Cells[(a+i,b+j)] += 1
for c in Count:
  print(c)

Measured memory_bytes: 174284
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)(n);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
// struct before_main_function {
//     before_main_function() {
//         #ifdef int
//             #undef INF
//             #define INF INFLL
//             #define stoi stoll
//             cerr<<"\x1b[7m"<<"'int' is 'long long'"<<"\x1b[m"<<endl;
//         #endif
//         cin.tie(0);ios::sync_with_stdio(false);
//         cout<<setprecision(15)<<fixed;
//     }
// } before_main_function;
//------------------------------------------------------------------------------

struct RMQ {
    int n;
    vector<int> dat;
    RMQ(int n_=0) {
        n=1;
        while(n<n_) n*=2;
        dat=vector<int>(n*2-1,2147483647);
    }
    void update(int i,int x) {
        i+=n-1;
        dat[i]=x;
        while(i>0) {
            i=(i-1)/2;
            dat[i]=min(dat[i*2+1],dat[i*2+2]);
        }
    }
    int query(int a,int b) {
        return query(a,b,0,0,n);
    }
    int query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return 2147483647;
        if(a<=l and r<=b) return dat[k];
        int ml=query(a,b,k*2+1,l,(r+l)/2);
        int mr=query(a,b,k*2+2,(r+l)/2,r);
        return min(ml,mr);
    }
};
signed main() {
    int n,q;
    cin>>n>>q;
    RMQ segtree(n);
    while(q--) {
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0) {
            segtree.update(x,y);
        }
        else {
            cout<<segtree.query(x,y+1)<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4940
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();
    int ans = 0;

    for (int i = 0; i <= a; i++) {
      for (int j = 0; j <= b; j++) {
        for (int k = 0; k <= c; k++) {
          if (x == 500 * i + 100 * j + 50 * k) {
            ans++;
          }
        }
      }
    }
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 35896
#include <bits/stdc++.h>
#define inf 111111111
using namespace std;

int h, n, dp[10001], a[1001], b[1001], dif, rez = inf;

int main()
{
    cin >> h >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i <= h; ++i) dp[i] = inf;

    dp[h] = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = h; j >= 0; --j)
        {
            dp[max(0, j - a[i])] = min(dp[max(0, j - a[i])], dp[j] + b[i]);
        }
        rez = min(rez, dp[0]);
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 256
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        s: chars,
    }
    let s = s
        .iter()
        .map(|&c| if c == '0' { 'b' } else { 'w' })
        .collect::<Vec<char>>();

    let mut bw = 0;
    let mut wb = 0;
    for (i, &c) in s.iter().enumerate() {
        match (i % 2, c) {
            (0, 'b') => bw += 1,
            (0, 'w') => wb += 1,
            (1, 'w') => bw += 1,
            (1, 'b') => wb += 1,
            _ => (),
        }
    }
    println!("{}", std::cmp::min(bw, wb));
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct RangeSumQuery {
	int n;
	vector<int>d;
	RangeSumQuery(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, 0);
	}
	void add(int i, int x) {
		d[n + i] += x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)d[j] += x;
	}
	int sum(int a, int b) {
		return sum(a, b, 1, 0, n);
	}
	int sum(int a, int b, int k, int l, int r) {
		// [a,b) [l,r)
		if (r <= a || b <= l)return 0;
		else if (a <= l&&r <= b)return d[k];
		else {
			int vl, vr;
			vl = sum(a, b, 2 * k, l, (l + r) / 2);
			vr = sum(a, b, 2 * k + 1, (l + r) / 2, r);
			return vl + vr;
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeSumQuery<int>rsq(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << rsq.sum(x - 1, y) << endl;
		else rsq.add(x - 1, y);
	}
	return 0;
}

Measured memory_bytes: 3876
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ').ToArray();
            // 文字列の個数
            int N = int.Parse(str[0]);
            // 文字列の長さ
            int L = int.Parse(str[1]);
            string[] S = new string[N];
            for (int i = 0; i < N; ++i)
            {
                S[i] = Console.ReadLine();
            }

            Array.Sort(S);
            Console.WriteLine(string.Join("", S));
        }
    }
}

Measured memory_bytes: 13268
# ABC119D - Lazy Faith
from bisect import bisect_right as bsr


def dist(x: int) -> int:
    i, j = bsr(S, x), bsr(T, x)
    ret = min(
        min(abs(s - x) + abs(t - s), abs(t - x) + abs(s - t))
        for s in S[i - 1 : i + 1]
        for t in T[j - 1 : j + 1]
    )
    return ret


def main():
    global S, T
    A, B, Q, *STX = map(int, open(0).read().split())
    INF = 1 << 60
    S, T, X = [-INF] + STX[:A] + [INF], [-INF] + STX[A : A + B] + [INF], STX[A + B :]
    ans = [dist(x) for x in X]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 40284
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e18;

int main(){
    cout << fixed;
    cout << setprecision(10);
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        
        vector<double> px(n),py(n),pz(n),vx(n),vy(n),vz(n),r(n),vr(n);
        for(int i=0; i<n; i++){
            cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
        }
        vector<pair<double, pair<int,int> > > time;
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                double a,b,c; //coef of quad eq
                a = ((vx[i]-vx[j])*(vx[i]-vx[j])
                     +(vy[i]-vy[j])*(vy[i]-vy[j])
                     +(vz[i]-vz[j])*(vz[i]-vz[j]))
                    -(vr[i]+vr[j])*(vr[i]+vr[j]);

                b = 2 *((px[i]-px[j])*(vx[i]-vx[j])
                        +(py[i]-py[j])*(vy[i]-vy[j])
                        +(pz[i]-pz[j])*(vz[i]-vz[j]))
                    +2 *(vr[i]+vr[j])*(r[i]+r[j]);
                c = ((px[i]-px[j])*(px[i]-px[j])
                     +(py[i]-py[j])*(py[i]-py[j])
                     +(pz[i]-pz[j])*(pz[i]-pz[j]))
                    -(r[i]+r[j])*(r[i]+r[j]);
                double d = b*b -4*a*c;
                if(d < -EPS) continue;
                if(d < 0) d = 0;
                double sol[2] = {(-b+sqrt(d))/(2*a), (-b-sqrt(d))/(2*a)};
                for(int k=0; k<2; k++){
                    if(sol[k] > 0){
                        time.push_back(make_pair(sol[k], make_pair(i, j)));
                    }
                }
            }
        }
        for(int i=0; i<n; i++){
            time.push_back(make_pair(r[i]/vr[i], make_pair(i, i)));
        }
        sort(time.begin(), time.end());
        vector<double> ans(n, INF);
        for(int i=0; i<(int)time.size(); i++){
            int s1 = time[i].second.first;
            int s2 = time[i].second.second;
            double t = time[i].first;
            if(ans[s1]==INF && ans[s2]==INF){
                ans[s1] = ans[s2] = t;
            }
        }
        for(int i=0; i<n; i++){
            cout << ans[i] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3800
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;





int main(){

	int a;
	char buf[11];

	scanf("%d",&a);
	scanf("%s",buf);

	if(a >= 3200){

		printf("%s\n",buf);

	}else{

		printf("red\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {
  
  ll N, K;
  cin >> N >> K;
  vector<ll> P(N), C(N);
  rep(i,N) {
    cin >> P[i];
    P[i]--;
  }
  rep(i,N) cin >> C[i];

  ll ans = (-1) * LINF;

  rep(i,N) {
    int now = i;
    ll loopScore = 0;
    ll loopCount = 0;
    while (true) {
      now = P[now];
      loopScore += C[now];
      loopCount++;
      if (now == i) break;
    }

    ll count = K;
    ll score = 0;

    if (K / loopCount >= 2 && loopScore > 0) {
      score += loopScore * (K / loopCount - 1);
      count -= loopCount * (K / loopCount - 1);
      ans = max(ans, score);
    } else if (loopScore <= 0) {
      count = loopCount;
    }

    while (count > 0) {
      now = P[now];
      score += C[now];
      ans = max(ans, score);
      count--;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3696
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    vector<ll> T(N);

    rep(i, N) { cin >> T[i]; }
    sort(all(T));

    vector<bool> ride(N, false);

    ll ans = 0;
    rep(i, N) {
        if (!ride[i]) {
            ll limit = T[i] + K;
            ll cnt = 0;
            while (T[i] <= limit && cnt < C && i < N) {
                ride[i] = true;
                i++;
                cnt++;
            }
            i--;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
	int a, b, c, x, i, j;
	int ans = 0;
	int m, n;
	int s50;
	int mon;
	scanf("%d %d %d %d", &a, &b, &c, &x);
	m = x / 500;
	n = x / 100;
	if(x >= 500)
	{
		for(i = 0 ; i <= m ; i++)
		{
			for(j = 0 ; j <= n ; j++)
			{
				mon = x - i * 500 - j * 100;
				s50 = mon / 50;
				if(mon >= 0 && i <= a && j <= b && s50 <= c)
				{
					ans++;
				}
			}
		}
	}
	else
	{
		for(i = 0 ; i <= n ; i++)
		{
			mon = x - i * 100;
			s50 = mon / 50;
			if(s50 <= c && i <= b)
			{
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()
from collections import deque

def is_ok(l):
    hs = set()
    q = deque()
    for i in range(N-l+1):
        h = hash(S[i:i+l])
        if h in hs:
            return True
        q.append(h)
        if len(q) >= l:
            hs.add(q.popleft())
    return False

ok = 0
ng = N//2+1
while ng-ok > 1:
    m = (ng+ok)//2
    if is_ok(m):
        ok = m
    else:
        ng = m
print(ok)

Measured memory_bytes: 43612
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

int rsolve(int k, int n) {
	while (n % k && n >= k) {
		n -= n / k + 1;
	}
	if (n < k) return 0;
	return n / k;
}

int solve(int k, int n) {
	while (n % k && n >= k) {
		//n/k = const
		//minn = (n / k) * k
		int minn = (n / k) * k;
		int delta = (n - minn);
		int cnt = (delta) / (n / k + 1);
		if (cnt > 0) {
			n -= cnt * (n / k + 1);
		} else {
			n -= n / k + 1;
		}
	}
	if (n < k) return 0;
	return n / k;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int x = 0;
	int n;
	cin >> n;
	while (n--) {
		int a, k;
		cin >> a >> k;
		x ^= solve(k, a);
	} 
	if (x) {
		cout << "Takahashi" << endl;
	} else {
		cout << "Aoki" << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <atcoder/all>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
using namespace atcoder;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q; cin >> N >> Q;
  fenwick_tree<ll> ft(N);
  REP(i, N){
    ll a; cin >> a;
    ft.add(i, a);
  }
  REP(i, Q){
    int q; cin >> q;
    if(q == 0){
      int p; ll x; cin >> p >> x;
      ft.add(p, x);
    }else{
      int l, r; cin >> l >> r;
      ll ans = ft.sum(l, r);
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 8240
for num in range(9):
    a,b,c = input().split(" ")
    num1 = int(b) * 200
    num2 = int(c) * 300
    num3 = int(b) + int(c)
    num4 = num1 + num2
    print(a + " " + str(num3) + " " + str(num4))
    continue


Measured memory_bytes: 5588
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n,k;
    cin>>n>>k;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    int ans=0;
    rep(i,k)ans+=a[i];
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3636