akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn INT_MIN
#define imx INT_MAX

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) 20
#endif

ll power(ll a,ll b,ll m=1e9+7)
{
    a%=m;
    if(b==1)
    return a;
    if(b==0)
    return 1;
    ll ret=power(a,b/2);
    ret=(ret%m*ret%m)%m;
    if(b&1)
    ret=(ret%m*a%m)%m;
    return ret;
}

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

void solve()
{
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

int main()
{
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(){
  int n,max,min,i,a;
  long int sum=0;
  max = -1000000;
  min = 1000000;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%",&a);
    if(max<a) max = a;
    if(min>a) min = a;
    sum+=a;
  }
  printf("%d %d %ld\n",min,max,sum);

  return 0;
}

Measured memory_bytes: 600
import re
pat_RRLL = re.compile(r"R+L+")
pat_RL = re.compile(r"RL")

S = input()
ans = [0 for _ in S]
RRLLs = []
RLs = []
pos = 0
while pos < len(S):
  RRLLs.append(pat_RRLL.search(S, pos))
  RLs.append(pat_RL.search(S, pos))
  pos = RRLLs[-1].end()
for rrll, rl in zip(RRLLs, RLs):
  r = rl.start()
  l = rl.end()-1
  num = rrll.end()-rrll.start()
  ans[r] = num // 2
  ans[l] = num // 2
  if num %2 == 1:
    ans[r] += int(rrll.start()%2 == r%2)
    ans[l] += int(rrll.start()%2 == l%2)
ans_str = ""
for a in ans:
  ans_str += "%s "%a
print(ans_str)


Measured memory_bytes: 16140
use proconio::input;

const MOD: i64 = 1_000_000_007;

fn get_val(a: i64, b:i64) -> i64 {
  let c = get_pn(a + b);
  let p = get_pn(a) % MOD * get_pn(b) % MOD;
  c * modinv(p, MOD) % MOD
}
  
fn get_pn(v: i64) -> i64 {
  let mut result = 1;
  for i in 1..=v {
    result = result * i % MOD;
  }
  result
}

fn swap(a: i64, b: i64) -> (i64, i64) {
  (b, a)
}

fn modinv(
  mut a: i64,
  m: i64
) -> i64 {
    let mut b = m;
    let mut u = 1;
    let mut v = 0;
    while 0 < b {
      let t = a / b;
      a -= t * b;
      let s = swap(a, b);
      a = s.0;
      b = s.1;
      u -= t * v;
      let s = swap(u, v);
      u = s.0;
      v = s.1;
    }
    u %= m; 
    if u < 0 {
      u += m;
    }
    u
}

fn main() {
  input! {
    x: i64,
    y: i64,
  }
  
  let a = 2 * x - y;
  if a % 3 != 0 {
    println!("0");
    return
  }
  let a = a / 3;
  let b =  x - (2 * a);
  
  if a < 0 || b < 0 {
    println!("0");
    return
  }
  
  println!("{}", get_val(a, b));
}

Measured memory_bytes: 2184
a = input()
leng = len(a)
list(a)
time = 0

if leng % 2 == 0:
    for i in range(int(leng / 2)):
        if a[i] != a[-i - 1]:
            time += 1
else:
    for i in range(round(leng/ 2)):
        if a[i] != a[-i - 1]:
            time += 1

print(time)


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  for (int i = 0; i < n; i++) {
    cin>>a[i]>>b[i];
  }
  SORT(a);SORT(b);
  if(n%2!=0){
    cout<<b[n/2]-a[n/2]+1;
  }else{
    cout<<b[n/2]+b[(n-1)/2]-a[n/2]-a[(n-1)/2]+1;
  }
}


/* きょむ〜 */


Measured memory_bytes: 4844
def ascan; gets.split.map(&:to_i);end

cnt = Hash.new(0)

gets.to_i.times{c=gets[0];cnt[c]+=1}

x = 0
"MARCH".chars.combination(3) do |s|
    x += cnt[s[0]]*cnt[s[1]]*cnt[s[2]]
end

p x

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

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, -1, 1, 0, -1, -1, 1, 1},
          dy[] = {-1, 0, 0, 1, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x;
  cin >> x;
  x %= 1000;
  cout << (x == 0 ? 0 : 1000 - x) << '\n';
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int to, cost; };

signed main() {
	int a, b; cin >> a >> b; cout << (a - 1)*(b - 1) << endl;
}


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

using namespace std;

const int maxn=2e3+550;

typedef long long ll;

int n,m,p;

struct Edge{
	int from,to,w;
}edge[10000];

const int inf=0x3f3f3f3f;

int dis[maxn];

bool BF(int s){
	memset(dis,inf,sizeof(dis));
	dis[s]=0;
	for(int i=0;i<2*n;i++){
		for(int j=0;j<m;j++){
			int from=edge[j].from;
			int to=edge[j].to;
			int w=edge[j].w;
			if(dis[from]!=inf&&dis[to]>dis[from]+w){
				dis[to]=dis[from]+w;
				if(i>=n-1){
					if(i==n-1) dis[to]=-inf;
					if(to==n) return false;
				}
			}
		}
	}
	return true;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<m;i++){
		int x,y,w;
		scanf("%d%d%d",&x,&y,&w);
		edge[i].from=x;edge[i].to=y;edge[i].w=p-w;
	}
	if(BF(1)){
		printf("%d",max(0,-dis[n]));
	}
	else printf("-1");
	return 0;
}

Measured memory_bytes: 256
<?php
 
$n = trim(fgets(STDIN));
 
$i = 0;
$s = [];
 
while($i < $n){
	$s[$i] = str_split(trim(fgets(STDIN)));
  	sort($s[$i]);
    $s[$i] = implode($s[$i]);
	$i++;
}
 
$tmp = array_count_values($s); 

$count = 0;
foreach($tmp as $value) {
  for($i = $value -1; $i > 0; $i--) {
  	 $count += $i;
  }
}
 
echo $count;

Measured memory_bytes: 43764
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}
*/


int main() {
	int n,a[M],t;
	cin>>n>>t;
	int lmin[M],rmax[M]={};
	rep(i,0,M)lmin[i]=inf;
	rep(i,0,n)cin>>a[i];
	//1-index
	rep(i,1,n+1)lmin[i]=min(lmin[i-1],a[i-1]);
	for(int i=n+1;i>0;i--)rmax[i]=max(rmax[i-1],a[i-1]);
	int tmp_div=0,div=0,cnt_min=0,cnt_max=0;
	rep(i,1,n+1){
		int tmp=rmax[i]-lmin[i];
		tmp_div=max(tmp_div,tmp);
		if(tmp_div==tmp){
			if(div<=tmp_div){
				if(div<tmp_div){
					cnt_max=0;
					cnt_min=0;
				}
				div=tmp_div;
				cnt_max++;
				cnt_min++;
			}
		}
	}
	print(min(cnt_min,cnt_max));

}

Measured memory_bytes: 1408
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);	
	
	int N; cin >> N;
	int data[N]; F0R(i, N) {
		cin >> data[i];
	}
	
	int best, sec; best = -1, sec = -1;
	
	F0R(i, N) {
		if (data[i] > best) {
			sec = best;
			best = data[i];
		} else if (data[i] > sec) {
			sec = data[i];
		}
	}
	
	F0R(i, N) {
		if (data[i] == best) {
			cout << sec << endl;
		} else {
			cout << best << endl;
		}
	}

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 2432
#include <iostream>
#include <bitset>
#include <algorithm>
#include <queue>
#include <functional>
#include <numeric>
#include <map>
using namespace std;

int main(int argc, char *argv[])
{
#ifndef  ONLINE_JUDGE
	//freopen("test.txt", "r", stdin);
	//freopen("result.txt", "w", stdout);
#endif
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	map<char, int> mp;
	int passed = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'c')
		{
			cout << "No" << endl;
		}
		else if (s[i] == 'a')//japan
		{
			if (passed < a + b)
			{
				passed++;
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
		else if (s[i] == 'b')
		{
			mp[s[i]]++;
			if (mp[s[i]] <= b && passed < a + b)
			{
				passed++;
				cout << "Yes" << endl;
			}
			else
			{
				cout << "No" << endl;
			}
		}
	}
#ifndef  ONLINE_JUDGE
	//fclose(stdin);
	//fclose(stdout);
	//system("result.txt");
#endif
	

	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int A, B; cin >> A >> B;
    string S; cin >> S;

    string res = "Yes";
    
    if(S[A] != '-') res = "No";
    
    for(int i = 0; i < A; ++i) {
        if(S[i] == '-') {
            res = "No";
        }
    }

    for(int i = A + 1; i < A + B + 1; ++i) {
        if(S[i] == '-') {
            res = "No";
        }
    }

    cout << res << endl;
}

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

namespace AtCoder.ABC094.B
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            int n = sc.NextInt ();
            int m = sc.NextInt ();
            int x = sc.NextInt ();
            var A = sc.ArrayInt (m);
            var lcost = A.Where (val => val < x).Count ();
            var rcost = A.Where (val => val > x).Count ();
            Console.WriteLine (Math.Min (lcost, rcost));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int NextInt ()
        {
            return int.Parse (Next ());
        }
        public int[] ArrayInt (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (int N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define Long long long
#define fastIO ios::sync_with_stdio(0) , cin.tie(0)

#define all(v) v.begin() ,v.end()
#define rall(v) v.rbegin(),v.rend()
#define forn(i,n) for(__typeof(n) i=0 ;i<n ;++i)
#define pb push_back
#define debug(x) cout << "[ " << #x << " = " << x << " ]\n"

#define PI acos(-1.0)
#define EPS 1e-6
#define MOD 1e9+7

const int MXS = 2e5 + 5 ;
const Long MX = 1e18 + 5 ;


int main(){
    fastIO;
    int n,m;
    cin >> n >> m;
    vector<int> h(n);
    vector<int> adj[n];
    forn(i,n) cin >> h[i];
    forn(i,m){
        int x,y;
        cin >> x >> y;
        x-- , y--;
        adj[x].pb(h[y]);
        adj[y].pb(h[x]);
    }

    int cnt = 0;
    forn(i,n){
        int hc = h[i];
        sort(all(adj[i]));
        if(adj[i].empty() || hc > adj[i].back() ) cnt++;
    }
    cout << cnt;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
	int n, m;
	cin >> n >> m;
	string a[n], b[m];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	

	int index1 = 0;
	int index2 = 0;
	for (int i = 0; i < n - m + 1; i++) {
		for (int j = 0; j < n - m + 1; j++) {
			while (index2 < m) {
				if (a[i + index1][j + index2] == b[index1][index2]) {
					index2++;
					if (index2 == m) {
						index1++;
						index2 = 0;
						if (index1 == m) {
							cout << "Yes" << endl;
							return 0;
						}
					}
				} else {
					index1 = 0;
					index2 = 0;
					break;
				}
			}
			
		}
	}
	cout << "No" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector < pair< int, bool>> m(n);
	for (int i = 0; i < n; i++)
	{
		cin >> m[i].first;
		m[i].second = false;
	}
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		if (m[m[i].first - 1].first == i + 1
			&& m[i].second == false) {
			count++;
			m[m[i].first - 1].second = true;
		}
	}
	cout << count << endl;
}

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

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, x, y, res;
int main() {
    cin >> a >> b >> c >> x >> y;

    if (a + b < c + c) res = (a + b) * min(x, y);
    else res = 2 * c * min(x, y);
    
    if (x > y) {
        if (a < 2 * c) res += (x - y) * a;
        else res += (x - y) * 2 * c;
    } else if (y > x) {
        if (b < 2 * c) res += (y - x) * b;
        else res += (y - x) * 2 * c;
    }

    cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

const int N = 8e3+5;

int a[N];

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=0;
    ans+=min(a,k);
    k-=(a+b);
    while(k>0){
        ans-=1;
        k--;
    }
    cout<<ans<<endl;
	return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main(){
    int N;
    cin >> N;
    vector < vector <int> > graph(N);
    vector < pair <int, int> > input;
    rp(i, 0, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
        input.emplace_back(a, b);
    }
    map<pair<int, int>, int> color_map;
    vector<int> parent_color(N+1);
    queue<int> q;
    vector<int> reached(N+1);
    int K = 0;
    q.push(0);
    reached[0] = 1;
    while(!q.empty()) {
        int v = q.front(); q.pop();
        int color = 1;
        if(K < graph[v].size()) K = graph[v].size();
        for(auto x: graph[v]) {
            if(reached[x] == 1) continue;
            q.push(x);
            reached[x] = 1;
            if(color == parent_color[v]) color++;
            parent_color[x] = color_map[make_pair(v, x)] = color_map[make_pair(x, v)] = color;
            color++;
        }
    }
    printf("%d\n", K);
    rp(i, 0, N-1) {
        printf("%d\n", color_map[input[i]]);
    }
    return 0;

}

Measured memory_bytes: 22960
def way11(ball, box):
    """ball: False / box: False / constraints: 1 or less
    -> ans = int(ボールの数 <= 箱の数)
    """
    return int(ball <= box)


n, k = map(int, input().split())
MOD = 10 ** 9 + 7

print(way11(n, k))


Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n,k; cin>>n>>k;
    int t=n;
    int ans=1;
    if(n==k){
        cout<<ans<<endl;
        return 0;
    }
    t-=k;
    while(true){
        if(t<=0){
            cout<<ans<<endl;
            return 0;
        }else{
            t-=k-1;
            ans++;
        }
    }
    
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a[300000],n,temp,k;
    vector <ll> adj;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    temp=1;
    adj.push_back(temp);
    for(int i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
        {
            temp++;
            adj.push_back(temp);
        }
        else
        {
            adj.push_back(temp);
        }
    }
  //  cout<<adj.size()<<'\n';
    for(int i=1;i<adj.size();i++)
    {
        if(adj[i]<=adj[i-1])
        {
            cout<<"No\n";
        }
        else
        {
            cout<<"Yes\n";
        }
    }
    return 0;
}

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

int a[10];
bool flag;
vector< int > l;
vector< int > r;
void dfs(int dep)
{
	if (flag) return;
	if(dep == 10) {
		flag = true;
		return;
	}
	if (l.size() == 0 || l.back() < a[dep]) {
		l.push_back(a[dep]);	
		dfs(dep + 1);
	}
	if (r.size() == 0 || r.back() < a[dep]) {
		r.push_back(a[dep]);
		dfs(dep + 1);
	}
}
int main()
{
	int t;
	cin >> t;
	for (int cas = 0; cas < t; cas++) {
		l.clear();
		r.clear();
		for (int i = 0; i < 10; i++) { cin >> a[i]; }
		flag = false;
		dfs(0);
		if (flag) cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

#ifdef DEBUG
#define  DPRINT printf
#else
#define DPRINT(...)
#endif

#define SWAP(a, b, v) v = a, a = b, b = v
#define PRED(a, b) ((a)->id < (b)->id)

typedef int ID;

typedef struct node {
	ID id;
	int parent;
	int depth;
	int cnum;
	int *cids;
} TYPE;

void
insert(TYPE **a, int n, TYPE *x)
{
	int i;

	for (i = n; i > 0; i--) {
		if (PRED(a[i - 1], x))
			break;
		a[i] = a[i - 1];
	}
	a[i] = x;
}

int /* index */
find(TYPE **a, int n, ID id)
{
	int lb = 0, rb = n - 1;
	int p;

	while (p = (lb + rb) / 2, lb < rb) {
		if (a[p]->id == id)
			return p;
		if (a[p]->id < id)
			lb = p + 1;
		else
			rb = p - 1;
	}

	return a[p]->id == id ? p : -1;
}

void
define_tree(TYPE **a, int n, int r, int p)
{
	int i;
	if (a[p]->parent != -1)
		return;
	a[p]->parent = r;

	for (i = 0; i < a[p]->cnum; i++) {
		int ind = find(a, n, a[p]->cids[i]);
		DPRINT("id:%d ind %d\n", a[p]->cids[i], ind);
		if (ind >= 0)
			define_tree(a, n, p, ind);
	}
}

int
depth(TYPE **a, int p)
{
	if (a[p]->depth != -1)
		return a[p]->depth;

	a[p]->depth = a[p]->parent == -1 ? 0 : depth(a, a[p]->parent) + 1;

	return a[p]->depth;
}

int
main(void)
{
	int i, j, n;
	TYPE **a;

	scanf("%d", &n);

	a = (TYPE **)malloc(sizeof(TYPE *) * n);
	if (a == NULL)
		return 1;

	for (i = 0; i < n; i++) {
		TYPE *arg = (TYPE *)malloc(sizeof(TYPE));

		if (arg == NULL)
			return 1;
		scanf("%d%d", &arg->id, &arg->cnum);
		arg->parent = -1;
		arg->depth = -1;

		if (arg->cnum > 0) {
			arg->cids = (int *)malloc(sizeof(int) * arg->cnum);
			if (arg->cids == NULL)
				return 1;
			for (j = 0; j < arg->cnum; j++)
				scanf("%d", arg->cids + j);
		} else {
			arg->cids = NULL;
		}
		insert(a, i, arg);
	}

	for (i = 0; i < n; i++)
		define_tree(a, n, -1, i);

	for (i = 0; i < n; i++) {
		printf("node %d: ", a[i]->id);
		printf("parent = %d, depth = %d, %s, [",
		       a[i]->parent, depth(a, i),
		       a[i]->parent == -1 ? "root" :
		       a[i]->cnum > 0 ? "internal node" : "leaf");
		for (j = 0; j < a[i]->cnum; j++)
			printf("%s%d", j ? ", " : "", a[i]->cids[j]);
		puts("]");
	}

	return 0;
}



Measured memory_bytes: 6100
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  string S, T;
  int A, B;
  string U;
  cin >> S >> T >> A >> B >> U;
  map<string, int> D;
  D[S] = A;
  D[T] = B;
  D[U] --;
  cout << D[S] << " " << D[T] << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void solve(){
    int n;
    cin>>n;
    int a[n];
    for(int i =0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int cnt = 0;
    for(int i = 0;i<n;i++){
        for(int j = i+1;j<n;j++){
            for(int k =j+1;k<n;k++){
                if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<'\n';
}
int main(){
    int tt;
    tt = 1;
    //cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
number=int(input())
h=int(number/100)
t=int(number/10)-h*10
o=int(number-100*h-10*t)

if h==1:
    h=9
elif h==9:
    h=1

if t==1:
    t=9
elif t==9:
    t=1

if o==1:
    o=9
elif o==9:
    o=1

print(h*100+t*10+o)

Measured memory_bytes: 3064
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n = int(input())
ns = defaultdict(set)
uv2e = {}
for i in range(n-1):
    u,v = map(int, input().split())
    ns[u-1].add(v-1)
    ns[v-1].add(u-1)
    uv2e[u-1,v-1] = i
    uv2e[v-1,u-1] = i
    
m = int(input())
uvs = [None]*m
for i in range(m):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    uvs[i] = (u,v)
    
from queue import deque    
def bfs(start):
    q = deque([start])
    seen = [None] * n
    seen[start] = 0
    while q:
        u = q.pop()
        d = seen[u]
        for v in ns[u]:
            if seen[v] is None:
                seen[v] = u
                q.appendleft(v)
    return seen

paths = [None]*m
for i,(u,v) in enumerate(uvs):
    seen = bfs(u)
    ss = set()
    z = v
    while z!=u:
        z1 = seen[z]
        ss.add(uv2e[z,z1])
        z = z1
    paths[i] = ss
    
ans = 0
def dfs(l, s):
    if len(l)==m:
        global ans
        val = pow(2, n-1-len(s)) * pow(-1, sum(l))
        ans += val
#         print(val, sum(l), ans)
        return
    l.append(0)
    dfs(l, s)
    l.pop()
    
    i = len(l)
    p = paths[i]
    l.append(1)
    dfs(l, s|p)
    l.pop()
    
dfs([], set())
# ans = pow(2,n-1) - ans
print(ans)

Measured memory_bytes: 78632
#include<iostream>
#include <stdlib.h>
using namespace std;

#define MAX 2000001
#define N 10000

int main(){
  unsigned  short *A,*B;
int C[N+1];
int n;

cin >> n;

A=(unsigned short*)malloc(sizeof(int)*n+1);
B=(unsigned short*)malloc(sizeof(int)*n+1);

for(int i=0;i<=N;i++) C[i]=0;

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

for(int i=1;i<=N;i++)C[i]=C[i]+C[i-1];

for(int j=1;j<=n;j++){
  B[C[A[j]]]=A[j];
  C[A[j]]--;
}

for(int i=1;i<=n;i++){
  if(i>1) cout << " ";
  cout << B[i];
}
cout << endl;
  return 0;
}



Measured memory_bytes: 10868
N, W = map(int, input().split())
v = []
w = []
for _ in range(N):
    value, weight = map(int, input().split())
    v.append(value)
    w.append(weight)

dp = [[0] * (W + 1) for _ in range(N+1)]


for i in range(N):
    for j in range(W+1):
        
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],
                             dp[i][j-w[i]] + v[i]
                             )    
print(dp[N][W])


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

template <typename T>
class WeightedUnionFind {

private:

    std::vector<std::size_t> m_parent;
    std::vector<T> m_weight;

public:

    // constructor
    WeightedUnionFind(std::size_t n, T default_weight = T(0))
        : m_parent(n)
        , m_weight(n, default_weight)
    {
        std::iota(m_parent.begin(), m_parent.end(), 0);
    }

    // copy constructor
    WeightedUnionFind(WeightedUnionFind&) = default;
    WeightedUnionFind& operator=(WeightedUnionFind&) = default;

    // move constructor
    WeightedUnionFind(WeightedUnionFind&&) = default;
    WeightedUnionFind& operator=(WeightedUnionFind&&) = default;

    // destructor
    ~WeightedUnionFind() = default;

    std::size_t root(std::size_t x) {
        if (x == m_parent[x]) {
            return x;
        } else {
            auto r = root(m_parent[x]);
            m_weight[x] += m_weight[m_parent[x]];
            return m_parent[x] = r;
        }
    }

    T weight(std::size_t x) {
        root(x);
        return m_weight[x];
    }

    /* x -(w)-> y */
    void unite(std::size_t x, std::size_t y, T w) {
        w += weight(x) - weight(y);
        x = root(x), y = root(y);
        m_parent[y] = x;
        m_weight[y] = w;
    }
};

int N, M;

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

    WeightedUnionFind<long long> wuf(N);

    bool ans = true;

    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if (wuf.root(l) == wuf.root(r)) {
            if (wuf.weight(r) - wuf.weight(l) != d) {
                ans = false;
                break;
            }
        } else {
            wuf.unite(l, r, d);
        }
        // for (int j = 0; j < M; ++j) {
        //     cout << wuf.weight(j) << " ";
        // } cout << endl;
    }

    cout << (ans ? "Yes" : "No") << endl;
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;


int main() {
    ll n; cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N, L;
	scanf("%d %d", &N, &L);
	int list[N];
	int i, sum=0;
	int small = L;
	for(i=0; i<N; i++){
		list[i] = L+i;
		sum+=L+i;
		if(abs(L+i)<abs(small)){
			small = L+i;
		}
	}
	printf("%d", sum-small);
}

Measured memory_bytes: 128
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

a = LIST()

dd =defaultdict(int)

for el in a:
    dd[el]+=1

q = INT()

ans = sum(a)

while(q!=0):
    b, c = MAP()

    ans+=dd[b]*c - dd[b]*b

    dd[c]+=dd[b]
    dd[b] = 0

    print(ans)

    q-=1

Measured memory_bytes: 93948
#include <iostream>
#include <cmath>
using namespace std;
int n,a,b,h[100005];
bool check(long long times){
	long long t=times;
	for(int i=0;i<n;i++){
		if(times*b>=(long long)h[i]);
		else if(times*a>=(long long)h[i]){
			t-=(long long)ceil((double)((double)(h[i]-times*b))/((double)(a-b)));
			if(t<0) return false;
		}
		else return false;
	}
	return true;
}
int solve()
{
	int lb=-1,rb=1e9;
	while (lb<rb-1)
	{
		int mid=(lb+rb)/(long long)2;
		if (check(mid))
		{
			rb=mid;
		}
		else
		{
			lb=mid;
		}
	}
	return rb;
}
int main()
{
	cin >> n >> a >> b;
	for (int i=0;i<n;i++)
	{
		cin >> h[i];
	}
	cout << solve();
	return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
currentSum = 0
count3 = 0
count4 = 0

currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count3 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] <= 0 and restSum == 0:
        count3 += abs(currentSum) + 1
        currentSum = 1
        
currentSum = 0
for i in range(N):
    restSum = currentSum
    currentSum += A[i]
    if currentSum <= 0 and restSum < 0:
        count4 += abs(currentSum) + 1
        currentSum = 1
    elif currentSum >= 0 and restSum > 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
    elif A[i] >= 0 and restSum == 0:
        count4 += abs(currentSum) + 1
        currentSum = -1
        
print(min(count3, count4))


Measured memory_bytes: 14468
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 100003;
template<typename T>
inline void read(T &x){
	int ch = getchar();
	bool flag = false;
	x = 0;
	while((ch < '0' || ch > '9') && ch != '-') ch = getchar();
	if(ch == '-'){
		flag = true;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	if(flag) x = -x;
}
int n, a[N], ans, ans1[N], ans2[N], m;
int main(){
	read(n);
	for(Rint i = 1;i <= n;i ++) read(a[i]);
	sort(a + 1, a + n + 1);
	if(a[1] >= 0){
		int tmp = a[1];
		for(Rint i = 2;i < n;i ++){
			ans1[++ m] = tmp; ans2[m] = a[i]; tmp -= a[i];
		}
		ans1[++ m] = a[n]; ans2[m] = tmp; tmp = a[n] - tmp;
		printf("%d\n", tmp);
		for(Rint i = 1;i <= m;i ++)
			printf("%d %d\n", ans1[i], ans2[i]);
	} else if(a[n] >= 0){
		int fen = lower_bound(a + 1, a + n + 1, 0) - a, tmp = a[1];
		for(Rint i = fen;i < n;i ++){
			ans1[++ m] = tmp; ans2[m] = a[i]; tmp -= a[i];
		}
		ans1[++ m] = a[n]; ans2[m] = tmp; tmp = a[n] - tmp;
		for(Rint i = 2;i < fen;i ++){
			ans1[++ m] = tmp; ans2[m] = a[i]; tmp -= a[i];
		}
		printf("%d\n", tmp);
		for(Rint i = 1;i <= m;i ++)
			printf("%d %d\n", ans1[i], ans2[i]);
	} else {
		int tmp = a[n];
		for(Rint i = 1;i < n;i ++){
			ans1[++ m] = tmp; ans2[m] = a[i]; tmp -= a[i];
		}
		printf("%d\n", tmp);
		for(Rint i = 1;i < n;i ++)
			printf("%d %d\n", ans1[i], ans2[i]);
	}
}

Measured memory_bytes: 3072
#include<cstdio>
#include<cstring>
#define INF 1e9+7
int main()
{
    char t[100004];
    int a,b,c,d;
    while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
    {
    	int aa=0;
    	for(int i=1;i<=d-b;i++)
    	t[aa]='U',aa++;
    	for(int i=1;i<=c-a;i++)
    	t[aa]='R',aa++;
    	for(int i=1;i<=d-b;i++)
    	t[aa]='D',aa++;
    	for(int i=1;i<=c-a;i++)
    	t[aa]='L',aa++;
//    	puts(t);
    	int n=aa;
    	t[aa]='L';aa++;
    	t[aa]=t[0];t[aa+1]=t[0];aa+=2;
    	for(int i=1;i<n;i++)
    	{
    		if(t[i]=='D'&&t[i-1]=='R')
    		{
    			t[aa]='D',t[aa+1]='R',aa+=2;
//    			continue;
			}
    		if(t[i]==t[i-1])
    		t[aa]=t[i],aa++;
    		else
    		t[aa]=t[i],t[aa+1]=t[i],aa+=2;
    		
		}
		t[aa]='U';aa++;
		for(int i=0;i<aa;i++)
		printf("%c",t[i]);
		printf("\n");
	}
return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N = int(input())
    words = [input() for _ in range(N)]

    prev = words[0]
    se = set([words[0]])

    bl = True
    for w in words[1:]:
        if w in se:
            bl = False
        if prev[-1] != w[0]:
            bl = False
        se.add(w)
        prev = w

    answer = 'Yes' if bl else 'No'
    print(answer)


if __name__ == '__main__':
    main()

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int check(string s, char key){
    REP(i, 0, s.size()){
        if(s[i] != key){
            return 1;
        }
    }
    return 0;
}

int main(){
    string s; cin >> s;
    int ans = 1e9;
    REP(i, 0, 26){
        string scp = s;
        int count = 0;
        while(check(scp, alpha[i])){
            REP(l, 0, scp.size()-1){
                if(scp[l+1] == alpha[i]){
                    scp[l] = alpha[i];
                }
            }
            scp.pop_back();
            count++;
            //cout << scp << endl;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def make_divisors(n: int):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors, upper_divisors[::-1]



def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())
    lower_divisors, _ = make_divisors(n)
    print(min(lower_divisor + (n // lower_divisor) - 2 for lower_divisor in lower_divisors))





if __name__ == "__main__":
    resolve()


Measured memory_bytes: 65400
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
long long int MOD = 1000000007;
using namespace std;

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

#define MAX_N 200000

using namespace std;

int par[MAX_N];
int rnk[MAX_N];
long long int diff[MAX_N];

// 初期化
void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
		diff[i] = 0;
	}
}

// x の親を返す
P find(int x){
	P p;
	if(par[x] == x){
		p.first = x;
		p.second = 0;
		return p;
	}
	p = find(par[x]);
	diff[x] += p.second;
	p.second = diff[x];
	par[x] = p.first;
	return p;
}

// x と y を併合する
void unite(int x, int y, int z){
	P px = find(x);
	P py = find(y);
	int x_par = px.first;
	int y_par = py.first;
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
		diff[x_par] = diff[y_par] - px.second + py.second + z;
	}else{
		par[y_par] = x_par;
		diff[y_par] = diff[x_par] + px.second - py.second - z;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

// x, y が同じグループか判定
bool same(int x, int y){
	P px = find(x);
	P py = find(y);
	int x_par = px.first;
	int y_par = py.first;
	return (x_par == y_par);
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	init(n);
	
	for(int i = 0; i < q; i++){
		int num, a, b, c;
		cin >> num >> a >> b;
		if(num == 0){
			cin >> c;
			unite(a, b, c);
		}else{
			if(!same(a, b)){
				cout << "?" << endl;
			}else{
				cout << diff[a] - diff[b] << endl;
			}
		}
		/*
		for(int j = 0; j < n; j++){
			cout << par[j] << " ";
		}
		cout << endl;
		for(int j = 0; j < n; j++){
			cout << diff[j] << " ";
		}
		cout << endl;
		*/
	}
	
	return 0;
}


Measured memory_bytes: 4692
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;
int main()
{
	string a,b,c;
	while(cin>>a>>b)
	{
		c=a+a;
		for(int i=0;i<a.size();i++)
			if(b==c.substr(i,b.size()))
				{
					cout<<"Yes"<<endl;
					goto EXIT;
			}
			cout<<"No"<<endl;
EXIT:;

			return 0;
	}

}

Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>

using namespace std;

int main (void){
    int mountain_height[10];
    for (int i = 0; i < 10; i++) cin >> mountain_height[i];
    sort(&mountain_height[0],&mountain_height[0]+10,std::greater<int>());
    for (int i = 0; i < 3; i++) cout << mountain_height[i] << endl;
}


Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Highway Express Bus
 */
public class Main {

	static final int INF = 1 << 29;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int c, n, m, s, d;
			c = parseInt(st.nextToken());   //?????????????????°
			n = parseInt(st.nextToken());   //????????°
			m = parseInt(st.nextToken());   //?????????????????°
			s = parseInt(st.nextToken());   //????????????
			d = parseInt(st.nextToken());   //????????°??????
			if ((c | n | m | s | d) == 0) break;

			int[][] G = new int[n + 1][n + 1];

			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= n; j++) {
					G[i][j] = INF;
				}
			}

			for (int i = 0; i < m; i++) {
				st = new StringTokenizer(br.readLine());
				int a, b, f;
				a = parseInt(st.nextToken());
				b = parseInt(st.nextToken());
				f = parseInt(st.nextToken());
				G[a][b] = G[b][a] = f;
			}

			//
			int[][] D = new int[n + 1][c + 1];
			boolean[][] V = new boolean[n + 1][c + 1];

			for (int i = 0; i <= n; i++) {
				for (int j = 0; j <= c; j++) {
					D[i][j] = INF;
				}
			}
			D[s][c] = 0;

			//
			while (true) {

				int u = -1, k = -1, min = INF;

				for (int i = 1; i <= n; i++) {
					for (int j = 0; j <= c; j++) {
						if (!V[i][j] && D[i][j] < min) {
							min = D[i][j];
							u = i;
							k = j;
						}
					}
				}

				if (min == INF) break;

				//
				V[u][k] = true;

				for (int v = 1; v <= n; v++) {
					if (G[u][v] == INF) continue;
					D[v][k] = Math.min(D[v][k], G[u][v] + min);
					if (k > 0) {
						D[v][k - 1] = Math.min(D[v][k - 1], G[u][v] / 2 + min);
					}
				}
			}

			//
			int min = INF;

			for (int i = 0; i <= c; i++) {
				min = Math.min(min, D[d][i]);
			}

			System.out.println(min);
		}
	}
}

Measured memory_bytes: 41748
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}

int main(){
  int d,n;
  cin>>d>>n;
  if(n==100)n++;
  if(d==0){cout<<n<<endl;}
  else if(d==1){cout<<100*n<<endl;}
  else cout<<10000*n<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

// int solve(vector<int> a){
	// int 
// }

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, sum = 0, minimum = INF;
	vector<int> a;
	
	cin>>N;
	
	a.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>a[i];
		minimum = min(minimum, a[i]);
		sum += a[i];
	}
	
	if(N % 2) {
		if(sum % 2) cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	} else {
		if(sum % 2) {
			if(minimum % 2) cout<<"First"<<endl;
			else cout<<"First"<<endl;
		} else {
			if(minimum % 2) cout<<"First"<<endl;
			else cout<<"Second"<<endl;
		}
	}
	
	return 0;
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
    while (u != NIL && k != u->key) {
        if (k < u->key) {
            u = u->left;
        } else {
            u = u->right;
        }
    }
    return u;
}

Node * treeMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

Node * treeSuccessor(Node *x) {
    if (x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while (y!= NIL && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node * z) {
    Node *y;
    Node *x;

    if (z->left == NIL || z->right == NIL) {
        y = z;
    } else {
        y = treeSuccessor(z);
    }

    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    } else if (y == y->parent->left) {
        y->parent->left = x;
    } else {
        y->parent->right = x;
    }

    if (y != z) {
        z->key = y->key;
    }

    free(y);
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, x;
    string com;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com == "find") {
            cin >> x;
            Node *t = find(root, x);
            if (t != NIL) {
                cout << "yes" << endl;
            } else {
                cout << "no" << endl;
            }
        } else if (com == "insert") {
            cin >> x;
            insert(x);
        } else if (com == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if (com == "delete") {
            cin >> x;
            treeDelete(find(root, x));
        }
    }
}



Measured memory_bytes: 21988
/* ex2-4
    kas056*/

#include<stdio.h>
#define SIZE 15


int main(void){
    char sentence[SIZE];
    char *p;
    int length = 0;
    int maxlen = 0;

    scanf("%s", sentence);

    p = sentence;//ポインタを連結

    //ヌル文字に到達するまで操作を行う
    while(*p){
        //該当する文字があったらカウント開始。
        if(*p == 'A' || *p == 'C' || *p == 'G' || *p == 'T'){
            length++;
        }
        else{//該当するものが続かなければ、カウントをリセットする。
            length = 0;
        }

        if(length > maxlen){
            maxlen = length;//最高記録を超えたら更新
        }

        p++;//次の文字に進む
    }

    printf("%d\n", maxlen);

    return 0;

}

Measured memory_bytes: 1696