akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
#define mall (nod*)malloc(sizeof(nod))
using namespace std;
typedef long long ll;
ll n,m;
ll dep[100005],pa[100005];
ll find(ll x)
{
	if(x==pa[x]) return x;
	else return pa[x]=find(pa[x]);
}
void unite(ll x,ll y)
{
	x=find(x);
	y=find(y);
	if(dep[x]>dep[y]) pa[y]=x;
	else if(dep[x]<dep[y]) pa[x]=y;
	else pa[x]=y,dep[y]++;
}
int main(void)
{
	scanf("%lld%lld",&n,&m);
	for(ll i=1;i<=n;i++) dep[i]=1,pa[i]=i;
	while(m--)
	{
		ll u,v;
		scanf("%lld%lld",&u,&v);
		unite(u,v);
	}
	vector<ll> ve;
	for(ll i=1;i<=n;i++)
	{
		ve.push_back(find(i));
	}
	sort(ve.begin(),ve.end());
	ve.erase(unique(ve.begin(),ve.end()),ve.end());
	printf("%lld\n",ve.size()-1);
} 

Measured memory_bytes: 5880
x=input()
if x == 'hi':
	print('Yes')
elif x == 'hihi':
	print('Yes')
elif x == 'hihihi':
	print('Yes')
elif x == 'hihihihi':
	print('Yes')
elif x == 'hihihihihi':
	print('Yes')
else:
	print('No')

Measured memory_bytes: 2940
n, m = gets.chomp.split(" ").map(&:to_i)
a = []
n.times do
  a << gets.chomp.split("")
end

b = []
m.times do
  b << gets.chomp
end
b = b.join("")
(n - m + 1).times do |py|
  (n - m + 1).times do |px|
    a_sub = []
    (py...(py+m)).each do |y| 
       a_sub +=  a[y][px...(px+m)]
    end
    a_sub = a_sub.join("")
    if b == a_sub then
      puts "Yes"
      exit
    end
  end
end

puts "No"

Measured memory_bytes: 9888
pypy -cn,a,b="`tr \  ,`
m=10**9+7
s=r=1
for i in range(b):
 r=r*(n-i)*pow(i+1,m-2,m)%m
 if i+1in[a,b]:s+=r
print(pow(2,n,m)-s)%m"

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

string s;
int a[100];

int main(){
  cin >> s;
  for(int i = 0 ; i < s.length(); i++){
        a[ s[i] - 'a' ] =  1;
   }
  
   int  flag = 1; 
   char  ch = 'a';  
 for (int i=0 ; i < 26; i++){
      if (a[i]==0){
          ch = ch + i;
          flag  = 0;
          break;
     }
}
if (flag ) 
   cout<< "None" <<endl;
else 
   cout<<ch<<endl;
return 0;
}

Measured memory_bytes: 512
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	ll X;
	scll(X);
	ll val = X * 360 / __gcd(X, 360LL);
	printf("%lld\n", val/X);
	return 0;
}

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

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    static class Solve
    {
        public static void Answer()
        {
            var nums = IO_ShortCut.ReadSplitInt;

            var answerList = new[] { nums[2], nums[0], nums[1] };

            IO_ShortCut.OutJoinSpace(answerList);
        }
    }

    static class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static string[] ReadSplitString => ReadLine().Split();
        public static int[] ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        #endregion
    }
}

Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef unsigned long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

lli n, k;
vector<int> a, b;

lli calc(lli m){
	m = ~m;
	lli ret = 0;
	rep(i, a.size()) if((m&a[i])==0) ret += b[i];
	return ret;
}

int main(void){
	cin >> n >> k;
	rep(i, n){
		lli ta, tb;
		cin >> ta >> tb;
		if(ta <= k){
			a.push_back(ta);
			b.push_back(tb);
		}
	}
	
	lli ans = calc(k);
	ireg(i, 1, 30) if(((k>>i)&1) == 1) ans = max(ans, calc(((k>>i)<<i)-1));
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 100005

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

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, tot;
bool vis[N];
int cnt[N], du[N];
vector<int> T[N];
queue<int> que, tmp;

inline void AddEdge(int x, int y) {
	T[x].push_back(y);
	T[y].push_back(x);
	++du[x], ++du[y];
}

void Win() {
	puts("First");
	exit(0);
}

int main() {
	read(n), tot = n;
	for (int i = 1; i < n; ++i) AddEdge(read, read);

	for (int i = 1; i <= n; ++i) if (du[i] == 1) que.push(i);

	while (tot) {
		for (int i = 1, sz = que.size(); i <= sz; ++i)
			vis[que.front()] = true, que.push(que.front()), que.pop();

		while (!que.empty()) {
			int u = que.front(); que.pop();
			vis[u] = true, --tot;
			for (int v : T[u])
				if (!vis[v]) {
					tmp.push(v);
					++cnt[v];
				}
		}

		for (int i = 1, sz = tmp.size(); i <= sz; ++i)
			vis[tmp.front()] = true, tmp.push(tmp.front()), tmp.pop();

		while (!tmp.empty()) {
			int u = tmp.front(); tmp.pop(), --tot;
			if (cnt[u] > 1) Win();
			for (int v : T[u])
				if (!vis[v]) {
					if (!--du[v]) Win();
					if (du[v] == 1) que.push(v);
				}
		}
	}

	puts("Second");
	return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();
        int D = in.nextInt();
        System.out.println(Math.min(B * ((N + A - 1) / A), D * ((N + C - 1) / C)));
    }
}


Measured memory_bytes: 26332
#include<bits/stdc++.h>
#include<vector>
#include<map>
#include<set>
using namespace std;

#define mod 1000000007

#define ll long long
#define ff first
#define ss second
#define E endl;
#define PII pair<int, int>
#define PCI pair<char, int>
#define PLL pair<ll, ll>
#define O " "
#define ghur(i, n) for(int i = 0; i < n; i++)
#define pb(x) push_back(x);
#define i_n v.begin(), v.end()
#define dec_v(v) std::vector<int> v;
#define in(x) insert(x)
#define file()  freopen("input.text", "rt", stdin), freopen("out.txt", "wt", stdout);
#define inf INT_MAX
void cin_ar(int n, int ar[]) {for(int i = 0; i < n; i++) cin>>ar[i];}
void cin_ll(int n, ll ar[]) { for(int i = 0; i < n; i++) cin>>ar[i];}
void cin_v(int n, vector<int> v){int x; for(int i = 0; i < n; i++){cin>>x; v.pb(x);}}
bool cmp(int a, int b) {return a>b;}
bool cmp_pair(PII &a, PII &b){return a.ss<b.ss;}
int n, k;
int bs(int x1, int x2)
{
	return abs(2*x2 - x1) - k;
}

void solve()
{
  int n, x, t;

  cin>>n>>x>>t;

  printf("%d\n", (int) ceil(n*1.00/x*1.00)*t);

}


void solve_2() {int t; cin>>t; while(t--) solve();}

int main()
{   
 	//file();
    
    solve();
    //solve_2();



    return 0;
} 

Measured memory_bytes: 3712
"""
https://atcoder.jp/contests/abc137/tasks/abc137_a
"""

import numpy as np


def calc(A: int, B: int) -> int:
    return max(A + B, A - B, A * B)


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    A, B = load_input_as_int_array()
    result = calc(A, B)
    print(result)


main()


Measured memory_bytes: 21932
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad
import           Data.Array.Unboxed

main :: IO ()
main = print =<< solve <$> getInput

getInput :: IO (Int, UArray (Int, Int) Int)
getInput = do
  n <- readLn
  arr <- readArray 2 n
  return (n, arr)

readArray :: Int -> Int -> IO (UArray (Int, Int) Int)
readArray x y = array ((1, 1), (x, y)) <$> readAssocList x y

readAssocList :: Int -> Int -> IO [((Int, Int), Int)]
readAssocList x y = zip
  [(i, j) | i <- [1 .. x], j <- [1 .. y]]
  <$> readMat x y

readMat :: Int -> Int -> IO [Int]
readMat x y = concat <$> replicateM x readInts

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

solve :: (Int, UArray (Int, Int) Int) -> Int
solve (n, ass) = maximum [turnAt i | i <- [1 .. n]] where
  turnAt x = sum [ass ! (1, i) | i <- [1 .. x]]
               + sum [ass ! (2, i) | i <- [x .. n]]


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int n, m;
    cin >> n >> m;

    vector<int> num(n, 1);
    vector<bool> red(n, false);
    red[0] = true;

    rep(i, m){
        int x, y;
        cin >> x >> y;

        num[x-1]--;
        num[y-1]++;
        if(red[x-1] == true){
            red[y-1] = true;
        }
        if(num[x-1] == 0){
            red[x-1] = false;
        }
    }

    int ans = 0;
    rep(i, n){
        ans += red[i];
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = [int(input()) for i in range(N)]
A_max_primary = A.index(max(A))

temp = A[A_max_primary]
A[A_max_primary] = 0
A_max_secondary = A.index(max(A))
A[A_max_primary] = temp

for i in range(N):
  if i == A_max_primary:
    print(A[A_max_secondary])
  else:
    print(A[A_max_primary])

Measured memory_bytes: 12512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL;

using namespace std;

LL A, B;

LL mysqrt(LL x) {
	LL y = sqrt(x);
	if (y * y > x)
		y--;
	if ((y + 1LL) * (y + 1LL) <= x)
		return y + 1;
	return y;
}

int main() {
	int tests;
	cin >> tests;
	FOR (test, tests) {
		cin >> A >> B;
		if (A * B <= -1) {
			LL ret = 0LL;
			bool usedi[A * B + 1];
			bool usedj[A * B + 1];
			SET(usedi, 0);
			SET(usedj, 0);
			usedi[A] = true;
			usedj[B] = true;
			ffor (i, 1, A * B + 1)
				for (int j = A * B; j > 0; j--) {
					if (usedi[i] || usedj[j])
						continue;
					if (i * j < A * B) {
						usedi[i] = true;
						usedj[j] = true;
						ret++;
					}
				}
			cout << ret << endl;
			continue;
		}
		LL ret = 0LL;
		LL mm = A * B - 1;
		LL s = mysqrt(mm);
		ret += 2 * s;
		if (s * (s + 1) > mm)
			ret--;
		if (s >= min(A, B))
			ret--;
		cout << ret << endl;
		//cout << "ret = " << ret << "; s = " << s << "; mm  = " << mm << endl;
	}
  return 0;
}

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

int main(void) {
    int n, l, cnt;
    ostringstream ss;
    
    while (cin >> n, n) {
        string s[2], prev;
        cin >> s[0];
        int to = 1;
        for (int i = 0; i < n; ++i) {
            l = s[to^1].length();
            s[to] = "";
            int j = 0;
            for (; j < l; ++j) {
                if (j != 0) {
                    char c0 = s[to^1].c_str()[j], c1 = prev.c_str()[0];
                    if (c0 == c1)
                        ++cnt;
                    else {
                        ss.str("");
                        ss.clear(stringstream::goodbit);
                        ss << cnt;
                        s[to] += ss.str() + prev;
                        cnt = 1;
                        prev = s[to^1][j];
                    }
                } else {
                    cnt = 1;
                    prev = s[to^1][j];
                }
            }
            ss.str("");
            ss.clear(stringstream::goodbit);
            ss << cnt;
            s[to] += ss.str() + prev;
            to ^= 1;
        }
        cout << s[to^1] << endl;
    }
    
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

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


Measured memory_bytes: 256
/*input
5
9 5 6 8 4

*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 4;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int n, mm = 0, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    if (a >= mm) {
      mm = a;
      cnt++;
    }
  }
  cout << cnt;

  return 0;
} 

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

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if (a <= 0 && 0 <= b)printf("Zero\n");
	else if (0 < a)printf("Positive\n");
	else{
		printf((b - a) & 1 ? "Positive\n" : "Negative\n");
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
C = input()

f = 0
b = N - 1
ans = 0

while True:
    while  f <= N -1 and C[f] == "R":
        f += 1
    while b >= 0 and C[b] == "W":
        b -= 1
    if f > b:
        print(ans)
        break
    ans += 1
    f += 1
    b -= 1

Measured memory_bytes: 9344
s = input()
l = len(s)

txt1 = ''
txt2 = ''

for i in range(l):
    if i%2==0:
        txt1 += '0'
        txt2 += '1'
    else:
        txt1 += '1'
        txt2 += '0'

cnt1 = 0
cnt2 = 0

for i in range(l):
    if s[i] != txt1[i]:
        cnt1 += 1
    if s[i] != txt2[i]:
        cnt2 += 1
print(min(cnt1,cnt2))

Measured memory_bytes: 3316
use std::io::*;
const MOD: u64 = 1_000_000_007;

fn mod_pow(mut x: u64, mut e: u64, m: u64) -> u64 {
    let mut res = 1;
    while e > 0 {
        if e & 1 == 1 {
            res = res * x % m;
        }
        x = x * x % m;
        e >>= 1;
    }
    res
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let n: u64 = itr.next().unwrap().parse().unwrap();
    let a: u64 = itr.next().unwrap().parse().unwrap();
    let b: u64 = itr.next().unwrap().parse().unwrap();

    let mut ans = mod_pow(2, n, MOD) - 1;

    let mut nca = 1;
    let mut ncb = 1;
    for i in 0..a {
        nca = nca * (n - i) % MOD * mod_pow(a - i, MOD - 2, MOD) % MOD;
    }
    for i in 0..b {
        ncb = ncb * (n - i) % MOD * mod_pow(b - i, MOD - 2, MOD) % MOD;
    }
    ans = (ans + MOD - nca) % MOD;
    ans = (ans + MOD - ncb) % MOD;
    println!("{}", ans);
}


Measured memory_bytes: 4352
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := intScanner(), intScanner(), intScanner()
	fmt.Println(a + b + c - max([]int{a, b, c}))
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15); 
    string s; 
    cin >> s;
    bool flag = 0;  
    for (int i = 0; i < (int)s.size() - 1; ++i) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << ' ' << i + 2 << endl; 
            flag = 1;
            break; 
        }
    }
    if (!flag) {
        for (int i = 0; i < (int)s.size() - 2; ++i) {
            if (s[i] == s[i + 2]) {
                cout << i + 1 << ' ' << i + 3 << endl; 
                flag = 1; 
                break;  
            }
        }
    }
    if (!flag) cout << -1 << ' ' << -1 << endl; 
    return 0; 
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int a, m; cin >> a >> m, a || m;) {
		vector<pair<int, char> > v;
		v.push_back(mp(a + m, 'A'));
		for(int i = 1; i <= 4; i++) {
			cin >> a >> m;
			v.push_back(mp(a + m, 'A' + i));
		}
		sort(v.rbegin(), v.rend());
		cout << v[0].second << " " << v[0].first << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  vector<int> hs(n);
  F0R(i, n) cin >> hs[i];

  sort(rng(hs));
  hs.resize(max<int>(hs.size() - k, 0));

  i64 result = 0;
  for (auto h : hs) {
    result += h;
  }
  cout << result;
}
#endif


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n); rep (i, n) cin >> a[i];
    int x = 0;
    rep (i, n) x ^= a[i];
    rep (i, n) cout << (x ^ a[i]) << " \n"[i == n - 1];
    return 0;
}

Measured memory_bytes: 3984
#include<cstdio>

const int N_MAX = 200'000;
int dp[N_MAX] = {};

int main() {
	int n;
	scanf("%d", &n);
	int max = 0;
	for(int i=0;i<n;i++) {
		int p;
		scanf("%d", &p);
		p--;
		dp[p] = p == 0 ? 1 : dp[p-1]+1;
		if(dp[p] > max) max = dp[p];
	}
	printf("%d\n", n - max);
	return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		int h = 60 * 60;
		int m = 60;
		stdIn.close();
		System.out.printf("%d:%d:%d\n",x/h,x%h/m,x%h%m);

	}

}


Measured memory_bytes: 26296
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    int c;
    if(op=='+') c=a+b;
    if(op=='-') c=a-b;
    if(op=='*') c=a*b;
    if(op=='/') c=a/b;
    cout << c << endl;
    cin >> a >> op >> b;
  }
  return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
const long long M =2e5+2,MOD=1e9+7;
typedef long long ll;
#define pb push_back
#define Y printf("YES\n")
#define N printf("NO\n")
#define O printf("-1\n")
bool f_2=false,vis[M]= {false},f=false;
vector<ll>v[M],v_1,v_2;
string s,p,q,ok,ch;
map<ll,ll>mp,mp_2;
set<ll>st,st_1;
ll parent[M],subtree[M]={0};
ll cnt=0,cost=0,mx=0,NODE,t,par,zero=0,pos=0,neg=0;
//deque<ll>Q;
//vector< pair<ll,ll > >v,v_1;
struct node
{
    ll pa,ran,visit;

};
//node X[M];
void bfs()
{
    for(ll i=0;i<M;i++)
    {
        parent[i]=i;
    }
    queue<ll>Q;
    Q.push(1);
    while(!Q.empty())
    {
        ll a=Q.front();
        //cout<<a<<endl;
        Q.pop();
        vis[a]=true;
        for(ll i=0;i<v[a].size();i++)
        {
            ll b=v[a][i];
           // cout<<a<<" "<<b<<endl;
            if(!vis[b])
            {
                Q.push(b);
                subtree[b]+=subtree[a];
                vis[b]=true;
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);//ISHWAR
    cin.tie(0);//Tourist_Twin
    //freopen("kamona.txt","r",stdin);
    ll a,b,c,n,t,sum=0,mx=0,l,x,y,i=0,j=0,res,m,second=0,d;
    cin>>n>>t;
    for(i=0;i<n-1;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    for(i=0;i<t;i++)
    {
        cin>>x>>y;
        subtree[x]+=y;
    }
    bfs();
    for(i=1;i<=n;i++)
        cout<<subtree[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 19696
#include<iostream>
using namespace std;
#define NIL -1
struct zs{int id;int l;int r;}a[30];
int n;
void Pre(int p)
{
    if(p==NIL)return;
    else
    {
        cout<<" "<<p;
        Pre(a[p].l);
        Pre(a[p].r);
    }
}
void Ino(int p)
{
    if(p==NIL)return;
    else
    {   Ino(a[p].l);
        cout<<" "<<p;
        Ino(a[p].r);
    }
}
void Pos(int p)
{
    if(p==NIL)return;
    else
    {
        Pos(a[p].l);
        Pos(a[p].r);
        cout<<" "<<p;
    }
}
int main()
{
    int i,v,l,r,root;
    cin>>n;
    for(i=0;i<n;i++)
    {
        a[i].id=NIL;
    }
    for(i=0;i<n;i++)
    {
        cin>>v>>l>>r;
        a[v].l=l;
        a[v].r=r;
        if(l!=NIL)a[l].id=v;
        if(r!=NIL)a[r].id=v;
    }
    for(i=0;i<n;i++)if(a[i].id==NIL)root=i;
    cout<<"Preorder"<<endl;
    Pre(root);
    cout<<endl;
    cout<<"Inorder"<<endl;
    Ino(root);
    cout<<endl;
    cout<<"Postorder"<<endl;
    Pos(root);
    cout<<endl;
    return 0;
}

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

int main() {
  ll N;
  cin >> N;
  int count = 0;
  int ans = 0;
/*  while(N % 2 == 0){
    N = N / 2;
    count++;
  }
  for(ll i = 1;i < 70; i++) {
    if(count >= i) {
      ans++;
      count -= i;
    }
    else{
      break;
    }
  }
  count = 0;
//  cout << ans << endl;
*/
  for( ll i = 2; i <= sqrt(N); i++){
    while(N % i == 0){
      N = N / i;
      count++;
    }
    for(ll j = 1;j < 70; j++) {
      if(count >= j) {
         ans++;
         count -= j;
      }
      else{
        break;
      }
    }
    count = 0;
  }
  if(N != 1){
    ans++;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 3624
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

char a[300000];
int n;
int d[300000];

int main()
{
	int i, j, k, l;
	cin>>(a+1);
	n=strlen(a+1);
	d[0]=1;
	string s[5]={"dream", "dreamer", "erase", "eraser"};
	for(i=1;i<=n;i++)
	{
		for(j=0;j<4;j++)
		{
			int flag=0;
			for(k=0;k<s[j].size();k++)
			{
				if(a[i+k] != s[j][k]) flag=1;
			}
			if(!flag && d[i-1]) d[i+s[j].size()-1]=1;
		}
	}
	if(d[n] == 1) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}
//*/

Measured memory_bytes: 768
#!/usr/bin/python
#_*_coding:utf-8_*_


def partition(array, p, r):
    x = array[r]
    i = p - 1
    for j in range(p, r):
        if array[j] <= x:
            i = i + 1
            v = array[i]
            array[i] = array[j]
            array[j] = v
    va = array[i + 1]
    array[i + 1] = array[r]
    array[r] = va

    return i + 1, array


def main():
    n = raw_input()
    num = raw_input()
    array = num.strip().split(" ")
    array = map(int, array)
    index, new_array = partition(array, 0, len(array) - 1)
    new_array = map(str, new_array)
    new_array[index] = "[" + new_array[index] + "]"
    print " ".join(new_array)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18268
#!/usr/bin/env python3
import sys


def solve(N: int, x: int, a: "List[int]"):
    a.sort()
    answer = 0
    for i in range(N):
        if x >= a[i]:
            x -= a[i]
            answer += 1
        else:
            x -= a[i]
            break
    if x > 0:
        answer -= 1
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()


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

int x, n, p[100];

int search(int a)
{
	for (int i = 0; i < n; i++)
	{
		if (p[i] == a)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	cin >> x >> n;
	for (int in = 0; in < n; in++)
		cin >> p[in];

	for (int i = 0; ; i++)
	{
		if (search(x - i))
		{
			cout << x - i;
			break;
		}
		if (search(x + i))
		{
			cout << x + i;
			break;
		}
	}
}

Measured memory_bytes: 3616
loop do
  h, w = gets.split.map(&:to_i)
  break if h.zero? && w.zero?

  tiles = []

  h.times do
    tiles << gets.chomp.split('')
  end

  tiles = tiles.transpose
  passed = []
  current_x, current_y = [0, 0]
  loop = false

  loop do
    if passed.include?([current_x, current_y])
      loop = true
      break
    end

    passed << [current_x, current_y]

    case tiles[current_x][current_y]
    when '>'
      current_x += 1
    when '<'
      current_x -= 1
    when '^'
      current_y -= 1
    when 'v'
      current_y += 1
    else
      break
    end
  end

  if loop
    puts 'LOOP'
  else
    puts "#{current_x} #{current_y}"
  end
end

Measured memory_bytes: 9208
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 510;
int sum[maxn][maxn], A[maxn][maxn];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);
    
    int n, m, q;
    while (cin >> n >> m >> q) {
        FOR(i,0,maxn) FOR(j,0,maxn)
            sum[i][j] = A[i][j] = 0;
        int a, b;
        FOR(i,0,m) {
            cin >> a >> b;
            FOR(j,b,n+1)
                A[j][a]++;
        }
        FOR(i,0,n+1) FOR(j,1,n+1) {
            sum[i][0] = 0;
            sum[i][j] = sum[i][j-1] + A[i][j];
        }
        FOR(i,0,q) {
            cin >> a >> b;
            int x = sum[b][b];
            int y = sum[b][a-1];
            int ans = x-y;
            cout << ans << endl;
        }
    }
}   


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

int main(){
  int A; int B; int C; int X; int Y;
  cin >> A >> B >> C >> X >> Y;
  //long ans=(A+B+C)*(X+Y); 
  long ans=(A+B+C)*(X+Y)+1000000000000; 
  long temp;
  
  int Z=max(X,Y);
  for(int  i=0; i < Z+1; i++){
    temp = max(0,X-i)*A +max(0,Y-i)*B + 2*i*C;
    ans=min(ans,temp);
  }
  
  cout << ans << endl;
}

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

int main(){
    int n , m;
    cin>>n>>m;
    map<int,int>mp;
    for(int i=0;i<m;i++){
        int tt;cin>>tt;
        mp[tt] = 1;
    }
    vector<int>dp(n+3);
    dp[n] = 1;
    for(int i=n-1;i>=0;i--){
        if(mp[i]){dp[i] = 0;}
        else dp[i] = (dp[i+1]+dp[i+2])% 1000000007;

    }
    cout<<dp[0]<<endl;
}


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

long A[200000];
long B[200000];
long d[200000];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for(int n=0; n<N; n++)cin >> A[n];
  for(int n=0; n<N; n++)cin >> B[n];
  for(int n=0; n<N; n++)d[n] = A[n] - B[n];
  int num = 0, m = N, sp = 0;
  sort(d, d+N);
  for(int n=0; n<N; n++){
    if(d[n] >= 0){
      num = n + (N - m);
      break;
    }
    sp += d[n];
    while(sp < 0){
      m--;
      if(d[m] < 0 || m <= n){
        num = -1;
        break;
      }
      sp += d[m];
    }
    if(num == -1)break;
  }
  cout << num  << "\n";
  return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;


int main(){

	int n;
	scanf("%d",&n);

	double hour,minute,degree1,degree2,div;

	char buf[6];

	for(int i=0; i < n; i++){
		scanf("%s",buf);

		hour = 10*(buf[0]-'0')+(buf[1]-'0');
		minute = 10*(buf[3]-'0')+(buf[4]-'0');

		degree1 = 360*(minute/60);
		degree2 = (60*hour+minute)/2;

		div = min(fabs(degree1-degree2),360.0-fabs(degree1-degree2));

		if(div < 30.0){
			printf("alert\n");
		}else if(div < 90.0){
			printf("warning\n");
		}else{
			printf("safe\n");
		}
	}

    return 0;
}

Measured memory_bytes: 2508
n, m = map(int, input().split())
mod = 10**9 + 7
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	ans += X[i]*(n-2*i-1)%mod
t = 0
for j in range(m):
	t += Y[j]*(m-2*j-1)%mod
ans *= t%mod
print(ans%mod)

Measured memory_bytes: 19648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int a[100000],b[100000],x[5];
int main(){
	int N;
	cin>>N;
	rep(i,N) cin>>a[i];
	rep(i,N-1){
		if(a[i]<a[i+1]) b[i]=1;
		else if(a[i]==a[i+1]) b[i]=0;
		else b[i]=-1;
	}
	int p=10;
	rep(i,N-2){
		if(b[i]==b[i+1]){
			if(b[i]!=0) p=b[i];
			continue;
		}
		if(b[i]==1&&b[i+1]==-1) x[3]++;
		else if(b[i]==-1&&b[i+1]==1) x[4]++;
		else if(b[i]==0){
			if(p==10) continue;
			if(p==b[i+1]) x[2]++;
			else if(p==1) x[0]++;
			else x[1]++;
		}
		if(b[i]!=0) p=b[i];
	}
	rep(i,4) cout<<x[i]<<" ";
	cout<<x[4]<<endl;
}


Measured memory_bytes: 1944
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int m=t.length();

    int **dp=new int*[n+1];
    for(int i=0;i<=n;i++){
      dp[i]=new int[m+1];
      for(int j=0;j<=m;j++){
        dp[i][j]=0;
      }
    }

    for(int i=0;i<=n;i++){
      dp[i][0]=0;
    }

    for(int i=0;i<=m;i++){
      dp[0][i]=0;
    }
    for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
        if(s[i-1]==t[j-1]){
          dp[i][j]=dp[i-1][j-1]+1;
        }
        else{
          dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
      }
    }
    string ans="";



    // for(int i=0;i<=n;i++){
    //   for(int j=0;j<=m;j++){
    //     cout<<dp[i][j]<<" ";
    //   }
    //   cout<<endl;
    // }
int i = n, j = m;
   while (i > 0 && j > 0)
   {
      // If current character in X[] and Y are same, then
      // current character is part of LCS
      if (s[i-1] == t[j-1])
      {
          ans = s[i-1]+ans; // Put current character in result
          i--; j--; ;     // reduce values of i, j and index
      }

      // If not same, then find the larger of two and
      // go in the direction of larger value
      else if (dp[i-1][j] > dp[i][j-1])
         i--;
      else
         j--;
   }
















    // for(int i=n;i>=1;){
    //   for(int j=m;j>=1;){
    //     if(dp[i][j]>dp[i-1][j] && dp[i][j]>dp[i][j-1] && dp[i][j]==(dp[i-1][j-1]+1)){
    //       ans=s[i-1]+ans;
    //       i=i-1;
    //       j=j-1;
    //     }
    //     else if(dp[i][j]==dp[i-1][j]){
    //       i=i-1;
    //       j=j;
    //     }
    //     else{
    //       i=i;
    //       j=j-1;

    //     }
    //     if(i<=0 || j<=0){
    //       break;
    //     }
    //   }
    //   if(i<=0){
    //       break;
    //     }
    // }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 35456
N=int(input())
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

bunkai=factorize(N)
blist=list(set(bunkai))

ans=0
for i in blist:
    tmp=bunkai.count(i)
    for p in range(1,50):
        if tmp>=p:
            ans+=1
            tmp-=p
        else:
            break
print(ans)

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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
template <class T> void print(T &x) {
    cout << x << '\n';
    return;
}

template <class T> ll iterate_sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

struct union_find {
    int size;
    vector<int> par;
    union_find(int N) : size(N), par(N) { REP(i, N) par[i] = i; }
    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        else {
            par[rx] = ry;
            return;
        }
    }
    bool same(int x, int y) { return root(x) == root(y); }
};

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

int main() {
    ll n = in(), m = in();
    pll shop[n];
    REP(i, n) { cin >> shop[i].first >> shop[i].second; }
    sort(shop, shop + n);
    ll bought=0,ans=0;
    for(int i=0;bought<m;i++){
        if(bought+shop[i].second<m){
            ans+=shop[i].second*shop[i].first;
            bought+=shop[i].second;
        }else{
            ll buy=m-bought;
            ans+=buy*shop[i].first;
            bought+=buy;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1920
N = int(input())  
L = [list(map(int, input().split())) for _ in range(N)]
answer = 'Yes'

# 時間、位置をt(i-1)に対する相対的な値に変換する
for i in range(1, N):
    L[i] = [L[i][0]-L[i-1][0], L[i][1]-L[i-1][1], L[i][2]-L[i-1][2]]


def judge(t, x, y):
    distance = abs(x) + abs(y)
    global answer
    if distance > t:
        answer = 'No'
        return
    else:
        if t % 2 == distance % 2:
            return
        else:
            answer = 'No'
            return


for l in L:
    judge(l[0], l[1], l[2])
    if answer == 'No':
        break

print(answer)

Measured memory_bytes: 27664
#include<bits/stdc++.h>
// #define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int n;
    cin >> n;
    vector<bool> color(8, false);
    int over = 0;

    rep(i, n){
        int tmp;
        cin >> tmp;
        if(tmp < 400) color[0] = true;
        else if(tmp < 800) color[1] = true;
        else if(tmp < 1200) color[2] = true;
        else if(tmp < 1600) color[3] = true;
        else if(tmp < 2000) color[4] = true;
        else if(tmp < 2400) color[5] = true;
        else if(tmp < 2800) color[6] = true;
        else if(tmp < 3200) color[7] = true;
        else over++;
    }

    int cnt = 0;
    rep(i, 8) if(color[i]) cnt++;
    int ans_max = cnt;
    if(cnt != 0){
        while(over > 0){
            ans_max++;
            over--;
        }
    }else{
        cnt = 1;
        ans_max = over;
    }
    
    cout << cnt << " " << ans_max << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    //A: 水100A, B: 水100B
    //C: 砂糖C, D: 砂糖D
    //E: 水100gあたりに溶ける砂糖の量
    //F: ビーカーに入れられる物質の質量(水+砂糖)
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    set<ll> S, W;

    //水
    for(int i=0; i<=F; i++) {
        for(int j=0; j<=F; j++) {
            ll x = 100 * i * A + 100 * j * B;
            if(x <= F) {
                W.insert(x);
            }
        }
    }

    //砂糖
    for(int i=0; i<=F; i++) {
        for(int j=0; j<=F; j++) {
            ll y = i * C + j * D;
            if(y <= F) {
                S.insert(y);
            }
        }
    }

    //全列挙して配列に入れた、水と砂糖から最大濃度の砂糖水を作る
    double max_concentration = -100;
    ll amount_of_beaker = 0;
    ll amount_of_suger = 0;
    for(auto w:W) {
        for(auto s:S) {
            ll sum = w + s;
            if(sum > F) continue;
            double concentration = ((double)(100 * s) / (sum));
            if(concentration > max_concentration && (((double)E / 100) >= ((double)s / w))) {
                amount_of_beaker = sum;
                amount_of_suger = s;
                max_concentration = concentration;
            }
        }
    }
    //出力: 砂糖水の質量, 砂糖の質量
    cout << amount_of_beaker << " "<< amount_of_suger << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int res1 = A * X + B * Y;
	int res2;
	if (X<Y){
		res2 = C * 2 * X + B * (Y - X);
	}else{
		res2 = C * 2 * Y + A * (X - Y);
	}
	int res3 = C * 2 * max(X, Y);

	cout << min(min(res1, res2), res3) << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

def main():
    N, *LR = map(int, stdin.buffer.read().split())
    L, R = LR[::2], LR[1::2]

    Lp = max(L)
    Rq = min(R)

    AB = sorted((max(0, r - Lp + 1), -max(0, Rq - l + 1)) for l, r in zip(L, R))

    mi = float("inf")
    ma = max(r - l + 1 for l, r in zip(L, R)) + max(0, Rq - Lp + 1)

    for i, (a, b) in enumerate(AB):
        if i:
            ma = max(ma, mi + a)
        mi = min(mi, -b)

    print(ma)


main()


Measured memory_bytes: 28384
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll ans = 1,dv=1;
  ll n;
  ll a[12];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    ans *= 3;
    if(a[i]%2==0) dv*=2;
  }
  cout << ans - dv<<endl;
}


Measured memory_bytes: 256