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

#define REP(i, s, n) for (ll i = s; i < n; i++)
#define setarr(arr, v) for (ll i = 0; i < sizeof(arr)/sizeof(arr[0]); ++i) {arr[i] = v;}
#define pvar(x) cout << #x << " = " << x << endl;
#define mset(x, v) memset(x, v, sizeof(x));
#define fi() first
#define se() second
#define pb() push_back
#define be() begin()
#define en() end()
#define len() length()
#define mp(x, y) make_pair(x, y)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<ll> sll;
typedef queue<ll> qll;

#define let auto

template<class U, class V>
ostream& operator<<(ostream& os, const pair<U, V>& p) {os << "(" << p.first << ", " << p.second << ")";return os;}

template<class U, class V>
istream& operator>>(istream& in, pair<U, V>& p) {in >> p.first >> p.second;return in;}

namespace cp {
    template <typename T>
    T min (T first) {return first;}
    template <typename T, typename... Args>
    T min (T first, Args... args) {return std::min (first, min (args...));}

    template <typename T>
    T max (T first) {return first;}
    template <typename T, typename... Args>
    T max (T first, Args... args) {return std::max (first, max (args...));}
};

using cp::min;
using cp::max;

ll n;
const ll N = 2e6;
bool vis[N];

void dfs (ll u, vvll & al) {
    if (vis[u]) return;
    vis[u] = true;
    for (ll v: al[u]) {
	dfs (v, al);
    }
}

void solve () {
    ll m; cin >> n >> m;
    vvll al (n); REP (i, 0, m) {
	ll u, v; cin >> u >> v;
	u--, v--;
	al[u].push_back (v);
	al[v].push_back (u);
    }
    ll components = 0;
    for (ll i = 0; i < n; i++) {
	if (!vis[i]) {
	    components++;
	    dfs (i, al);
	}
    }
    cout << components-1 << endl;
}

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


Measured memory_bytes: 10024
#include <iostream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
using ll = long long;

int main() {

    set<string> items;
    int N;
    cin >> N;
    while (N--) {
        string item;
        cin >> item;
        items.insert(item);
    }

    cout << items.size() << "\n";

    return 0;
}


Measured memory_bytes: 19204
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5 + 1e2;
int n,a[N],b[N],c[N],t;
LL ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>t;
		ans+=t;
	}
	for(int i=1;i<=n-1;i++)
	{
		cin>>c[i];
	}
	for(int i=1;i<=n-1;i++)
	{
		if(a[i+1]==a[i]+1)ans+=c[a[i]];
	}
	cout<<ans;
}


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

using namespace std;
typedef long long ll;

static ll num[] = {0,2,5,5,4,5,6,3,7,6};

int main() {
  ll N; cin >> N;
  ll M; cin >> M;
  vector<ll> A(M);
  for (ll j=0; j < M; ++j) cin >> A[j];
  sort(A.rbegin(), A.rend());
  vector<ll> dp(N+1);
  for (ll j=1; j < N+1; ++j) {
    dp[j] = -1000000;
    for (ll k=0; k < M; ++k) {
      if (j >= num[A[k]]) {
        dp[j] = max(dp[j], dp[j-num[A[k]]]+1);
      }
    }
  }
  ll n = N;
  for (ll j=0; j < dp[N]; ++j) {
    for (ll k=0; k < M; ++k) {
      if (n-num[A[k]] >= 0 && dp[n-num[A[k]]] == dp[n]-1) {
        cout << char('0'+A[k]);
        n -= num[A[k]];
        break;
      }
    }
  }
  cout << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if((s =="RSS" || s == "SSR")||(s == "SRS" || s == "RSR")) cout << 1 << endl;
  else if(s == "RRS" || s == "SRR") cout << 2 << endl;
  else if(s == "RRR") cout << 3 << endl;
  else cout << 0 << endl;
}

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


int main() {
    string s;
    cin>>s;
    int c=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='+'){
            c++;
        }else{
            c--;
        }
    }
    cout<<c<<endl;
    return 0;



}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: int(x) - 1, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n)

    def get(self, init=None):
        if self.v is None:
            return init
        else:
            return self.v


def main():
    N = format(int(input()), "b")
    D = len(str(N))
    dp = [[0 for _ in range(3)] for __ in range(D + 1)]

    dp[0][0] = 1
    for d in range(D):
        for k in range(3):
            for s in range(3):
                sd = 2 * s + int(N[d]) - k
                if sd > 2:
                    sd = 2
                if sd < 0:
                    continue
                dp[d + 1][sd] += dp[d][s]
                dp[d + 1][sd] %= mod

    print(sum(dp[D]) % mod)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
n = int(input())
a = [ i for i in list(map(int,input().split()))]
b = [j for j in list(map(int,input().split()))]
c = [k for k in list(map(int,input().split()))]
c.append(0)
count  = 0
prev = 0
for o in a:
    count += b[o-1]
    if o == prev +1:
        count +=c[o-2]
        prev = o
    else:
        prev = o
print(count)

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

using namespace std;

const int N = 400010;

int p[N], n;

int find(int x) {
    return x == p[x] ? p[x] : p[x] = find(p[x]);
}

int main() {
    cin >> n;
    int m;
    cin >> m;
    for (int i = 1; i <= n; ++i) p[i] = i;
    for (int i = 1; i <= m; ++i) {
        int t, a, b;
        cin >> t >> a >> b;
        if (t == 0) p[find(a)] = find(b);
        else {
            if (find(a) == find(b)) cout << 1 << '\n';
            else cout << 0 << '\n';
        }
    }
    return 0;
}

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


#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<int, int> P;
typedef tuple<int, int, int> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;

int main() {
	ll n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
	}
	ll s, t;
	cin >> s >> t;
	s--; t--;
	vector<vector<ll>> dp(n, vector<ll>(3, INF));
	priority_queue<P, vector<P>, greater<P>> q;
	q.emplace(0, s);
	while (!q.empty()) {
		auto p = q.top(); q.pop();
		auto step = p.first;
		auto ns = step % 3;
		auto current = p.second;
		if (dp[current][ns] <= step) continue;
		dp[current][ns] = step;
		if (current == t && ns == 0) break;
		for (auto e : g[current]) {
			if (dp[e][(step + 1) % 3] <= step+1) continue;
			q.emplace(step + 1, e);
		}
	}
	if (dp[t][0] == INF) {
		cout << -1 << endl;
	}
	else {
		cout << dp[t][0] / 3 << endl;
	}
	return 0;
}


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

int main(){
  int N,count = 0,flag,end,m;
  cin>>N;
  int i=0,h[N];
    while(i<N){
        cin>>h[i];
        i++;
    }
  
  while(true){
    flag = 0;
    end = 0;
    for(i=0;i<N;i++){
      if(h[i] > 0){
        end = 1;
        h[i]--;
        if(flag==0){
          count++;
        }
        flag = 1;
      } 
      else if(h[i]==0){
        flag = 0;
      }
      
    }
    if(end==0){
    cout<<count<<endl;
    break;
    }
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	//AGC 017 Biscuits

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int p = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		int []b = new int [n];
		
		for(int i = 0 ;i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
			b[i] = a[i] % 2;
		}
		
		int x = 0;
		int y = 0;
		
		
		for(int i = 0 ; i < n ;i++) {
			if(b[i] == 0) {
				x++;
			}
		}
		y = n - x; 

		long []c = new long [y+1];
		
		c[0] = 1;
		
		for(int i = 1 ; i <= y ;i++) {
			c[i] = c[i-1] * (y+1-i)/i;
		}
		
		long ans = (long)Math.pow(2, x);
		
		if(p == 0) {
			long temp = 0;
			for(int i = 0 ; i <= y ; i+= 2) {
				temp += c[i];
			}
			System.out.println((temp*ans));
		}
		else {
			long temp = 0;
			for(int i = 1 ; i <= y;i+= 2) {
				temp += c[i];
			}
			System.out.println(temp*ans);
		}
	}
}


Measured memory_bytes: 23636
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():

    N, M, *A = map(int, read().split())
    B = [False] * (N + 1)
    for a in A:
        B[a] = True

    dp = [0] * (N + 10)
    dp[0] = 1
    for i in range(N):
        if B[i]:
            continue
        dp[i + 1] = (dp[i + 1] + dp[i]) % MOD
        dp[i + 2] = (dp[i + 2] + dp[i]) % MOD

    print(dp[N])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

ll n,k;

int mul(int a, int b){
    return (ll) a*b % mod;
}

vvi matmul(vvi &a, vvi &b){
    vvi res(n, vi(n));
    
    forn(i,n)
        forn(j,n)
            forn(k,n)
                add_self(res[i][j], mul(a[i][k], b[k][j]));
    return res;
}

vvi matPow(vvi &a, ll p){
    vvi res(n, vi(n));
    forn(i,n)
        res[i][i] = 1;
    
    while(p){
        if(p&1)
            res = matmul(res,a);
        a = matmul(a,a);
        p>>=1;
    }
    return res;
}

int main(){
    
    while(cin>>n>>k){
        vvi can(n, vi(n));
        forn(i,n)
            forn(j,n) 
                cin>>can[i][j];

        can = matPow(can,k);

        int ans = 0;
        forn(i,n)
            forn(j,n)
                add_self(ans, can[i][j]);
        
        cout<<ans<<endl;

        // vi dp(n,1);
        // for(ll steps =0; steps<k; ++steps){
        //     vi ndp(n);
        //     forn(i,n){
        //         forn(j,n){
        //             if(can[i][j])
        //                 add_self(ndp[j], dp[i]);
        //         }
        //     }
        //     dp = ndp;
        // }

        // int ans = 0;
        // for(auto x: dp)
        //     add_self(ans,x);
        // cout<<ans<<endl;
    
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define LOOP_IT(it,s) for(auto it=(s).begin();it!=(s).end();++it)






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...)
#endif




int main(int argc,char* argv[])
{
    ZOOM


    string s;bool f=0;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        f=1;
    cout<<(f?"Yes\n":"No\n");

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct coord { ll x, y; };

int main() {
  ll H, W; cin >> H >> W;
  coord c, d; cin >> c.x >> c.y >> d.x >> d.y; c.x--; c.y--; d.x--; d.y--;
  string S[H]; rep(i,H) cin >> S[i];

  ll dis[H][W] = {}; rep(i,H) fill_n(dis[i],W,LLINF);  dis[c.x][c.y] = 0;
  deque<coord> deq; deq.push_back({c.x,c.y});
  bool jump[5][5] = {
    {1, 1, 1, 1, 1},
    {1, 1, 0, 1, 1},
    {1, 0, 0, 0, 1},
    {1, 1, 0, 1, 1},
    {1, 1, 1, 1, 1}
  };
  while (deq.size()) {
    coord from = deq[0]; deq.pop_front();
    rep(i,5) rep(j,5) {
      coord to = {from.x+i-2, from.y+j-2};
      if (to.x<0||to.x>=H||to.y<0||to.y>=W||S[to.x][to.y]=='#') continue;
      if (dis[to.x][to.y]>dis[from.x][from.y]+jump[i][j]) {
        dis[to.x][to.y] = dis[from.x][from.y]+jump[i][j];
        if (jump[i][j]) deq.push_back({to.x, to.y});
        else deq.push_front({to.x, to.y});
      }
    }
  }
  // rep(i,H) debug(dis[i],dis[i]+W);

  ll result = dis[d.x][d.y];
  if (result==LLINF) result = -1;
  cout << result << endl;
  return 0;
}

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

using namespace std;

int solve(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	long long sum = min(a,k);
	k = k-(a+b);
	if(k<=0)
		return sum;
	sum -= k;
	return sum;
}
int main(){
	
	cout<<solve();

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define EB emplace_back
#define G(i,x) get<i>(x)
#define F(i,s,n) for(int i = s; i < n; i++)

int N;
int a[100000];
int dp[100000];

int solv (int index) {
	if (index >= N - 1) {
		return 0;
	}

	if (dp[index] != -1) {
		return dp[index];
	}

	//jump to i + 1
	int cost1 = abs(a[index] - a[index + 1]);
	int option1 = solv(index + 1) + cost1;

	if (index == N - 2) {
		return dp[index] = option1;
	}
	//option2 : jump to i + 2
	int cost2 = abs(a[index] - a[index + 2]);
	int option2 = solv(index + 2) + cost2;


	return dp[index] = min(option1, option2);
}

int main( ) {
	iostream::sync_with_stdio(false);
	int i,j;
	cin >> N;
	F(i,0,N) {
		cin>> a[i];
		dp[i] = -1;
	}
	
	int result = solv(0);
	cout << result;
	
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);
const ll L = (MOD-7)*(MOD-7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	ll ans = 1ll,a;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		if(!(ans && a)){
			ans = 0ll;
			continue;
		}
		if(ans < 0ll){
			continue;
		}
		if(L/ans<a){
			ans = -1ll;
		}else{
			ans *= a;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3624
n, m = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(m)]

ans = [-1]*n
flag = False

for s, c in X:
    if ans[s-1] >= 0 and ans[s-1] != c:
        flag = True
    if n > 1 and s == 1 and c == 0:
        flag = True
    else:
        ans[s-1] = c

if flag:
    print(-1)
    exit(0)

for i in range(n):
    if ans[i] == -1:
        if n > 1 and i == 0:
            ans[i] = 1
        else:
            ans[i] = 0

print(*ans, sep="")

Measured memory_bytes: 61764
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstring>

#define M 10000000
#define L 14

using namespace std;

char H[M][L];

//将字符转换为数值
int getChar(char ch);
//将字符串转换为数值并生成Key
long long getKey(char str[]);
//散列函数1
int h1(int key);
//散列函数2
int h2(int key);//开放地址法解决冲突
//散列查找函数
int find(char str[]);
//散列插入函数
int insert(char str[]);
int main() {

	int i, n;
	char str[L], com[9];
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com >> str;
		if (com[0] == 'i')insert(str);
		else {
			if (find(str))
				cout << "yes\n";
			else
				cout << "no\n";
		}
	}
	return 0;
}

int getChar(char ch)
{
	if (ch == 'A')
		return 1;
	else if (ch == 'C')
		return 2;
	else if (ch == 'G')
		return 3;
	else if (ch == 'T')
		return 4;
	else
		return 0;
}

long long getKey(char str[])
{
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += getChar(str[i])*p;
		p *= 5;
	}
	return sum;
}

int h1(int key)
{
	return key % M;
}

int h2(int key)
{
	return 1 + (key % (M - 1));
}

int find(char str[])
{
	long long key, i, h;
	key = getKey(str);//将字符串转为key值
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;//当前位置为所要查找的字符串
		else if (strlen(H[h]) == 0) return 0;//当前位置为空
	}
	return 0;
}

int insert(char str[])
{
	long long key, i, h;//键值key，散列值h
	key = getKey(str);//获取键值
	for (i = 0;; i++) {
		h = h1(key) + i * h2(key);
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 51864
N,M,Q = map(int,input().split())
LR = [[0 for _ in range(N)] for _ in range(N)]

for j in range(M):
  l,r = map(int,input().split())
  LR[l-1][r-1] += 1

for i in range(N):
  for j in range(1,N):
    LR[i][j] += LR[i][j-1]

for _ in range(Q):
  p,q = map(int,input().split())
  ans = 0
  for i in range(q-p+1):
    ans += LR[p+i-1][q-1]
  print(ans)

Measured memory_bytes: 53592
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;

const int N = 1e5;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int tc, ca = 0;
  double r;
  cin >> r;
  double pi = acos(-1.0);
  cout << fixed <<  setprecision(2);
  cout << 2*pi*r << '\n';
  return 0;
}


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

using namespace std;

int main()
{
    int n,i;
    double a,ans=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        ans =ans + 1/a;
    }
    ans = 1/ans;
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	priority_queue<int> que;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		que.push(a);
	}

	for (int i = 0; i < M; ++i) {
		int a = que.top(); que.pop();
		a /= 2;
		que.push(a);
	}

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

	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  string str;
  int c = 0;
  while (cin >> str) {
    cin.ignore();
    string S, R;
    S = str.substr(0, str.size() / 2);
    if (str.size() % 2 == 0) {
      R = str.substr(str.size() / 2, str.size() / 2);
    } else {
      R = str.substr(str.size() / 2 + 1, str.size() / 2);
    }
    reverse(R.begin(), R.end());
    if (S == R) {c++;}
  }
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

	ll k,n;
  	cin >> k >> n;
  	vl A(n+1);
  	rep(i,n) cin >> A[i];
  	ll t = A[0];
  	rep(i,n) A[i]-=t;	
  	A[n] = k;
  	vl aida(n);
  	rep(i,n) aida[i] = A[i+1] - A[i];
  	cout << k - maxel(aida) << endl;
  	
  	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main(){
	char c;
	cin >> c;
	int ans;
	switch(c){
		case 'a':
			ans=1;
			break;
		case 'i':
			ans=1;
			break;
		case 'u':
			ans=1;
			break;
		case 'e':
			ans=1;
			break;
		case 'o':
			ans=1;
			break;
		default:
			ans=0;
	}
	if(ans) cout << "vowel" << endl;
	else cout << "consonant" << endl;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))

u = v[1::2] #奇数列
d = v[0::2] #偶数列

U = [0] * 100010
for i in range(len(u)): #何種類の数が何個現れるか記録
    U[u[i]] += 1
    
D = [0] * 100010
for i in range(len(d)): #何種類の数が何個現れるか記録
    D[d[i]] += 1
   
if U.index(max(U)) == D.index(max(D)): #最頻値が同じ場合
    u = sorted(U, reverse=True)
    d = sorted(D, reverse=True)
    s = n - u[1] - d[0] if u[1] > d[1] else n - u[0] - d[1]
    print(s)
    exit()
    
print(n - max(U) - max(D))


Measured memory_bytes: 20792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,k,x[105];
int ans;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
        ans+=(min(abs(x[i]),abs(k-x[i]))*2);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	ll dp[n+1][k+1];
	for(int i=0;i<=n;i++)dp[i][0]=1;
	for(int j=1;j<=k;j++)dp[0][j]=0;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(j<=a[i])
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;	
			else
				dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-a[i]-1]+mod)%mod;	
		}	
	}
	cout<<dp[n][k]<<endl;
}



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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){roll(1,2,4,3);} 
    void roll_y(){roll(0,2,5,3);} //to W
    void roll_x(){roll(0,1,5,4);} //to N
    void roll(int i,int j,int k,int l){
        int tmp=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=tmp;
    }
    void move(char ch){
        if(ch=='E') for(int i=0;i<3;i++)roll_y();
        if(ch=='W') roll_y();
        if(ch=='N') roll_x();
        if(ch=='S') for(int i=0;i<3;i++) roll_x();
    }
};

//???????????????????????????????????????????????????????????????????????¢??°
bool eq(Cube c1,Cube c2){
    for(int i=0;i<6;i++)
        if(c1.f[i]!=c2.f[i])return false;
    return true;
}

bool equal(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(eq(c1,c2))return true;
            c1.roll_z();
        }
        if(i%2==0)c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

Cube C[100];
int n;

bool check(){
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)if(equal(C[i],C[j]))return false;
    return true;
}

int main(void){
    cin>>n;
    for(int j=0;j<n;j++)
     for(int i=0;i<6;i++)cin>>C[j].f[i];
    Cube c1,c2;
        
    if(check())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = (s); i < (n); i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int n;
  cin >> n >> s;
  
  long long r=0, g=0, b=0;
  rep(i, 0, n) {
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
  }

  long long ans = r*g*b;
  
  rep(i, 1, n-1) {
    int r = min(n-1-i, i-0);
    rep(j, 1, r+1) {
      if(s[i-j]!=s[i] and s[i]!=s[i+j] and s[i+j]!=s[i-j]) ans--;
    }
  }
  cout << max(0LL, ans) << "\n";  
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve(){
	double d,t,s;
	cin>>d>>t>>s;
	if((d/s)<=t)
	cout<<"Yes\n";
	else
	cout<<"No\n";
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define MAX_N 100001
#define mod(x) ((x % MOD) + MOD) % MOD

using namespace std;

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

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int M = max(max(A, B), C);
    
    int tmp_M = M;
    for (int i = 0; i < K; ++i) {
        tmp_M *= 2;
    }
    
    cout << (A + B + C) - M + tmp_M << endl;
    
    return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  ll X, Y;
  cin >> X >> Y;

  if ((X+Y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  int m = (2 * X - Y) / 3;
  int n = X - 2 * m;

  if (m < 0 || n < 0) {
    cout << 0 << endl;
    return 0;
  }

  combination c(n+m);
  mint ans = c(n+m, n);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){

	double n;
	double max = 0, min = 20000000;
	while(cin >> n){
		if(cin.eof()) break;
		if(max < n) max = n;
		if(min > n) min = n;
	}

	printf("%0.1f\n", max - min);

	return 0;
}

Measured memory_bytes: 1236
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,X=mi()

    def solve(n,x):
        # print(n,x)
        if n == 0: return 1
        c = 2**(n+2)-3
        half = c//2

        res = 0
        if x <= half:
            if x == 1:
                res += 0
            else:
                res += solve(n-1,x-1)
        elif x == half+1:
            res += 2**(n-1+1) - 1 + 1
        elif x < c:
            res += 2**(n-1+1) - 1 + 1 + solve(n-1,x-(half+1))
        else:
            assert x == c
            res += 2**(n+1)-1

        return res

    print(solve(N,X))



if __name__ == "__main__":
    main()

Measured memory_bytes: 9140
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	cout << min_element(A.begin(), A.end()) - A.begin() + 1 << endl;
	return 0;
}


Measured memory_bytes: 3356
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;

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

    for(int i = 1; i < n; i++){
        if(s[i] != s[i-1]) res = min(res, max(i,n-i));
    }

    cout << res << endl;

    return 0;
}


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

int main(){
  char b;
  cin>>b;
  if(b=='A')cout<<'T'<<endl;
  if(b=='T')cout<<'A'<<endl;
  if(b=='G')cout<<'C'<<endl;
  if(b=='C')cout<<'G'<<endl;
}


Measured memory_bytes: 256
import math

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n,x,t=input2()
ans=(math.ceil(n/x))*t
print(ans)

Measured memory_bytes: 9048
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final String S = sc.next();
		for(int i=0;i<S.length();i+=2) {
			final char c = S.charAt(i);
			// 0文字目＝1文字目なので奇数
			if(c == 'L') {
				out.println("No");
				return;
			}
		}
		for(int i=1;i<S.length();i+=2) {
			final char c = S.charAt(i);
			// 1文字目＝2文字目なので奇数
			if(c == 'R') {
				out.println("No");
				return;
			}
		}
		out.println("Yes");
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define NMAX 100005
using namespace std;

long long n,g,w[105],v[105],dp[100005],maxim,rasp;

int main()
{
    cin>>n>>g;
    for(int i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
    }
    memset(dp,9999999,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        for(int j=maxim;j>=1;j--)
        {
            if(dp[j]&&dp[j]+w[i]<=g)
            {
                dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
                maxim=max(maxim,j+v[i]);
                rasp=max(rasp,j+v[i]);
            }
        }
        dp[v[i]]=min(w[i],dp[v[i]]);
        rasp=max(rasp,v[i]);
        maxim=max(maxim,v[i]);
    }
    cout<<rasp;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
ss = [False for _ in range(n + 1)]
ts = [False for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        ss[b] = True
    if b == n:
        ts[a] = True
ok = False
for i in range(n):
    if ss[i] and ts[i]:
        ok = True
        break
if ok:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 6320
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N,A,B;

    private void solve() {
        N = nextInt();
        A = nextInt();
        B = nextInt();

        if (Math.abs(A - B) % 2 == 1) {
            out.println("Borys");
        } else {
            out.println("Alice");
        }
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21460
using System;
using System.Linq;
using static System.Console;
using static System.Math;
public class Hello{
    public static void Main(){
        var line = int.Parse(Console.ReadLine());
        var s = line % 60;
        var m = line / 60 % 60;
        var h = line / 3600;
        WriteLine($"{h}:{m}:{s}");
    }
}



Measured memory_bytes: 19888
#include<bits/stdc++.h>
using namespace std;
 
/*
*****************code written By**********************
..................Marajul islam.......................
...................BSMRSTU,CSE........................
*/ 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
 
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 5e6 + 5;
 
inline int add(int a, int b) {a += b; return a >= mod ? a - mod : a;}
inline int sub(int a, int b) {a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b) {return (ll)a * b % mod;}
 

 
 
int solve() {
 
	long double a,b,c;
	cin>>a>>b>>c;
	long double a1=sqrt(a)+0.0000000000000000000001;
	long double b1=sqrt(b)+0.0000000000000000000001;
	long double c1=sqrt(c)+0.0000000000000000000001;
	long double pk=a+b+2.00*(a1*b1);
	if(pk<c){
		puts("Yes");
	}
	else{
		puts("No");
	}
 
	return 0;
}
 
 
 
 
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
 
	int test = 1, tc = 0;
	//scanf("%d", &test);
	//cin >> test;
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
 
	return 0;
 
 
 
 
}




Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(x1:i64 y1:i64 x2:i64 y2:i64));

    let (a, b, c, d) = (x2 - y2 + y1, y2 + x2 - x1, x1 - y2 + y1, y1 + x2 - x1);
    format!("{} {} {} {}", a, b, c, d).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "0 0 0 1" => "-1 1 -1 0",
    test2: "2 3 6 6" => "3 10 -1 7",
    test3: "31 -41 -59 26" => "-126 -64 -36 -131",
}


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

int main(){
    int n;
    cin >> n;
    vector<char> v(n);
    int64_t c_r = 0;
    int64_t c_g = 0;
    int64_t c_b = 0;
    for(int i = 0; i < n;i++) {
        char c;
        cin >> c;
        if(c == 'R') c_r++;
        else if(c == 'G') c_g++;
        else if(c == 'B') c_b++;
        v.at(i) = c;
    }
    int64_t eq_c = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n;j++){
            int k = j + j - i;
            if(k >= n)continue;
            if(v.at(i) != v.at(j) && v.at(j) != v.at(k) && v.at(i) != v.at(k)) eq_c++;
        }
    }
    int64_t ans = c_r * c_b * c_g - eq_c;
    cout << ans << endl;
     
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <stack>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int func(vector<int>& v) {
	stack<P> st;
	int n = v.size(), ret = 0;

	rep(i, n) {
		int len = 1, c = v[i];
		REP(j, i+1, n) {
			if(c == v[j]) {
				i++;
				len++;
				continue;
			} else break;
		}

		if(len >= 4) continue;
		else {
			if(st.size() == 0) {
				st.push(mp(c, len));
				ret += len;
			} else {
				P p = st.top();
				if(p.first == c) {
					if(p.second + len < 4) {
						st.top().second += len;
						ret += len;
					} else {
						st.pop();
						ret -= p.second;
					}
				} else {
					st.push(mp(c, len));
					ret += len;
				}
			}
		}
	}

	return ret;
}

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

		vector<int> v(n);
		rep(i, n) cin >> v[i];

		int ans = n + 1;
		rep(i, n) {
			int t = v[i];

			v[i] = 1;
			if(i == 0) {
				v[i] = v[i+1];
				ans = min(ans, func(v));
			} else if(i == n-1) {
				v[i] = v[i-1];
				ans = min(ans, func(v));
			} else {
				if(v[i+1] == v[i-1]) {
					v[i] = v[i+1];
					ans = min(ans, func(v));
				} else {
					v[i] = v[i-1];
					ans = min(ans, func(v));

					v[i] = v[i+1];
					ans = min(ans, func(v));
				}
			}

			v[i] = t;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main() {
    ios;
  unsigned ll x,y,a,b,c;cin>>x>>y>>a>>b>>c;
  unsigned ll ar[a]; unsigned ll bb[b]; unsigned ll cc[c];
   f(i,0,a)cin>>ar[i];
   sort(ar,ar+a);
   f(i,0,b)cin>>bb[i];
   sort(bb,bb+b);
   f(i,0,c)cin>>cc[i];
   sort(cc,cc+c);
  unsigned ll ans=0;
   int j=a-x; int k=b-y;
   int i;
   for( i=c-1;i>=0&&j<a&&k<b;i--)
   {
       if(ar[j]>=bb[k]&&cc[i]>bb[k])ans+=cc[i],k++;
       else if(ar[j]<bb[k]&&cc[i]>ar[j])ans+=cc[i],j++;
   }
   if(j==a)
   {
       for( ;i>=0&&k<b;i--){
           if(bb[k]<cc[i])ans+=cc[i],k++;
       }
   }
   if(k==b)
   {
       for( ;i>=0&&j<a;i--){
           if(ar[j]<cc[i])ans+=cc[i],j++;
       }
   }
   //cout<<ans;
   for(int p=j;p<a;p++){
       ans+=ar[p];
   }
   for(int p=k;p<b;p++){
       ans+=bb[p];
   }
   cout<<ans;
   
   
 
    
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
 
 
int main() {
	
int N;
cin>>N;
ll takahashi=0,aoki=0;
cin>>takahashi>>aoki;
fx(N-1){
	ll a,b,i=1,k;
	cin>>a>>b;
 
if(takahashi%a==0){
i=takahashi/a;
}else{
i=takahashi/a+1;
}
 
if(aoki%b==0){
k=aoki/b;
}else{
k=aoki/b+1;
}
	takahashi=a*max(i,k);
aoki=b*max(i,k);
}
 
ce(takahashi+aoki)
	
}

Measured memory_bytes: 256
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print("AC x "+ str(ac))
print("WA x "+ str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 110000
#define offset 200
#define ptr nodo*
const ll inf=2e18;
int v[4];
int doit(int i,int j)
{
	int c=0;
	while(v[j]<=v[i])
		v[j]*=2,c++;
	return c;
}
int main()
{
	int k;
	forr(i,0,3)
	cin>>v[i];
	cin>>k;
	k-=doit(0,1);
	k-=doit(1,2);
	if (k>=0)
		cout<<"Yes\n";
	else
		cout<<"No\n";

}				

Measured memory_bytes: 3608