akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    unsigned long long n_max = 1000000000000000000;

    int n;
    unsigned long long ans=1;
    cin >> n;

    bool a=false;
    bool b=false;
    vector<unsigned long long> q(n);
    rep(i,n){
        cin >> q[i];
        if(q[i]==0){
            b=true;
        }
    }
    if(b){
        cout<< 0;
        return 0;
    }

    rep(i,n){
        unsigned long long m;
        m = q[i];
        if((n_max/m)>=ans){
            ans*=m;
        }
        else{
            cout << -1 ;
            return 0;
        }
        if(ans>1000000000000000000){
            a = true;
        }
    }
    if(a){
        cout << -1 ;
        return 0;
    }
    else{
        cout << ans;
        return 0;
    }
}

Measured memory_bytes: 3992
#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() {
    int N,M; cin >> N >> M;
    vector<int> v(M);
    rep(i,N){
        int K; cin >> K;
        rep(i,K){
            int a; cin >> a;
            v[a-1]++;
        }
    }
    int ans = 0;
    rep(i,M){
        if(v[i] == N) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<ctime>

#define ll long long
#define R register
#define IL inline
#define Rf(a,b,c) for(R int (a)=(b);(a)<=(c);++(a))
#define Tf(a,b,c) for(R int (a)=(b);(a)>=(c);--(a))
#define MP make_pair
#define PA pair<int,int>
#define MES(a,b) memset((a),(b),sizeof((a)))
#define MEC(a,b) memcpy((a),(b),sizeof((b)))
#define D double

using namespace std;

ll a,b; 

IL int read() {
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x*=10;x+=(ch-'0');ch=getchar();}
    return x*f;
}
IL void write(int x) {
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

signed main()
{
		 a=read(),b=read();
		 write(a*b);


    return 0;
}


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

class Bank
{
  public:
    Bank(int num, int type, int rate);

  public:
    static void SetYear(int year);
    bool operator<(const Bank& other) const;
    int num();

  private:
    static int m_year;
    double m_bank;
    int m_num;
};

Bank::Bank(int num, int type, int rate)
{
  m_num = num;
  if (type == 1)
  {
    //  単利
    m_bank = 1 + m_year * rate / 100.0;
  }
  else
  {
    //  複利
    m_bank = pow(1 + rate / 100.0, m_year);
  }
}

inline void Bank::SetYear(int year)
{
  m_year = year;
}

bool Bank::operator<(const Bank& other) const
{
  return m_bank < other.m_bank;
}

int Bank::num()
{
  return m_num;
}

int Bank::m_year;

int main(void)
{
  int n;
  int year;
  while (cin >> n >> year)
  {
    Bank::SetYear(year);

    vector<Bank> banks;
    for (int i = 0; i < n; ++i)
    {
      int num, rate, type;
      cin >> num >> rate >> type;
      Bank buf_bank(num, type, rate);
      banks.push_back(buf_bank);
    }

    sort(banks.begin(), banks.end());
    cout << banks.back().num() << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,k;cin>>n>>k;
    vector<ll>a(n),b(n);
    ll ans=0;
    rep(i,n){
        ll c;cin>>c;
        if(c>0)ans+=c;
        if(i!=0){
            a[i]=a[i-1]+c;
            if(c>0)b[i]=b[i-1]+c;
            else b[i]=b[i-1];
        }else{
            a[i]=c;
            if(c>0)b[i]=c;
        }
    }
    //rep(i,n)cout<<b[i]<<endl;
    ll ma=ans-b[k-1]+a[k-1];
    ma=max(ma,ans-b[k-1]);
    REP(i,k,n){
        ma=max(ans-(b[i]-b[i-k])+a[i]-a[i-k],ma);
        ma=max(ma,ans-(b[i]-b[i-k]));
        //cout<<i<<' '<<a[i]-a[k]<<' '<<b[i]-b[k]<<endl;
    }
    cout<<ma<<endl;
}

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

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

  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < n; i++) x[i] -= a;
  unordered_map<int, long long> dp;
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    auto ndp = dp;
    for (auto kv : dp) {
      auto k = kv.first;
      auto v = kv.second;
      if (ndp.find(k+x[i]) != ndp.end()) {
        ndp[k+x[i]] += v;
      } else {
        ndp[k+x[i]] = v;
      }
    }
    dp = ndp;
  }
  cout << dp[0] - 1 << '\n';
  return 0;
}

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

int n, c[5];
string s;
int main() {
	cin >> n;
	while(n--) {
		cin >> s;
		if(s=="AC") c[0]++;
		else if(s=="WA") c[1]++;
		else if(s=="TLE") c[2]++;
		else c[3]++;
	}
	printf("AC x %d\n", c[0]);
	printf("WA x %d\n", c[1]);
	printf("TLE x %d\n", c[2]);
	printf("RE x %d\n", c[3]);
	return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
  int x, y;
  cin >> x >> y;
  for (int tsuru = 0; tsuru <= x; tsuru++) {
    int kame = x - tsuru;
    if (kame*4 + tsuru*2 == y) {
      cout << "Yes"<< endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
from collections import *
from fractions import *

N = int(input())

if N%2==1:
    print(0)
    exit()

two = 0

for p in range(1, 65):
    two += N//2**p

five = 0

for p in range(1, 65):
    five += N//(2*5**p)

print(min(two, five))

Measured memory_bytes: 63980
n = int(input())
s = input()

a = []
tmp = 0
for i in range(n):
    if s[i] == '(':
        tmp += 1
    else:
        tmp -= 1
    a.append(tmp)

m = min(a)
if m < 0:
    ans = -m * '(' + s
    last = -m + a[-1]
else:
    ans = s
    last = a[-1]
if last > 0:
    ans += ')' * last
print(ans)


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

int a[100009], p[100009];
bool vs[100009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> a[i];
	sort(a + 1, a + m + 1);
	for (int i = 1; i < m; i++)
		p[i] = a[i + 1] - a[i];
	sort(p + 1, p + m); reverse(p + 1, p + m);
	int ans = a[m] - a[1];
	for (int i = 1; i < min(n, m); i++) 
		ans -= p[i];
	cout << ans << '\n';
	return 0;
}

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

#define int long long

signed main() {
	int a;
	cin >> a;
	a += 3;
	a %= 7;
	if (a == 0)cout << "mon" << endl;
	if (a == 1)cout << "tue" << endl;
	if (a == 2)cout << "wed" << endl;
	if (a == 3)cout << "thu" << endl;
	if (a == 4)cout << "fri" << endl;
	if (a == 5)cout << "sat" << endl;
	if (a == 6)cout << "sun" << endl;

	return 0;
}


Measured memory_bytes: 3104
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min
// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

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

fn check_all(a:&i64,b:&i64,x:&i64) -> bool{
    let c = a * b;

    // println!("----------{}",x);
    for i in 0..*x{
        let aa = if i+1 < *a { i+1 } else { i + 2 };
        let bb = if x-*b > i {*x-i} else {*x-i-1};

        // println!("check ({},{}):{}",aa,bb,aa*bb);
        if aa * bb >= c {
            return false;
        }
    }

    true
}


fn check_middle(a:&i64,b:&i64,x:&i64) -> bool{
    
    let c = a * b;
    let x0 = ((a*b) as f64).sqrt() as i64 - 10;
    // println!("----------{}",x);
    for i in x0..x0+20{
        let aa = if i+1 < *a { i+1 } else { i + 2 };
        let bb = if x-*b > i {*x-i} else {*x-i-1};

        // println!("check ({},{}):{}",aa,bb,aa*bb);
        if aa * bb >= c {
            return false;
        }
    }

    true
}

fn solve(a:i64,b:i64) -> i64{
    if a == 1 && b == 1 {
        return 0;
    }

    let mut xmax = cmp::max(2,(((a*b) as f64).sqrt() * 2.0 + 20.0) as i64);

    if xmax < 50 {
        while ! check_all(&a,&b,&xmax){
            xmax = xmax - 1;
        }
    }else {
        while ! check_middle(&a,&b,&xmax){
            xmax = xmax - 1;
        }
    }
    xmax-1
}

fn main(){
    let q = read_int();
    for _ in 0..q{
        let input =read_ints();
        let (a,b) = (input[0],input[1]);
        println!("{}",solve(a,b));
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderBeginner
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string[] xAxis = Console.ReadLine().Split(' ');
            string[] yAxis = Console.ReadLine().Split(' ');
            

            Console.WriteLine((calc(input[0], xAxis) * calc(input[1], yAxis)) % MOD);

        }

        const int MOD = 1000000007;

        static long calc(string _input, string[] _tmp)
        {
            int _num = int.Parse(_input);
            long sum = 0;
            for (int i = 0; i < _num; i++)
            {
                sum += long.Parse(_tmp[i]) * (2 * i - _num + 1);
            }
            return sum % MOD;
        }
    }
}



Measured memory_bytes: 33756
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);
const nin=()=>{const r = input[0];input.shift();return Number(r);}
const sin=()=>{const r = input[0];input.shift();return String(r);}
const out = (...a) => {console.log(...a);}
const rep = (n, callback) => {for(let i = 0;i < n; i++){callback();}}

const main = () => {
  let [n, i, p, before] = [0, 0, 0, -1];
  const a = [];
  const b = [];
  const c = [];
  n = nin();
  rep(n, ()=>a.push(nin()));
  rep(n, ()=>b.push(nin()));
  rep(n-1, ()=>c.push(nin()));
  for(i=0;i<n;i++){
    a[i]-=1;
    p += b[a[i]];
    if(a[i] == before + 1 && before != -1) p+= c[before];
    before = a[i];
  }
  out(p);
}
main();

Measured memory_bytes: 7372
a=list(map(int,input().split()))
o=0
e=0
ans=0
for i in range(3):
    if a[i]%2==0:
        e+=1
    else:
        o+=1
if e==2:
    ans+=1
    for i in range(3):
        if a[i]%2==0:
            a[i]+=1
elif e==1:
    ans+=1
    for i in range(3):
        if a[i]%2==1:
            a[i]+=1
a.sort()
print(ans+a[2]-a[1]+(a[1]-a[0])//2)

Measured memory_bytes: 3064
import sys
from functools import reduce

n = int(input())
x = list(map(int, input().split()))
l = ((i, reduce(lambda a, j: a + (x[j] - i) * (x[j] - i), range(0, n), 0)) for i in range(1, 100 + 1))
print(min(l, key=lambda x: x[1])[1])

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  vector<int> x(n);
  int i;
  for(i = 0; i< n;i++){
    cin >> v[i];
  }
  for(i = 0; i< n;i++){
    cin >> c[i];
  }
  for(i = 0; i< n;i++){
    x[i] = v[i] - c[i];
  }
  int ans = 0;
  for(i = 0; i< n;i++){
    if(x[i] > 0){
      ans += x[i];
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import numpy as np
n,m = map(int, input().split())
x = np.array([int(i) for i in input().split()])
x = np.sort(x)
d = np.diff(x)
d = np.sort(d)[::-1]
if m < n:
    ans = 0
else:
    '''
    x ---+---+----------+-+----+-
    d    3   10         1 4    -
    このとき、d = 3,1の点を選んでいる
    なぜ？
        d = 10で分割している
    分割したあとは、左から距離を足せばおｋ
    分割の回数はn-1個 -> dの大きいものからn-1個除去し、残りのsumを取る
    '''
    ans = d[n-1:].sum()
print(ans)

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

typedef long long ll;
const ll MOD = 1000000007;

using namespace std;

int n;
double dp[301][301][301] = {};

double ans(int i, int j, int k) {
    //debug
    // cout << i << " " << j << " " << k << " called" << endl;

    if (i == 0 && j == 0 && k == 0)
        return 0;
    else if (dp[i][j][k] != 0)
        return dp[i][j][k];

    double a = 0;
    if (i > 0) {
        a += (double)i * ans(i - 1, j + 1, k);
        a += double(i * n) / double(i + j + k);
    }
    if (j > 0) {
        a += (double)j * ans(i, j - 1, k + 1);
        a += double(j * n) / double(i + j + k);
    }
    if (k > 0) {
        a += (double)k * ans(i, j, k - 1);
        a += double(k * n) / double(i + j + k);
    }
    a /= (i + j + k);
    dp[i][j][k] = a;
    // debug
    // cout << i << " " << j << " " << k << " returned " << a << endl;
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int i = 0, j = 0, k = 0;
    for (int it = 0; it < n; it++) {
        int x;
        cin >> x;
        if (x == 3)
            i++;
        else if (x == 2)
            j++;
        else if (x == 1)
            k++;
    }
    cout.precision(30);
    cout << ans(i, j, k);

    return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (a); i > (b); i--)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vi A(N);
  rep(i, 0, N) in(A[i]);
  auto a = A;
  sort(a.rbegin(), a.rend());
  rep(i, 0, N) {
    print(A[i] == a[0] ? a[1] : a[0]);
  }
}


Measured memory_bytes: 3200
let id x = x

let (n,m) = Scanf.scanf "%d %d" (fun a b -> (a,b))
  
let rec fact x acc =
  if x = 0 then acc else
    if x * acc > 1000000007 then fact (x-1) ((x*acc) mod 1000000007)
      else fact (x-1) (x*acc)

let ans' = if abs (n-m) > 1 then 0 else
    if n = m then (fact n 1) * (fact n 1) * 2
    else (fact (max n m) 1) * (fact (min n m) 1)

let ans = ans' mod (1000000007)
  
let () =
  Printf.printf "%d\n" ans

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

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

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    unordered_set<string> dct;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string comm, arg;
        cin >> comm >> arg;
        if(comm=="insert"){
            dct.insert(arg);
        }else{
            cout << ((dct.count(arg)>0)?"yes":"no") << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 31896
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, int>P;
int main(){
    long long w, h, ans = 0;
    cin>>w>>h;
    vector<P>vec(w+h);
    for(int i=0;i<w;i++){
        cin>>vec[i].first;
        vec[i].second=0;
    }
    for(int i=0;i<h;i++){
        cin>>vec[w+i].first;
        vec[w+i].second=1;
    }
    sort(vec.begin(), vec.end());
    long long cols = w + 1, rows = h + 1;
    for(int i=0;i<vec.size();i++){
        if(vec[i].second){
            ans += vec[i].first * cols;
            rows--;
        }
        else{
            ans += vec[i].first * rows;
            cols--;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3456
import java.util.*;

class Main{
    public static void main(String[] args){
        List<Integer> array = new ArrayList<>();
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        for(int i=0;i<N;i++){
            int q = sc.nextInt();
            
            if(q == 0){
                int x = sc.nextInt();
                array.add(x);
            }else if(q == 1){
                int x = sc.nextInt();
                System.out.println(array.get(x));
            }else{
                array.remove(array.size() - 1);
            }
        }
    }
}


Measured memory_bytes: 140524
#include<stdio.h>
#define N 101
#define INF 1000000000

void matrixChainOrder(int);

int m[N][N];
int p[N];


int min(int a,int b){
  if(a<b) return a;
  else return b;
}

int main(){
  int n,i,a,b,j;
  
  scanf("%d",&n);

  p[0] = 1;

  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&p[i+1]);
    
  }
  
  matrixChainOrder(n);

  printf("%d\n",m[1][n]);

  
  return 0;
}

void matrixChainOrder(int n){
  int i,l,j,q,k;


  for(i=1;i<=n;++i)m[i][i] = 0;

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i;k<j;++k){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j] = min(m[i][j],q);
      }
    }
  }

}



Measured memory_bytes: 2112
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N = a_int()
D1, D2 = read_col(N)

cnt = 0
for d1, d2 in zip(D1, D2):
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        exit('Yes')
print('No')


Measured memory_bytes: 69160
#include <cstdio>
#include <algorithm>
using namespace std;
char imap[101][101];
int d[101][101];
int h, w;

void dfs(int x, int y, int step) {
    if (d[x][y] != -1) { printf("LOOP\n"); return; }
    d[x][y] = step;
    if (imap[x][y] == '.') { printf("%d %d\n", y, x); return; }
    else if (imap[x][y] == '^') dfs(x-1, y, step+1);
    else if (imap[x][y] == 'v') dfs(x+1, y, step+1);
    else if (imap[x][y] == '>') dfs(x, y+1, step+1);
    else if (imap[x][y] == '<') dfs(x, y-1, step+1);
}


int main()  {

    for (; ;) {
        scanf("%d %d", &h, &w);
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++) {
            fill(d[i], d[i]+w, -1);
            scanf("%s", imap[i]);
        }
        dfs(0, 0, 0);
    }
    return 0;
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
//一括include
using namespace std;
/*
int main(){
    int n,num;
    int od = 0;
    int cnt = 0;
    int sm = 0;
    cin >> n;
    for (int i = 1; i <= n;i++){
        od = i;
        while (od){
            od = od / 2;
            cnt++;
            
        }
        if(sm<cnt){
            sm = cnt;
            num = i;
        }
        cnt = 0;
    }
    cout << num << endl;
}
*/

int main()
{
    int n;
    cin >> n;
    int ans = 1;
    while (ans * 2 <= n)
        ans *= 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
import sys

N, M, R = map(int, input().split())
r = [int(i) for i in input().split()]
a = [[sys.maxsize for i in range(N)] for i in range(N)]
for i in range(N):
	a[i][i] = 0
for i in range(M):
	A, B, C = map(int, input().split())
	a[A - 1][B - 1] = C
	a[B - 1][A - 1] = C
for i in range(N):
	for j in range(N):
		if a[j][i] == sys.maxsize:
			continue
		for k in range(N):
			if a[i][k] == sys.maxsize:
				continue
			a[j][k] = min(a[i][k] + a[j][i], a[j][k])
r.sort()
ans = sys.maxsize
for i in itertools.permutations(r):
	b = 0
	j = 1
	while j < R:
		b += a[i[j - 1] - 1][i[j] - 1]
		j += 1
	ans = min(b, ans)
print(ans)

Measured memory_bytes: 47960
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//素因数分解をする関数.
map<long long int, int> prime_factorization(long long int a)
{
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}

//最大公約数を返す関数.
long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main()
{
	int a, b;
	cin >> a >> b;
	if(a==1)
		a = 100;
	if(b==1)
		b = 100;
	if (a < b)
		puts("Bob");
	else if (a > b)
		puts("Alice");
	else
		puts("Draw");

	return 0;
}




Measured memory_bytes: 3532
#include<bits/stdc++.h>
#define REP(i,N) for (int i=0;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main(){
    int N;
    vector<int> A(N),B(N-1);
    cin >>N;
    REP(i,N-1) cin >>B[i];

    A[0]=B[0];
    A[N-1]=B[N-2];
    for (int i=1; i<N-1; ++i){
        if(B[i-1]<=B[i]){
            A[i]=B[i-1];
        }
        else{
            A[i]=B[i];
        }
    }
    int val=0;
    REP(i,N) val+=A[i];
    cout <<val<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{

	int c,a,n,i,nen,count[100],m;
	scanf("%d",&nen);
	for(i=0;i<nen;i++){
		scanf("%d %d %d",&c,&a,&n);
		count[i]=0;
		m=1;
		while(m!=0){
			m=0;
			if(n>=1&&a>=1&&c>=1){
				count[i]++;
				n--;
				a--;
				c--;
				m++;
			}
			else if(a>=1&&c>=2){
				count[i]++;
				a--;
				c-=2;
				m++;
			}
			else if(c>=3){
				count[i]++;
				c-=3;
				m++;
			}
		}
	}
	for(i=0;i<nen;i++){
		printf("%d\n",count[i]);
	}
	return 0;
}

Measured memory_bytes: 600
from collections import deque
import sys
input = sys.stdin.readline
s = deque(input().rstrip())
q = int(input())
flg = 0
for _ in range(q):
  t = input()
  if t[0] == "1":
    flg = 1-flg
  else:
    _,x,y = t.split()
    if x == "1":
      if flg:
        s.append(y)
      else:
        s.appendleft(y)
    else:
      if flg:
        s.appendleft(y)
      else:
        s.append(y)
if flg:
  u = list(s)[::-1]
  print(*u,sep="")
else:
  print(*s,sep="")

Measured memory_bytes: 86084
from collections import defaultdict
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
node2set_id = defaultdict(int)
set_id2nodes = defaultdict(set)

# idxなどを振る
id_left = [i + 1 for i in range(M)]

for i in range(M):
    x, y, z = list(map(int, input().split()))

    # ともにIDが振られていないとき
    if node2set_id[x] + node2set_id[y] == 0:
        id = id_left.pop()
        # x,yが所属するグループIDを振る
        node2set_id[x] = id
        node2set_id[y] = id

        # グループIDに対するセットを追加
        set_id2nodes[id] |= {x, y}

    # どちらか一方にのみIDが振られているとき(片方が0になる)
    elif node2set_id[x] * node2set_id[y] == 0:
        id = node2set_id[x] + node2set_id[y]
        node2set_id[x] = id
        node2set_id[y] = id
        set_id2nodes[id] |= {x, y}

    # 両方振られているとき
    else:
        # 同じIDならそもそも考える必要がない
        if node2set_id[x] - node2set_id[y] == 0:
            continue

        # 異なるグループのときにはマージする
        id = node2set_id[x]
        prev_y = node2set_id[y]

        # yが所属するグループIDをすべてxのものに置き換える
        for y_idx in set_id2nodes[node2set_id[y]]:
            node2set_id[y_idx] = id
            set_id2nodes[id] |= {y_idx}

        del set_id2nodes[prev_y]


num = sum([len(m)-1 for m in set_id2nodes.values()])

print(N - num)


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}


struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};



int m,n;

int main(){
    int i,j,k;
    int x,y;
    
    cin >> n >> m;
    
    int size =m;
    
    set<int> lang;
    UnionFind uf(m+1);
    
    for (i=0;i<n;i++){
        cin >> k;
        y = -1;
        for (j=0;j<k;j++){
            scanf("%d",&x);
            if (0<=y)
                size-=uf.unionSet(x,y);
            lang.insert(x);
            y=x;
        }
    }
    
    //printf("%d %d %d \n",lang.size(),size-1,m);
    if (lang.size()==m-size+1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#pragma gcc optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <bitset>
#include <string>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
//#include <unordered_map>
#include <stack>
#include <cstdlib>
#include <numeric>
#include <cassert>
#include <complex>
using namespace std;
#define maxn 200007
#define maxm 400007
#define maxq 1000007
#define maxl 1234
#define modn 998244353
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define scanl2(a,b) scanf("%lld%lld",&a,&b)
#define scans(a) scanf("%s",a)
#define scans2(a,b) scanf("%s%s",a,b)
#define scand(a) scanf("%lf",&a)
#define scan2(a,b) scanf("%d%d",&a,&b)
#define scand2(a,b) scanf("%lf%lf",&a,&b)
#define scan3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scan5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define print(a) printf("%d\n",a);
#define printl(a) printf("%lld\n",a);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>= b;i--)
#define fscan(a) fscanf(stream,"%d", &a);
#define mp      make_pair	
#define pb      push_back
#define eb      emplace_back
#define mm(a,b) memset(a,b,sizeof a)
#define log2(n) (double)(log(n) / log(2.0))
#define _crt_disable_perfcrit_locks
#define bll __int128
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef pair <char, int> pci;
typedef complex<double> cd;
typedef vector<complex<double> > vcd;

const double eps = 1e-8;
const double pi = 2 * acos(0.0);

int cc, bb; char ch; inline int F() {
	while (ch = getchar(), (ch < 48 || ch> 57) && ch != '-'); ch == '-' ? cc = bb = 0 : (cc = ch - '0', bb = 1);
	while (ch = getchar(), ch > 47 && ch < 58)cc = (cc << 1) + (cc << 3) + (ch ^ 48); return bb ? cc : -cc;
}
void write(int x) {
	int y = 10, len = 1;
	while (y <= x) { y *= 10; len++; }
	while (len--) { y /= 10; putchar(x / y + 48); x %= y; }
}
int n;
string s;
int has1 = 0;
int sum = 0;
int main() {
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	//FILE* stream = fopen("L:/1.in", "rb+");
	int n, m;
	cin >> n >> m;
	int res = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
	long long num, a, b, mi, ma;
	cin >> num >> a >> b;
	if (num == 1) {
		if (a != b)
			printf("0\n");
		else
			printf("1\n");
	}
	else if (a > b)
		printf("0\n");
	else
		cout << (b - a) * (num - 2) + 1 << "\n";
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

int N,X;
const int maxn = 201;
const int maxm = 100005;
const int modu = 1e9+7;
int dp[2][maxm];

vector<int> vi;

int mult(int a,int b){
    LL c = a;c *= b;c %= modu;return c;
}

int add(int a,int b){
    LL c = a;c += b;c %= modu;return c;
}


int get_int(){int x;scanf("%d",&x);return x;}
double get_double(){double x;scanf("%lf",&x);return x;}
long long get_long(){long long x;scanf("%lld",&x);return x;}

void init(){
    vi.clear();
    _for(i,0,maxm) dp[0][i] = 0;
}

int main(){
    scanf("%d %d",&N,&X);
    init();
    _for(i,0,N){
        int s = get_int();
        vi.push_back(s);
    }
    sort(ALL(vi),greater<int>());
    dp[0][X] = 1;
    int t = 0;

    _for(i,0,N){
        _for(j,0,maxm){
            dp[t^1][j] = 0;
        }

        _for(j,0,maxm){
            if(dp[t][j]){
                //printf("%d\n",j);
                dp[t^1][j%vi[i]] = add(dp[t][j],dp[t^1][j%vi[i]]);
                dp[t^1][j] = add(dp[t^1][j],mult(dp[t][j],(N-i-1)));
            }
        }
        t= t^1;
    }

    int ans = 0;

    _for(i,1,maxm){
        if(dp[t][i] > 0){
            //printf("%d %d\n",i,dp[t][i]);
            ans = add(ans,mult(i,dp[t][i]));
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, t, sum;
	
	while(cin >> n, n){
		sum = 0;
		REP(i, n/4){
			cin >> t;
			sum += t;
		}
		cout << sum << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int L = int.Parse(s[0]);
            int R = int.Parse(s[1]);
            int min = 2019;

          
          if(R-L>2019)min=0;
          
          
            L = L % 2019;
            R = R % 2019;

            if (L >= R)
            {
                min = 0;
            }

            for (int i = L; i < R; ++i)
            {
                for (int j = i + 1; j <= R; ++j)
                {
                    if ((i * j) % 2019 < min)
                    {
                        min = (i * j) % 2019;
                    }
                }
            }
            Console.WriteLine(min);
        }
    }
}


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

using Graph = vector<vector<int>>;

int main()
{
    int n, m;
    cin >> n >> m;
    Graph G(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(n, -1);
    queue<int> que;
    vector<int> oya(n);

    dist[0] = 0;
    que.push(0);

    while (!que.empty())
    {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v])
        {
            if (dist[nv] != -1)
                continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            oya[nv] = v;
            que.push(nv);
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++)
    {
        cout << oya[i] + 1 << endl;
    }
}

Measured memory_bytes: 10664
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,A,B;
    cin>>a>>b>>c>>d;
    if(a<b){
        A=a;
    }else{
        A=b;
    }
    if(c<d){
        B=c;
    }else{
        B=d;
    }
    cout<<A+B<<endl;
}


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

using namespace std;

bool isPrime(int x)
{
	const static int pl[]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
	if(x<2) return false;
	for(int i=0; i<10&&pl[i]<x; i++) {
		if(x%pl[i]==0) return false;
	}
	int r = sqrt(x);
	for(int i=31; i<r; i+=30) {
		if(x%i==0) return false;
		if(x%(i+6)==0) return false;
		if(x%(i+10)==0) return false;
		if(x%(i+12)==0) return false;
		if(x%(i+16)==0) return false;
		if(x%(i+18)==0) return false;
		if(x%(i+22)==0) return false;
		if(x%(i+28)==0) return false;
	}
	return true;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x;
	int count=0;
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>x;
		if(isPrime(x)) count++;
	}
	cout<<count<<'\n';
	return 0;
}



Measured memory_bytes: 3136
x = input()
l = len(x)


if x == x[::-1]:
    pre_x = x[:int((l-1)/2)]
    ato_x = x[int((l+1)/2):]
    if pre_x == ato_x:
        print('Yes')
    else:
        print('No')
else:
    print('No')
    

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
long long ni(long long ta, vector<long long> & v) {

}
long long rui(long long n, long long k, long long p) {
	if (k == 0) {
		return 1;
	}
	else {
		long long a = rui(n, k / 2, p);
		if (k % 2 == 0) {
			return (a*a) % p;
		}
		return (((a*a) % p)*n) % p;
	}
}
int main(){
	string s;
	cin >> s;
	if (s[0] == 'a') {
		cout << "square1001" << endl;
	}
	else {
		cout << "e869120" << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pl = pair<ll, ll>;
using Tl = tuple<ll, ll, ll>;

const ll INF = 1e15;
const ld eps = 1e-6;
const ll MOD = 1e9+7;


ll gcd (ll a, ll b){
  if(a%b==0)
    return b;
  else
    return gcd(b,a%b);
}

ll extgcd(ll a, ll b){
  if(b%a==0)
    return 1;
  else{
    return (1-b*extgcd(b%a, a))/a;
  }
}

vector<ll> fact;
vector<ll> factinv;

ll comb(ll n, ll r){
  return fact[n] * factinv[n-r] % MOD * factinv[r] % MOD;
}


int main(){
  ll N;
  cin >> N;
  if(N == 2){
    cout << 1 << endl;
    return 0;
  }
  fact.assign(N + 2, 1);
  factinv.assign(N+2, 1);
  for(ll i=1;i<fact.size();i++){
    fact[i] = fact[i - 1] * i % MOD;
    factinv[i] = (extgcd(fact[i], MOD) + MOD) % MOD;
    assert(factinv[i] >= 0);
    assert(factinv[i] * fact[i] % MOD == 1);
  }
  ll ans = 0;
  /*
    xo ooo ox
    xo o ox
    N - 3
    1以上でunuse個にN-2を振り分ける -> N-2-unuseを0以上unuse種で振り分ける-> (N-2-unuse + unuse) C unuse
    unuse個に振り分ける
   */
  ll before = 0;
  for(ll use = (N + 1) / 2; use <= N  - 1; use++){
    ll unuse = N - 1 - use;
    ll now = (fact[use] * comb(N - 3 - unuse + 1, unuse) % MOD - before + MOD) % MOD;
    ans = (ans + use * now % MOD * fact[unuse] % MOD) % MOD;
    //cout << "before" << before << " fact" << fact[use] << " now" << now <<  " comb" << comb(N - 3 - unuse + 1, unuse) << " use" << use << " ans" << ans << endl;
    before = (now * unuse + before * unuse) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[3];

int main() {
  for(int i = 0; i < 3; i++) {
    scanf("%d", &l[i]);
  }
  sort(l, l+3);
  int r = 0;
  while(l[0] != l[2]) {
    r++;
    if(l[0] + 2 <= l[2]) {
      l[0] += 2;
    }
    else {
      l[0]++;
      l[1]++;
    }
    sort(l, l+3);
  }
  printf("%d\n", r);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N,mod,res;
    
    scanf("%d",&N);
    
    mod = N % 1000;
    
    if(mod==0){
        printf("0\n");
    }
    
    else{
        res = 1000 - mod;
        printf("%d\n",res);
    }
    
    return 0;
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
//const ll p = 1e9 + 7;
//const ll p = 998244353;
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long S, long long W) {
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

int main() {
    long long S;
    scanf("%lld", &S);
    long long W;
    scanf("%lld", &W);
    solve(S, W);
    return 0;
}


Measured memory_bytes: 3660
using System;

namespace ConsoleApplication34
{
    class Program
    {
        static void Main(string[] args)
        {
            //???????????\????????¢
            string s = Console.ReadLine();
            //?????????????????\????????¨??????????????\????????????
            string[] ss = s.Split(' ');
            //int????????´???
            int a = int.Parse(ss[0]);
            //int????????´???
            int b = int.Parse(ss[1]);
            Console.WriteLine((a*b)+" "+((a+b)*2));
    }
  }
}

Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000

int main(){
  int S,W;
  cin>>S>>W;
  if(S>W){
    cout<<"safe"<<endl;
  }else{
    cout<<"unsafe"<<endl;
  }
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    int n, p;
    vi s(50, 0);

    while (cin >> n >> p) {
        if (n == 0 && p == 0) break;
        fill(s.begin(), s.end(), 0);

        int i = 0, all = p;
        while (true) {
            if (p != 0) {
                p--;
                s[i]++;
                if (s[i] == all) break;
            } else {
                p += s[i];
                s[i] = 0;
            }

            i = (i+1) % n;
        }
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 2996
A = []
B = []
for i in range(5):
    a = int(input())
    A.append(a)
    B.append((a+9)-(a+9)%10)
ans = A[0] + sum(B) - B[0]
for i in range(1,5):
    ans = min(ans, A[i] + sum(B) - B[i])
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 924844033;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n; cin >> n;
	vector<int> G[100000];
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int d[100000];
	fill(d, d + n, -1);
	queue<int> q; q.push(0); d[0] = 0;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		int len=G[x].size();
		rep(j, len) {
			int v = G[x][j];
			if (d[v] == -1) {
				d[v] = d[x] + 1;
				q.push(v);
			}
		}
	}
	int c[100000];
	fill(c, c + n, -1);
	q.push(n - 1); c[n - 1] = 0;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		int len = G[x].size();
		rep(j, len) {
			int v = G[x][j];
			if (c[v] == -1) {
				c[v] = c[x] + 1; q.push(v);
			}
		}
	}
	int dis = d[n - 1];
	int ddis = dis / 2;
	int chk;
	rep(i, n) {
		if (d[i] == ddis && d[i] + c[i] == dis) {
			chk = i;
		}
	}
	q.push(n - 1);
	int cnt = 0;
	int used[100000] = {};
	used[n - 1] = 1;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		int len = G[x].size();
		rep(j, len) {
			int v = G[x][j];
			if (used[v])continue;
			if (v == chk)continue;
			q.push(v); used[v] = 1; cnt++;
		}
	}
	int s = (n - 1) / 2;
	if (cnt >= s) {
		cout << "Snuke" << endl;
	}
	else {
		cout << "Fennec" << endl;
	}
	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

vector<set<int> > g;
vector<vector<int> > v;
map<pair<int, int> , int> mp;
bool used[100000];
void dfs1(int now){
	used[now] = true;
	for(auto& to: v[now]){
		if(!used[to]){
			g[now].insert(to);
			dfs1(to);
		}
	}
	return;
}
int dfs(int now, int p = -1){
	int ret = 0;
	int maki = v[now].size();
	for(int j=0;j<maki;j++){
		int i = v[now][j];
		if(i == -1) continue;
		if(p == i) continue;
		if(g[now].count(i)){
			if(dfs(i, now)){
				v[now][mp[{now, i}]] = -1;
			}else{
				v[i][mp[{i, now}]] = -1;
				ret ^= 1;
			}
		}else{
			ret ^= 1;
			v[i][mp[{i, now}]] = -1;
		}
	}
	return ret;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(used,0,sizeof(used));
    int n, m, a, b;
    cin >> n >> m;
    g.resize(n);
    v.resize(n);
    for(int i=0;i<m;i++){
    	cin >> a >> b;
    	a--; b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    if(m & 1){
    	cout << -1 << endl;
    	return 0;
    }
    for(int i=0;i<n;i++){
    	int maki = v[i].size();
    	for(int j=0;j<maki;j++){
    		mp[{i, v[i][j]}] = j;
    	}
    }
    dfs1(0);
    dfs(0);
    for(int i=0;i<n;i++){
    	for(auto& j: v[i]) if(j != -1){
    		cout << i+1 << " " << j+1 << endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 43520
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	ll a, b, c, n;
	string s, t;
	cin >> a >> b >> c >> n;
	cout << min(a, b) + min(c, n) << endl;
}

Measured memory_bytes: 256