akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	
	public static int exec(int a, int b, int ops){
		return ops == 0 ? a + b : ops == 1 ? a - b : a * b; 
	}
	
	public static String print(String l, String r, int ops){
		return "(" + l + (ops == 0 ? " + " : ops == 1 ? " - " : " * ") + r +  ")";
	}
	
	public static String print(int a, int b, int ops){
		return "(" + a + (ops == 0 ? " + " : ops == 1 ? " - " : " * ") + b +  ")";
	}
	
	public static String print(String l, int b, int ops){
		return "(" + l + (ops == 0 ? " + " : ops == 1 ? " - " : " * ") + b +  ")";
	}
	
	public static String print(int a, String l, int ops){
		return "(" + a + (ops == 0 ? " + " : ops == 1 ? " - " : " * ") + l +  ")";
	}
	
	public static boolean check2(int a, int b, int c, int d, int ops1, int ops2, int ops3){
		if((exec(exec(exec(a,b,ops1),c,ops2),d,ops3)) == 10){
			System.out.println((print(print(print(a,b,ops1),c,ops2),d,ops3)));
			return true;
		}else if(exec(exec(a,exec(b,c,ops2),ops1),d,ops3) == 10){
			System.out.println(print(print(a,print(b,c,ops2),ops1),d,ops3));
			return true;
		}else if((exec(exec(a,b,ops1),exec(c,d,ops3),ops2)) == 10){
			System.out.println(print(print(a,b,ops1),print(c,d,ops3),ops2));
			return true;
		}else if((exec(exec(a,exec(b,c,ops2),ops1),d,ops3)) == 10){
			System.out.println(print(print(a,print(b,c,ops2),ops1),d,ops3));
			return true;
		}else if((exec(a,exec(b,exec(c,d,ops3),ops2),ops1)) == 10){
			System.out.println(print(a,print(b,print(c,d,ops3),ops2),ops1));
			return true;
		}
		return false;
	}
	
	public static boolean check(int a, int b, int c, int d){
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					if(check2(a,b,c,d,i,j,k)){
						return true;
					}
				}
			}
		}
		
		return false;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			final int c = sc.nextInt();
			final int d = sc.nextInt();

			if (a == 0 && b == 0 && c == 0 && d ==0) {
				break;
			}
			
			int[] array = {a, b, c, d};
			
			boolean found = false;
			end:
			for(int i = 0; i < 4; i++){
				for(int j = 0; j < 4; j++){
					for(int k = 0; k < 4; k++){
						for(int l = 0; l < 4; l++){
							if(i == j || j == k || k == l || l == i || i == k || j == l){
								continue;
							}
							
							if(check(array[i], array[j], array[k], array[l])){
								found = true;
								break end;
							}
						}
					}
				}
			}
			
			if(!found){
				System.out.println("0");
			}
		}

	}

}

Measured memory_bytes: 12000
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
    int k,a,b,bo=0;
    scanf("%d%d%d",&k,&a,&b);
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            printf("OK");
            bo =1;
            break;
        }
    }
    if(bo==0)
        printf("NG");

    return 0;
}

Measured memory_bytes: 3728
#include<stdio.h>
#include<queue>
#include<map>
using namespace std;
typedef pair<int,int> P;
int len[100002];
int main(){
	int n,m,i;
	scanf("%d %d",&n,&m);
	len[0]=0;
	len[n+1]=0;
	for(i=1;i<=n;i++)scanf("%d",&len[i]);
	priority_queue< P,vector<P>,greater<P> > que;
	for(i=1;i<=n;i++)if(len[i]>len[i-1]&&len[i]>len[i+1])que.push(P(m-len[i],i));
	int ans=0;
	while(!que.empty()){
		P p=que.top();
		que.pop();
		int v=p.second;
		ans=p.first;
		len[v]=0;
		if(v>1&&len[v-1]>len[v-2])que.push(P(p.first+m-len[v-1],v-1));
		if(v<n&&len[v+1]>len[v+2])que.push(P(p.first+m-len[v+1],v+1));
	}
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N, Q; cin >> N >> Q;
	Graph G(N);
	for(int i = 0; i < N - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<vector<int>> score(N);
	for(int i = 0; i < Q; i++) {
		int p, x; cin >> p >> x;
		p--;
		score[p].push_back(x);
	}
	stack<int> s;
	s.push(0);
	vector<int> visit(N);
	vector<ll> ans(N);
	while(!s.empty()) {
		int u = s.top();
		if(visit[u] != 1) {
			visit[u] = 1;
			for(auto v: score[u]) ans[u] += v;
			for(auto v: G[u]) {
				if(visit[v] != 1) {
					s.push(v);
					ans[v] = ans[u];
				}
			}
		}
		else s.pop();
	}
	for(int i = 0; i < N; i++) {
		if(i == N - 1) {
			cout << ans[N - 1] << endl;
			return 0;
		}
		cout << ans[i] << " ";
	}
}

Measured memory_bytes: 29068
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

ll solve(vector<ll> A, vector<ll> B) {
  int N	= A.size();
  ll ans = 0;
  REP(i,N-1) {
    ll tmp = min(A[i], B[i]);
    B[i] -= tmp;
    A[i] -= tmp;
    ans += tmp;
    tmp = min(A[i+1], B[i]);
    B[i] -= tmp;
    A[i+1] -= tmp;
    ans	+= tmp;
    //    pp(A, A.size());                                                                  
    //    pp(B, B.size());                                                                  
    //    cout << ans << endl;                                                              
  }

  return ans;
}

int main() {
  int N; cin>>N;
  vector<ll> A(N+1), B(N);
  REP(i,N+1) cin>>A[i];
  REP(i,N) cin>>B[i];
  ll ans1 = solve(A, B);
  reverse(A.begin(), A.end());
  reverse(B.begin(), B.end());
  ll ans2 = solve(A, B);
  ll ans = max(ans1, ans2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3424
#include <stdio.h>
#include <string.h>
int main()
{
 char a[200000];
char b[200000];
gets(a);
fflush(stdin);
gets(b);
int t;
int c=0;
int s=0;
for(int i=0;i<200000;i++)
{
if (a[i]==0) 
{
 t=i;c=1;
}
if(c==1) break;
}
for(int x=0;x<=t;x++)
{
if(a[x]!=b[x]) s++;
}
printf("%d",s);

}


Measured memory_bytes: 2412
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  for(ll i=n;i>=0;i--){
    string str1=s.substr(t.size()-i,i);
    string str2=t.substr(0,i);
    if(str1==str2){
      cout<<n*2-str1.size()<<endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 256
module Main where

import Data.Functor
import Data.List

main :: IO ()
main =  do
 { [r,c] <- getInts
 ; sheet <- loop r
 ; putStr $ unlines $ map (unwords . map show) $ transpose $ map addsum $ transpose sheet
 }

loop :: Int -> IO [[Int]]
loop 0 = return []
loop n = do
  { r <- getInts
  ; rs <- loop (n-1)
  ; return (addsum r : rs)
  }

addsum :: [Int] -> [Int]
addsum xs = xs ++ [sum xs]

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 8224
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

const int INF = 1e8;

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

	vector<vector<int>> data(3, vector<int>(n));
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			cin >> data[i][j];
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum = data[1][i] + sum;
	}

	int ex = 0;
	vector<int>c(n - 1);
	rep(i, n - 1) {
		cin >> c[i];
	}
	
	for (int i = 0; i < n - 1; i++) {
		if (data[0][i] + 1 == data[0][i + 1]) {
			ex = c[data[0][i] - 1] + ex;
		}
	}
	int ans = sum + ex;

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k << endl;
  } else if (k <= a + b) {
    cout << a << endl;
  } else {
    cout << a - (k - a - b) << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
main()
{
    fast;
    ll t;
    cin>>t;
        map<string,ll>mp;
    while(t--)
    {
        string s;
        cin>>s;

        mp[s]++;

    }
    cout<<"AC"<<" "<<"x"<<" "<<mp["AC"]<<"\n";
    cout<<"WA"<<" "<<"x"<<" "<<mp["WA"]<<"\n";
    cout<<"TLE"<<" "<<"x"<<" "<<mp["TLE"]<<"\n";
    cout<<"RE"<<" "<<"x"<<" "<<mp["RE"]<<"\n";
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;

    vector<int> fast;
    for(int i=0, pre=-c-1; i<s.size(); i++)
    {
        if(i <= pre+c) continue;
        if(s.at(i) == 'o')
        {
            pre = i;
            fast.push_back(i);
        }
        if(fast.size() == k) break;
    }

    vector<int> tail(k);
    for(int i=k-1, j=s.size()-1, pre=n+c+1; j>=0; j--)
    {
        if(j >= pre-c) continue;
        if(s.at(j) == 'o')
        {
            pre = j;
            tail.at(i) = j;
            i--;
            if(i<0) break;
        }
    }

    for(int i=0; i<k; i++)
    {
        if(fast.at(i) == tail.at(i)) cout << fast.at(i) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4936
#include <bits/stdc++.h>
using namespace std;
int  main(){
int N,M;
cin>>N>>M;
vector<int>L(M);
vector<int>R(M);
int max=0;
int min=100000;
for(int i=0; i<M; i++){
    cin>>L.at(i);
    if(max<L.at(i)){
        max=L.at(i);
    }
    cin>>R.at(i);
    if(R.at(i)<min){
        min=R.at(i);
    }
}
if(min-max+1>0){
cout<<min-max+1<<endl;
}
else
{
    cout<<0<<endl;
}

}




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

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()) if (s[i] != t[i]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3928
#include <iostream>

using namespace std;

int main()
{
	int n, y;
	cin >> n >> y;
	
	int a = 0;
	int b = 0;
	int c = 0;
	
	c = y / 1000;
	
	if(5000*b + 9000*c == 10000*n - y)
	{
		cout << n - b - c << " " << b << " " << c << endl;
		return 0;
	}
	
	while(c >= 5)
	{	
		c -= 5;
		b++;
		
		if(5000*b + 9000*c == 10000*n - y)
		{
			cout << n - b - c << " " << b << " " << c << endl;
			return 0;
		}
		
		int copy_b = b;
		while(b >= 2)
		{
			b -= 2;
			a++;
	
			if(5000*b + 9000*c == 10000*n - y)
			{
				cout << n - b - c << " " << b << " " << c << endl;
				return 0;
			}
		}
		
		b = copy_b;
		a = 0;
	}
	
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  int a[N];
  for (int i=0;i<N;i++){
    cin>>a[i];
  }
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      if (a[i] < a[j]) {
        int tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  int atotal=0;
  int btotal=0;
  int turn=1;
  for (int i=0;i<N;i++){
    if(turn==1){
      atotal=atotal+a[i];
      turn=0;
      continue;
    }
    if(turn==0){
      btotal=btotal+a[i];
      turn=1;
      continue;
    }
  }
  cout<<atotal-btotal<<endl;

  return 0;
}


  

Measured memory_bytes: 256
#include <cstdio>
//trace函数见前面, 按顺序输出数组元素
void trace(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (i > 0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}
void swap(int &a, int &b) {
	int t = a;
	a = b;
	b = t;
}
void bubbleSort(int a[], int n) {
	int swapCount = 0;
	for (int i = n - 1; i > 0; i--) {
		int flag = 1; 
		for (int j = 0; j < i; j++) {
			if (a[j] > a[j + 1]) {
				swap(a[j], a[j + 1]);
				flag = 0; swapCount++;
			}
		}
		//trace(a, n); 
		if (flag) break; //当数组不存在顺序相反的相邻元素提前退出 
	}
	trace(a, n);
	printf("%d\n", swapCount);
}

int main() {
    int N;
    scanf("%d", &N);
    int a[N];
    for (int i = 0; i < N; i++) {
    	scanf("%d", &a[i]);
	}
    bubbleSort(a, N);
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    cin >> n;

    int mn = 1e9 , ans = 0;
    for (int i = 0 ;i < n ;i++) {
        int x;
        cin >> x;
        ans += x < mn;
        mn = min(mn , x);
    }

    cout << ans;
}


Measured memory_bytes: 3580
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]
    t = lines[1]

    return (s, t)


def solve(s, t):

    count = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            count = count + 1


    return count


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

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

#define INF ((1<<31)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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



int main(){
    bool flag=true;
    ll ans=0,sum=0;
    string s;
    cin >>s;
    
    if(s == "Sunny"){
        
        cout << "Cloudy" <<endl;

    }else if(s == "Cloudy"){
        cout << "Rainy" <<endl;
    }else{
        cout << "Sunny" <<endl;
    }



    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define pb push_back
#define mp make_pair
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define db double
#define ldb long double
#define uint unsigned
#define ll long long
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef pair<pii,pii> ppp;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef map<int,int> mii;
const int INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const int xx[4]={1,-1,0,0};
const int yy[4]={0,0,1,-1};
int inline nextin(){
	int t;
	if(scanf("%d",&t)!=1)exit(0);
	return t;
}
int inline in(){
	int x=0,c;
	for(;(uint)((c=getchar())-'0')>=10;){
		if(c=='-')return -in();
		if(!~c)throw ~0;
	}
	do{
		x=(x<<3)+(x<<1)+(c-'0');
	}while((uint)((c=getchar())-'0')<10);
	return x;
}
int main(){
    cin.sync_with_stdio(false);cin.tie(0);
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <type_traits>
#include <vector>

// lib/pow2.hpp
#ifndef POW2_HPP
#define POW2_HPP

/*
usage:

tools::pow2(5) => 32
*/


namespace tools {
  template <typename T, typename std::enable_if<std::is_unsigned<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(1) << x;
  }

  template <typename T, typename std::enable_if<std::is_signed<T>::value, std::nullptr_t>::type = nullptr>
  constexpr T pow2(const T x) {
    return static_cast<T>(static_cast<typename std::make_unsigned<T>::type>(1) << static_cast<typename std::make_unsigned<T>::type>(x));
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, A, B, C;
  std::cin >> N >> A >> B >> C;
  std::vector<i64> l;
  tools::read(l, N);

  i64 answer = std::numeric_limits<i64>::max();
  for (i64 search_space = 0; search_space < tools::pow2<i64>(N * 2); ++search_space) {
    i64 a = 0;
    i64 b = 0;
    i64 c = 0;
    i64 possible_answer = 0;
    for (i64 i = 0; i < N; ++i) {
      switch ((search_space >> (i * 2)) & 3) {
      case 0:
        if (a > 0) possible_answer += 10;
        a += l[i];
        break;
      case 1:
        if (b > 0) possible_answer += 10;
        b += l[i];
        break;
      case 2:
        if (c > 0) possible_answer += 10;
        c += l[i];
        break;
      }
    }
    if (a == 0 || b == 0 || c == 0) continue;
    possible_answer += std::abs(A - a) + std::abs(B - b) + std::abs(C - c);
    answer = std::min(answer, possible_answer);
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    int A,B;
    cin >> A >> B;
    cout << (A+B)%24 << "\n";
}

Measured memory_bytes: 3636
N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

def calc_inv(n, k, mod):
    a = 1
    b = 1
    for i in range(1,k+1):
        a *= i
        a %= mod
        b *= n
        n -= 1
        b %= mod
    return b * pow(a, mod-2, mod) % mod

ret = pow(2, N, MOD) - 1 - calc_inv(N,A,MOD) - calc_inv(N,B,MOD)
ret %= MOD
if ret < 0:
    ret += MOD
print(int(ret))


Measured memory_bytes: 39024
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 998244353
#define INF2 1000000000000000000
#define int long long

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

int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt[100010] = {};
    int k = 0;
    rep(i, N) {
        int d; cin >> d;
        if((i == 0 && d != 0) || (i != 0 && d == 0)) {
            cout << 0 << endl;
            return 0;
        }
        cnt[d]++;
        k = max(k, d);
    }
    int ans = 1;
    rep(i, k) {
        ans = Mul(ans, power(cnt[i], cnt[i + 1]));
        //cout << i << " " << ans << endl;
    }
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll r,d,x;
cin>>r>>d>>x;
for(ll i=0;i<10;i++)
{
	cout<<r*x-d<<el;
	x=r*x-d;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    if(s=="RRR")cout<<3<<endl;
    else if(s=="RRS" || s=="SRR")cout<<2<<endl;
    else if(s=="SSS") cout<<0<<endl;
    else cout<<1<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int n, m;
int cost[100][100];
bool usedv[100];
int d[100];
int pre[100];
map<pair<int, int>, bool> usede;

void dijkstra(int s) {
	fill(d, d + n, INF);
	fill(usedv, usedv + n, false);
	fill(pre, pre + n, -1);
	d[s] = 0;
	while (true) {
		int v = -1;
		for (int u = 0; u < n; u++) {
			if (!usedv[u] && (v == -1 || d[u] < d[v]))v = u;
		}
		if (v == -1)break;
		usedv[v] = true;
		for (int u = 0; u < n; u++) {
			if (d[u] > d[v] + cost[v][u]) {
				d[u] = d[v] + cost[v][u];
				pre[u] = v;
			}
		}
	}

	return;
}

void getpath(int t) {
	while (t != -1) {
		usede[pair<int, int>(min(t, pre[t]), max(t, pre[t]))] = true;
		t = pre[t];
	}

	return;
}

int main() {

	cin >> n >> m;

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

	rep(i, m) {
		int a, b, c; cin >> a >> b >> c; a--; b--;
		cost[a][b] = cost[b][a] = c;
		usede[pair<int, int>(a, b)] = usede[pair<int, int>(b, a)] = false;
	}

	for (int i = 0; i < n; i++) {
		dijkstra(i);
		for (int j = i + 1; j < n; j++) {
			getpath(j);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (usede[pair<int, int>(i, j)])m--;
		}
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 640
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];

int main(){
	int N,M,K;
	//std::cin >> N;
    std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
    //std::vector<long long> v(N);
 	
 	//stack<int> sta;   
    //queue<int> que;
    
 	
    // 入力
    if(N-1>=M){
		printf("%d",N+N-1);
	}
	else if(M-1>=N){
		printf("%d",M+M-1);
    }
    else{
		printf("%d",M+N);
	}
    //printf("%d",N);
    //printf("%d",N*M);
	return 0;
}

Measured memory_bytes: 256
///Coder ---->>>> Kael (Joan Marcos Rivera)
///Team ACM : CyberSpace ____ IPVCE FEDERICO ENGELS
///KingOfString
///Copyright

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;

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

#define pb push_back
#define mp make_pair
#define s second
#define f first
#define maxn 100010
#define mod 1000000007
#define less(n) order_of_key(n)
#define en_pos(n) find_by_order(n) /// --- >> iterador --- >> empieza en 0

ll dp[maxn][2];
vector<int>g[maxn];

void dfs(int u,int p=0){
    bool flag = 0;
    ll mult = 1,multi = 1;
    for(auto i : g[u]){
        if(i != p){
            dfs(i,u);
            multi *= dp[i][1];
            multi %= mod;
            mult = (mult * (dp[i][0] + dp[i][1])) % mod;
            flag = 1;
        }
    }
    if(!flag)dp[u][0] = dp[u][1] = 1;
    else dp[u][0] = multi % mod , dp[u][1] = mult % mod;
}
main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i=1;i<n;i++){
        int a,b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);

    }

    dfs(1);

    cout << (dp[1][0]+dp[1][1])%mod;
}
/*
5 5
5 1
5 4
4 3
5 2
3 2
10
3 4
2 2
5 4
5 3
3 5
5 1
5 3
3 4
2 3
3 4*/


Measured memory_bytes: 14208
def main():
	N = int(input())
	T = list(map(int, input().split()))
	M = int(input())
	px = [[0] for _ in range(M)]
	for i in range(M):
		px[i] = list(map(int, input().split()))
	ans = sum(T)
	for i in range(M):
		print(ans-T[(px[i][0]-1)]+px[i][1])


if __name__ == '__main__':
	main()

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

int main(void)
{
    int n,ans=0;
    cin >> n;

    rep(i, n)
    {
        int  a;
        cin >> a;
        if((i+1)%2==1&&a%2==1)ans++;
    }

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


Measured memory_bytes: 3632
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 


void _main(){
  ll N; cin >> N ;
  ll K; cin >> K ;
  vl a(N);
  vvi g(N);
  rep(i,N) cin >> a[i] ;
  rep(i,N) a[i]--;
  REP(i,1,N){
    g[a[i]].pb(i);
  }
  int ans = 0;
  function<int(int,int)> dfs = [&](int u,int p){
    int res = 0;
    for(auto&& v:g[u]){
      chmax(res,dfs(v,u));
    }
    if(p!=0 && res==K-1){
      res = -1;
      ans++;
    }
    return res+1;
  };
  if(a[0]!=0) ans++;
  dfs(0,0);
  cout << ans << endl;
}

Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int mod(int a, int b, int c, int x);

int main(){
	int n, a, b, c, x;
	while(cin >> n >> a >> b >> c >> x, n || a || b || c || x){
		vector<int> y(n);
		
		for(int i = 0; i < n; i++){//input
			cin >> y[i];
		}

		int i, j;
		for(i = 0, j = 0; i <= 10000; i++){
			if(y[j] == x){
				j++;
			}
			x = mod(a, b, c, x);
			if(j >= n){
				break;
			}
		}

		if(i > 10000){
			cout << -1 << endl;
		}else{
			cout << i << endl;
		}
	}

	return 0;
}

int mod(int a, int b, int c, int x){
	int tmp = (a * x + b) % c;
	return tmp;
}


Measured memory_bytes: 3048
package main

import (
	"bufio"
	"fmt"
	"os"
)

var writer = bufio.NewWriter(os.Stdout)

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

	ret := float64(t) / float64(x)
	fmt.Fprintf(writer, "%f\n", ret)
	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int a,b,c,k;
  cin>>a>>b>>c>>k;

  while(k>0){
    if(a>=b) {
      b*=2;
    }
    else if(b>=c) {
      c*=2;
    }
    if (a<b && b<c){
      cout << "Yes" << endl;
      return 0;
    }
    k--;
  }

  cout << "No" << endl;

}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n,q,tp;ll x,s[maxn],f[maxn],d[maxn];
void add(ll x,ll y){
    int t=lower_bound(s+1,s+tp+1,x)-s;
    if(s[t]>x) --t;
    if(!t) d[1]+=y,d[x+1]-=y;
    else f[t]+=x/s[t]*y,add(x%s[t],y);
}
int main(){
    scanf("%d%d",&n,&q);
    s[++tp]=n;
    rep(i,1,q){
        scanf("%lld",&x);
        while(tp&&s[tp]>x) --tp;
        s[++tp]=x;
    }
    f[tp]=1;
    per(i,tp,2) f[i-1]+=s[i]/s[i-1]*f[i],add(s[i]%s[i-1],f[i]);
    d[1]+=f[1],d[s[1]+1]-=f[1];
    rep(i,1,n) d[i]+=d[i-1],printf("%lld\n",d[i]);
    return 0;
}

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

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

    string s;
    cin >> s;

    long long g, p = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'g') g++;
        else p++;
    }

    long long ans;
    long long my_p = s.size() / 2;
    long long my_g = s.size() - my_p;

    if (my_p > g) {
        ans = g - my_g;
    } else {
        ans = my_p - p;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200016
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
int n , m , k;
int A[MAXN];
bool apl( char* s , int l ) {
    for( int i = 0 ; i < l ; ++ i ) {
        if( s[i] != s[l - i - 1] ) return false;
    }
    return true;
}
char str[MAXN];
void solve( ) {
    cin >> n;
    double x = 1.0 * n / 3;
    printf("%.7lf",x * x * x);
}
signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;
long long  N,M,X,Y,Z;
long long  i=0;
long long  j=0;
long long maxX=0;
long long minY=200;

int main(){
  cin >> N >> M >> X >> Y;
  vector<long long> x(N);
  for(i=0;i<N;i++){
    cin >> x.at(i);
    maxX= max(maxX,x.at(i));
  }
  sort(x.begin(),x.end());
  maxX=x.at(N-1);
  maxX++;
  vector<long long> y(M);
  for(i=0;i<M;i++){
    cin >> y.at(i);
    minY= min(minY,y.at(i));
  }
  
  sort(y.begin(),y.end());
  minY=y.at(0);
  
  if(maxX > minY){
    cout << "War" << endl;
    return 0;
  }
  if(X < maxX  && maxX<=Y){
    cout << "No War" << endl;
    return 0;
  }
  for(Z=maxX;Z<minY;Z++){
    if(X < Z && Z<=Y){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

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

    int v = 0;
    int p;
    int c;
    cin >> p;
    for (int i = 1; i < n; i++) {
        cin >> c;
        if (c - p < t) {
            v += c - p;
        } else {
            v += t;
        }
        p = c;
    }
    v += t;
    cout << v << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextInt();
		long[] arr=new long[(int)n];
		long[] arr1=new long[(int)n];
		Arrays.fill(arr, 0);
		Arrays.fill(arr1, 0);
		arr[0]=sc.nextInt();
		arr[0]=arr[0];
		long sum=0;
		for(int i=1;i<n;i++)
		{
			arr[i]=sc.nextInt();
			arr1[i]=arr1[i-1]+arr[i];
		}
		
		long num=(int)(Math.pow(10, 9))+7;
		for(int i=0;i<n;i++)
		{
			sum+=(((arr1[(int)n-1]-arr1[(int)i])%num)*arr[(int)i])%num;
		}
		System.out.println(sum%num);
	}

}


Measured memory_bytes: 53388
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
int n,m,a[310][310],ans=1e9,cnt,vis[310],p[310];
typedef struct hu
{
    int kind,ssum;
};
hu sum[310];
int cmp(hu a,hu b)
{
    return a.ssum>b.ssum;
}
int cmp2(hu a,hu b)
{
    return a.kind<b.kind;
}
int main()
{
    scanf("%d%d",&n,&m);
    ff(i,1,m)
    sum[i].ssum=0;
    ff(i,1,n)
    {
        ff(j,1,m)
        {
            scanf("%d",&a[i][j]);
            if(j==1)
            sum[a[i][j]].ssum++;
            sum[j].kind=j;
        }
        p[i]=1;
    }
    cnt=m;
    while(cnt--)
    {
        sort(sum+1,sum+1+m,cmp);
        ans=min(ans,sum[1].ssum);
      //  printf("%d\n",sum[1].ssum);
        vis[sum[1].kind]=1;
        sum[1].ssum=0;
        sort(sum+1,sum+1+m,cmp2);
        //printf("  %d\n",sum[5].ssum);
        ff(i,1,n)
        {
            int pan=0;
            for(;vis[a[i][p[i]]];p[i]++)
            pan=1;
            if(pan)
            sum[a[i][p[i]]].ssum++;
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 640
//@samraj2k
//#2ksr
//Don't copy my codes. They produce wrong output.
#include<bits/stdc++.h>
using namespace std;

int main()
{int n;
  cin>>n;
  int x=0,maxi=0;
  string s;
  cin>>s;
  for (int i = 0; i < n; ++i)
  {
    if (s[i]=='I')
    {
      x++;
    }
    else if (s[i]=='D')
    {
      x--;
    }
    maxi=max(x,maxi);
  }
  cout<<maxi;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cstdlib>
#include<string>
using namespace std;
int main(){
  int x;
  for(int i=1; i<10001; i++){
    cin >> x;
    if(x==0){
      break;
    }
    cout << "Case " << i << ": " << x <<endl;  
  }
}



Measured memory_bytes: 3084
/*input
RRR
SSS
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) {
            ++ans;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<double,double>>data(n);
  double sum = 0;
  for(int i = 0;i < n;i++) cin >> data[i].first >> data[i].second;
  for(int i = 0;i < n;i++){
    for(int j = i;j < n;j++){
      sum += sqrt((data[i].first-data[j].first)*(data[i].first-data[j].first)+(data[i].second-data[j].second)*(data[i].second-data[j].second));
    }
  }
  sum /= n;
  std::cout << std::fixed;
  std::cout << std::setprecision(7) << 2*sum << endl;;
}


Measured memory_bytes: 256
/**
 *      purpose : ABC 62 C
 *      author  : kyomukyomupurin
 *      created : 2018-10-17 19:43:58
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int64 H, W; cin >> H >> W;

    if (H % 3 == 0 || W % 3 == 0){
        cout << 0 << '\n'; return 0;
    }

    int64 ans1 = 2e11; int64 ans2 = 2e11;

    for (auto i = 1; i <= W - 2; ++i) {
        int64 temp1; int64 S1, S2, S3;
        S1 = i * H; S2 = (W - i) / 2 * H; S3 = (W - i) * H - S2;
        temp1 = max({S1, S2, S3}) - min({S1, S2, S3});
        if (temp1 < ans1) ans1 = temp1;
    }

    for (auto i = 1; i <= W - 1; ++i) {
        int64 temp1; int64 S1, S2, S3;
        S1 = i * H; S2 = (W - i) * (H / 2); S3 = (W - i) * H - S2;
        temp1 = max({S1, S2, S3}) - min({S1, S2, S3});
        if (temp1 < ans1) ans1 = temp1;
    }

    for (auto i = 1; i <= H - 2; ++i) {
        int64 temp2; int64 S1, S2, S3;
        S1 = i * W; S2 = (H - i) / 2 * W; S3 = (H - i) * W - S2;
        temp2 = max({S1, S2, S3}) - min({S1, S2, S3});
        if (temp2 < ans2) ans2 = temp2;
    }

    for (auto i = 1; i <= H - 1; ++i) {
        int64 temp2; int64 S1, S2, S3;
        S1 = i * W; S2 = (H - i) * (W / 2); S3 = (H - i) * W - S2;
        temp2 = max({S1, S2, S3}) - min({S1, S2, S3});
        if (temp2 < ans2) ans2 = temp2;
    }
    cout << min(ans1, ans2) << '\n';
    
    return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(raw_input())

M = [[0]*n for _ in xrange(n)]
color = [0] * n
WHITE = 0
GRAY = 1
BLACK = 2
d = [-1] * n
Q = deque([])

def bfs():
    color[0] = GRAY
    d[0] = 0
    Q.append(0)
    while len(Q) > 0:
        u = Q.popleft()
        for v in xrange(n):
            if M[u][v] == 1 and color[v] == WHITE:
                color[v] = GRAY
                d[v] = d[u] + 1
                Q.append(v)
        color[u] = BLACK
    for u in xrange(n):
        print "{} {}".format(u+1, d[u])
    return

def main():
    for i in xrange(n):
        a = map(int, raw_input().split())
        u = a[0]-1
        k = a[1]
        for j in xrange(k):
            v = a[j+2] -  1
            M[u][v] = 1
    
    bfs()
    return 0

main()

Measured memory_bytes: 6804
/*
[abc101] A - Eating Symbols Easy
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

string S;

int solve() {
    int ans = 0;
    for (char c : S) {
        ans += (c == '+' ? 1 : -1);
    }
    return ans;
}

int main() {
    cin >> S;

    cout << solve() << endl;

    return 0;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;
    REP(i, A + 1) {
        REP(j, B + 1) {
            int p = X - 500*i - 100*j;
            if(0 <= p && p/50 <= C) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int x;
  int i=1;
  int flag=1;
  while(flag=1){
    scanf("%d",&x);
    if(x==0){
      flag=0;
      break;
    }
    printf("Case %d: %d\n",i,x);
    i=i+1;
  }
  return 0;
}


Measured memory_bytes: 2036