akhauriyash/Code-Regression huggingface dataset:
#encoding:utf-8
#スタックの出番だぜ！

railroad = []
while gets
 railroad.push $_.to_i
end

out_cars = []
i = 0
until railroad.length == 0
 if railroad[i] == 0
  out_cars.push railroad.slice!(i-1,2)
  i = 0
 else
  i += 1
 end
end

i = 0
while i < out_cars.length
 puts out_cars[i][0]
 i += 1
end

Measured memory_bytes: 6088
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,k=INTM()
    p=LIST()
    p=sorted(p)
    print(sum(p[0:k]))
if __name__ == '__main__':
    do()

Measured memory_bytes: 9256
n = int(input())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n) - 1, n) + chr(97 + X % n)
    return chr(97 + X % n)

print(Base_10_to_n(n - 1, 26))

Measured memory_bytes: 9200
n = gets.to_i

c = []
s = []
f = []

0.upto(n-2) do |i|
  c[i], s[i], f[i] = gets.split.map(&:to_i)
end

0.upto(n-2) do |i|
  sum = 0
  i.upto(n-2) do |j|
    tmp = sum-s[j]
    sum =
      if tmp < 0
        s[j]
      else
        if sum%f[j] == 0
          sum
        else
          sum + f[j] - tmp%f[j]
        end
      end
    sum += c[j]
  end
  puts sum
end

puts 0


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

#define maxn 150000
#define ll long long
#define md 1000000007
int n,m;
int fac[maxn+5];

int main()
{
	
	#ifdef WXL
	freopen("in.txt","r",stdin);
	#endif
	
	scanf("%d%d",&n,&m);
	fac[0]=1; for (int i=1;i<=maxn;++i) fac[i]=(ll)fac[i-1]*i%md;
	
	if (abs(n-m)>1){
		printf("0\n");
		return 0;
	}
	else
	{
		if (n==m) printf("%lld\n",(ll)fac[n]*fac[n]*2%md);
		else printf("%lld\n",(ll)fac[n]*fac[m]%md);
	}
	
}

Measured memory_bytes: 768
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
n = int(input())

for i in range(n):
    b = int(input())
    for j in range(3):
        if A1[j] == b:
            A1[j] = 0
        if A2[j] == b:
            A2[j] = 0
        if A3[j] == b:
            A3[j] = 0

if A1[0]==A1[1]==A1[2]==0:
    print("Yes")
    exit
elif A2[0]==A2[1]==A2[2]==0:
    print("Yes")
    exit
elif A3[0]==A3[1]==A3[2]==0:
    print("Yes")
    exit

elif A1[0]==A2[0]==A3[0]==0:
    print("Yes")
    exit
elif A1[1]==A2[1]==A3[1]==0:
    print("Yes")
    exit
elif A1[2]==A2[2]==A3[2]==0:
    print("Yes")
    exit
    
elif A1[0]==A2[1]==A3[2]==0:
    print("Yes")
    exit
elif A1[2]==A2[1]==A3[0]==0:
    print("Yes")
    exit
else:
    print("No")

Measured memory_bytes: 9236
s = input()
if s[0] == s[1] == s[2] == "R":
    print(3)
elif s[0] == s[1] == "R" or s[1] == s[2] == "R":
    print(2)
elif s[0] == "R" or s[1] == "R" or s[2] == "R":
    print(1)
else:
    print(0)

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

typedef long long ll;

const int Maxn = 200005;
const ll Inf = 1000000000000000000ll;

int n;
int x[Maxn];
int X;
ll res;

ll Get(int parties)
{
    int my = 2;
    int lft = parties;
    ll cost = ll(parties) * X;
    for (int i = n - 1; i >= 0 && cost < Inf; i--) {
        if (lft == 0) {
            my++; lft = parties;
        }
        if (my == 2) cost += 5ll * ll(x[i]);
        else cost += (ll(my) * my - ll(my - 1) * (my - 1)) * ll(x[i]);
        lft--;
    }
    return min(Inf, cost);
}

ll Get(int l, int r)
{
    if (l == r) return Get(l);
    else if (l + 1 == r) return min(Get(l), Get(r));
    else if (l + 2 == r) return min(min(Get(l), Get(l + 1)), Get(r));
    else {
        int q1 = (2 * l + r) / 3, q2 = (l + 2 * r) / 3;
        ll v1 = Get(q1), v2 = Get(q2);
        if (v1 <= v2) return Get(l, q2 - 1);
        else return Get(q1 + 1, r);
    }
}

int main()
{
    scanf("%d %d", &n, &X);
    for (int i = 0; i < n; i++)
        scanf("%d", &x[i]);
    res = Get(1, n) + ll(X) * n;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
# C - Lining Up

N = int(input())
A = sorted(list(map(int, input().split())))

if N%2 == 0:
    tmp = []
    tmp2 = 1
    while tmp2 <= N-1:
        tmp.extend([tmp2, tmp2])
        tmp2 += 2
        
    if A != tmp:
        print(0)
    else:
        print((2**(N//2))%(10**9+7))
    
else:
    tmp = [0]
    tmp2 = 2
    while tmp2 <= N-1:
        tmp.extend([tmp2, tmp2])
        tmp2 += 2
        
    if A != tmp:
        print(0)
    else:
        print((2**((N-1)//2))%(10**9+7))

Measured memory_bytes: 13880
#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

MOD=10**9+7
S=get_nsp.reverse
#S=["?"]*(10**5)
L=S.size
dp=Array.new(13){0}
dp[0]=1
b=1
S.each_with_index do|s,i|
    dp2=Array.new(13){0}
    if s!="?"
        t=s.to_i*b
        k=0
        while k<13
            dp2[(k+t)%13]+=dp[k]
            dp2[k]%=MOD
            k+=1
        end
    else
        k=0
        while k<13
            t=0
            d=0
            while d<10
                dp2[(k+t)%13]+=dp[k]
                t+=b
                d+=1
            end
            dp2[k]%=MOD
            k+=1
        end
    end
        #13.times do|k|
          #if s!="?"
              #dp2[(k+s.to_i*b)%13]+=dp[k]
          #else
            #10.times do|d|
                #dp2[(k+d*b)%13]+=dp[k]
            #end
          #end
          #dp2[k]%=MOD
        #end
    dp=dp2
    b*=10
    b%=13
end
puts dp[5]%MOD

Measured memory_bytes: 14076
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

string S;
int jdg[26];
int ans = 0;
int idx;

int main(){
	
	cin>>S;
	
	fill( jdg, jdg+26, 0 );
	
	REP( i, S.size() ){
		idx = S[i]-'a';
		jdg[idx]++;
		if( jdg[idx] > 1 ) ans = 1;
	}
	
	if( ans ) puts("no");
	else{	puts("yes");}
	
	
	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  double ans = 0;
  double n;
  scanf("%lf", &n);
  int i;
  for(i = 0; ans * ans <= n; i++){
    ans++;
  }
  printf("%.0f\n", (ans-1) * (ans-1));
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(){
  int w, h, x, y, r;
  
  std::cin >> w;
  std::cin >> h;
  std::cin >> x;
  std::cin >> y;
  std::cin >> r;
  
  if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int x = 0;
		try {
			x = Integer.parseInt(in.readLine());
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		x = x * x * x;
		System.out.println(x);
	}
}

Measured memory_bytes: 24428
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [(p+1)/2.0 for p in P]
tmp = sum(E[0:K])
ans = tmp
for i in range(1, N-K+1):
    tmp = tmp - E[i-1] + E[i+K-1]
    ans = max(ans, tmp)
print(ans)

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

int main(){
    int n,m;
    cin>>n>>m;
    int a[n+1];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int cnt=0,limit=ceil(double(sum)/(4.0*double(m)));
    //cout<<limit<<endl;
    for(int i=0;i<n;i++){
        if(a[i]>=limit) cnt++;
    }
    if(cnt>=m) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.IORef
import Control.Monad.ST
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
applyTuple :: (a -> b, a -> c) -> a -> (b, c)
applyTuple (f,g) a = (f a, g a)
-- end of templete

f (x,y) 1 = [x,y]
f (x,y) n = f (x+dx,y+dy) (n-1)
  where
    r = sqrt $ x ^ 2 + y ^ 2
    dx = (-y) / r
    dy = x / r

main = map (f (1,0)) . takeWhile (/=(-1)) . map readInt . lines <$> getContents >>= mapM_ (mapM_ print)

Measured memory_bytes: 4676
#include<bits/stdc++.h>
#define int long long
#define for(i,a,b) for(int i=a;i<(signed)b;i++)

using namespace std;
int dp[100005]={0};
signed main(){
    int n;
    cin>>n;
    int h[n];
    for(i,0,n) cin>>h[i];
    dp[1]=abs(h[1]-h[0]);
    for(i,2,n){
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        dp[i] = min(dp[i],(i>1)?(dp[i-2] + abs(h[i]-h[i-2])):INT_MAX);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
n = int(input())
r = []
for i in range(1, n+1):
  hoge = input().split()
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:int(x[1]), reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

Measured memory_bytes: 3060
#include<stdio.h>



int main()
{
	int num[100000],count =0, tc, i, k, l;
	
	scanf("%d", &tc);
	
	for(i =1; i<= tc; i++)
	{
		scanf("%d", &num[i]);	
	} 
	
	for(i = 1; i <= tc-2; i++)
	{
		k = i + 1;
		l = i + 2;
		
		if(num[i] > num[k]  && num[k] > num[l])
		{
			count++;
		}
		else if(num[i] < num[k] && num[k] < num[l])
		{
			count++;
		}
	}
	printf("%d\n", count);
	
	return 0;
	
	
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
  int n;cin>>n;
  string s;cin>>s;
  int cnt=0;
  repi(i,0,n-2){
   if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


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

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

int main() {
  string s;
  cin >> s;

  int p = 0, g = 0, ans = 0;

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'p') {
      if (g > p) {
        p++;
      } else {
        g++;
        ans--;
      }
    } else if (s[i] == 'g') {
      if (g > p) {
        p++;
        ans++;
      } else {
        g++;
      }
    }
    // printf("%d %d\n", i, ans);
  }

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


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	ll n,k;
	cin>>n>>k;
	map<ll,ll> mp;
	for (ll i = 0; i < n; i++){
		ll a,b;
		cin>>a>>b;
		mp[a] += b;
	}

	ll cnt = 0;
	for(auto x:mp){
		cnt += x.second;
		if(cnt>=k){
			cout<<x.first<<endl;
			break;
		}
	}
	return 0;
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

const ll MAX_N = 1e4;
ll c[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[MAX_N + 1];


int main(){
   ll N, M;
   cin >> N >> M;
   Vi A(M);
   REP(i, M) cin >> A[i];
   SORT(A);

   REP(i, N + 1) dp[i] = "";
   REP(j, M) dp[c[A[j]]] = to_string(A[j]);

   REP(i, N){
      REP(j, M){
         if(
            i + 1 >= c[A[j]]
         && dp[i + 1 - c[A[j]]] != "" 
         && dp[i + 1 - c[A[j]]].size() + 1 >= dp[i + 1].size()
         ){
            dp[i + 1] = to_string(A[j]) + dp[i + 1 - c[A[j]]];
         }
      }
   }
   cout << dp[N] << endl;
}


Measured memory_bytes: 32384
n = int(input())

b = list(map(int,input().split()))

Flag = True

memo = []

while Flag:
    Flag = False
    index = -1
    for i, v in enumerate(b):
        if i == v-1:
            Flag = True
            index = i
    if index != -1:
        m = b.pop(index)
        memo.append(m)
if len(b):
    print(-1)
else:
    memo.reverse()
    for aa in memo:
        print(aa)

Measured memory_bytes: 64376
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V vec(n);
    rep(i, n) cin >> vec[i];
    V dp(n+1,0);
    ll Max = 0;
    rep(i,n){
        dp[vec[i]] = dp[vec[i] - 1] + 1;
        chmax(Max,dp[vec[i]]);
    }
    cout << n - Max << endl;

}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<string> a(N),b(M);
    for(int i = 0; i < N; ++i) cin >> a[i];
    for(int i = 0; i < M; ++i) cin >> b[i];

    for(int i = 0; i < N-M+1; ++i){
        for(int k = 0; k < N-M+1; ++k){
            bool contain = true;
            for(int j = 0; j < M; ++j){
                for(int l = 0; l < M; ++l){
                    if(a[i+j][k+l] != b[j][l]){
                        contain = false;
                        break;
                    }
                }
                if(!contain) break;
            }
            if(contain){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf8');

// Your code here!
const max = (a)=>{
    let i = a.length;
    let max=-Infinity;
    while (i--) {
        if (a[i] > max)max = a[i];
    }
    return max;
}
const min = (a)=>{
    let i = a.length;
    let max=Infinity;
    while (i--) {
        if (a[i] < max)max = a[i];
    }
    return max;
}
const Main = (p)=>{
	p = p.split("\n");//2 or more
	//const s=p[0];
	//const t=p[1];
	//const N = parseInt(p[0]);//N
    const H = parseInt(p[0].split(" ")[0]);//N M
	const W = parseInt(p[0].split(" ")[1]);//N M
	//const h = (p[1].split(" ").map(Number));//a1 a2 a3...
	const a = new Array(H);
	const w = new Array(H);
	for(let i=0;i<H;i++){
	    a[i] = p[i+1].split("");
	    w[i] = new Array(W).fill(-1);
	    w[i][0]=0;
	}
	w[0].fill(0);
	for(let j=0;j<W;j++)if(a[0][j]==="#")break;else w[0][j]=1;
	for(let i=0;i<H;i++)if(a[i][0]==="#")break;else w[i][0]=1;
	//console.log(H,W,a,w)
	
    for(let i=1;i<H;i++){
	    for(let j=1;j<W;j++){
	        if(a[i][j]==="#")w[i][j]=0;else
	        w[i][j]=w[i-1][j]+w[i][j-1];
	        w[i][j]%=1000000007;
	    }   
	}
	console.log(w[H-1][W-1]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

using namespace std;
using ll = long long;

int main() {
  ll A, B, C, ans{};
  cin >> A >> B >> C;
  if (A % 2 && B % 2 && C % 2) {
    ans = min({A*B,B*C,C*A});
  }
  cout << ans << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int a = sc.nextInt();
		System.out.println((h+a-1)/a);

	}
	
	static class FastScanner {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public FastScanner() {
			reader = new BufferedReader(new InputStreamReader(System.in), 32768);
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch(IOException e) {
				throw new RuntimeException(e);
			}
		}
	}

}


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

using int64 = long long;
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int64 N, K;

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

   // Kの倍数である数値の個数を数える
   int64 a = 0;
   for (int64 x = 1; x <=N; x++) {
      if (x % K == 0) {
         a++;
      }
   }

   // 余りがKの半分となる数値の個数を数える
   int64 b = 0;
   for (int64 x = 1; x <=N; x++) {
      if (x % K == K/2) {
         b++;
      }
   }

   int64 ans = a * a * a;
   if (K % 2 == 0) {
      ans += b * b * b;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c,x,y,z;
    cin >> a >> b >> c;
    if (a<b && a<c){
        if(b<c){
            x = a;
            y = b;
            z = c;
        }else{
            x = a;
            y = c;
            z = b;
        }
    }else if (b<a && b<c){
        if(a<c){
            x = b;
            y = a;
            z = c;
        }else{
            x = b;
            y = c;
            z = a;
        }
    }else{
        if(a<b){
            x = c;
            y = a;
            z = b;
        }else{
            x = c;
            y = b;
            z = a;
        }
    }    
    cout << x << " " << y << " " << z << endl;
    return 0;
        
}



Measured memory_bytes: 3040
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

long long choose2(long long n) {
    return n * (n - 1) / 2;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n) cin >> a[i];
    REP(i, n) a[i]--;

    // 出現回数を求める
    vector<int> count(n);
    REP(i, n) count[a[i]]++;

    // 全部のパターンの合計を計算する
    long long total = 0;
    REP(i, n) total += choose2(count[i]);

    REP(i, n) {
        long long ans = total;
        // 一度対象の組合せを合計から引く
        ans -= choose2(count[a[i]]);
        // 対象の個数を1つ減らしてから，
        count[a[i]]--;
        // 1つ減らした組合せをもう一度足す
        ans += choose2(count[a[i]]);
        cout << ans << '\n';
        count[a[i]]++;
    }
    return 0;
}


Measured memory_bytes: 4224
/* ex3_4 "81"
   dada__    */
#include<stdio.h>
int main(void){
    int integerN, i;
    scanf("%d", &integerN);//整数Nの入力

    for(i=1;i<10;i++){
        if( (integerN/i)<10 && integerN%i==0 ){ //整数Nが九九に含まれるかの判定
            printf("Yes\n"); 
            break; //Yes出力後ループ終了
        }
    }

    if(i==10){
        printf("No\n"); //九九の表に含まれない場合の出力
    }
    return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int N = 500005;

int n, m;

char s[N];

vector<pair<int, int> > q[N];

bool ans[N];

int fa[N];

struct Node {
	int id;
	Node* next[26];

	Node(int id) : id(id) {
		for (int i = 0; i < 26; ++i) {
			next[i] = NULL;
		}
	}
};

int find(int u) {
	return u == fa[u] ? u : fa[u] = find(fa[u]);
}

void merge(int u, int v) {
	fa[u] = v;
}

void mergeTree(Node* u, Node* v) {
	merge(u->id, v->id);
	for (int i = 0; i < 26; ++i) {
		if (u->next[i] != NULL) {
			if (v->next[i] == NULL) {
				v->next[i] = u->next[i];
			} else {
				mergeTree(u->next[i], v->next[i]);
			}
		}
	}
}

void printTree(Node *u) {
	printf("%d\n", u->id);
	for (int i = 0; i < 26; ++i) {
		if (u->next[i] != NULL) {
			printf("-%c->%d\n", 'a' + i, u->next[i]->id);
		}
	}
	for (int i = 0; i < 26; ++i) {
		if (u->next[i] != NULL) {
			printTree(u->next[i]);
		}
	}
}

int main() {
	scanf("%s", s);
	n = strlen(s);
	scanf("%d", &m);
	for (int i = 0; i < m; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		--l, --r;
		q[r].push_back(make_pair(l, i));
	}
	for (int i = 0; i <= n; ++i) {
		fa[i] = i;
	}
	Node* root = new Node(0);
	for (int i = 0; i < n; ++i) {
		Node* newroot = new Node(i + 1);
		newroot->next[s[i] - 'a'] = root;
		int num = s[i] - 'a';
		Node* cur = root;
		while (num < 26 && cur->next[num] != NULL) {
			Node* ncur = cur->next[num];
			cur->next[num] = NULL;
			if (num == 25) {
				mergeTree(ncur, newroot);
				break;
			} else {
				++num;
				newroot->next[num] = ncur;
				cur = ncur;
			}
		}
		root = newroot;
		/*
		printf("!!!! %d\n", i);
		printTree(root);
		*/
		for (int j = 0; j < (int)q[i].size(); ++j) {
			ans[q[i][j].second] = find(q[i][j].first) == find(i + 1);
		}
	}
	for (int i = 0; i < m; ++i) {
		puts(ans[i] ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 127360
k, s = map(int, input().split())
list = []
for x in range(k + 1):
    for y in range(k - x + 1):
        z = s - (x + x + y)
        if x + y <= z <= k: list.append([x, y + x, z])
        y += 1
    x += 1

answer = 0
for id in list:
    if id[0] == id[1] == id[2]: answer += 1
    elif id[0] == id[1] or id[1] == id[2]: answer += 3
    else: answer += 6
print(answer)

Measured memory_bytes: 132940
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int X, N;
    cin >> X >> N;

    if (N == 0) {
        cout << X << endl;
        return 0;
    }

    vector<int> P(N);
    vector<int> ans;
    for (int i = 0; i < N; i++){
        cin >> P[i];
    }
    sort(P.begin(), P.end());

    for (int a = X - (N + 1) / 2; a <= X + (N + 1) / 2; a++){
        ans.push_back(a);
    }

    for (size_t i = 0; i < P.size(); i++){
        auto result = find(ans.begin(), ans.end(), P[i]);
        if(result != ans.end()){
            ans.erase(result);
        }
    }
    int above = *lower_bound(ans.begin(), ans.end(), X);
    int dis = above - X;
    if(dis == 0){
        cout << X << endl;
        return 0;
    }

    int low = ans[0];
    for (size_t i = 0; i < ans.size(); i++) {
        // X との絶対値の小さいindex を探す
        if (ans[i] < above) {
            low = max(ans[i], low);
        }
    }
    int answer = dis < abs(low - X) ? dis : low - X;
    cout << answer + X << endl;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;


using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define rep(i,a,b) for (int i=a; i<b; i++)
#define pb push_back
#define vvi vector<vector<int>> 
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vector<bool>> 

vi visit, componente;
void dfs_visit(vvi & adj, int i, int comp) {
	visit[i] = 1;
	componente[i] = comp;
	for (int j : adj[i]) {
		if (!visit[j]) {
			dfs_visit(adj, j, comp);
		}
	}
}

void dfs(vvi & adj, int n) {
		visit.assign(n+1, 0);
		componente.assign(n+1, 0);
		int comp = 1;
		for(int i=1; i<=n; i++) {
			if (!visit[i]) {
				dfs_visit(adj, i, comp++);
			}
		}
}

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

	vvi adj;
	vi lista;
	lista.clear();
	adj.assign(n+1, lista);
	for (int i=1; i<=m; i++) { 
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	dfs(adj, n);

	map<int, int> mp;
	for(int i=1; i<=n; i++) {
		mp[componente[i]]++;
	}
	int ans = 0;
	for(auto e : mp) {
		ans = max(ans, e.second);
	}

	cout << ans << endl;
   return 0;

}


Measured memory_bytes: 24616
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ha,ans,n,m,tot,e[10000],nt[10010],hd[10010],c[5010][5010],sz[10010],a[10010],p=1e9+7,f[10010],jc[10010],ny[10010];
void build(ll x,ll y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
void dfs(ll x,ll fa){
	ll i,mx=0;
	sz[x]=1;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		dfs(e[i],x);
		mx=max(mx,sz[e[i]]);
		sz[x]+=sz[e[i]];
	}
	mx=max(mx,n-sz[x]);
	if(mx<=n/2){
		ha++;
		for(i=hd[x];i;i=nt[i]){
			if(e[i]==fa)continue;
			a[++m]=sz[e[i]];
		}
		a[++m]=n-sz[x];
	}
}
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
int main(){
	ll now,i,x,y,j,sum=0,k;
	scanf("%lld",&n);
	for(i=1;i<n;i++){
		scanf("%lld%lld",&x,&y);
		build(x,y);build(y,x);
	}
	dfs(1,0);
	if(ha>1){
		ans=1;
		for(i=1;i<=n/2;i++)ans=ans*i%p;
		ans=ans*ans%p;
		printf("%lld",ans);
		return 0;
	}
	jc[0]=ny[0]=1;
	for(i=1;i<=n;i++)jc[i]=jc[i-1]*i%p,ny[i]=ksm(jc[i],p-2)%p;
	for(i=0;i<=n;i++)c[i][0]=1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%p;
	f[0]=1;
	for(i=1;i<=m;i++){
		//printf("%lld %lld\n",i,a[i]);
		sum+=a[i];
		for(j=sum;j>=0;j--){
			now=0;
		 for(k=0;k<=min(j,a[i]);k++)now=(now+f[j-k]*c[a[i]][k]%p*jc[a[i]]%p*ny[a[i]-k]%p)%p;
		 f[j]=now;
	  }
	}
	for(i=0;i<n;i++){
		//printf("%lld %lld\n",i,f[i]);
		sum=f[i]*jc[n-i]%p;
		if(i%2==0)ans=(ans+sum)%p;
		 else ans=(ans-sum+p)%p;
	}
	printf("%lld",ans);
}
/*
不（很）难想到所有点经过重心就是最优解 
*/

Measured memory_bytes: 195456
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9+7;
signed main(){
  lint N; cin >> N;
  string s, t; cin >> s >> t;
  string x;
  for(lint i = 0; i < N; i++){
    if(s[i] == t[i]) x += 'X';
    else{
      x += 'Y'; 
      i++;
    }
  }
  lint ans;
  if(x[0] == 'X') ans = 3;
  if(x[0] == 'Y') ans = 6;
  for(lint i = 1; i < x.size(); i++){
    if(x[i] == 'X' && x[i - 1] == 'X') ans *= 2;
    else if(x[i] == 'X' && x[i - 1] == 'Y') ans *= 1;
    else if(x[i] == 'Y' && x[i - 1] == 'X') ans *= 2;
    else ans *= 3;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  ll X;
  cin>>X;
  
  ll a=X/500;
  ll b=X%500;
  ll c=b/5;
  
  cout<<a*1000+c*5<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long ll;

const ll N = 1e7 + 5, P = 998244353;

ll fac[N], inv[N], fnv[N];

void pre() {
	fnv[0] = fac[0] = inv[1] = 1;
	for(ll i = 2; i <= N; ++i) inv[i] = (P - P / i) * 1ll * inv[P % i] % P;
	for(ll i = 1; i <= N; ++i) fac[i] = fac[i - 1] % P * i % P, fnv[i] = fnv[i - 1] % P * inv[i] % P;
} 

ll C(ll a, ll b) {
	if(a < 0 or b < 0 or b > a) return 0;
	return fac[a] % P * fnv[b] % P  * fnv[a - b] % P;
}

int main(void) {
	pre();
	ll a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	ll ans = 0;
	for(ll i = 0; i <= a; ++i)
		{
			if((d - i * b) % c == 0)
			{
				ll k = (d - i * b) / c;
				ans = (ans + C(a, k) % P * C(a, i)) % P;				
			}
		}
	printf("%lld", ans % P);
} 

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

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

    string A[N];
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }
    string B[M];
    for(ll i = 0; i < M; i++){
        cin >> B[i];
    }

    string ans = "No";

    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j++){
            if(i + M - 1 >=N or j + M -1 >= N) continue;

            bool match = true;
            for(ll k = 0; k < M; k++){
                for(ll l = 0; l < M; l++){
                    if(A[i + k][j + l] != B[k][l])match = false;
                }
            }

            if(match){
                ans = "Yes";
            }

        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = (ll)1e17;

int n, m;
int c[20], dp[50001]; //dp[i]:i円を払うのに必要な最小の枚数

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; i++) cin >> c[i];
	fill(dp, dp + 50001, n); //1円でn枚払うとする
	dp[n] = 0;
	for (int i = n; i > 0; i--) {  //n円から
		for (int j = 0; j < m; j++) {
			if (i >= c[j]) { //払えるなら
				dp[i - c[j]] = min(dp[i] + 1, dp[i - c[j]]); //i円をc[j]で払う
			}
		}
	}
	cout << dp[0] << endl; //ピッタリ払える
	return 0;
}


Measured memory_bytes: 3324
N=int(input())
s=input()
PIN=[]
firs=[]
sec=[]
thir=[]
for i in range(N-2):
    if s[i] not in firs:
        firs.append(s[i])
        for j in range(i+1,N-1):
            if s[j] not in sec:
                sec.append(s[j])
                for k in range(j+1,N):
                    if s[k] not in thir:
                        thir.append(s[k])
                        PIN.append(s[i]+s[j]+s[k])
                thir=[]
        sec=[]       
print(len(PIN))

Measured memory_bytes: 3064
n,m,x,y = map(int,input().split())

x_n = list(map(int,input().split()))
y_m = list(map(int,input().split()))

if x < max(x_n) and max(x_n) <min(y_m) and min(y_m) <=y:
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

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


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,anss=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>n;
    int a[n+1];
    for(i=1;i<=n;i++)
    {
        a[i]=0;
    }
    for(i=1;i*3<=n;i++)
    {
        a[3*i]=1;
    }
    
    for(i=1;i*5<=n;i++)
    {
        a[5*i]=1;
    }
    
    for(i=1;i<=n;i++)
    {
        if(a[i]==0) sum+=i;
    }
    cout<<sum<<endl;
    
    
    
    
        
    
}

Measured memory_bytes: 11448
N,Q = map(int,input().split())
S = input()
lst = [0] * (N+1)
before = ''
count = 0
for i in range(len(S)-1):
    if S[i:i+2] == 'AC':
        count += 1
    lst[i+2] = count
for i in range(Q):
    l,r = map(int,input().split())
    print(lst[r]-lst[l])


Measured memory_bytes: 7980
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int ret = 0;
  for (int i = 0, j, k = 1; i < n; i = j + 1, ++k) {
    for (j = i; j < n && a[j] != k; ++j);
    if (j == n) break;
    ++ret;
  }
  if (ret == 0) {
    puts("-1");
  } else {
    printf("%d\n", n - ret);
  }
  return 0;
}


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

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

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

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}
*/

int dp[100013][2];
vector<int> g[100013];

int v[100013];

void dfs(int n)
{
    v[n]=1;
    for(auto i:g[n])
    {
        if(!v[i])
            dfs(i);
    }
    if(g[n].size()==1&&!dp[g[n][0]][0])
        dp[n][0]=dp[n][1]=1;
    else
    {
        dp[n][0]=dp[n][1]=1;
        for(auto i:g[n])
        {
            if(dp[i][0])
            {
                dp[n][0]=(dp[n][0]*(dp[i][0]+dp[i][1]))%mod;
                dp[n][1]=(dp[n][1]*dp[i][0])%mod;
            }
        }
    }
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for(int i=1;i<n;i++)
    {
        int d,p;
        cin >> d >> p;
        g[d].pb(p);
        g[p].pb(d);
    }
    dfs(1);
    cout << (dp[1][0]+dp[1][1])%mod;
    return 0;
}


Measured memory_bytes: 12288
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int N,M; cin >> N >> M;
	int l = 0;
	int r = INF;
	rep(i,N){
		int L,R; cin >> L >> R;
		l = max(l,L);
		r = min(r,R);
	}
	cout  << max(r-l+1,0) << endl;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define INF 2e8
#define all(a) a.begin(), a.end()
#define pb push_back
#define maxer max_element
#define miner min_element

int main() {
  int n;
  cin >> n;
  vector<string> vcWord;
  bool fRule = true;

  rep(i, n) {
    string w;
    cin >> w;

    if (i != 0) {
      if (vcWord.back().back() != w[0]) {
        fRule = false;
      }
    }
    for (string z : vcWord) {
      if (z == w) {
        fRule = false;
      }
    }

    vcWord.pb(w);
  }

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


Measured memory_bytes: 256
def resolve():
    a, b, c, x, y = map(int, input().split())
    p1 = x*a + y*b
    minp = min(x, y)
    if x >= y:
        p2 = minp*2*c + (max(x, y)-minp)*a

    else:
        p2 = minp * 2 * c + (max(x, y) - minp) * b
    p3 = max(x, y) * 2 * c
    print(min(p1, p2, p3))

resolve()

Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define CMAX 10000

int A[MAX], B[MAX];

void countsort(int A[], int n, int B[], int k) {
    int C[k+1];
    for (int i = 0; i <= k; i++)  C[i] = 0;
    for (int i = 1; i <= n; i++)  C[A[i]]++;
    for (int i = 1; i <= k; i++) C[i] = C[i] + C[i-1];
    for (int i = n; i >= 1; i--) {
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }

}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }
    int k = A[1];
    for ( int i = 2; i <= n; i++) {
        if (A[i] >= k) {
            k = A[i];
        }
    }
    countsort(A, n, B, k);

    for ( int i = 1; i <= n; i++){
        if (i != 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");
    return 0;
}




Measured memory_bytes: 18264
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(d2 == 1){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
#define int long long
const int N = (int) 2e5 + 5, mod = (int) 0;
int a[N], f[N];
pair<int, int> sr[N];
void update(int m, int x) { ++m;
	while (m < N)
		f[m] += x, m += m & -m;
}
int query(int m) { ++m;
	int res = 0;
	while (m > 0)
		res += f[m], m -= m & -m;
	return res;
}
int32_t main() {
	int n, k;
	cin >> n >> k;
	++n;
	for (int j = 1; j < n; ++j) {
		cin >> a[j];
		a[j] -= k;
		a[j] += a[j - 1];
	}
	for (int j = 0; j < n; ++j)
		sr[j] = mp(a[j], j);
	sort(sr, sr + n);
	int pt = n - 1, res = 0;
	for (int i = 0; i < n; ++i) {
		int j = sr[i].second;
		update(j, 1);
		res += query(j - 1);
	}
	cout << res << endl;
	
	
	
}




Measured memory_bytes: 6528
#include<cstdio>
#include<algorithm>
#define MAXN 106
using namespace std;
int n,a[MAXN],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
			ans++;
			i++;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int i,n,k;cin>>n>>k;
  vector<int> p(n),c(n);
  for(i=0; i<n; ++i) cin>>p[i];
  for(i=0; i<n; ++i) cin>>c[i];
  vector<vector<long int>> dp(n, vector<long int>(0));
  for(i=0; i<n; ++i){
    int cnt=0;
    vector<bool> seen(n,false);
    for(int j=i; seen[j]==false;){
      seen[j] = true;
      j = p[j]-1;
      dp[i].push_back(c[j]);
      if(cnt>0) dp[i][cnt] += dp[i][cnt-1];
      ++cnt;
    }
  }
  long int score=0,sum=0,j=0;
  int l,q;
  for(i=0; i<n; ++i){
    l=dp[i].size();
    if(l>=k||dp[i][l-1]<=0){
      q=(k>l? l:k);
      for(l=0; l<q; ++l) if(l==0 || j<dp[i][l]) j=dp[i][l];
    }
    else{
      q=k;
      j=dp[i][l-1]*((q-1)/l);
      q-=((q-1)/l)*l;
      for(int p=0; p<q; ++p) if(p==0 || sum<dp[i][p%l]) sum=dp[i][p%l];
      j+=sum;
    }
    if(score<j || i==0) score=j;
  }
  cout<<score<<endl;
  return 0;
}

Measured memory_bytes: 218916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    ll a=0;
    REP(i,n){
        a+=m+i;
    }
    int ans=INF;
    REP(i,n){
        if(abs(ans)>abs(m+i)){
            ans=m+i;
        }
    }
    cout<<a-ans<<endl;
    return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    double r;
    cin >> r;
    double pi= 3.1415926535;
    cout << 2 * r * pi << endl;
    return 0;
}

Measured memory_bytes: 3784