akhauriyash/Code-Regression huggingface dataset:
from collections import deque

s = deque(list(input()))
q = int(input())
flg = 1
for i in range(q):
    array = input().split(' ')
    if array[0] == '1':
        flg *= -1
    elif array[0] == '2':
        if array[1] == '1' and flg == 1 or array[1] == '2' and flg == -1:
            s.appendleft(array[2])
        else:
            s.append(array[2])

s = list(s)
if flg == -1:
    s = s[::-1]

s = ''.join(s)
print(s)

Measured memory_bytes: 10084
#include <iostream>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<int> v(n);
	for(int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	
	sort(v.begin(), v.end());

	double ans = (double)v[0];
	for(int i = 1; i < n; ++i) {
		ans = (ans + (double)v[i]) / 2.0;
	}
	
	printf("%.10f\n", ans);
	
	return 0;
}


Measured memory_bytes: 3700
#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 rev(v) reverse(v.begin(), v.end())
#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; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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};

ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U; int a,b,c;
vi A,B,C;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    ll X;cin>>X;
    int ans = 0;
    ll now = 100;
    while(X >now) {
        now *= 1.01;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    double t,x;
    cin>>t>>x;
    
    cout<<t/x<<endl;
}

Measured memory_bytes: 256
n,m,l=map(int, input().split())
A=[ [ int(a) for a in input().split() ] for i in range(n) ]
B=[ [ int(b) for b in input().split() ] for i in range(m) ]
Bt=[ list(x) for x in zip(*B) ]
for a in A:
    print(" ".join(map(str, [ sum([ x*y for x,y in zip(a,b) ]) for b in Bt ])))

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

long long int INF = 110110110;
long long int _INFL = -INF * INF;

int N;
int A[200100];
long long int dp[200100][20];//i/2-j+10

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  for (int i = 0; i < 200100; i++){
    for (int j = 0; j < 20; j++){
      dp[i][j] = _INFL;
    }
  }

  dp[0][10] = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 20; j++){
      if (i/2 - j + 10 < 0) continue;
      //dont choose
      int nj = (i+1) / 2 - i / 2 + j;
      if(nj < 20){
        dp[i+1][nj] = max(dp[i+1][nj], dp[i][j]);
      }
      //choose
      nj = (i+2) / 2 - i / 2 + j - 1;
      if(nj < 20){
        dp[i+2][nj] = max(dp[i+2][nj], dp[i][j] + A[i]);
      }
    }
  }
  long long int ans = _INFL;
  for (int i = 0; i <= N+1; i++){
    for (int j = 0; j < 20; j++){
      if (i / 2 - j + 10 == N / 2){
        ans = max(ans, dp[i][j]);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 35640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      int[] seq = new int[n+2];
      seq[0] = seq[n+1] = 0;
      int[] d = new int[n+1];

      String line = in.readLine();
      char regex = ' ';
      boolean isContinue = true;
      for(int i=1, offset=0,next=0; isContinue; offset = ++next) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        seq[i++] = Integer.parseInt(line.substring(offset,next));
      }

      int sum=0;
      StringBuilder buf = new StringBuilder();
      for(int i=0; i<=n; i++) {
        sum += d[i] = Math.abs(seq[i+1] - seq[i]);
      }
      // sum += Math.abs(seq[n]);

      int t=0;
      for(int i=1; i<=n; i++) {
        t = 0;
        // t -= Math.abs(seq[i] - seq[i-1]);
        // t -= Math.abs(seq[i+1] - seq[i]);
        t -= d[i-1];
        t -= d[i];
        t += Math.abs(seq[i+1] - seq[i-1]);
        buf.append(sum + t).append('\n');
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 43648
import Data.Array.ST (STUArray, runSTUArray, newArray, writeArray, getBounds)
import Data.Array.Unboxed
import Data.Ix (range)
import Control.Monad.ST (ST,runST)
import Control.Monad
import Control.Applicative

type PosXY = (Int,Int)
type Box = UArray PosXY Char
type STBox s = ST s (STUArray s PosXY Char)

mkBox :: Int -> Int -> Box
mkBox w h =
    let dirs = [(1,0), (0,1), (-1,0), (0,-1)] in
    runSTUArray $ do
        box <- newArray ((1,1),(w,h)) '.' :: STBox s
        go box (1,1) dirs
    where
    go :: (STUArray s PosXY Char) -> PosXY -> [PosXY] -> STBox s
    go box _ [] =
        return box
    go box xy dxdys@(dxy:nextdxys) = do
        rng <- getBounds box
        writeArray box xy '#'
        let nxy = (\(x1,y1) (x2,y2) -> (x1+x2, y1+y2)) xy dxy
        if (inRange rng nxy) then
            go box nxy dxdys
        else
            go box xy nextdxys

solve :: [Int] -> String
solve [h,w] =
    let box = mkBox w h in
    let ((sx,sy), (ex,ey)) = bounds box in
    unlines [[box!(x,y) | x<-[sx..ex]] | y<-[sy..ey]]

main =
    mapM_ putStrLn =<< map solve . takeInputs . lines <$> getContents
    where
    takeInputs :: [String] -> [[Int]]
    takeInputs = takeWhile (not . all (== 0)) . map (map read . words)

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

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;




int main()
{
  ll x, y;
  scanf("%lld %lld", &x, &y);
  int ans = 0;
  while (x <= y)
    {
      ++ans;
      x *= 2;
    }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count = 0;

        for (int i = 1; i <= n; i++) {
            int i1 = i / 10000;
            int i2 = (i % 10000) / 1000;
            int i3 = (i % 1000) / 100;
            int i4 = (i % 100) / 10;
            int i5 = i % 10;
            int add = i1 + i2 + i3 + i4 + i5;
            if (a <= add && add <= b) {
                count += i;
            }
        }
        System.out.println(count);
    }
}



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

int main(){
    int H,W,A,B;cin>>H>>W>>A>>B;
    rep(i,H){
        rep(j,W){
            if(A-j>=1 and B-i>=1)cout<<0;
            else if(B<=i and A<=j)cout<<0;
            else cout<<1;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
import java.lang.Math;

public class Main {

	public static void main(String args[]){
		
		int num,max,min,sum,avg;
		Scanner in = new Scanner(System.in);
		
		while(true){
			num = Integer.parseInt(in.next());
			
			if(num == 0)break;
			
			sum = 0;
			max =0;
			min = 1001;
			
			int score[] = new int[num];
			
			for(int i=0;i<num;i++){
				score[i] = Integer.parseInt(in.next());
				sum += score[i];
				
				if(score[i] > max)max = score[i];
				if(score[i] < min)min = score[i];
			}
			
			sum = sum-max-min;
			avg = sum / (num-2);
			
			System.out.println(avg + "");
		}
		
		in.close();
	}
}

Measured memory_bytes: 28220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
{ cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

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

int main() {
    sonic();
    int n, ret = 0, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    rep(i, n){
        if (s[i] == 'I') ret += 1;
        else ret -= 1;
        ans = max(ans, ret);
    }
    co(ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
      
      
public class Main {
	static HashMap<String,Boolean> map;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		for(int i = 0; i < Q; i++) {
			String in = sc.next();
			map = new HashMap<String,Boolean>();
			int count = 0;
			while(in.length() != 1) {
				if(map.containsKey(in)) {
					count = -1;
					break;
				}
				map.put(in, true);
				
				count++;
				BigInteger Max = new BigInteger("0");
				for(int j = 1; j < in.length(); j++) {
					BigInteger A = new BigInteger(in.substring(0,j));
					BigInteger B = new BigInteger(in.substring(j));
					BigInteger C = A.multiply(B);
					if(Max.compareTo(C) == -1) Max = C;
				}
				in = Max.toString(10);
			}
			System.out.println(count);
			
		}
		
	}
 }

Measured memory_bytes: 36064
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll n;
string s;


int main()
{
  finp;
  cin>>n>>s;
  ll ans = 0;
  map<pair<string,string>,ll> my,my2;
  afor(i,0,(1 << n) - 1)
  {
    //left part
    string lef,ri;
    afor(j,0,n-1)
    {
      if(i & (1 << j))ri.pb(s[j]);
      else lef.pb(s[j]);
    }
    my[{lef,ri}]++;
    lef.clear();
    ri.clear();

    afor(j,0,n-1)
    {
      if(i & (1 << j))ri.pb(s[2*n - 1 - j]);
      else lef.pb(s[2*n - 1 - j]);
    }
    my2[{lef,ri}]++;
    lef.clear();
    ri.clear();
  }

  for(auto i:my)
  {
    if(my2.count(i.fr))ans+= i.se * my2[i.fr];
  }

  cout<<ans;
  
return 0;
}

Measured memory_bytes: 91904
#include <stdio.h>

int main(){
	int n;
	int i, j;
	int ans[100]={};
	int a=0, b=0;
	int m;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		for(j=0;j<10;j++){
			scanf("%d", &m);
			if(a<m){
				a=m;
			}else{
				if(b<m){
					b=m;
				}else{
					ans[i]=1;
				}
			}
		}
		a=0;
		b=0;
	}
	for(i=0;i<n;i++){
		if(ans[i]==0){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool dp[5005];
vector<int> v;
int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int h=0,s=0;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a;
		v.push_back(a);
	}
	sort(v.rbegin(),v.rend());
	dp[0]=true;
	for(i=0;i<n;i++){
		if(h+v[i]>=m)s=i+1;
		for(j=m;j>=0;j--){
			if(!dp[j])continue;
			a=j+v[i];
			if(a>=m)continue;
			dp[a]=true;
			if(h<a)h=a;
		}
	}
	cout<<n-s<<endl;
	return 0;
}
			
	


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<functional>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  int h, w;
  cin >> h >> w;
  vs s;
  rep(i, 0, h) {
    string a;
    cin >> a;
    if(count(all(a), '#')) s.push_back(a);
  }

  set<int> st;
  rep(i, 0, w) {
    bool ok = true;
    rep(j, 0, s.size()) {
      if(s[j][i] == '#') ok = false;
    }
    if(ok) st.insert(i);
  }

  rep(i, 0, s.size()) {
    rep(j, 0, w) {
      if(!st.count(j)) cout << s[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def YesNo(x): return 'Yes' if x else 'No'
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, M = LI()
    S = LI()
    T = LI()
    dp = [[1] * (M + 1)] + [[1] + [0] * M for _ in range(N)]
    for j in range(1, 1 + N):
        for i in range(1, 1 + M):
            if S[j - 1] == T[i - 1]:
                dp[j][i] = (dp[j][i - 1] + dp[j - 1][i]) % MOD
            else:
                dp[j][i] = (dp[j][i - 1] + dp[j - 1][i] - dp[j - 1][i - 1]) % MOD
    ans = dp[-1][-1]
    return ans

print(main())

Measured memory_bytes: 76252
#include <bits/stdc++.h>
using namespace std;
int modpow(long long x, long long n, long long mod){
    long long i, result=1;
    for(i=1;i<=n;i++){
        result*=x;
        result%=mod;
    }
    return result;
}
int main(){
    long long n, ans=0;
    cin >> n;
    ans=modpow(10, n, 1000000007)-modpow(9, n, 1000000007);
    if(ans<0) ans+=1000000007;
    ans=ans-modpow(9, n, 1000000007);
    if(ans<0) ans+=1000000007;
    ans+=modpow(8, n, 1000000007);
    ans%=1000000007;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, FN) for(int i = 0; i < (FN); i++)

int main() {
    char a, b;
    cin >> a >> b;
    if(a == 'H') {//atocoderr is honest
        if(b == 'H') cout << 'H' << endl;
        else if(b == 'D') cout << 'D' << endl;
    }else if(a == 'D') {
        if(b == 'H') cout << 'D' << endl;
        else if(b == 'D') cout << 'H' << endl;
    }

    return 0;
}


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

constexpr int MAX_N = 100100;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    
    int dp[MAX_N][3] = {};
    for (int i = 0; i < n; i++) {
        dp[i+1][0] = max(dp[i][1] + b[i], dp[i][2] + c[i]);
        dp[i+1][1] = max(dp[i][2] + c[i], dp[i][0] + a[i]);
        dp[i+1][2] = max(dp[i][0] + a[i], dp[i][1] + b[i]);
    }
    
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << '\n';
    return 0;
}

Measured memory_bytes: 2560
using System;

namespace _094B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int mcount = Convert.ToInt32(str[0]);
            int rcount = Convert.ToInt32(str[1]);
            int current = Convert.ToInt32(str[2]);

            int leftCost = 0;
            int rightCost = 0;
            str = Console.ReadLine().Split(' ');
            for (int i = 0; i < str.Length; i++)
            {
                int pos = Convert.ToInt32(str[i]);
                if (pos < current)
                {
                    leftCost++;
                } else if (current < pos)
                {
                    rightCost++;
                }
            }
            int minCost = Math.Min(leftCost, rightCost);
            System.Console.WriteLine(minCost);
        }
    }
}

Measured memory_bytes: 11220
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        n: usize,
        d: usize,
        x: [[i64; d]; n]
    }
    dbg!(x);
    let mut ans: i64 = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            let mut sum: i64 = 0;
            for k in 0..d {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            let mut i = 1;
            while i <= (sum as f64).sqrt() as i64 {
                if i * i == sum {
                    ans += 1;
                    break;
                }
                i += 1;
            }
        }
    }
    println!("{}", ans);
}

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

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

    while(1) {
        int a, b;
        char op;
        cin >> a >> op >> b;

        if (op == '?') {
            break;
        } else if (op == '+') {
            cout << a + b << endl;
        } else if (op == '-') {
            cout << a - b << endl;
        } else if (op == '*') {
            cout << a * b << endl;
        } else {
            cout << a / b << endl;
        }

    }

    return 0;
}



Measured memory_bytes: 3104
W = input()
t = []
count = 0
c = 0

while True:
    T = input()
    if T == "END_OF_TEXT":
        break
    else:
        t.append(T)
        c += 1

for i in range(c):
    l = t[i].split()
    m = len(l)
    for j in range(m):
        l[j] = l[j].lower()
        if l[j] == W:
            count += 1

print(count)


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = (int)1e5 + 1000;
int n, u, v, a[maxn], b[maxn], vis[maxn];
vvi g(maxn);
 
void dfs1(int now, int step) {
	for (auto it : g[now]) {
		if (a[it] == -1) {
			a[it] = step + 1;
			dfs1(it, step + 1);
		}
	}
}
void dfs2(int now, int step) {
	for (auto it : g[now]) {
		if (b[it] == -1) {
			b[it] = step + 1;
			dfs2(it, step + 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif
	
	ms(a, -1); ms(b, -1);
	cin >> n >> u >> v;
	forn(i, n - 1) {
		int e1, e2;
		cin >> e1 >> e2;
		g[e1].pb(e2);
		g[e2].pb(e1);
	}
	a[u] = 0;
	dfs1(u, 0);
	b[v] = 0;
	dfs2(v, 0);
	int ans = -1;
	for1(i, n) {
		if (a[i] <= b[i]) {
			ans = max(ans, b[i]);
		}
	}
	cout << (ans - 1) << '\n';
		
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 9088
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	sort.Ints(aa)
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		k := getNextInt(scanner)
		l := -1
		r := n
		for l+1 < r {
			m := (l + r) >> 1
			if aa[m] < k {
				l = m
				continue
			}
			r = m
		}
		if r == n {
			fmt.Fprintln(writer, 0)
			continue
		}
		if aa[r] != k {
			fmt.Fprintln(writer, 0)
			continue
		}
		fmt.Fprintln(writer, 1)
	}
}



Measured memory_bytes: 5936
//D
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;
const double pi = acos(-1.0);

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int main() {
    reg double a, b, x;
    cin >> a >> b >> x;
    double V = a * a * b;
    if (x * 2 <= V) {
        reg double area = x / a;
        reg double A = b, B = area * 2.0 / A;
        reg double angle = atan(A / B);
        angle = angle * 180.0 / pi;
        printf("%.9f\n", angle);
    }
    else {
        reg double area = (V - x) / a;
        reg double A = a, B = area * 2.0 / A;
        reg double angle = atan(B / A);
        angle = angle * 180.0 / pi;
        printf("%.9f\n", angle);
    }
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
s,c=[0]*M,[0]*M
for i in range(M):
    s[i],c[i] = map(int,input().split())
for i in range(10**N):
    if len(str(i)) != N:
        pass
    else:
        num=list(str(i))
        ok = True
        for j in range(M):
            if num[s[j]-1] != str(c[j]):
                ok = False
        if ok:
            print(i)
            exit()
print(-1)

Measured memory_bytes: 3064
# coding:utf-8

import math
import re

def main(params):
    n,m = params[0]
    mi = 0
    mx = 0
    for g in params[1:]:
        f = int(g.split()[0])
        s = int(g.split()[1])
        if mi == 0 or mi < f:
            mi = f
        if mx == 0 or mx > s:
            mx = s
    if mi <= mx:
        l = 0
        for i in range(mi,mx+1):
            l += 1
        print l
    else:
        print 0
#    a = params[1].split()
#    b = list(params[2])

if __name__ == "__main__":
    n,m = raw_input().split()
    n = int(n)
    m = int(m)
    cnt = m # TODO: edit here
    params = [[n,m]]
    for i in range(cnt):
        param = raw_input()
        params.append(param)
    main(params)



Measured memory_bytes: 12136
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int n,cnt;
  while(scanf("%d",&n) != EOF){
    cnt = 0;
    for(int i = 0;i < 10;i++){
      for(int j = 0;j < 10;j++){
	for(int k = 0;k < 10;k++){
	  for(int l = 0;l < 10;l++){
	    if(i + j + k + l == n)cnt++;
	  }
	}
      }
    }
    cout << cnt << endl;
  }
}

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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

typedef long long ll;

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

void printVec(const vector<ll> &v, int except) {
    REP(i, v.size()) {
        if (v[i] != except) cout << v[i] << endl;
    }
}

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    vector<ll> v;
    ll over = -1;
    FOR(i, 1, N+1) {
        sum += i;
        v.push_back(i);
        if (sum >= N) {
            over = sum - N;
            break;
        }
    }
    if (over == -1) return 1;

    printVec(v,over);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long L,R;
  cin>>L>>R;
  if((R-L+1)<2019){
    vector<long long>S(R-L+1);
    for(int i=0;i<R-L+1;i++){
      S.at(i)=(L+i);
    }
    long long mini=2019;
    for(int i=0;i<S.size()-1;i++){
      for(int j=i+1;j<S.size();j++){
        mini=min(mini,(S.at(i)*S.at(j))%2019);
      }
    }
    cout<<mini<<endl;
  }
  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    int k;
    cin >> k;
    int odd, even;
    even = k / 2; odd = k - even;
    cout << odd * even << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
c1,c2,c3,c4=0,0,0,0
for i in range(n):
  s=input()
  if(s=='AC'):
    c1+=1
  elif(s=='WA'):
    c2+=1
  elif(s=='TLE'):
    c3+=1
  else:
    c4+=1
print('AC x'+' '+str(c1))
print('WA x'+' '+str(c2))
print('TLE x'+' '+str(c3))
print('RE x'+' '+str(c4))

Measured memory_bytes: 9216
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K; cin >> N >> K;
	VI A(N);
	REP(i, N)cin >> A[i];
	int L = 0, R = INF;
	while (R - L > 1) {
		int mid = (L + R) / 2;
		int cnt = 0;

		REP(i, N) {
			cnt += ceil((double)A[i] / mid) - 1;
		}

		if (cnt <= K)R = mid;
		else L = mid;
	}


	cout << R << endl;
	return 0;
}



Measured memory_bytes: 4756
import java.io.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    br.lines()
      .parallel()
      .map(line -> String.valueOf(Stream.of(line.split(" ")).mapToInt(Integer::parseInt).sum()).length())
      .sequential()
      .forEach(System.out::println);
  }
}

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



  
int main(){
  
  int64_t x;
  cin>>x;
  
  int64_t money=100;
  
  int64_t answer=0;
  
  while (money<x){
    money*=1.01;
    answer++;
  }
  
  cout<<answer<<endl;
    
    
  

  
  return 0;
        
}

    












Measured memory_bytes: 3636
n=int(input())
h=list(map(int,input().split()))

dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])



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

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

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

int main() {
    int h, n;
    int r;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);

    rep(i, n) { cin >> a[i]; }
    sort(a.begin(), a.end(), std::greater<int>());
    b[0] = a[0];
    for (int i = 1; i < n; i++) {
        b[i] = b[i - 1] + a[i];
    }

    if (b[n - 1] >= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    map<pair<ll,ll>,ll> ec;

    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        b[i]=a[i];
    }
    sort(b.begin(),b.end());
    
    for (int i = 0; i < n; i++) {
        ec[{i%2,b[i]}]++;
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        if(ec[{i%2,a[i]}]>0){
            ec[{i%2,a[i]}]--;
        }else{
            res++;
            ec[{(i+1)%2,a[i]}]--;
        }
        // std::cout << res << std::endl;
    }
    
    std::cout << res/2 << std::endl;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B;
    cin >> A >> B;
    if(A > 8 || B > 8)cout << ":(" << endl;
    else         cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int t[105];
int tnum[105];
int drink[105];

int main(void){
    int sum = 0;
    int n, m;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d", &t[i]);
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; i++){
        scanf("%d %d", &tnum[i], &drink[i]);
    }

    for (int i = 1; i <= m; i++){
        sum = 0;
        for (int j = 1; j <= n; j++){
            if (tnum[i] == j){
                sum += drink[i];
                continue;
            }
            sum += t[j];
        }
        printf("%d\n", sum);
    }

    return 0;
}



Measured memory_bytes: 128
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=gets.to_i
MOD=10**9+7
dp=array(S+1,0)
dp[0]=1
3.upto(S) do|i|
    3.upto(i) do|j|
        dp[i]+=dp[i-j]
        dp[i]%=MOD
    end
end
puts dp[S]

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

int main(){
  int n,m,X,Y;
  cin >> n >> m >> X >> Y;
  int x[n],y[m];
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  
  bool flag=false;
  
  int z = X+1;
  while(z<=Y && !flag){
    bool tmp=true;
    rep(i,n){
      if(x[i] >= z){
        tmp = false;
        break;
      }
    }
    rep(i,m){
      if(y[i] < z){
        tmp = false;
        break;
      }
    }
    flag = tmp;
    z++;
  }
  
  if(flag) cout << "No War" << endl;
  else cout << "War" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    long[] a = new long[n], b = new long[n];
    foreach (i; 0 .. n) {
        long[] tmp = readln.split.to!(long[]);
        a[i] = tmp[0], b[i] = tmp[1];
    }
    zip(b, a).sort!((t1, t2) => t1[0] < t2[0]);
    long t = 0;
    bool ok = true;
    foreach (i; 0 .. n) {
        if (t + a[i] <= b[i]) {
            t += a[i];
        } else {
            ok = false;
            break;
        }
    }
    writeln(ok ? "Yes" : "No");
}

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

#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const i64 MOD = 1000000007;
const int INF = 2000000000;

bool cmp(pi64 p1, pi64 p2) {
    return p1.sc < p2.sc;
}

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

    int n;
    cin >> n;

    vpi64 a(n);
    REP(i, 0, n-1) cin >> a[i].fi >> a[i].sc;

    sort(all(a), cmp);

    i64 cur = 0;

    REP(i, 0, n-1) {
        // cout << cur << " " << a[i].fi << " " << a[i].sc << endl;
        if (cur + a[i].fi <= a[i].sc) {
            cur += a[i].fi;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3456
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func popCount(v int) int {
	cnt := 0
	for v > 0 {
		if v&1 == 1 {
			cnt++
		}
		v = v >> 1
	}
	return cnt
}

func main() {
	defer write.Flush()

	var n, m int
	fmt.Fscan(read, &n, &m)

	a := make([]int, n+2)
	var l, r int
	for i := 0; i < m; i++ {
		fmt.Fscan(read, &l, &r)
		a[l]++
		a[r+1]--
	}
	ans := 0
	for i := 0; i <= n; i++ {
		a[i+1] += a[i]
		if a[i+1] == m {
			ans++
		}
	}
	fmt.Fprintln(write, ans)
}


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

#define int long long
#define ll long long
#define vll vector<int>
#define mset(a) memset(a,0,sizeof(a))
#define pb push_back
#define range(c) c.begin() , c.end()
#define forn(i,n) for(ll i=0; i<(int)n; ++i)
#define for1(i,n) for(ll i=1; i<(int)n; ++i)
#define endl '\n'
#define MOD 1000000007
#define pii pair<int,int>
#define test ll t;cin>>t;while(t--)
using namespace std;

vector<bool> sieve(ll n){
    vector<bool>prime(n+1,true);
    prime[0]=prime[1]=false;
    for(ll i=2; i<=n; ++i){
        if(prime[i]&&(i*i)<=n)
        for(ll j=i*i; j<=n; j+=i)prime[j]=false;
    }
    return prime;
}

ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

//////////////////////////////////////////////////////////////

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

    double n;cin>>n;
    n*=1.0;
    n/=3;
    double res = n*n*n;
    cout<<fixed<<res<<endl;

    return 0;
}


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

class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int k = sc.nextInt();
   String s = sc.next();
   
   
   if(s.length()<=k){
   	System.out.println(s);
   }
   else if(s.length()>k){
   	System.out.println(s.substring(0,k)+"...");
   }
 
 }
}


Measured memory_bytes: 38424
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int N,W;cin>>N>>W;
    int v[N],w[N];
    REP(i,N)cin>>v[i]>>w[i];
    int dp[N+1][W+1];
    REP(i,N+1)memset(dp[i],0,sizeof(dp[i]));
    REP(i,N)REP(j,W+1){
        if(j-w[i]>=0)
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
        else
            dp[i+1][j]=dp[i][j];
    }
    cout<<dp[N][W]<<endl;
    return 0;
}



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

int main()
{
    int need = 1;
    int result = 0;
    int N;
    cin >> N;
    int A;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (A == need) {
            need++;
        } else {
            result++;
        }
    }
    if (result == N) {
        result = -1;
    }
    cout << result;
    
    return 0;
}

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

//Do not get frustrated over WA. Check for edge cases and runtime errors :)
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll sum = 0;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end(), greater<>());
    double f = a[m - 1] * 1.0 / sum;
    double req = 1.0 / (4 * m);
    if (f >= req) cout << "Yes";
    else cout << "No";
    return 0;
}


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

using namespace std;

const int MAXN = 100005;

int a[MAXN];

int n, w1, w2;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);	
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	if (a[n] % 2 == 0)
		w1 = a[n] / 2, w2 = w1 + 1;
	else
		w1 = w2 = (a[n] + 1) / 2;
	int x = lower_bound(a + 1, a + n, w2) - a, y = x - 1;
	if (x == n)
		cout << a[n] << " " << a[y] << endl;
	else if (y == 0)
		cout << a[n] << " " << a[x] << endl;
	else
	{
		if (w1 - a[y] <= a[x] - w2)
			cout << a[n] << " " << a[y] << endl;
		else
			cout << a[n] << " " << a[x] << endl;
	}
	return 0;
}


Measured memory_bytes: 640