akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
	bool operator<(const Edge& right) const {
		return dst < right.dst;
	}
};

using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph& g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

signed main() {
	int H, W;
	cin >> H >> W;

	vector<vector<int>> c(10, vector<int>(10, 0));
	vector<vector<int>> A(H, vector<int>(W, 0));

	rep(i, 10) {
		rep(j, 10) {
			cin >> c[i][j];
		}
	}

	rep(y, H) {
		rep(x, W) {
			cin >> A[y][x];
		}
	}

	rep(k, 10) {
		rep(i, 10) {
			rep(j, 10) {
				chmin(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}

	int ans = 0;
	rep(y, H) {
		rep(x, W) {
			if (A[y][x] != -1) {
				ans += c[A[y][x]][1];
			}
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3928
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, m, k[50], a[50][50];

    cin >> n >> m;

    int b[50] = {0};

    REP(i, n)
    {
        cin >> k[i];
        REP(j, k[i])
        {
            cin >> a[i][j];
            b[a[i][j]]++;
        }
    }

    int res = 0;

    REP(i, m)
    {
        if (b[i + 1] == n)
            res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 == 0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}

void solve(){

	int n;
	cin >> n;
	vector <ll> a(n,0);
	vector <ll> count(n+1,0);
	rep0(i,n){
		cin >> a[i];
		count[a[i]]++;
	}

	ll ans = 0;
	rep1(i,n){
		ans += (count[i]*(count[i]-1))/2;
	}

	rep0(i,n){
		ans -= (count[a[i]]*(count[a[i]]-1))/2;
		ans += ((count[a[i]]-2)*(count[a[i]]-1))/2;
		cout << ans << "\n";
		ans -= ((count[a[i]]-2)*(count[a[i]]-1))/2;
		ans += (count[a[i]]*(count[a[i]]-1))/2;
	}

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n; cin >> n;
    int a[100010] = {};
    int sum = 0;

    rep(i,0,n) {
        cin >> a[i];
        sum += a[i];
    }

    int cs[100010] = {};
    int ret[100010] = {};
    int cntnum = 0;

    if(sum % (n * (n+1) / 2)) cout << "NO" << endl;
    else {
        cntnum = sum / (n*(n+1) / 2);
        rep(i,0,n) {
            int prev = (i - 1 + n) % n;
            int s = a[prev] - a[i];
            if( (s+cntnum) % n != 0 || (s + cntnum) / n < 0) {
                cout << "NO" << endl;
                return 0;
            }
            cs[i] += (s + cntnum) / n;
        }
        rep(i,0,n) ret[0] += cs[i] * ((n - i) % n + 1);
        rep(i,1,n) ret[i] = ret[i-1] - cs[i] * n + cntnum;
        rep(i,0,n) {
            if(ret[i] != a[i]) {
                cout << "NO" << endl;
                return 0;
            }
        }
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 2688
n,m = map(int,input().split())
input_lines = [[int(j)-1 for j in input().split()] for i in range(m)]

map_list = [[] for i in range(n)]

for line in input_lines:
    map_list[line[0]].append(line[1])
    map_list[line[1]].append(line[0])

stack = [[0],]
visited = [0 for i in range(n)]

def dfs(stack,visited):
    if sum(visited)==n:
        return 1
    ans = 0
    
    search = stack.pop(-1)
    for s in search:
        if visited[s]==1:
            continue
        visited[s]=1
        stack.append(map_list[s])
        ans += dfs(stack,visited)
        visited[s]=0
    return ans

ans = dfs(stack,visited)
print(ans)      



Measured memory_bytes: 3064
"use strict";
    
const main = arg => {
    const packs = arg.split("\n")[0].split(" ").map(n=>parseInt(n)).sort((a,b)=>b-a);
    console.log(packs[0] === packs[1] + packs[2] ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

max = 0
min = 10**9

# print(A)

for i in range(N):
    # print(A[i])
    if A[i] > max:
        max = A[i]
        # print("max="+str(max))

for i in range(N):
    # print(A[i])
    if A[i] < min:
        min = A[i]
        # print("min="+str(min))
# print("min="+str(min))

# print("ans" + str(max - min))
print(max - min)


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main(){
	var x, k, d int
	fmt.Scan(&x, &k, &d)


	if x == 0 {
		if k % 2 == 0 {
			fmt.Println(0)
			return
		}
		fmt.Println(d)
		return
	}
	x = abs(x)
	ans := x % d
	a := x / d
	if a > k {
		// 往復に辿り着く前に終る
		fmt.Println(x - k * d)
		return
	} else if a <= k  {
		// 往復する
		if (k - a) % 2 == 0 {
			fmt.Println(ans)
			return
		} else if (k-a) % 2 == 1 {
			if ans > 0 {
				ans -= d
			} else {
				ans += d
			}
			fmt.Println(abs(ans))
			return
		}
	}
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}


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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  
  //初期化
  int watch_me = 0;
  for(int i = 1; i < S.size(); i++){
      if(S.at(i) == 'W') watch_me++;
  }
  
  //メイン
  int max_watch_me = watch_me;
  for(int i = 1; i < S.size(); i++){
      if(S.at(i) == 'W') watch_me--;
      if(S.at(i-1) == 'E') watch_me++;
      max_watch_me = max(max_watch_me,watch_me);
  }
  int ans = S.size() - 1 - max_watch_me;
  cout << ans << endl;
}



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

public class Main {
    void run(String[] args){
        Scanner scan=new Scanner(System.in);
        Integer count=scan.nextInt();
        Integer one;
        Integer two;
        Integer i;
        ArrayList<Integer>ones=new ArrayList<>();
        ArrayList<Integer>twos=new ArrayList<>();
        ArrayList<Integer>counts=new ArrayList<>();
        for(i=0;i<count;i++){
            one=scan.nextInt();
            two=scan.nextInt();
            ones.add(one);
            twos.add(two);
        }
        for(i=0;i<count;i++){
            if(ones.get(i)==twos.get(i)){
                counts.add(1);
            }
            else{
                counts.add(0);
            }
        }
        print(count,counts);
    }
    Integer print(Integer count,ArrayList<Integer>counts){
        Integer i;
        for(i=0;i<count-2;i++){
            if((1==counts.get(i))&&(counts.get(i)==counts.get(i+1))&&(counts.get(i+1)==counts.get(i+2))){
                System.out.println("Yes");
                return 0;
            }
        }
        System.out.println("No");
        return 0;
    }
    public static void main(String args[]){
        Main printer = new Main();
        printer.run(args);
    }
}

Measured memory_bytes: 36024
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    ll x1, x2, v1, v2, t;
    cin >> x1 >> v1 >> x2 >> v2 >> t;
    if ((v1 - v2) * t >= abs(x1 - x2))
        cout << "YES\n";
    else 
        cout << "NO\n";



}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

int main(){
    string s,result="";
    cin >> s;
    for(int i=0; i<s.length(); i++){
        char c = s[i];
        switch(c){
            case '0':
                result += '0';
                break;
            case '1':
                result += '1';
                break;
            case 'B':
                if(result.length()>0){
                    result = result.substr(0, result.length()-1);
                }
                break;
        }
    }
    cout << result << '\n';
}

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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007

vi l(61), r(61);
ll dp[61][2][2][2];

/*f1が「L <= xが決定済み」に、f2が「y <= Rが決定済み」に、
f3が「xとyのMSBの一致が決定済み」に対応*/
ll rec(int n, bool f1, bool f2, bool f3) {
    if (n == -1) return 1;

    ll &res = dp[n][f1][f2][f3];
    if (~res) return res;
    res = 0;

    //nビットではx=0,y=0を選ぶ
    if (f1 || l[n] == 0) // x=0の条件
        res += rec(n - 1, f1, r[n] | f2, f3);
    //x=0,y=1
    if ((f1 || l[n] == 0) && (f2 || r[n] == 1) && f3)
        res += rec(n - 1, f1, f2, f3);
    //x=1,y=1
    if (f2 || r[n] == 1) //y=1の条件
        res += rec(n - 1, (1 - l[n]) | f1, f2, 1);

    res %= MOD;
    return res;

}

int main() {
    ll L, R; cin >> L >> R;
    rep(i, 61) {
        l[i] = (L >> i) & 1;
        r[i] = (R >> i) & 1;
    }
    memset(dp, -1, sizeof(dp));

    ll ans = rec(60, 0, 0, 0);
    cout << ans << endl;

}





Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;

#define mod 1000000007
#define pb push_back
#define ll long long int
#define ull unsigned ll
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

/*
const ll infinity = 9e18;

bool compare(ll a,ll b) {return a > b;}
bool compare1(ppl a,ppl b) {return a.ff > b.ff;}
bool compare2(ppl a,ppl b) {return a.ss < b.ss;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}

ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md = mod) {ll product = 1; while(b){if(b&1){product = (product*a)%md;}a = (a*a)%md;b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/




int main()
{
    fast

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

        
    ll n;
    cin>>n;

    string s;
    cin>>s;

    ll w = 0,r = 0;

    forn(i,0,n)
    {
        if(s[i] == 'W') w++;
        else r++;
    }
    
    ll cnt = 0;    
        
    forn(i,0,r)
    {
        if(s[i] == 'W') cnt++;
    }   

    ll ans = w == 0 ? 0 : cnt;
    cout<<ans;









    return 0;
}       

Measured memory_bytes: 3760
N = int(input())
W = list(map(int, input().split()))
count = abs(sum(W[:1]) - sum(W[1:]))
for T in range(2, N):
    if count > abs(sum(W[:T]) - sum(W[T:])):
        count = abs(sum(W[:T]) - sum(W[T:]))
print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
main()
{
    int t,n,i,j,a=0,b=0,c=0,d=0;

    cin>>n;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
        ++a;
        else if(s=="WA")
        ++b;
        else if(s=="TLE")
        ++c;
        else
        {
            ++d;
        }



    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;

}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <complex>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, b, a) for(int i=(b)-1;i>=(a);--i)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979
#define x0 ikjnrmthklmnt
#define y0 lkrjhkltr
#define y1 ewrgrg

typedef long long Int;
typedef unsigned long long UInt;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<Int, Int> PLL;
typedef pair<double, double> PDD;
typedef complex<double> base;

const int INF = 1000000000;
const int BASE = 1000000007;
const int MAX = 107;
const int MAXX = 1000000;
const int ADD = 1000000;
const int MOD = 998244353;
const int CNT = 800;

int dp[2][MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("distance.in",  "r", stdin);
    //freopen("distance.out", "w", stdout);
    //freopen("out.txt" , "w" , stdout);
    
    int n;
    cin >> n;
    FOR(i,0,2)
    {
        FOR(j,0,n)
        {
            cin >> dp[i][j];
            if (i == 0)
            {
                if (j) dp[i][j] += dp[i][j - 1];
            }
            else
            {
                dp[i][j] += max(dp[0][j] , (j > 0 ? dp[i][j - 1] : 0));
            }
        }
    }
    cout << dp[1][n - 1] << endl;
    
    return 0;
}













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

using namespace std; 

int main()
{
  string s, t;
  cin>>s>>t;
  int ss = s.length(), ts = t.length();
  vector< vector<lli> > dp(ss+1, vector<lli>(ts+1));
  //dp[i][j] -> lo mejor que se puede hacer con s de tama;o i y con t de tama;o j

  for(int i = 1; i <= ss; i++)
    for(int j = 1; j<= ts; j++)
    {
      if(s[i-1] == t[j-1]){
        dp[i][j] = dp[i-1][j-1] + 1;
        continue;
      }
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  
  lli counter = 0;
  string res;
  lli i = ss, j = ts;
  while(counter < dp[ss][ts])
  {
    if(dp[i][j] == dp[i-1][j])
    {
      i--;
    }
    else if(dp[i][j] == dp[i][j-1])
    {
      j--;
    }
    else
    {
      res.push_back(s[i-1]);
      counter++; i--; j--;
      continue;
    }
  }
  reverse(res.begin(), res.end());
  cout<<res<<endl;


}

Measured memory_bytes: 70784
#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#define Max 0x3F3F3F
#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>
#include<stdio.h>
#include<queue>
//#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a,b;cin >>a>>b;
    cout<<100<<" "<<100<<endl;;
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            if(i==0)cout<<".";
            else if(i%2){
                if(j%2==1&&b>1)cout<<"#",b--;
                else cout<<".";
            }
            else cout<<".";
        }
        cout<<endl;
    }a--;
    for(int i=0;i<50;i++){
        for(int j=0;j<100;j++){
            if(i==0)cout<<"#";
            else if(i%2){
                if(j%2==1&&a>0)cout<<".",a--;
                else cout<<"#";
            }
            else cout<<"#";
        }cout<<endl;
    }
    return 0;
}


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

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair(a, b)
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, m;
vector<pi> s;
int dp[1024];
int main() {
	int nn;
	while ((cin >> nn) && nn) {
		s.clear();
		for (int i = 0; i < nn; ++i) {
			int  a, b, c, d, e, f, g, h,iiii;
			cin >> a >> b >> c >> d >> e >> f >> g >> h>>iiii;
			s.push_back(make_pair(b*60+c+d*60+e+f*60+g+h*60+iiii,a));
		}
		sort(s.begin(),s.end());
		cout<<s[0].second<<endl;
		cout<<s[1].second<<endl;
		cout<<s[nn-2].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
long long w[101],v[101],f[101][100001];
int main()
{
        long long i,j,n,W,s=0;
        scanf("%lld %lld",&n,&W);
        for(i=1;i<=n;i++)
        {
                scanf("%lld %lld",&w[i],&v[i]);
                s+=v[i];
        }
        for(i=1;i<=s;i++)
        {
                f[0][i]=INT_MAX;
        }
        for(i=1;i<=n;i++)
        {
                for(j=1;j<=s;j++)
                {
                        f[i][j]=f[i-1][j];
                        if(j>=v[i])
                                f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
                        //printf("%lld %lld %lld\n",i,j,f[i][j]);
                }
        }
        for(i=s;i>=1;i--)
        {
                if(f[n][i]<=W)
                {
                        printf("%lld",i);
                        break;
                }
        }
        return 0;
}


Measured memory_bytes: 79104
d, g = map(int, input().split())
scores = [list(map(int, input().split())) for i in range(d)]
pod = []

for i in range(2 ** d):
    cnt = 0
    point = 0
    for j in range(d):
        if (i >> j) & 1:
            point += 100 * (j + 1) * scores[j][0]
            point += scores[j][1]
            cnt += scores[j][0]
    if point >= g:
        pod.append(cnt)
        continue
    else:
        for p in range(d - 1, -1, -1):
            if not (i >> p) & 1:
                for q in range(scores[p][0]):
                    if point < g:
                        point += (p + 1) * 100
                        cnt += 1
                    else:
                        continue
    pod.append(cnt)

print(min(pod))


Measured memory_bytes: 42480
#include <cstdio>
#pragma warning(disable : 4996)
typedef long long ll;
int n, q, tp, v1, v2, v3; ll seg[262156], lazy[262156];
void push(int k) {
	if (lazy[k] != 0) {
		seg[k * 2] += lazy[k] >> 1; lazy[k * 2] += lazy[k] >> 1;
		seg[k * 2 + 1] += lazy[k] >> 1; lazy[k * 2 + 1] += lazy[k] >> 1;
		lazy[k] = 0;
	}
}
void add(int a, int b, int x, int k, int l, int r) {
	if (a <= l && r <= b) {
		seg[k] += x * (r - l), lazy[k] += x * (r - l);
		return;
	}
	if (r <= a || b <= l) return;
	push(k);
	add(a, b, x, k * 2, l, (l + r) >> 1);
	add(a, b, x, k * 2 + 1, (l + r) >> 1, r);
	seg[k] = seg[k * 2] + seg[k * 2 + 1];
}
ll query(int a, int b, int k, int l, int r) {
	if (a <= l && r <= b) return seg[k];
	if (r <= a || b <= l) return 0;
	push(k);
	ll lc = query(a, b, k * 2, l, (l + r) >> 1);
	ll rc = query(a, b, k * 2 + 1, (l + r) >> 1, r);
	return lc + rc;
}
int main() {
	scanf("%d %d", &n, &q);
	while (q--) {
		scanf("%d", &tp);
		if (tp == 0) {
			scanf("%d %d %d", &v1, &v2, &v3); v2++;
			add(v1, v2, v3, 1, 0, 131072);
		}
		else {
			scanf("%d %d", &v1, &v2); v2++;
			ll ret = query(v1, v2, 1, 0, 131072);
			printf("%lld\n", ret);
		}
	}
	return 0;
}

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

int f(int a){
	if(a%2==0)return a/2;
	else return 3*a+1;
}
int main(){
	int s;scanf("%d",&s);
	set<int>se;
	int a=s;se.insert(a);
	for(int i=2;;i++){
		a=f(a);
		if(se.count(a)){
			cout<<i<<endl;
			return 0;
		}
		se.insert(a);
	}
}

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

int main() {
  std::string s;
  std::cin >> s;
  if (s == "Sunny")
    std::cout << "Cloudy" << std::endl;
  else if (s == "Cloudy")
    std::cout << "Rainy" << std::endl;
  else
    std::cout << "Sunny" << std::endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split()) 
sunuke = list(range(1,N+1))
#print(sunuke)
for i in range(K): 
    kasi = int(input()) 
    motteru = map(int, input().split()) 
    for _ in motteru: 
        if _ in sunuke:
            sunuke.remove(_) 
print(len(sunuke))

Measured memory_bytes: 9184
A,B,K = map(int, input().split())

if A+B > K:
  if A > K:
    print(str(A-K) + " " + str(B))
  else:
    print(str(0) + " " + str(B - (K-A)))
else:
  print(str(0) + " " + str(0))

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

bool board[305][305], used[305][305];
int h, w;
void dfs(int y, int x) {
  used[y][x] = true;
  REP(k, 4) {
    int nx = x + dx[k], ny = y + dy[k];
    if(IN(0LL, w, nx) && IN(0LL, h, ny) && !used[ny][nx] && !board[ny][nx]) {
      dfs(ny, nx);
    }
  }
}

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

  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    VI sx(n), sy(n), gx(n), gy(n);
    VI vx, vy;
    REP(i, n) {
      cin >> sx[i] >> sy[i] >> gx[i] >> gy[i];
      sx[i] *= 2, sy[i] *= 2, gx[i] *= 2, gy[i] *= 2;
      vx.PB(sx[i]); vx.PB(sx[i]-1); vx.PB(sx[i]+1);
      vy.PB(sy[i]); vy.PB(sy[i]-1); vy.PB(sy[i]+1);
      vx.PB(gx[i]); vx.PB(gx[i]-1); vx.PB(gx[i]+1);
      vy.PB(gy[i]); vy.PB(gy[i]-1); vy.PB(gy[i]+1);
    }
    vx.PB(-1); vy.PB(-1);
    sort(ALL(vx)); vx.erase(unique(ALL(vx)), vx.end());
    sort(ALL(vy)); vy.erase(unique(ALL(vy)), vy.end());
    memset(board, false, sizeof(board));
    REP(i, n) {
      sx[i] = lower_bound(ALL(vx), sx[i]) - vx.begin();
      sy[i] = lower_bound(ALL(vy), sy[i]) - vy.begin();
      gx[i] = lower_bound(ALL(vx), gx[i]) - vx.begin();
      gy[i] = lower_bound(ALL(vy), gy[i]) - vy.begin();
      FOR(j, sx[i], gx[i]+1) board[sy[i]][j] = board[gy[i]][j] = true;
      FOR(j, gy[i], sy[i]+1) board[j][sx[i]] = board[j][gx[i]] = true;
    }

    h = vy.size(), w = vx.size();

    memset(used, false, sizeof(used));
    int cnt = 0;
    REP(i, h) REP(j, w) {
      if(used[i][j] || board[i][j]) continue;
      dfs(i, j);
      cnt++;
    }

    cout << cnt << endl;
  }

  return 0;
}



Measured memory_bytes: 4472
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		int total = 0;
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			total += a[i];
		}
		
		int ave = Math.round((float) total / n);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (a[i] - ave) * (a[i] - ave);
		}
		
		out.println(ans);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

using namespace std;
using ll = long long;

//container util
#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)


int main(void){

	
	int A, B; cin >> A >> B;
	int ans = 0;
	if(A > 9 or B > 9) ans = -1;
	else ans = A * B;

	cout << ans << endl;


	return 0;

}


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

int main(void){
    int N;
    cin>>N;
    int ans = 0;
    for (int i=1;i<=N;i+=2) {
        int n = i;
        int d = 0;
        for (int j=1;j<=n;j++) {
            if (n%j == 0) d++;
        }
        if (d == 8) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);

  sort(a.begin(), a.end());
  long long s = 0;
  int t = n - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (i + 1 < n) {
      if (t > 2) {
        s += a[i] * 2;
        t -= 2;
      }
      else {
        s += t * a[i];
        break;
      }
    }
    else {
      t--;
      s += a[i];
    }
  }

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

  return 0;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    string s, t;
    cin >> s >> t;
    i64 n = s.size();
    i64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3820
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	vector<ll> d(3);
	cin>>d[0]>>d[1]>>d[2];
	sort(d.begin(),d.end());
	if(d[1]!=d[0]){
		cout<<d[0]<<endl;
	}else{
		cout<<d[2]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

class Main {
   public static void main(String[] args) {
       Scanner in = new Scanner(System.in);
       int    a = in.nextInt();
       int    b = in.nextInt();
       int    c = in.nextInt();
       int    i;
       int    x=0;
      
       for(i=a;i<=b;i++){
       if((c%i)==0){
       x++;
       }
       }

        System.out.println(x);

      

}
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
#define     ll      long long int
vector<ll>v;
set<char>st;
int main()
{
    ll n;
    cin>>n;
    if(n%1000==0){
        cout<<0<<endl;
    }
    else{
        ll bagses=n%1000;
        cout<<1000-bagses<<endl;
    }
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>

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

  int mx = 0, mn = 1 << 30;

  for (int i = 0; i < N; i++) {
    int a;
    std::cin >> a;

    mx = std::max(mx, a);
    mn = std::min(mn, a);
  }

  std::cout << mx - mn << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
string s1, s2;
int n, m;
int dp[N + 7][N + 7], dir[N + 7][N + 7];
int solve(int i, int j) {
    if ( i >= n || j >= m ) return 0;
    if ( dp[i][j] != -1 ) return dp[i][j];
    int ret1 = 0, ret2 = 0, ret3 = 0;
    if ( s1[i] == s2[j] ) {
        ret1 = solve(i + 1, j + 1) + 1;
    } else {
        ret2 = solve(i + 1, j);
        if ( ret1 < ret2 ) {
            ret1 = ret2;
        }
        ret3 = solve(i, j + 1);
        if ( ret1 < ret3 ) {
            ret1 = ret3;
        }
    }
    return dp[i][j] = ret1;
}
string s;
void print(int i, int j) {
    if ( i >= n || j >= m ) return;
    int ret1 = 0, ret2 = 0, ret3 = 0;
    if ( s1[i] == s2[j] ) {
        s += s1[i];
        print(i + 1, j + 1);
    } else {
        ret2 = solve(i + 1, j);
        ret3 = solve(i, j + 1);
        if ( ret2 == dp[i][j] && ret3 == dp[i][j] ) {
            if ( s1[i] < s2[j] ) {
                print(i + 1, j);
            } else {
                print(i, j + 1);
            }
        } else if ( ret2 == dp[i][j] ) {
            print(i + 1, j);
        } else if ( ret3 == dp[i][j] ) {
            print(i, j + 1);
        }
    }
}
int main() {
    cin >> s1 >> s2;
    n = (int)s1.length(), m = (int)s2.length();
    memset(dp, -1, sizeof(dp));
    solve(0, 0);
    print(0, 0);
    cout << s << endl;
    return 0;
}


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

using namespace std;

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  int m = 101010101;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x -= a;
    m = min(m, a);
  }
  cout << n + x / m << endl;
  return 0;
}


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

int main(){
  int n; cin >> n;
  vector<int> a(n);
  int absmax = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(abs(a[i]) > abs(a[absmax])) absmax = i;
  }
  if(a[absmax] == 0) cout << 0 << endl;
  else if(a[absmax] < 0){
    cout << n-1+n-1 << endl;
    for(int i=0;i<n;i++) if(i != absmax)cout << absmax+1 << " " << i+1 << endl;
    for(int i=n-1;i>0;i--) cout << i+1 << " " << i << endl;
  }
  else if(a[absmax] > 0){
    cout << n-1+n-1 << endl;
    for(int i=0;i<n;i++) if(i != absmax)cout << absmax+1 << " " << i+1 << endl;
    for(int i=0;i<n-1;i++) cout << i+1 << " " << i+2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#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};

struct UnionFind {
    vector<LL> data;
    UnionFind(LL size) : data(size, -1) { }

    // xとyをmergeする
    bool unionSet(LL x, LL y) {
    x = root(x); y = root(y);
    if (x != y) {
        if (data[y] < data[x]) swap(x, y);
        data[x] += data[y]; data[y] = x;
    }
    return x != y;
    }

    // xとyが同一のグループかを判定する
    bool findSet(LL x, LL y) {
        return root(x) == root(y);
    }

    // xのrootノードの番号を返す
    LL root(LL x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

    // xのノードが含まれる木のサイズを返す
    LL size(LL x) {
        return -data[root(x)];
    }

    // グループの数を返す O(N)
    LL tree_count() {
        LL cnt = 0;
        REP(i, data.size()) cnt += (root(i) == i);
        return cnt;
    }
};

void solve(long long N, long long M, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> Z){
    UnionFind uf(N);
    REP(i, M) uf.unionSet(X[i], Y[i]);

    cout << uf.tree_count() << endl;
}

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


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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    int d_min=1e+5;
    int d_max=1;
    for(int i=0;i<N;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    cout << d[N/2]-d[N/2-1] << endl;
    
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
#define VN(v) # v
#define print(a) cout << a << "#" << VN(a) << endl;
#define ldout fixed << setprecision(40) 

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll K, R, L; ld p, e, t; cin >> K >> R >> L >> p >> e >> t; swap(R, L);
    function<ld(ll, ld, ld)> f = [&](ll k, ld l, ld r) { 
        ld h = (l + r) / 2;
        if (!k) return (ld)(t - e <= h && h <= t + e);
        if (t - e <= l && r <= t + e) return 1.0l;
        if (t - e > r || t + e < l) return 0.0l;
        ld P = ((l + r) / 2 <= t + EPS ? 1 - p : p);
        return f(k-1, h, r) * P + f(k-1, l, h) * (1 - P);
    };
    cout << ldout << f(K, L, R) << endl;
    return 0;
}

Measured memory_bytes: 3284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String base;
		String comparison;
		
		try {
			base = br.readLine();
			comparison = br.readLine();
			
			Inversions(base, comparison, br);
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

	public static void Inversions(String base, String comparison,  BufferedReader br){ 
		StringBuilder sb = new StringBuilder();
		int length = base.length() - comparison.length();
		String 	container;
		int ans_num = 0;
		int[] ans = new int[1000000];
		
		for(int i = 0; i <= length ; i ++ ) {
			container = base.substring( i, i + comparison.length() );
			if( container.equals(comparison) ) {
				ans[ans_num] = i;
				ans_num ++;
			}
		}
		
		for(int i = 0; i <ans_num; i++){;
			sb.append(ans[i] + "\n");
		}
		 
		System.out.print(sb);
	}
}


Measured memory_bytes: 28568
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
 
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
 
 
int main(void) {
    ll h, w;
    cin >> h >> w;
    if(h==1 || w==1) { cout << 1 << endl;  return 0; }
    cout << (ll)((double)(h*w)/2.0+0.5) << endl;
    
}

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


int main()
{
	string card;
	int m, h;
	while (1) {
		cin >> card;
		if (card == "-")
			break;
		cin >> m;
		for (int i = 0;i < m;i++) {
			cin >> h;
			card = card+card.substr(0,h);
			card.erase(0,h);
		}
		cout << card << endl;
	}
    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll ans = n/500*1000;
	n %=500;
	ans += n/5*5;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int l = in.nextInt();
        String[] a = new String[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.next();
        }
        Arrays.sort(a);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(a[i]);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 30020
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;
int inf = 1e9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, t, a;
  cin >> n >> t >> a;
  int res = -1;
  int diff = inf;
  REP(i,n) {
    int h;
    cin >> h;
    int h_diff = abs(a * 1000 - (t * 1000 - h * 6));
    //cout << i+1 << " " << res << " " << h_diff << " " << diff << " " << t * 1000 - h * 6 << endl;
    if(h_diff < diff) { diff = h_diff; res = i + 1; }
  }
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e5+100;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

VI v[N];
inline int dfs(int k,int fa) {
	int a=0,b=0;
	for (int t:v[k])
		if (t!=fa) {
			int x=dfs(t,k);
			a+=x;b+=!x;
		}
	return a+(b?b-1:0);
}
int main()
{
	int n=gi(),i,a,b;
	for (i=1;i<n;i++) {
		a=gi(),b=gi();
		v[a].pb(b);
		v[b].pb(a);
	}
	for (i=0;i<n&&v[i].size()<3;i++);
	if (i==n)
		puts("1");
	else
		cout<<dfs(i,n)<<endl;
	return 0;
}


Measured memory_bytes: 7424