akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;


int main() {
  int w,a,b;
  cin >> w >> a >> b;
  if(a > b) swap(a,b);
  int ans = b-(a+w);

  cout << ((ans < 0)?0:ans) << "\n";
}

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

int main(){
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  
  if(abs( a - c)<= d) cout<<"Yes"<<endl;
  else if(abs(a - b) <= d && abs(b - c) <= d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    char s;
    cin >> s;
    string list = "abcdefghijklmnopqrstuvwxyz";
    bool judge = false;
    rep1(i, 27){
        if (list[i]==s) judge = true;
    }
    if (judge) cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	string s; cin >> s;
	sort(s.begin(), s.end());
	if(s=="abc") cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
import itertools
n,a,b,c=(map(int,input().split()))
l=[int(input()) for i in range(n)]
ans=10**9
for k in itertools.product(range(4),repeat=n):
    A=[[] for i in range(4)]
    for i in range(n):
        A[k[i]]+=[l[i]]
    if A[1] and A[2] and A[3]:
        tmp=10*(n-len(A[0])-3)
        tmp+=abs(a-sum(A[1]))
        tmp+=abs(b-sum(A[2]))
        tmp+=abs(c-sum(A[3]))
        ans=min(tmp,ans)
print(ans)

Measured memory_bytes: 3064
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int[] side = new int[3];
  foreach (i; 0 .. 3)
    sc.scan(side[i]);

  sort(side);

  writeln(side[0] * side[1] / 2);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            int n = NextInt;
            System.Console.WriteLine((double)((n - 1) / 2 + 1) / n);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(17);
    
  long long a, b, c;
  cin >> a >> b >> c;
  long long x = c - a - b;
  long long y = 4 * a * b;
  if(x > 0 && x * x > y)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define reep(i,a,b) for(int i=a; i<b; i++)
#define INF 0x3f3f3f3f

bool check(string a, string b){
	if(a.size() > b.size()) return false;
	rep(i,b.size()){
		if(b.substr(i,a.size()) == a) return true;	
	}
	return false;
}

int overlap(string &a, string &b){
	rep(i,a.size()){
		if(a.substr(i) == b.substr(0,a.substr(i).size())) return a.size()-i;
	}
	return 0;
}

int dp[1<<14][14];
int ol[14][14];

int main(){
	int n;
	while(cin>>n,n){
		vector<string> v(n);
		rep(i,n){
			cin>>v[i];
		}
		vector<int> use(n);
		rep(i,n){
			rep(j,n){
				if(i==j) continue;
				if(check(v[i], v[j])){
					use[i] = 1;
				}
			}
		}
		vector<string> w;
		rep(i,n){
			if(use[i]==0){
				w.push_back(v[i]);
			}
		}
		int nn = w.size();
		rep(i,1<<nn) rep(j,nn) dp[i][j] = INF;
		rep(i,nn){
			dp[1<<i][i] = w[i].size();
		}
		rep(i,nn){
			rep(j,nn){
				if(i==j) continue;
				ol[i][j] = overlap(w[i], w[j]);
			}
		}
		rep(i,1<<nn){
			rep(j,nn){
				if(dp[i][j]==INF) continue;
				rep(k,nn){
					if(i&(1<<k)) continue;
					//int ol = overlap(w[j], w[k]);
					dp[i|(1<<k)][k] = min(dp[i|(1<<k)][k], dp[i][j] - ol[j][k] + (int)w[k].size());
				}
			}
		}
		int ans = INF;
		rep(i,nn){
			ans = min(ans, dp[(1<<nn)-1][i]);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3960
#include <iostream>
#include <string>
 
using namespace std;
 
#define M 100
#define REP(i, n) for(int i=0; i<n; ++i)
 
std::string d[M];
 
#define N 10000
int eastern[N];
int western[N];
 
typedef long long ll;
ll sum_eastern[N+1] = {};
ll sum_western[N+1] = {};
 
ll sum[N+1] = {};
 
int main(){
  int n,m;
  cin >> n >> m;
  REP(i, m) cin >> d[i];
  
  REP(i_n, n) REP(i_m, m) (d[i_m][i_n] == 'E' ? eastern[i_n] : western[i_n]) += 1;
  
  for(int i = 0; i < n; ++i) sum_eastern[i+1] = sum_eastern[i] + eastern[i];
  for(int i = n-1; i >= 0; --i) sum_western[i] = sum_western[i+1] + western[i];
 
  REP(i, n+1) sum[i] = sum_eastern[i] + sum_western[i];
 
  ll current_i = -1;
  ll current_cost = 10000000;
 
  REP(i, n+1) if(current_cost > sum[i]){
    current_i = i;
    current_cost = sum[i];
  }
 
  cout << current_i << " " << current_i + 1 << endl;
 
  return 0;
}

Measured memory_bytes: 4908
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K, X = MAP()

print("Yes" if K*500-X>=0 else "No")

Measured memory_bytes: 59628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;cin >> N;long double x;
    string u;
    long double sum1 = 0,sum2 = 0,bit = 380000.0;
    for(int i = 0; i < N;i++){
        cin >> x >> u;
        if (u == "JPY") sum1 += x;
        else sum2 += x;
    }
    cout << fixed << setprecision(15) << sum1 + sum2 * bit << endl;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline

import numpy as np

N,M,L,R = map(int,input().split())

MOD = 10 ** 9 + 7

X=1000
fact = np.arange(X*X,dtype=np.int64).reshape(X,X)
fact[0,0] = 1
for n in range(1,X):
    fact[:,n] *= fact[:,n-1]
    fact[:,n] %= MOD
for n in range(1,X):
    fact[n] *= fact[n-1,-1]
    fact[n] %= MOD
fact = fact.ravel()

fact_inv = np.arange(1,X*X+1,dtype=np.int64)[::-1].reshape(X,X)
fact_inv[0,0] = pow(int(fact[-1]),MOD-2,MOD)
for n in range(1,X):
    fact_inv[:,n] *= fact_inv[:,n-1]
    fact_inv[:,n] %= MOD
for n in range(1,X):
    fact_inv[n] *= fact_inv[n-1,-1]
    fact_inv[n] %= MOD
fact_inv = fact_inv.ravel()[::-1]

U = N - M
comb = fact[U] * fact_inv[:U+1] % MOD * fact_inv[U::-1] % MOD
comb[1::2] *= (-1)

P = np.zeros(R+1,dtype=np.int64)
for i,x in enumerate(comb,M):
    P[::i] += x

P[M:] -= P.copy()[:-M]
P %= MOD

# (1-x)^{N+1}で割る
Q = fact[N:N+R+1] * fact_inv[:R+1] % MOD * fact_inv[N] % MOD

def f(R):
    total = fact[R+N] * fact_inv[R] % MOD * fact_inv[N] % MOD
    x = (Q[R::-1] * P[:R+1] % MOD).sum() % MOD
    coef = fact[N] * fact_inv[M] % MOD * fact_inv[N-M] % MOD
    return (total - x*coef)%MOD

answer = (f(R) - f(L-1))%MOD
print(answer)


Measured memory_bytes: 42076
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define ordered_set         tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
/*

    order_of_key (k) : Number of items strictly smaller than k .
    find_by_order(k) : K-th element in a set (counting from zero).

*/
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
       
       int k;
       cin>>k;
       string s;
       cin>>s;
       if(s.length()<=k)
       {
           cout<<s<<"\n";
       }
       else
       {
           string ans=s.substr(0,k);
           ans+="...";
           cout<<ans<<"\n";
       }
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||

|| A year from now you may wish you had started today ||
*/



Measured memory_bytes: 3656
#include <cmath>
#include<vector>
#include<iostream>
using namespace std;

long long abs_sub(long long a, long long b){
  return abs(a - b);
}

int main(){
  int n;
  while(cin >> n){
    vector<long> cards;
    long long sum_a = 0;
    long long sum_b = 0;
    long long min = 10e10;
    
    for(int i = 0; i < n; i++){
      int card;
      cin >> card;
      cards.push_back(card);
      sum_b += card;
    }

    for(int i = 0; i < n - 1; i++){
      sum_b -= cards[i];
      sum_a += cards[i];
      long long tmp = abs_sub(sum_a, sum_b);
      min = tmp < min ? tmp : min;
    }

    cout << min << endl;
  }

  return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
 
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	char num[255];
	scanf("%s",num);
	int counter=0;
	
	for(int i=0; num[i] != '\0'; i++){
		if(num[a] != '-'){
			printf("No");
			return 0;
		}
		if(num[i] >= '0'&&num[i] <= '9'){
			counter++;
		}
	}
	if(counter==a+b){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,A,B;
    cin>>N>>A>>B;
    if(N>A*B||N<A+B-1) cout <<-1<<"\n";
    else{
        if(B==1){
            rep(i,1,N+1){
                if(i==N) cout <<i<<"\n";
                else cout <<i<<" ";
            }
        }
        else{
            ll s=(N-A)/(B-1);
            ll u=(N-A)%(B-1)+1;
            ll t=N-B*s-u;
            rep(i,0,s){
                rep(j,0,B){
                    if(i==s-1&&j==B-1&&t<0) cout <<B*i+B-j<<"\n";
                    else cout <<B*i+B-j<<" ";
                }
            }
            if(t>0){
                rep(i,0,u){
                    cout <<B*s+u-i<<" ";
                }
                rep(i,0,t){
                    if(i<t-1) cout <<B*s+u+1+i<<" ";
                    else cout <<B*s+u+1+i<<"\n";
                }
            }
            if(t==0){
                rep(i,0,u){
                    if(i<u-1) cout <<B*s+u-i<<" ";
                    else cout <<B*s+u-i<<"\n";
                }
            }
        }
    }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string j;
    cin>>j;
    int i = 0;
    int k = j.size()-1;
    int c = 0;
    while(i<=k)
    {
        if(j[i]!=j[k])
        {
            c++;
        }
        i++;
        k--;
    }
    cout<<c;

}


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

int findSumofDigits (int n) {
  int sum = 0;
  while (n>0) {
    sum += n % 10;
    n = n / 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int sum = findSumofDigits(N);
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if (k%2){
        cout << b-a << endl;
    }else{
        cout << a-b << endl;
    }
    return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
int main(void)
{
    int a, b, c, cnt5=0, cnt7=0;

    scanf("%d%d%d", &a, &b, &c);
    if(a==5)
        cnt5++;
    if(a==7)
        cnt7++;
    if(b==5)
        cnt5++;
    if(b==7)
        cnt7++;
    if(c==5)
        cnt5++;
    if(c==7)
        cnt7++;
    if(cnt5==2 && cnt7==1)
        printf("YES\n");
    else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
import sys
N = input()
num = [int(x) for x in input().split()]
multiply = 1

if (0 in num):
    print(0)
    sys.exit()

for i in num:
    multiply *= i
    if (multiply > 10**18):
        print(-1)
        sys.exit()
if (0 < multiply and multiply <= 10**18):
    print(multiply)

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

void solve(){

	int n ;
	cin>>n ;
	cout<<pow(n,2) ;
}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n)    cin >> d.at(i);

    sort(all(d));
    int ans=d[n/2]-d[n/2-1];
    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 768
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    string s;
    int tmp=0;
    int ans=0;
    
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            tmp++;
        }else{
            if(tmp>ans){
                ans=tmp;
                tmp=0;
            }
        }
    }
    if(tmp>ans){
        ans=tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;

void main() {
    int W, H, N;
    readf("%d %d %d\n", &W, &H, &N);
    int px, py; readf("%d %d\n", &px, &py);
    px--; py--;
    int c = 0;
    foreach (i; 1 .. N) {
        int x, y; readf("%d %d\n", &x, &y);
        x--; y--;
        if (x >= px && y >= py) {
            c += max(x - px, y - py);
        } else if (x < px && y < py) {
            c += max(px - x, py - y);
        } else {
            c += abs(x - px) + abs(y - py);
        }
        px = x; py = y;
    }
    c.writeln;
}

Measured memory_bytes: 1056
def Q4(H, W, N, lst):
    l = []
    for (x, i) in zip(lst, range(1, len(lst) + 1)):
        l += [i] * x
    for i in range(H):
        if i % 2 == 0:
            m = []
            for j in range(W):
                m += [l.pop(0)]
            for j in range(W):
                print('{}'.format(m[j]), end="")
                if j!=W-1:
                    print(' ',end="")
            print('\n')
        else:
            m = []
            for j in range(W):
                m += [l.pop(0)]
            m = m[::-1]
            for j in range(W):
                print('{}'.format(m[j]), end="")
                if j!=W-1:
                    print(' ',end="")
            print('\n')

H,W = map(int, input().split())
N = int(input())
l = [int(i) for i in input().split()]
Q4(H,W,N,l)

Measured memory_bytes: 4724
use std::io::Read;

fn main() {
    let mut buf = std::string::String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let r = buf
        .lines()
        .next()
        .and_then(|x| x.parse::<f64>().ok())
        .unwrap();
    println!("{} {}",
             r * r * std::f64::consts::PI,
             (r * 2.) * std::f64::consts::PI);
}



Measured memory_bytes: 5068
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

typedef struct queue
{
	int front;
	int rear;
	int data[200];
}queue;

void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

void print(char* str, int a, int b)
{
	int i;

	for (i = a; i <= b; i++)
		printf("%c", str[i]);
	printf("\n");
}

void reverse(char* str, int a, int b)
{
	int i,j=0;
	char t;

	for (i = a; i <= (a + b) / 2; i++)
	{
		t = str[i];
		str[i] = str[b - j];
		str[b - j] = t;
		j++;
	}
}

void replace(char* str, int a, int b, char* temp)
{
	int i, j=0;

	for (i = a; i <= b; i++)
	{
		str[i] = temp[j];
		j++;
	}
}

double rad(int C)
{
	return M_PI * C / 180;
}

double distance(int* a, int* b, int n, int p)
{
	double sum = 0.0;

	int i, j;

	int max = 0;

	for (i = 0; i < n; i++)
	{
		sum += pow(ABS(a[i] - b[i]), p);

		if (ABS(a[i] - b[i]) > max)
			max = ABS(a[i] - b[i]);
	}

	if (p == INF)
		return max;

	return pow(sum, (double)1 / p);
}

typedef struct Dice
{
	int num[6];
}Dice;

void ROT(Dice* p,char R)
{
	int num2[6];
	int i;

	for (i = 0; i < 6; i++)
		num2[i] = p->num[i];

	if (R == 'E')
	{
		p->num[0] = num2[3];
		p->num[1] = num2[1];
		p->num[2] = num2[0];
		p->num[3] = num2[5];
		p->num[4] = num2[4];
		p->num[5] = num2[2];
	}

	if (R == 'S')
	{
		p->num[0] = num2[4];
		p->num[1] = num2[0];
		p->num[2] = num2[2];
		p->num[3] = num2[3];
		p->num[4] = num2[5];
		p->num[5] = num2[1];
	}

	if (R == 'W')
	{
		p->num[0] = num2[2];
		p->num[1] = num2[1];
		p->num[2] = num2[5];
		p->num[3] = num2[0];
		p->num[4] = num2[4];
		p->num[5] = num2[3];
	}

	if (R == 'N')
	{
		p->num[0] = num2[1];
		p->num[1] = num2[5];
		p->num[2] = num2[2];
		p->num[3] = num2[3];
		p->num[4] = num2[0];
		p->num[5] = num2[4];
	}
}

int main()
{
	Dice dice[100];
	int n;
	int i, j,k;
	int u, d;
	int temp;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 6; j++)
			scanf("%d", &dice[i].num[j]);
	}
	
	int cnt, ans = 0;
	int time = 3000;
	
	for (i = 0; i < n; i++)
	{
		for (j = i+1; j < n; j++)
		{
			time = 1000;
			while (time >= 0)
			{
				cnt = 0;

				temp = rand() % 4;

				if (temp == 0)
					ROT(&dice[i], 'E');
				if (temp == 1)
					ROT(&dice[i], 'S');
				if (temp == 2)
					ROT(&dice[i], 'W');
				if (temp == 3)
					ROT(&dice[i], 'N');
				
				for (k = 0; k < 6; k++)
				{
					if (dice[i].num[k] == dice[j].num[k])
						cnt++;
				}
				if (cnt == 6)
					break;
				time--;
			}

			if (cnt == 6)
			{
				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");

	return 0;
}



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

void print(char g){
    cout << g << endl;
    return;
}

void grade(int m, int f, int r){
    if(m == -1 || f == -1) print('F');
    else if(m+f >= 80) print('A');
    else if(65 <= m+f) print('B');
    else if(50 <= m+f) print('C');
    else if(30 <= m+f){
        if(r >= 50) print('C');
        else print('D');
    }
    else print('F');
    return;
}

int main(){
    while(1){
        int m, f, r;
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1) break;
        grade(m, f, r);
    }
    return 0;
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  ll x;
  cin >> x;
  ll ans = x / 11 * 2;
  if(x % 11 > 6) ans += 2;
  else if(x % 11 > 0) ans += 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
dp = Array.new(n, Float::INFINITY)
dp[0] = 0
n.times do |i|
  1.upto(k) do |j|
    break if i + j > n - 1
    dp[i + j] = dp[i] + (h[i] - h[i + j]).abs if dp[i] + (h[i] - h[i + j]).abs < dp[i + j]
  end
end
puts dp[n - 1]

Measured memory_bytes: 8844
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int x, a, b;
int main(void) {
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(void){
    int A, B, C;
    int count = 0;
    scanf("%d %d %d", &A, &B, &C);
    if(A == B)
        count++;
    if(A == C)
        count++;
    if(B == C)
        count++;
    if(count == 1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int(i)=int (a);i<=int (b);i++)
#define ff(i,a,b) for(int(i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int(i)=int (a);i>=int (b);i--)
#define foreach(i,x) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vt vector
#define ll long long
#define all(x) x.begin(),x.end()
#define lower(p,x) lower_bound(all(p),x)
#define upper(p,x) upper_bound(all(p),x)
#define ms(a,x) memset(a,x,sizeof a)
#define minn(a,b,c,d) min(a,min(b,min(c,d))) 
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const double pi=acos(-1.0);//NOTE:PI
const double eps=1e-5;
const int INF=1e9,mod=1e9+7,N=1e6+6;
int n;int a[N];int b[N];
int main(){
	//freopen("BIPERM.inp","r",stdin);
	//freopen("BIPERM.out","w",stdout);
	int n,l;
	cin>>n>>l;
	vt<string> a(n);
	ff(i,0,n) cin>>a[i];sort(all(a));
	ff(i,1,n) a[0]+=a[i];cout<<a[0];
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int p[101], N;

int num(int m){
    int ret = 0;
    for(int i=2; i<=N; i++){
        if(p[i] >= m) ret++;
    }
    return ret;
}

int main(void){
    cin >> N;

    // N!に含まれる素因数を全て列挙する
    for(int i=2; i<=N; i++){
        int cur = i;
        for(int j=2; j<=i; j++){
            while(cur%j == 0){
                p[j]++;
                cur /= j;
            }
        }
    }

    cout << num(74) + num(14)*(num(4)-1) + num(24)*(num(2)-1) + (num(4)*(num(4)-1)/2)*(num(2)-2) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {  
  int N;
  cin >> N;
  map<string, int> blue;
  
  int i;
  string str;
  for(i = 0; i < N; i++){
    cin >> str;
    blue[str]++;
  }
  
  int M;
  cin >> M;
  map<string, int> red;
  for(i = 0; i < M; i++){
    cin >> str;
    red[str]++;
  }
  
  // blueの各keyについて得点を求め，最大値を出力
  int score = 0;
  for (auto x : blue){
    string key = x.first;
    int value = x.second;
    int tmp_score;
    
    // cout << key << value << endl;
    
    if (red.count(key) != 0){
      tmp_score = value - red.at(key);
    } else {
      tmp_score = value;
    }
    if (tmp_score > score){
      score = tmp_score;
    }
  }
  cout << score << endl;
}

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

const int N = 2e5;
const int MX = 1e9;
int n, k;
int ar[N+2];

bool can(int x)
{
    int ret = 0;
    for (int i = 0; i < n; i++)
    {
        if (ar[i] <= x)
            continue;
        ret += ar[i]/x + (ar[i]%x != 0) - 1;
    }
    return (ret <= k);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> ar[i];
    }
    int ans;
    for (int l = 1, r = MX; l <= r; )
    {
        int m = (l+r) / 2;
        if (can(m))
        {
            ans = m;
            r = m-1;
        }
        else
            l = m+1;
    }
    cout << ans << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 4564
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;
#define ll long long

#define MAX 100020

int main(){

string s;
cin>>s;
int count=0;
int n= s.length();
for(int i=0;i<n/2;i++){
    if(s[i]!=s[n-i-1])
    count++;    
}
cout<<count;


}

Measured memory_bytes: 3156
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define ll long long
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e4 + 10;

int a[55],b[55],c[55],d[55];

int main() {
	
	int n,m;cin>>n>>m;
	rep(i,n) cin >> a[i] >> b[i];
	rep(i,m) cin >> c[i] >> d[i];

	rep(i,n)
	{
		int ans = 0;
		int minDist = 1e9;

		rep(j,m)
		{
			int dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			if(dist < minDist)
			{
				ans = j+1;
				minDist = dist;
			}
		}
		cout << ans << endl;

	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/

signed main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1')cout << 9;
		else if (s[i] == '9')cout << 1;
		else cout << s[i];
	}
	cout << endl;
end:;
	system("PAUSE");
	return 0;
}



Measured memory_bytes: 888
n=int(input())
v=list(map(int, input().split()))
c=list(map(int, input().split()))
x = 0
y = 0
z = []
min = 1000000

for i in range(n):
  z.append(v[i]-c[i])

ans1 = z[0]
for i in range(1, n):
  if ans1 < ans1 + z[i]:
    ans1 += z[i]

ans2 = 0
for i in range(1, n):
  if ans2 < ans2 + z[i]:
    ans2 += z[i]

print(max(ans1, ans2))

Measured memory_bytes: 3064
a = []
b = {}
n = int(input())
for _ in range(n):
    s, i = input().split()
    a += [(s, int(i))]
    b.setdefault(int(i), []).append(s)
b = {val: iter(s).__next__ for val, s in b.items()}

def partition(a, left, right):
    standard = a[right][1]
    cnt = left
    for i in range(left, right):
        if a[i][1] <= standard:
            a[cnt],a[i] = a[i], a[cnt]
            cnt += 1
    a[cnt],a[right] = a[right], a[cnt]
    return cnt

def quickSort(a, left = 0, right = len(a) - 1):
    if 1 <= right - left:
        cnt_ = partition(a, left, right)
        quickSort(a,left, cnt_ - 1)
        quickSort(a,cnt_ + 1, right)

quickSort(a, 0 , len(a)-1)

ok = 1
for s, i in a:
    if b[i]() != s:
        ok = 0
print(['Not stable','Stable'][ok])


for i in range(n):
    print(*a[i])


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

int main() {
  int A, B, C, D, L;
  int X, Y;

  cin >> L >> A >> B >> C >> D;

  X = A/C;
  if(A%C != 0)
    X++;
  Y = B/D;
  if(B%D != 0)
    Y++;

  cout << ((X>Y) ? (L-X) : (L-Y)) << endl;
}



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

int main(){
    int A,B,C,D , maxL, minL;
    cin >> A >> B >> C >> D;
    if(B<C || D<A){
        cout << 0;
    }else{
        if(B>D){
            maxL = D;
        }else{
            maxL = B;
        }
        if(C>A){
            minL = C;
        }else{
            minL = A;
        }
        cout << (maxL- minL);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
#define all(a) a.begin(), a.end() 
using namespace std;


int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll p = a*c;
  ll q = b*d;
  ll r = a*d;
  ll s = b*c;
  cout << max(p, max(q, max(r, s))) << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
vector<pii> g[2505], gr[2505];
int dp[2505];
bool vis[2505], vis2[2505];
int main(){
    int n, m, p;
    scanf("%d%d%d", &n, &m, &p);
    for(int i=1;i<=m;i++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        g[a].push_back(pii(b, -(c-p)));
        gr[b].push_back(pii(a, -(c-p)));
    }
    vis[1] = 1;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int i=0;i<g[u].size();i++){
            int v = g[u][i].first;
            if(vis[v]) continue;
            vis[v] = 1;
            q.push(v);
        }
    }

    if(!vis[n]){
        printf("-1\n");
        return 0;
    }

    vis2[n] = 1;
    q.push(n);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int i=0;i<gr[u].size();i++){
            int v = gr[u][i].first;
            if(!vis[v]) continue;
            if(vis2[v]) continue;
            vis2[v] = 1;
            q.push(v);
        }
    }

    for(int i=1;i<=n;i++) dp[i] = 1e9;
    dp[1] = 0;
    for(int i=1;i<=n-1;i++){
        for(int u=1;u<=n;u++){
            if(!vis2[u]) continue;
            for(int k=0;k<g[u].size();k++){
                int v = g[u][k].first, w = g[u][k].second;
                if(!vis2[v]) continue;
                if(dp[v] > dp[u] + w){
                    dp[v] = dp[u] + w;
                }
            }
        }
    }

    for(int u=1;u<=n;u++){
        if(!vis2[u]) continue;
        for(int k=0;k<g[u].size();k++){
            int v = g[u][k].first, w = g[u][k].second;
            if(!vis2[v]) continue;
            if(dp[v] > dp[u] + w){
                printf("-1\n");
                return 0;
            }
        }
    }
    dp[n] = -dp[n];
    dp[n] = max(dp[n], 0);
    printf("%d\n", dp[n]);
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		while (true)
		{
			int h = sc.nextInt();
			int w = sc.nextInt();

			if (h == 0 && w == 0)
			{
				break;
			}

			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					if ((i + j) % 2 == 0)
					{
						System.out.print("#");
					}
					else
					{
						System.out.print(".");
					}
				}
				System.out.println();
			}

			System.out.println();
		}
	}
}



Measured memory_bytes: 37704
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<cmath>

using namespace std;
typedef long long LL;
const int N=500050;

int head[N],to[N],nex[N],sg[N],n,tot;

void addedge(int u,int v){
	tot++;to[tot]=v,nex[tot]=head[u],head[u]=tot;
	tot++;to[tot]=u,nex[tot]=head[v],head[v]=tot;
}
void dfs(int x,int fa){
	for(int i=head[x];i;i=nex[i]){
		if(to[i]!=fa){
			dfs(to[i],x);
			sg[x]^=sg[to[i]]+1;
		}
	}
}

int main(){
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&j,&k);
		addedge(j,k);
	}
	dfs(1,0);
	if(sg[1])puts("Alice");
	else puts("Bob");
	return 0;
}


Measured memory_bytes: 9600
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

ans = sum(A)

for i in range(1, N + 2):
    if A[i] > 0:
        A[i] = max(A[i] - B[i - 1], 0)

    if A[i] > 0 and i != N + 1:
        if A[i] - B[i] > 0:
            A[i] -= B[i]
            B[i] = 0
        else:
            B[i] -= A[i]
            A[i] = 0

print(ans - sum(A))


Measured memory_bytes: 18476
#include <cstdio>

int S(int);

int main(){
    int N;
    scanf("%d",&N);
    if(N % S(N) == 0){
        printf("Yes");
    }else{
        printf("No");
    }
    printf("\n");

    return 0;
}

int S(int m){
    int ans = 0; 
    while(m != 0){
        ans += m % 10;
        m = m / 10;
    }

    return ans;
}

Measured memory_bytes: 888
#include <stdio.h>


int main () {

  

	int dataset = 0;


	while(1){
	  int x[200]={};
  int y[200]={};

	int input_x = 0;
	int input_y = 0;

	int present_x = 0;
	int present_y = 0;

	int max_x_r=0;
	int max_x_l=0;
	int max_y_u =0;
	int max_y_d=0;

	int result_x=0;
	int result_y=0;

	int der_x=0;
	int der_y=0;

	int left =0;
	int down =1;
	int right = 2;
	int up =3;
	int i=0;
		scanf("%d",&dataset);

		if ( dataset == 0){
			break;
		}
		//???????????¨???
		x[0] = 0;
		y[0] = 0;

		
		
			for ( i =1; i < dataset; i++){
				scanf("%d %d",&input_x,&input_y);

				//?????¨??????
				present_x = x[input_x];
				present_y = y[input_x];

				if( input_y == 0){
					der_x = -1;
				}

				else if ( input_y == 1){
					der_y = -1;
				}
				else if ( input_y == 2){
					der_x = 1;
				}
				else if ( input_y == 3){
					der_y = 1;
				}

				//??´??°
				x[i] = der_x + present_x;
				y[i] = der_y + present_y;
				der_x = 0;
				der_y = 0;

				//printf("xi:%d yi:%d\n",x[i],y[i] );

				if ( max_x_r < x[i]){
					max_x_r = x[i];
				}
				if(max_x_l > x[i]){
					max_x_l = x[i];
				}
				if ( max_y_u < y[i]){
					max_y_u = y[i];
				}
				if ( max_y_d > y[i]){
					max_y_d = y[i];
				}
			}
			result_x = max_x_r - (max_x_l) + 1;
			result_y = max_y_u - (max_y_d) + 1;
			printf("%d %d\n",result_x,result_y );
			result_x=0;
			result_y=0;

	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#define ll long long
using namespace std;

int pow2(ll A){
  if(A%2==1){return 0;}
  else{return pow2(A/2)+1;}
}

int main(){
  int N; cin >> N;
  ll a[N]; int sum=0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    sum = sum + pow2(a[i]);
  }
  
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>

using namespace std;

void Solution()
{
    int n;
    
    while(cin>>n)
    {
       //algorithm
       cout<<(n * (n + 1) / 2 + 1)<<endl; // 1+1 2+2 4+3 7+4 ....... (1+2+4)7 + (n = )4
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
long long q,w,e,r,t,y,u;
int main(){
	scanf("%lld%lld%lld%lld%lld%lld%lld",&q,&w,&e,&r,&t,&y,&u);
	if((q%2+r%2+t%2)%3==0) printf("%lld",q+w+r+t);
	else if(q>0&&r>0&&t>0||(q%2+r%2+t%2)%3==1) printf("%lld",q+w+r+t-1);
	else printf("%lld",q+w+r+t-2);
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    vector<vector<int> > a(n, vector<int>(n, 1));
    for(int x=0; x<n; ++x){
        for(int y=x+1; y<n; ++y){
            int z = x ^ y;
            while(!(z & 1)){
                ++ a[x][y];
                z >>= 1;
            }
        }
    }

    for(int x=0; x<n-1; ++x){
        cout << a[x][x+1];
        for(int y=x+2; y<n; ++y)
            cout << ' ' << a[x][y];
        cout << endl;
    }

    return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int L[110000], R[110000];
int idxL[110000], idxR[110000];
bool deleted[110000];

int exec(bool wayL) {
    for (int i = 0; i < N; i++) deleted[i] = false;
    int ans = 0, cur = 0;
    int Li = 0, Ri = 0;
    for (int i = 0; i < N; i++) {
        int next;
        if (wayL) {
            while (deleted[idxL[Li]]) Li++;
            next = idxL[Li];
            deleted[idxL[Li]] = true;
            Li++;
        } else {
            while (deleted[idxR[Ri]]) Ri++;
            next = idxR[Ri];
            deleted[idxR[Ri]] = true;
            Ri++;
        }
        if (L[next] <= cur && cur <= R[next]) {
        } else {
            if (abs(L[next] - cur) < abs(R[next] - cur)) {
                ans += abs(L[next] - cur);
                cur = L[next];
            } else {
                ans += abs(R[next] - cur);
                cur = R[next];
            }
        }
        wayL = !wayL;
    }
    ans += abs(cur);
    return ans;
}

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> L[i] >> R[i];
        idxL[i] = idxR[i] = i;
    }
    sort(idxL, idxL + N, [](int a, int b) { return L[a] > L[b]; });
    sort(idxR, idxR + N, [](int a, int b) { return R[a] < R[b]; });
    cout << max(exec(true), exec(false)) << endl;
}

Measured memory_bytes: 3456