akhauriyash/Code-Regression huggingface dataset:
/*
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  string S;
  cin >> S;
  for(int i = 0; i < (1 << 4); i++) {
    string s;
    s += S[0];
    int sum = S[0] - '0';
    for(int j = 1; j < 4; j++) {
      if((i >> j) & 1) s += "+", sum += S[j] - '0';
      else s += "-", sum -= S[j] - '0';
      s += S[j];
    }
    if(sum == 7) {
      cout << s << "=7" << endl;
      return (0);
    }
  }
}
*/

#include <bits/stdc++.h>
using namespace std;
int main(){
 
string S;
cin>>S;


for(int tmp=0;tmp<(1<<3);tmp++){
  string s;
  s+=S.at(0);
  int sum=S.at(0)-'0';
  for(int i=0;i<3;i++){
    if((tmp>>i)&1){//trueの時+
     s+="+";
     sum +=S.at(i+1)-'0';
     
     }else{
       s+="-";
       sum-=S.at(i+1)-'0';
       
    }s+=S.at(i+1);
  }
  if(sum==7){cout<<s<<"=7"<<endl;
             return 0;
            }
  
}
}

Measured memory_bytes: 256
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    N,M = map(int, input().split())
    a = [int(input()) for _ in range(M)]
    res = [0]*(N+1)
    res[0] = 1
    k = 0
    for i in range(1,N+1):
        if k<M:
            if i==a[k]:
                k += 1
                continue
        res[i] = (res[i-1]+res[i-2]) % mod
    print(res[-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 8208
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;

	rep2(i, 1, 10) {
		rep2(j, 1, 10) {
			if (i*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
    cout << "No" << endl;
}

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

int main() {
    int K, S;
    cin >> K >> S;

    int C = 0;

    for (int i = 0; i <= K; i++){
        for (int j = i; j <= K; j++){
            for (int l = j; l <= K; l++){
                if (i + j + l == S){
                    if (i == j && i == l && j == l){
                        C++;
                    } else if (i == j || j == l){
                        C += 3;
                    } else {
                        C += 6;
                    }
                }
            }
        }
    }
    
    cout << C << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  scanf("%d",&N);
  std::map<int, int, std::greater<int> > r;
  std::map<int, int> b;
  int temp1, temp2;
  for (int i=0; i<N; i++){
    scanf("%d",&temp1);
    scanf("%d",&temp2);
    r.insert(std::make_pair(temp2, temp1));
  }
  for (int i=0; i<N; i++){
    scanf("%d",&temp1);
    scanf("%d",&temp2);
    b.insert(std::make_pair(temp1, temp2));
  }
  //r(y,x) yでソート
  //b(x,y) xでソート
  int ans = 0;
  for (auto const& Bentry: b){
    //std::cout << "==========---" << std::endl;
    //std::cout<<"B:("<<Bentry.first << ","<<Bentry.second<<")"<<std::endl;
    //std::cout<<"R size=" << r.size() << std::endl;
    decltype(r)::iterator itr = r.lower_bound(Bentry.second);
    decltype(r)::iterator last = r.lower_bound(-1);
    if (itr==last){
      //std::cout<<"not found" << std::endl;
      continue;
    }
    while(itr!=last){
      //std::cout<<"checking " << itr->second << "<" <<  Bentry.first << std::endl;
      if (itr->second < Bentry.first){ // RのxがBのxより小さければ
        ans++;
        //std::cout<<"found" << std::endl;
        //std::cout<<"easing (" << itr->second << "," << itr->first << ")" << std::endl;
        r.erase(itr);
        break;
      }
      itr++;
    }
  }
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

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


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

#define  ll long long int
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define si(a) a.size()
#define p pair< ll,ll >
#define v vector< ll >
#define vi vector<p>
#define mem(tabl,i) memset(tabl, i, sizeof(tabl))
#define sp(x,y) fixed<<setprecision(y)<<lf(x)
#define debug(c) cout << #c << " = " << c << endl;
#define  f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define Mod 1000000007

const int N = 1e5 + 5;

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

           string s;
           ll n,k,b,c,x,y,z;
           ll counter=0,counter1=0,counter2=0;
           ll sum=0,result=0,ans=0, flag=0;
           cin>>n>>k;
           ll a[n];
           f(i,0,n)
           {
                cin>>a[i];
                  sum+=a[i];
           }

           double xi=(double)sum/(4*k);

           f(i,0,n)
           {
               if(a[i]>=xi)
               {
                    counter++;
               }

           }
           if(counter>=k)
            cout<<"Yes"<<endl;
           else
            cout<<"No"<<endl;




}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int h,k,n,s=0;
    cin >> n >> k;
    int a[n];
    for(long long int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    for(long long int i=0;i<n-k;i++)
    {
        s=s+a[i];
    }
    cout << s;
}

Measured memory_bytes: 1024
#include <iostream>

int main() {
  int N;
  std::cin >> N;
  N += 1;
  char a[N], b[N];
  int i = 0;
  std::cin >> a >> b;
  for(int i=0; i<N-1; ++i) std::cout << a[i] << b[i];
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  ll l = 1, r = 1;
  for(int i = 0; i < n; i++){
    int t, a;
    cin >> t >> a;
    ll pro = max((l + a - 1) / a, (r + t - 1) / t);
    l = a * pro;
    r = t * pro;
  }
  cout << l + r << endl;
	return 0;
}


Measured memory_bytes: 256
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 1005, mod = 1e9+7;
int n, m, dp[MAX_N][MAX_N];
char G[MAX_N][MAX_N];

void input() {
    RI(n, m);
    REP(i, n) {
        scanf("%s", G[i]);
    }
}

void solve() {
    dp[0][0]=1;
    REP(i, n) {
        REP(j, m) {
            if(G[i][j] == '.') {
                if(i>0) dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
                if(j>0) dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
            }
        }
    }
    printf("%d\n", dp[n-1][m-1]);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
ll cum[200010]; 
int main() {
  int n;
  cin >> n;
  //vector<ll> a(n);
  ll ans = 1e10, sum = 0;
  rep(i,n) {
    ll a; cin >> a;
    cum[i+1] = cum[i] + a;
    sum += a;
  }
  for (int i = 1; i < n; i++)
  {
    ans = min(ans, abs(2*cum[i]-sum));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5100
#include <iostream>

using namespace std;

int N;
long long int a[55];

int main(void) {

	cin >> N;

	long long int tmp;

	for (int i = 1; i <= N; i++) {
		cin >> tmp; a[i] = tmp;
	}

	int sig = 0;
	int max_ab = 0;
	int I;
	for (int i = 1; i <= N; i++) {
		if (abs(a[i]) >= max_ab) { max_ab = abs(a[i]); I = i; if (a[i] >= 0) { sig = 1; }
		else { sig = -1; }
		}
	}


	cout << 2 * N-1 << endl;
	if (sig == 1) {
		for (int i = 1; i <= N; i++) {
			cout << I << " " << i << endl;
		}
		for (int i = 1; i <= N-1; i++) {
			cout << i << " " << i + 1 << endl;
		}
	}
	else {
		for (int i = 1; i <= N; i++) {
			cout << I << " " << i << endl;
		}
		for (int i = N; i >= 2; i--) {
			cout << i << " " << i - 1 << endl;
		}

	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int s=0,t=0,n=0;
  for(int a,b;;n++){
    if(scanf("%d,%d",&a,&b) == EOF) break;
    s+=a*b;
    t+=b;
  }
  if(((t*10)/n)%10>4) t = t/n+1;
  else t/=n;
  cout <<s<<endl<<t<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
// #define DEBUG 100
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll >;
 
const ll oo = 1e18 + 7;
const ll mod = 1e9 + 7,maxn = 1e5 + 100, maxm = 1e5+100;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;

    if (s.back() == 's') s += "es";
    else s += 's';

    cout<< s << endl;
    return 0;
}

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

typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int MOD = 1e9 + 7 ;
const double PI = 2 * acos(0.0);

int main()
{
  ll ans ;
  ll n ;
  cin >> n ;
  for(int i = 0; i <= 41; i++) {
    if(ceil(pow(2, i) > n)) {
      ans = ceil(pow(2, i)) - 1 ;
      cout << setprecision(12) << ans << endl ;
      break ;
    }
  }
}


Measured memory_bytes: 512
s = input()
if s[0] == '>':
  a = [0]
else:
  a = []
flg = 1
for i in range(1,len(s)):
  if s[i] != s[i-1]:
    a.append(flg)
    flg = 1
  else:
    flg += 1
a.append(flg)
if s[-1] == '<':
  a.append(0)
ans = 0
for i in range(len(a)//2):
  if a[2*i] > a[2*i+1]:
    a[2*i+1] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
  else:
    a[2*i] -= 1
    ans += a[2*i]*(a[2*i]+1)//2 + a[2*i+1]*(a[2*i+1]+1)//2
print(ans)

Measured memory_bytes: 6300
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		Set<Integer> m = new HashSet<>();
		for(int i = 0; i<3; i++) {
			m.add(sc.nextInt());
		}
		System.out.println(m.size());
		
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/* -------------------------------Solution Sarted--------------------------------------*/
//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5

void solve(){
	int n, cnt = 0;
	cin >> n;
	vi a(n);
	scnarr(a, n);
	for(int i = 1; i <= n; i += 2){
		if(a[i -1]&1)
			cnt++;
	}
	cout << cnt << endl;
}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    int a, b;
    cin>>a>>b;
    cout<<a*1ll*b<<endl;
    return 0;
}


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

int main()
{
	int n;
	cin>>n;
	for ( int i=0; i<n; i++ )
	{
		int a[3];
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		cout << (a[0]*a[0]+a[1]*a[1]==a[2]*a[2]?"YES":"NO") << endl;
		
	}

	return 0;
}

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

int main() {
	int x;
	cin >> x;
	if (x >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3596
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "d.cpp"

vl gen_primes(ll n) {
  vector<bool> is_prime(n+1, true);
  is_prime[0] = is_prime[1] = false;
  rep(i, n+1) {
    if (is_prime[i]) {
      for (ll j = 2*i; j <= n+1; j += i) {
        is_prime[j] = false;
      }
    }
  }
  vl res;
  rep(i, n+1) {
    if (is_prime[i])
      res.push_back(i);
  }
  return res;
}

int main() {
  auto vec = gen_primes(55'555);
  ll n;
  cin >> n;
  for (auto&& i : vec) {
    if (n and i%5 == 2) {
      n--;
      cout << i << " ";
    }
  }
  cout << el;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	ll n;
	while(cin>>n&&n){
		ll ans=0;
		rep(i,256+1){
			for(int j=i;j<256+1;j++){
				for(int k=j;k<256+1;k++){
					ll sum=0;
					sum+=i*i + j*j + k*k;
					if(sum>n)continue;
					
					ll diff = n-sum;
					if((int)sqrt(diff)*(int)sqrt(diff) == diff && sqrt(diff)>=k){
						ans++;
					}
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

const int N = 1000 * 100 + 10;
int n, a[N], tt = 0;
string ans[2] = {"First\n", "Second\n"};

void solve() {
	long long sum = 0;
	bool one = false;
	int cnt[2] = {0, 0};
	for (int i = 0; i < n; i++) {
		 one |= a[i] == 1;
		sum += a[i] - 1;
		cnt[a[i] & 1]++;
	}
	if (one) {
		cout << ans[(sum + 1 + tt) & 1];
		exit(0);
	}
	if (n == 1) {
		cout << ans[(sum + 1 + tt) & 1];
		exit(0);
	}
	if (cnt[0] & 1) {
		cout << ans[tt & 1];
		exit(0);
	}
	if (cnt[1] >= 2) {
		cout << ans[(1 + tt) & 1];
		exit(0);
	}
	for (int i = 0; i < n; i++)
		if (a[i] & 1) {
			a[i]--;
			break;
		}
	long long g = a[0];
	for (int i = 1; i < n; i++)
		g = __gcd(1LL * a[i], g);
	for (int i = 0; i < n; i++)
		a[i] /= g;
	tt++;
	solve();
}

int main() { 
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	solve();
	return 0;
}


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

int main(){
	long n, k, a, b;
	map <long, long> input;
	cin >> n >> k;
	for (long i = 0; i < n; ++i){
		cin >> a >> b;
		input[a] += b;
	}
	for(auto itr = input.begin(); itr != input.end(); ++itr) {
		if (0 >= (k -= itr->second)){
			cout << itr->first << endl;
			break;
		}
    }
}

Measured memory_bytes: 4224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int l = in.nextInt();
            int[] t = new int[n];
            for (int i = 0; i < n; ++i) t[i] = in.nextInt();
            double koef = 0.5 * Math.PI / l;
            double rx = 0;
            double ry = 0;
            for (int i = 0; i < n; ++i) {
                double sum = 0;
                double sofar = 0;
                for (int j = 1, k = i + 1; j < n; ++j, ++k) {
                    if (k >= n) k = 0;
                    int delta = t[i] - t[k];
                    if (delta < 0) delta += l;
                    double f = Math.tan(koef * delta);
                    sum += f * sofar;
                    delta = t[k] - t[i];
                    if (delta < 0) delta += l;
                    f = Math.tan(koef * delta);
                    sofar += f;
                }
                sum = (n - 1) * (n - 2) / 2 - sum;
                sum = 0.5 * sum;
                rx += Math.cos(koef * t[i] * 4.0) * sum;
                ry += Math.sin(koef * t[i] * 4.0) * sum;
            }
            rx /= n * (n - 1) * (double) (n - 2) / 6;
            ry /= n * (n - 1) * (double) (n - 2) / 6;
            out.println(rx + " " + ry);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
  string S;
  cin >> S;
  int cnta = 0, cntb = 0;
  for(int i = 0;i < S.size();i++){
    if(S[i] == '0')cnta++;
    else cntb++;
  }
  cout << min(cnta, cntb) * 2 << endl;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;

    cin>>s;
    lli k=s.size();
    lli c=0;
    rep(i,s.size()){
        if (s[i]=='o') {
            c++;
        }
    }
    YES(c+(15-k)>7);

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n,k,x,y; cin>>n>>k>>x>>y;
  int ans;
  if(n<=k) ans=x*n;
  else ans=x*k+(n-k)*y;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}

int main(){
    ll n,k,ans = 0,wa = 1000000007;
    cin >> n >>k;

    vector<ll> vec(n);
    vector<ll> cnt(n);
    
    REP(i,n){cin >> vec[i];
             cnt[i] = 0;}

    REP(i,n){
        FOR(j,i+1,n){
            if(vec[i] > vec[j]){
                cnt[i] ++;
            }
        }
    }

    vector<ll> cnt2(n);
    REP(i,n) cnt2[i] = 0;

    REP(i,n){
        for(int j = 0 ; j < i ; j++){
            if(vec[i] > vec[j]) cnt2[i] ++;
        }
    }

    REP(i,n){
        ans += cnt[i] *(((k+1)*k /2)%wa);
        ans += cnt2[i] * (( (k)*(k-1)/2 )%wa);
    }
    cout << ans%wa<<endl;
}






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

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

    int N = scanner.nextInt();
    int[] L = new int[N];
    for (int i = 0; i < N; i++) L[i] = scanner.nextInt();
    Arrays.sort(L);
    long res = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        int c = upperBound(L, L[i] + L[j]);
        res += Math.max(0, c - j);
      }
    }
    System.out.println(res);
  }

  private static int upperBound(int[] a, int k) {
    int left = -1;
    int right = a.length;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a[mid] < k) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }
}


Measured memory_bytes: 27136
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;
int H,W;
string S[51][51];
int bom[51][51];
int main(){
    cin>>H>>W;

    string a;
    REP(h,H)
    //REP(w,W)
    {

        //cin>>S[h][W];
        cin>>a;
        cerr<<a<<endl;
        REP(i,a.size()){
            S[h][i]=a[i];
        }
    }

   
    // cerr<<"test"<<endl;
    // REP(h,H){
    //     REP(w,W){

    //        cerr<<S[h][w];
    //     }
    //     cerr<<endl;
    // }


    CLR(bom);
    int direch[8]={-1,0,1,-1,0,1,-1,1};
    int direcw[8]={1,1,1,-1,-1,-1,0,-0};
    
    REP(h,H){
        REP(w,W){
            
            for(int i=0;i<8;i++){
                int h2=h+direch[i];
                int w2=w+direcw[i];
                if(h2<0||h2>=H){continue;}
                if(w2<0||w2>=W){continue;}
                
                if(S[h2][w2]=="#"){
                    bom[h][w]++;
                }
            }
            
        }
    }

    REP(h,H){
        REP(w,W){

            if(S[h][w]!="#"){
           cout<<bom[h][w];
            }
            else{
                cout<<'#';
            }
            
        }
        cout<<endl;
    }




}


Measured memory_bytes: 384
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int a, b, c, d;
    cin >> a >> b >> c;
    if( a > b ){
    d = a; a = b; b = d;
    }
    if( b > c ){
    d = b; b = c; c = d;
    }
    if( a > b ){
    d = a; a = b; b = d;
    }
    cout << a + b << endl;
    return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<queue>
using namespace std;

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

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

    if(N*M == 15) put("*");
    else if(N+M == 15) put("+"); 
    else put("x");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
//#include <functional>
#include <queue>
//#include <stack>
//#include <set>
#include <cmath>
//#include <bitset>
#include <map>
using namespace std;
typedef long long ll;



int main() {
  int N;
  cin >> N;
  int A[N];
  ll S[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
    if(i==0) S[i] = A[i];
    else S[i] = S[i-1] + A[i];
  }
  ll ans =INT_MAX;
  for(int i=1; i < N-2; i++){
    int lb = 0;
    int rb = i-1;
    while(rb - lb >1){
      int mid = (rb + lb)/2;
      if(S[mid] < ((double) S[i])/2.)     {
	lb = mid;       
      }
      else{
	rb = mid;
      }
    }
    if(abs(S[i] - S[rb] - S[rb]) < abs(S[i] - S[lb] - S[lb])) lb = rb;


    int lb_2 = i+1;
    int rb_2 = N-2;
    while(rb_2 - lb_2 >1){
      int mid = (rb_2 + lb_2)/2;
      if(abs (S[N-1] - S[mid]) >= ((double) (S[N-1] - S[i]))/2.) {
	lb_2 = mid;
      } 
      else{
        rb_2 = mid;
      } 
    }
    //    cout << lb_2 << " " << rb_2 << endl;
    if(abs(S[N-1] - S[rb_2] - (S[rb_2]-S[i])) < abs(S[N-1] - S[lb_2] - (S[lb_2] - S[i]))) lb_2 = rb_2;
    //        cout << lb << " " << i << " " << lb_2 << endl;
      ll B = S[lb];
      ll C = S[i] - B;
      ll D = S[lb_2] - C - B;
      ll E = S[N-1] - D -C -B;      
      ans = min (ans,max(max(B,C),max(D,E)) - min(min(B,C),min(D,E)));
      
      //            cout << ans << endl;
  }
  
  cout << ans << endl;

}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;
typedef pair<int, int> p;

int main()
{
    lint n, m;
    cin >> n >> m;
    if (n == 1) {
        if (m == 1) {
            cout << 1 << endl;
        } else {
            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<bits/stdc++.h>
using namespace std;

const int N=5e5;
vector<int>v[N];
int in[N],ans[N],visit[N];

void dfs(int node,int val){
    if(visit[node]){
        if(ans[node]>val){
            return ;
        }
    }

    visit[node]=1;
    ans[node]=val;

    for (auto i:v[node]){
        dfs(i,val+1);
    }
}

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

    string s;
    cin>>s;
    int n=s.size();

    for (int i=0;i<s.size();i++){
        if(s[i]=='>'){
            v[i+1].push_back(i);
            in[i]++;
        }
        else
        {
            in[i+1]++;
            v[i].push_back(i+1);
        }
    }

    for (int i=0;i<=n;i++){
        if(in[i]==0)
            dfs(i,0);
    }

    long long sum=0;

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

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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans = 0;
    if (n <= k) {
        for (int i = 0; i < n; ++i) {
            ans += x;
        }
    } else {
        for (int i = 0; i < k; ++i) {
            ans += x;
        }

        for (int i = k + 1; i <= n; ++i) {
            ans += y;
        }
    }

    cout << ans << endl;
    return 0; 
}

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

using namespace std;

int main(){
    vector<int> a(3);
   // for(auto e: a) cin >>e;

  for(int i=0;i<3;i++) cin>>a[i];

  
  //cout << accumulate(a.begin(),a.end(),0) <<endl;
  
    if(accumulate(a.begin(),a.end(),0) >= 22){
        cout << "bust" <<endl;
    }else{
        cout << "win" <<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();

        var a = sc.NextInt();
        for (int i = 0; i < a; i++)
        {
            int b = sc.NextInt();
            int c = sc.NextInt();
            int d = sc.NextInt();
            int[] kasatomo = new int[3];
            kasatomo[0] = b;
            kasatomo[1] = c;
            kasatomo[2] = d;
            Array.Sort(kasatomo);
            if (kasatomo[0] * kasatomo[0] + kasatomo[1] * kasatomo[1] == kasatomo[2] * kasatomo[2])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
        /*
        if (a > 0)
        {
            w = true;
            while (w == true)
            {
                int b = sc.NextInt();
                int c = sc.NextInt();
                int d = sc.NextInt();
                a = a--;

                if (b * b + c * c == d * d)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
        else
        {
            w = false;
        }*/
    }

    static void Main()
    {
        new Program().Calc();
    }
    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

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

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }

  ll sum = accumulate(v.begin(), v.end(), 0ll);
  ll rui = 0, ans = INFL;
  for (int i = 0; i < n; i++) {
    if (rui * 2 < sum) { // 半分より手前なら、手前側を伸ばす
      ans = min(ans, (sum - rui) - rui);
    } else { // 半分より億なら、一番右を伸ばす
      ans = min(ans, rui - (sum - rui));
    }
    rui += v[i];
  }
  ans = min(ans, rui - (sum - rui));
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if(a < b) {
    a= b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if(a > b) {
    a= b;
    return 1;
  }
  return 0;
}
ll mod= 1e9 + 7;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  int a[n + 1];
  rep(i, n) cin >> a[i + 1];
  ll c[n + 1];
  rep(i, n) cin >> c[i + 1];
  ll anss= -1e18;

  rep(ddd, n) {
    ll point= 0, point2= 0;
    ll count2= 0;
    int r= ddd + 1; //現在地

    while(1) {
      count2++;
      r= a[r];
      point2+= c[r];
      if(ddd + 1 == r) break;
    }

    r= ddd + 1;

    rep(i, count2) {
      r= a[r];
      point+= c[r];
      if(i+1>k)break;
      if(point2>0){
      ll q= (k - i - 1) / count2;
      chmax(anss, point + point2 * q);}
      chmax(anss,point);
    }
  }
  cout << anss << endl;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N;
	cin >> N;
	vector <int> A(N, 0);
	for (int ii = 0; ii < N; ++ii){
		cin >> A[ii];
	}

	sort(A.rbegin(), A.rend());

	int a = 0;
	int b = 0;
	for (int ii = 0; ii < N; ++ii){
		if (ii % 2 == 0){
			a += A[ii];
		} else {
			b += A[ii];
		}
	}

	cout << a- b << "\n";
	

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==2) a=3;
	else if(a==4||a==6||a==9||a==11) a=2;
	else a=1;
	if(b==2) b=3;
	else if(b==4||b==6||b==9||b==11) b=2;
	else b=1;
	if(a==b) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = i()
a = l()
a.sort()
for i, num in enumerate(a[N:]):
    if i % 2 == 0:
        ans += num

print(ans)


Measured memory_bytes: 43964
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define rep2(i, l, r) for(Int i = (Int)(l); i < (Int)(r); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

int main() {
   Int n, m, e;
   std::cin >> n >> m >> e;
   std::vector<Int> ss(1), ts(1), fs(1), bs(1);
   auto addEdge = [&](Int s, Int t, Int f, Int b) {
      ss.emplace_back(s);
      ts.emplace_back(t);
      fs.emplace_back(f);
      bs.emplace_back(b);
   };
   rep(i, e) {
      Int x, y;
      std::cin >> x >> y;
      addEdge(x, n+y, 0, 1);
   }
   Int source = n+m, sink = n+m+1;
   Int v = n + m + 2;
   rep2(i,0,n)   addEdge(source, i, 0, 1);
   rep2(i,n,n+m) addEdge(i, sink, 0, 1);
   std::vector<std::vector<Int>> es(v);
   rep(i, fs.size()) {
      Int s = ss[i], t = ts[i];
      es[s].emplace_back(i);
      es[t].emplace_back(-i);
   }
   Int res = 0;
   for(;;) {
      std::queue<Int> q;
      std::vector<Int> xs(v, -1), ps(v, -1);
      xs[source] = (Int)1<<53;
      q.emplace(source);
      while( not q.empty() ) {
         Int s = q.front(); q.pop();
         for(Int i : es[s]) {
            Int t = i > 0 ? ts[i] : ss[-i];
            Int w = i > 0 ? bs[i] : fs[-i];
            guard( w > 0 );
            guard( xs[t] == -1 );
            xs[t] = std::min(xs[s], w);
            ps[t] = i;
            q.emplace(t);
         }
      }
      Int tf = xs[sink];
      fprintf(stderr, "tf=%ld\n", tf);
      if( xs[sink] <= 0 ) break;
      for(Int i=sink, k=ps[i]; i!=source; i=k>0?ss[k]:ts[-k], k=ps[i]) {
         if( k > 0 ) {
            fs[k] += tf;
            bs[k] -= tf;
         }
         else {
            fs[-k] -= tf;
            bs[-k] += tf;
         }
      }
      res += tf;
   }
   printf("%ld\n", res);
}



Measured memory_bytes: 3588
#include <iostream>
using namespace std;
bool bt[100001] = {};
int main()
{
	int n, m; cin >> n >> m;
	int l = 1;
	for (int i = m - (m % 2); i > 0; i -= 2)
	{
		cout << l << " " << l + i << "\n";
		l++;
	}
	int r = n;
	for (int i = m - !(m % 2); i > 0; i -= 2)
	{
		cout << r - i << " " << r << "\n"; 
		r--;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#define N 100005
#define NIL -1
  
struct Node{
  int p, left, right;
};
struct Node T[N];
int n;
  
void inorder(int p){
  if(p != NIL) {
    inorder(T[p].left);
    printf(" %d", p);
    inorder(T[p].right);
  }
}
  
void postorder(int p){
if(p != NIL) {
    postorder(T[p].left);
    postorder(T[p].right);
    printf(" %d", p);
  }
}
  
void preorder(int p){
if(p != NIL) {
  printf(" %d", p);
  preorder(T[p].left);
  preorder(T[p].right);
  }
}
  
  
  
main(){
  int i, id;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].left = T[i].p = T[i].right = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    scanf("%d %d", &T[id].left, &T[id].right);
      T[T[id].left].p = id;
      T[T[id].right].p = id;
    }    
  
  printf("Preorder\n");
  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      preorder(i);
    }
  }
  printf("\nInorder\n");
  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      inorder(i);
    }
  }
  printf("\nPostorder\n");
  for(i = 0; i < n; i++){
    if(T[i].p == NIL){
      postorder(i);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

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

int main()
{
    string s;
    cin >> s;
    map<char, ll> odd, even;
    for (int i = 0; i < s.size(); i++)
    {
        if (i % 2)
        {
            odd[s.at(i)]++;
        }
        else
        {
            even[s.at(i)]++;
        }
    }
    ll ans1 = odd['0'] + even['1'];
    ll ans2 = odd['1'] + even['0'];
    cout << min(ans1, ans2) << endl;
}

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

using namespace std;

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

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

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

struct edge {
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

using Graph = vector<vector<edge> >;

vint sz;
vint sum;
void calc_sz(int u, int p, const Graph& graph){
  sz[u] = 1;
  sum[u] = 0;
  for(auto e : graph[u]) {
    if(e.to == p) continue;
    calc_sz(e.to, u, graph);
    sz[u] += sz[e.to];
    sum[u] += sum[e.to]+e.cost*sz[e.to]*2;
  }
};

vint get_centroid(int root, const Graph& graph) {
  calc_sz(root, -1, graph);
  int n = sz[root];
  vint centroid(2, -1); int num = 0;
  function<void(int, int)> dfs = [&](int u, int p) {
    bool is_centroid = true;
    for(auto e : graph[u]) {
      if(e.to == p) continue;
      dfs(e.to, u);
      if(sz[e.to] > n/2) is_centroid = false;
    }
    if(n-sz[u] > n/2) is_centroid = false;
    if(is_centroid) centroid[num++] = u;
  };
  dfs(root, -1);
  return centroid;
}

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

  int n;
  cin >> n;
  Graph graph(n);
  map<Pi, int> es;
  rep(i, n-1) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    graph[a].emplace_back(b, c);
    graph[b].emplace_back(a, c);
    es[Pi(a, b)] = es[Pi(b, a)] = c;
  }
  resz(sz, n);
  resz(sum, n);
  auto centroid = get_centroid(0, graph);
  if(centroid[1] != -1) {
    calc_sz(centroid[0], centroid[1], graph);
    calc_sz(centroid[1], centroid[0], graph);
    cout << sum[centroid[0]]+es[Pi(centroid[0], centroid[1])]*(n-1)+sum[centroid[1]] << endl;
  } else {
    calc_sz(centroid[0], -1, graph);
    int mn = inf;
    for(auto e : graph[centroid[0]]) chmin(mn, e.cost);
    cout << sum[centroid[0]]-mn << endl;
  }

  return 0;
}


Measured memory_bytes: 29824