akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;
void solve(void)
{
    int a, b, x;
    cin >> a >> b >> x;
    if (x < a || a + b < x)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int a, b, h; cin >> a >> b >> h;

  num = (a + b) * h / 2;

  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
import bisect

N,Q = (int(x) for x in input().split())

stop_arr = [tuple(map(int, input().split())) for _ in range(N)]
Q_arr = [int(input()) for _ in range(Q)]

stop_arr.sort(key=lambda x:x[2])

ans_arr = [-1]*Q
skip_arr = [-1]*(Q+1)

def update_skip(skip_arr, x):
    if skip_arr[x] == -1:
        return x
    x_dest = update_skip(skip_arr, skip_arr[x])
    skip_arr[x] = x_dest
    return x_dest

for s,t,x in stop_arr:
    q_start = bisect.bisect_left(Q_arr, s-x)
    q_stop = bisect.bisect_left(Q_arr, t-x)
    l = q_start
    while l < q_stop:
        if skip_arr[l] == -1:
            skip_arr[l] = q_stop
            ans_arr[l] = x
            l += 1
        else:
            l = update_skip(skip_arr, l)

print(*ans_arr, sep="\n")


Measured memory_bytes: 56992
//




#include <bits/stdc++.h>
using namespace std;


#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define pf push_front
#define ppf pop_front()
#define ff first
#define ss second
#define mp make_pair
#define fr(i,j,n) for(ll i=j; i<n; i++)
#define rfr(i,j,n) for(ll i=n-1; i>=j; i--)
#define pll pair<ll,ll>
#define plb pair<ll,bool>
#define psl pair<string,ll>
#define psb pair<string,bool>
#define srt(v) sort((v).begin(),(v).end())
#define ub(v,val) upper_bound((v).begin(),(v).end(),(val))-(v).begin()
#define lb(v,val) lower_bound((v).begin(),(v).end(),(val))-(v).begin()


typedef long double ld;
typedef long long int ll;


//getline(cin,string);
const ll inf = (ll) 1e18 + 19;
const ll mod = (ll) 1e9  +  7;




ll ncr(ll n,ll r) {
    ll val=1,i,j,p=2;
    rfr(i,n-r+1,n+1) {
        val*=i;
        while(val%p==0 && p<=r) {
            val/=p;
            p+=1;
        }
    }
    if(p<r) {
        fr(i,p,r+1) val/=i;
    }
    return val;
}




void cazz() {
    ll t=1,i=0,j,n;
    //cin>>t;
    while(t--) {
        ll a,b,c;
        cin>>a>>b>>c;
        b=(a/b)+(a%b!=0);
        cout<<b*c<<"\n";
    }
}




int main() {
    spdio;
	cazz();
	return 0;
}


Measured memory_bytes: 3636
// Problem : B - Nice Shopping
// Contest : Social Infrastructure Information Systems Division, Hitachi Programming Contest 2020
// URL : https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)


// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int a,b,m;
	cin >> a >> b >> m;
	vector<int> ap(a),bp(b);
	for(int i=0;i<a;i++)
	cin >> ap[i];
	for(int i=0;i<b;i++)
	cin >>bp[i];
	vector<pair<int,pair<int,int>>> v;
	for(int i=0;i<m;++i)
	{
		int x,y,c;
		cin >> x >> y >> c;
		v.push_back({c,{y,x}});
	}
	
	int ans=ap[0]+bp[0];
	for(int i=0;i<m;++i)
	{
		ans=min(ans,ap[v[i].second.second-1]+bp[v[i].second.first-1]-v[i].first);
	}
	sort(ap.begin(),ap.end());
	sort(bp.begin(),bp.end());
	ans=min(ans,ap[0]+bp[0]);
	cout << ans << endl;
}
int main()
{
    solve();
	return 0;
}


Measured memory_bytes: 2680
use std::io::stdin;

fn main() {
    let mo:i64 = 1000000007;
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let n = st.trim().parse::<i32>().unwrap();
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let a:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i32>().unwrap()).collect();
    let mut r:Vec<i32> = [-1,-1,-1].to_vec();
    let mut result:i64 = 1;
    let mut c:i64 = 0;
    let mut num = 0;
    let mut p = 0;
    for i in 0..n {
        p = a[i as usize];
        for j in 0..3 {
            let t = j as usize;
            if p == &r[t]+1 {
                c += 1;
                num = t;
            }
        }
        r[num] += 1;
        result *= c;
        result %= mo;
        c = 0;
        num = 0;
    };
    println!("{}", result);
}

Measured memory_bytes: 4352
#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 INF=1e+09;
int main(){
    string S;
    cin >> S;
    char cur='R';
    int cnt=0;
    vector<int> ans(S.size());
    rep(i,S.size()){
        if(cur!=S[i]&&cur=='R'){
            ans[i-1]+=(cnt-cnt/2);
            ans[i]+=cnt/2;
            cur=S[i];
            cnt=1;
            if(i==S.size()-1) ans[i]++;
        }else if(cur!=S[i]&&cur=='L'){
            ans[i-cnt-1]+=cnt/2;
            ans[i-cnt]+=(cnt-cnt/2);
            cur=S[i];
            cnt=1;
        }else if(i==S.size()-1){
            cnt++;
            ans[i-cnt]+=cnt/2;
            ans[i+1-cnt]+=(cnt-cnt/2);
        }else{
            cnt++;
        }
    }
    rep(i,S.size()) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1024
console.log((args=>{
  const [s,t] = args.trim().split`\n`;
  const c = Array.from({length:26},_=>[]);
  const sl = s.length, tl = t.length;
  for ( let i = 0; i < sl; i++ ) c[s.charCodeAt(i)-97].push(i);
  for ( let i = 0; i < sl; i++ ) c[s.charCodeAt(i)-97].push(i+sl);
  const o = Array(26).fill(0);
  let i = -1, cyc = 0;
  for ( let j = 0; j < tl; j++ ) {
    const x = t.charCodeAt(j)-97;
    const l = c[x].length;
    if (!l) return '-1';
    for (; o[x] < l; o[x]++ ) if ( i < c[x][o[x]] ) break;
    i = c[x][o[x]];
    if ( i >= sl ) {
      cyc++;
      i -= sl;
      o.fill(0);
    }
  }
  return `${cyc * sl + i+1}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 38176
# N, M から相異なる二点を取った時のマンハッタン距離の、二点の取り方についての総和を、
# _{N + M - 2} C _{K - 2} 倍したものが答え。


N, M, K = map(int, input().split())

# コンビネーション前計算。
MOD = 10 ** 9 + 7
table_len = 2 * 10 ** 5 + 10

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)

finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, 0, -1):
    finv[i-1] = finv[i] * i % MOD

# マンハッタン距離の総和は、各距離の部分がカウントされるかを考えればよいので、
# (ex. 左半分と右半分にひとつずつなら、必ず二等分する線を横断する部分がある、みたいな)
# l + r = N に対し lM * rM = M^2 * lr の総和と、
# l + r = M に対し lN * rN = N^2 * lr の総和の和でよい。
# シグマ公式をつかえばO(1)にも出来そうだが、面倒なので省略。

# M^2は最後にまとめる
distsum1 = 0
for l in range(1, N):
    distsum1 += l * (N - l)
    distsum1 %= MOD
distsum1 *= pow(M, 2, MOD)
distsum1 %= MOD

# N^2は最後にまとめる
distsum2 = 0
for l in range(1, M):
    distsum2 += l * (M - l)
    distsum2 %= MOD
distsum2 *= pow(N, 2, MOD)
distsum2 %= MOD

print((distsum1 + distsum2) % MOD * fac[N * M - 2] % MOD * finv[K - 2] % MOD * finv[N * M - K] % MOD)


Measured memory_bytes: 81804
/*{{{*/
#include "bits/stdc++.h"
using namespace std;

#define MT make_tuple
#define all(x) begin(x), end(x)
#define putchar(x) cout << (x)
static int fastio = [](){ ios_base::sync_with_stdio(false); cin.tie(0); cout.precision(17); return 0; }();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename ...T> string format(const string& fmt, T&&... args) {
    size_t sz = snprintf(nullptr, 0, fmt.c_str(), args...) + 1;
    unique_ptr<char[]> buf(new char[sz]);
    snprintf(buf.get(), sz, fmt.c_str(), args...);
    return string(buf.get(), buf.get() + sz - 1);
}

template<class T> struct rge { T b, e; auto begin() const { return b; } auto end() const { return e; } };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
template<class T> auto dud(T* x) -> decltype(cerr << *x, 0);
template<class T> char dud(...);

struct debug {
#ifdef LOCAL
    debug(int line) {
        if(line) cerr << "LINE(" << line << ") -> ";
    }
    template<class T> typename enable_if<sizeof dud<T>(0) != 1, debug&>::type operator<<(T i) {
        cerr << boolalpha << i; return * this;
    }
    template<class T> typename enable_if<sizeof dud<T>(0) == 1, debug&>::type operator<<(T i) {
        return *this << range(begin(i), end(i));
    }
    template<class T, class U> debug& operator<<(pair<T, U> d) {
        return *this << "(" << d.first << ", " << d.second << ")";
    }
    debug& operator<<(tuple<>&) { return *this << "()"; };
    template<class ...T> debug& operator<<(tuple<T...> d) {
        *this << "("; debug_tuple<sizeof...(T), 0>(d);
        return *this << ")";
    }
    template<size_t L, size_t I, class T> void debug_tuple(const T& t) {
        *this << (I == 0 ? "" : ", ") << get<I>(t);
        if(I + 1 < L) debug_tuple<L, (I + 1) % L>(t);
    }
    template<class T> debug & operator <<(rge<T> d) {
        *this << "[";
        for(auto it = d.b; it != d.e; ++it)
            *this << (it != d.b ?  ", " : "") << *it;
        return *this << "]";
    }
    debug& operator<<(ostream&(*pf)(std::ostream&)) {
        cerr << pf; return *this;
    }
#else
    debug(int) {}
    template<class T> debug& operator<<(T&&) { return *this; }
    debug& operator<<(ostream&(*)(std::ostream&)) { return *this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ << ": " << (__VA_ARGS__) << "] "

#define debug0()  debug(__LINE__)
#define debug1(x) debug(0)
#define GET_MACRO(_0, _1, NAME, ...) NAME
#define debug(...) GET_MACRO(_0, ##__VA_ARGS__, debug1, debug0)(__VA_ARGS__)
/*}}}*/
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

void solve(int) {
    string S;
    cin >> S;
    cout << S.substr(0, 3) << endl;
}

int main() {
    int T = 1;
    //cin >> T;
    for(int i = 1; i <= T; ++i) {
        solve(i);
    }
    return 0;
}


Measured memory_bytes: 3620
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    String S = sc.next();
    int Rc[] = new int[K+1];//i文字目までのRの数
    int Gc[] = new int[K+1];//i文字目までのGの数
    int Bc[] = new int[K+1];//i文字目までのBの数
    Rc[0]=0;
    Gc[0]=0;
    Bc[0]=0;
    long ans =0;
    for(int i=0;i<K;i++){
      if(S.substring(i,i+1).equals("R")){
        Rc[i+1]=Rc[i]+1;
        Gc[i+1]=Gc[i];
        Bc[i+1]=Bc[i];
      }else if(S.substring(i,i+1).equals("G")){
        Gc[i+1]=Gc[i]+1;
        Rc[i+1]=Rc[i];
        Bc[i+1]=Bc[i];
      }else{
        Bc[i+1]=Bc[i]+1;
        Rc[i+1]=Rc[i];
        Gc[i+1]=Gc[i];
      }
    }
    for(int i=1;i<K+1;i++){
      //i文字目がR⇒(後ろのGの数＊後ろのBの数)-(i+t文字目,i+2t文字目)が(G,B)or(B,G)を満たすtの数
      //∴O(K^2)で解ける
      if(S.substring(i-1,i).equals("R")){
        ans=ans+((Gc[K]-Gc[i])*(Bc[K]-Bc[i]));
        for(int j=1;j<=((K-i)/2);j++){
          if((S.substring(i+j-1,i+j).equals("G")&&S.substring(i+j+j-1,i+j+j).equals("B"))||(S.substring(i+j-1,i+j).equals("B")&&S.substring(i+j+j-1,i+j+j).equals("G"))){
            ans=ans-1;
          }
        }
      }else if(S.substring(i-1,i).equals("G")){
        ans=ans+((Rc[K]-Rc[i])*(Bc[K]-Bc[i]));
        for(int j=1;j<=((K-i)/2);j++){
          if((S.substring(i+j-1,i+j).equals("R")&&S.substring(i+j+j-1,i+j+j).equals("B"))||(S.substring(i+j-1,i+j).equals("B")&&S.substring(i+j+j-1,i+j+j).equals("R"))){
            ans=ans-1;
          }
        }
      }else if(S.substring(i-1,i).equals("B")){
        ans=ans+((Gc[K]-Gc[i])*(Rc[K]-Rc[i]));
        for(int j=1;j<=((K-i)/2);j++){
          if((S.substring(i+j-1,i+j).equals("G")&&S.substring(i+j+j-1,i+j+j).equals("R"))||(S.substring(i+j-1,i+j).equals("R")&&S.substring(i+j+j-1,i+j+j).equals("G"))){
            ans=ans-1;
          }
        }
      }else{

      }
    }

    System.out.println(ans);
  }



    
    

  //最大公約数・最小公倍数（セットで使う）
  static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
  static int lcm (int a, int b) {return a*b/gcd(a,b);}
  
}


Measured memory_bytes: 74476
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int gcd( int, int );

int main()
{
	unsigned int moto = 100000;
	int n;

	scanf("%d", &n );

	for ( int i = 0; i < n; i++ )
	{
		moto *= 1.05;
		if ( moto % 1000 )
		{
			moto /= 1000;
			moto *= 1000;
			moto += 1000;
		}
	}

	printf("%d\n", moto );

	return 0;
}

Measured memory_bytes: 0
n, m = gets.split.map(&:to_i)
a = n.times.map { |i| gets.split.map(&:to_i) }

min_num = -10000000001 * 3
res = Array.new(2) { Array.new(2) { Array.new(2) { Array.new(m) { min_num } } } }

a.each do |a_eval|
  [0, 1].repeated_permutation(3) do |i, j, k|
    cake_eval = a_eval.zip([i, j, k]).map { |x, y| ((-1)**y) * x }.inject(:+)
    next_eval = res[i][j][k] + [cake_eval]
    res[i][j][k] = next_eval.sort.drop(1)
  end
end

p res.flatten(2).map { |i| i.inject(:+) }.max.to_i

Measured memory_bytes: 14712
import java.util.Scanner;
public class Main {
	static Scanner stdIn = new Scanner(System.in);
	public static void main(String args[]){
		while(true){
			int N=stdIn.nextInt();
			if(N==0){
				break;
			}
			int xMax=0,xMin=0,yMax=0,yMin=0,pos,tmp;
			Table[] tbl = new Table[N];
			tbl[0] = new Table();
			tbl[0].x=0;
			tbl[0].y=0;
			for(int i=1;i<N;i++){
				tbl[i]= new Table();
				tmp=stdIn.nextInt();
				pos=stdIn.nextInt();
				func(tbl,i,tmp,pos);
				if(xMax<tbl[i].x)
					xMax=tbl[i].x;
				else if(xMin>tbl[i].x)
					xMin=tbl[i].x;
				if(yMax<tbl[i].y)
					yMax=tbl[i].y;
				else if(yMin>tbl[i].y)
					yMin=tbl[i].y;
			}
			System.out.println((xMax-xMin+1)+" "+(yMax-yMin+1));
		}
	}
	private static void func(Table[] tbl, int i, int tmp, int pos) {
		switch(pos){
		case 0:tbl[i].x=tbl[tmp].x-1; tbl[i].y=tbl[tmp].y; break;
		case 1:tbl[i].x=tbl[tmp].x; tbl[i].y=tbl[tmp].y-1; break;
		case 2:tbl[i].x=tbl[tmp].x+1; tbl[i].y=tbl[tmp].y; break;
		case 3:tbl[i].x=tbl[tmp].x; tbl[i].y=tbl[tmp].y+1; break;
		}
	}
	
}
class Table{
	int x,y;	
}

Measured memory_bytes: 34764
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    double a,x,b;
    cin >> a >> b >> x;
    if(a*a*b == x){
        cout <<0<< "\n";
    }else if(a*a*b > 2*x){
        double exs = 2*x/a/b;
        double deg = atan(b/exs)*180/M_PI;
        cout <<deg<< "\n";
    }else if(a*a*b == 2*x){
        cout <<45<< "\n";
    }else{
        double exs = (2*a*a*b-2*x)/(a*a);
        double deg = atan(exs/a)*180/M_PI;
        cout <<deg<< "\n";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int K = sc.nextInt();
            int A = sc.nextInt();
            int B = sc.nextInt();
            System.out.println(can(K, A, B) ? "OK" : "NG");
        }
    }

    private static boolean can(int k, int a, int b) {
        for (int n = 1; n * k <= b; n++) {
            if (n * k >= a && n * k <= b) {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 26968
N = int(input())
lst = [{'s': 'a', 'c': 1}]
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
for n in range(N - 1):
    new_lst = []
    for x in lst:
        for c in range(x['c'] + 1):
            new_s = x['s'] + alphabet[c]
            if c == x['c']:
                new_c = c + 1
            else:
                new_c = x['c']
            new_lst.append({'s': new_s, 'c': new_c})
    lst = new_lst
for x in lst:
    print(x['s'])


Measured memory_bytes: 53620
#include <bits/stdc++.h>
using namespace std;
#define MAX_TIME 324000*60
#define EPS 0.001

bool eq(double a, double b){
  return abs(a-b) < EPS;
}

int main(void){
  int N;
  double dist_A = -1.0, dist_B = -1.0;
  int time_A = MAX_TIME, time_B = MAX_TIME;
  cin >> N;
  int pref = -1, prea = -1, pret = -1;
  double prex = -1.0, prey = -1.0;
  while(N--){
    int f, a, t, x, y;
    cin >> f >> a >> t >> x >> y;
    if(pret == t && prea != a){
      if(t == 0){
        double dist = sqrt(pow(prex - x, 2) + pow(prey - y, 2));
        if(eq(dist_A, dist)){
          time_A = min(time_A, f - pref);
        }else{
          if(dist_A < dist){
            dist_A = dist;
            time_A = f - pref;
          }
        }
      }else{
        double dist = sqrt(pow(prex - x, 2) + pow(prey - y, 2));
        if(eq(dist_B, dist)){
          time_B = min(time_B, f - pref);
        }else{
          if(dist_B < dist){
          dist_B = dist;
          time_B = f - pref;
          }
        }
      }
    }
    pret = t; prea = a; pref = f; prex = x; prey = y;
  }
  if(eq(dist_A, -1.0)){
    cout << -1 << " ";
  }else{
    printf("%f ", dist_A);
  }
  if(time_A == MAX_TIME){
    cout << -1 << endl;
  }else{
    printf("%f\n", time_A/60.0);
  }
  if(eq(dist_B, -1.0)){
    cout << -1 << " ";
  }else{
    printf("%f ", dist_B);
  }
  if(time_B == MAX_TIME){
    cout << -1 << endl;
  }else{
    printf("%f\n", time_B/60.0);
  }
  return 0;
}

Measured memory_bytes: 1232
from itertools import product


def main():
    n, *target = map(int, input().split())
    arr = [int(input()) for i in range(n)]

    tests = product(range(4), repeat=n) #0:使わない　i:竹iの材料に使う
    test_arr = [[] for _ in range(3)]
    min_cost = float("inf")

    for test in tests: #パターンで全探索
        cost = 0

        if 1 not in test or 2 not in test or 3 not in test:
            continue

        for i in range(3):
            test_arr[i] = [arr[x] for x in range(n) if test[x] == i + 1]
            cost += (len(test_arr[i]) - 1) * 10  #test_arr[i]の竹を全部合成するのに要するMP
            cost += abs(sum(test_arr[i]) - target[i]) #延長・縮小により合成した竹の長さをtarget[i]に調整するにに要するMP

        if min_cost > cost:
            min_cost = cost

    print(min_cost)


main()


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	b := big.NewInt(1)
	max := big.NewInt(int64(1e18))
	aa := make([]int64, n)
	valid := true
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
		if aa[i] == 0 {
			valid = false
		}
	}
	if valid == false {
		fmt.Fprintln(writer, 0)
		return
	}
	for i := 0; i < n; i++ {
		b.Mul(b, big.NewInt(aa[i]))
		if b.Cmp(max) == 1 {
			fmt.Fprintln(writer, -1)
			return
		}
	}

	fmt.Fprintln(writer, b)
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

using namespace std;

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> t(n);
    for (int i = 0; i < n; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        t[i] = a;
        x[i] = b;
        y[i] = c;
    }

    int pre_time = 0;
    int pre_x = 0;
    int pre_y = 0;
    for (int i = 0; i < n; i++)
    {
        int sum = abs(x[i]-pre_x) + abs(y[i]-pre_y);
        if (t[i] - pre_time - sum >= 0 and (t[i] - pre_time - sum) % 2 == 0)
        {
            pre_time = t[i];
            pre_x = x[i];
            pre_y = y[i];
        }
        else
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;
}

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

int main()
{
    int x, y;

    cin >> x >> y;

    for (int i = 0; i <= x; i++){
        if((i*2) + ((x-i)*4) == y){
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  ll n;
  cin >> n;
  ll a[n];
  REP(i, n) { cin >> a[i]; }

  ll index = 0;
  REP(i, n) {
    if (a[i] == index + 1) {
      index++;
    }
  }
  PRINT(index == 0 ? -1 : n - index);

  return;
}

Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
vector<PP> v[50];
ll n,m,s,a,b,c,d,C[50],D[50],dp[50][2500],cnt;
priority_queue<PP,vector<PP>,greater<PP>> que;
int main(void){
    cin>>n>>m>>s;
    for(int i=0;i<n;i++)for(int j=0;j<2500;j++)dp[i][j]=1e18;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c>>d;
        a--,b--;
        v[a].push_back({b,{c,d}});
        v[b].push_back({a,{c,d}});
    }
    for(int i=0;i<n;i++){
        cin>>C[i]>>D[i];
    }
    if(s>=2500)s=2499;
    que.push({0,{0,s}});
    dp[0][s]=0;
    while(que.size()){
        auto p=que.top();
        que.pop();
        
        if(dp[p.S.F][p.S.S]<p.F)continue;
        
        if(p.S.S+C[p.S.F]<2500){
            if(dp[p.S.F][p.S.S+C[p.S.F]]>p.F+D[p.S.F]){
                dp[p.S.F][p.S.S+C[p.S.F]]=p.F+D[p.S.F];
                que.push({p.F+D[p.S.F],{p.S.F,p.S.S+C[p.S.F]}});
            }
        }
        for(auto x:v[p.S.F]){
            if(x.S.F>p.S.S)continue;
            if(dp[x.F][p.S.S-x.S.F]>p.F+x.S.S){
                dp[x.F][p.S.S-x.S.F]=p.F+x.S.S;
                que.push({p.F+x.S.S,{x.F,p.S.S-x.S.F}});
            }
        }
        
    
    }
    for(int i=1;i<n;i++){
        ll ans=1e18;
        for(int j=0;j<2500;j++){
            ans=min(ans,dp[i][j]);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 7208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;

#define pi 3.141592653589793)
#define mod 1000000007

int main() {
	int n,d,x;
	cin >> n >> d >> x;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	int ans = 0;
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < n; j++) {
			if (i%a[j] == 1) {
				ans++;
			}
			else if(a[j] == 1)ans++;
		}
	}
	cout << ans+x;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
xys = [list(map(int, input().split())) for _  in range(M)]

children = [[] for _ in range(N)]
for x, y in xys:
    children[x-1].append(y-1)

has_no_parent = [True] * N
has_no_child = [True] * N
for x, y in xys:
    has_no_child[x-1] = False
    has_no_parent[y-1] = False

dp = [None] * N
for node in range(N):
    if has_no_child[node]:
        dp[node] = 0

for node in range(N):
    if dp[node] is not None:
        continue
    stack = []
    stack.append(node)
    while stack:
        parent = stack[-1]
        all_children_defined = True
        for child in children[parent]:
            if dp[child] is None:
                stack.append(child)
                all_children_defined = False
        if all_children_defined:
            stack.pop()
            dp[parent] = max([dp[child] + 1 for child in children[parent]])

print(max(dp))


Measured memory_bytes: 80088
//https://atcoder.jp/contests/abc099/tasks/abc099_b
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans1,ans2,ans3;
	cin>>a>>b;
	ans1=b-a;
	ans2=ans1*(ans1+1)/2;
	ans3=ans2-b;
	cout<<ans3<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<iomanip>
#include<functional>
#include<utility>
using namespace std;
typedef long long llong;
int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<int>t(n);
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		if (t[i] < a || b <= t[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
K,A,B = map(int, input().split(" "))


bis = 1

kaisu = 0

en = 0

if B <= A +  1:
    bis = bis + K
elif K <= A:
    bis = bis + K
else:
    K = K - (A - 1)
    bis = A
    K = K - 2
    bis = B
    #while K >= 2:
        #if B-A <= K + 1:
        #   bis = bis + K + 1
    #    K = K - 2
    #    bis = bis - A + B
    if K % 2 == 0:
        #print("test")
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2
    else:
        #print("test2")
        w1 = int(K /2)
        w2 = B-A
        bis = bis + w1*w2 
        bis = bis +1


print(bis)


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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  
  sort(a.begin(), a.end());
  
  vector<int> kind;
  int count = 0;
  int prev = a[0];
  for(int i = 0; i < n; i++){
    if(a[i] != prev){
      kind.push_back(count);
      count = 0;
    }
    count++;
    prev = a[i];
  }
  kind.push_back(count);
  
  sort(kind.begin(), kind.end());
  
  int re = 0;
  for(int i = 0; i < (int)kind.size() - k; i++){
    re += kind[i];
  }
  
  cout << re << endl;
  
  return 0;
}

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

int cmp(const void *a, const void *b)
{
     return(*(int *)a-*(int *)b);
}

int main(){
    int N,K,i,a[100000];
    scanf("%d %d",&N,&K);
    for (i=0;i<N;i++)
        scanf("%d",&a[i]);
    int j,t;
    qsort(a,N,sizeof(a[0]),cmp);
    int min=a[K-1]-a[0];
    for (i=0;i<N-K+1;i++){
        if (a[i+K-1]-a[i]<min){
            min=a[i+K-1]-a[i];
        }
    }
    printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 892
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Quad {
	int a, b, c, d;

	Quad(int a, int b, int c, int d) {
		this.a = a;
		this.b = b;
		this.c = c;
		this.d = d;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());
		int Q = Integer.parseInt(sc.get());
		Quad[] quads = new Quad[Q];
		for (int i = 0; i < Q; i++) {
			quads[i] = new Quad(Integer.parseInt(sc.get()) - 1, Integer.parseInt(sc.get()) - 1, Integer.parseInt(sc.get()), Integer.parseInt(sc.get()));
		}

		var arrays = createArrays(new int[N], 1, M ,0);

		int max = 0;
		for (int[] array : arrays) {
			int point = 0;
			for (Quad quad : quads) {
				if (array[quad.b] - array[quad.a] == quad.c) point += quad.d;
			}
			max = Math.max(max, point);
		}

		System.out.println(max);
	}

	Collection<int[]> createArrays(int[] filled, int min, int max, int target) {
		if (target >= filled.length) return Collections.singleton(filled);
		List<int[]> list  =new ArrayList<>();
		for (int i = min; i <= max; i++) {
			var copy = Arrays.copyOf(filled, filled.length);
			copy[target] = i;
			list.addAll(createArrays(copy, i, max, target + 1));
		}
		return list;
	}
}

class Main {
	public static void main(String... args) {
		try (var reader = new BufferedReader(new InputStreamReader(System.in))) {
			Solver.INSTANCE.solve(new Supplier<>() {
				StringTokenizer line;

				public String get() {
					while (line == null || !line.hasMoreTokens()) try {
						line = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new UncheckedIOException(e);
					}
					return line.nextToken();
				}
			});
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}
}

Measured memory_bytes: 59072
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;



int GCD(int a, int b){
    if(a < b) swap(a, b);
    if(b == 0) return a;
    return GCD(b, a%b);
}

ll a[100010];

bool cmp(const pair<int, int> &a, const pair<int, int> &b){
    if(a.first == b.first) return a.second == b.second;
    return a.first < b.first;
}
vector<pair<int, int>> vp;
int main() {
    //cout << fixed << setprecision(15);

    string s; cin >> s;

    if(s[0]==s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn main() {
    let v: Vec<i32> = read_vec();
    let result = if v[0] == v[1] { "a == b" } else if v[0] < v[1] { "a < b" } else { "a > b" };
    println!("{}", result);
}



Measured memory_bytes: 5024
#include <iostream>
using namespace std;
long long n,dp[1<<18|5][3],ans[1<<18|5],num[1<<18|5];
void cal(long long x,long long y)
{
	if (dp[x][0]==y || dp[x][1]==y) return;
	if (num[dp[x][1]]<num[y])
	{
		dp[x][1]=y;
		if (num[dp[x][0]]<num[dp[x][1]]) swap(dp[x][0],dp[x][1]);
	}
}
int main()
{
	cin>>n;
	for (int i=0;i<1<<n;i++)
	{
		cin>>num[i];
		dp[i][0]=i;
	}
	for (int i=0;i<1<<n;i++) for (int j=0;j<n;j++)
	{
		if (!((i>>j)&1))
		{
			cal((i|(1<<j)),dp[i][0]);
			cal((i|(1<<j)),dp[i][1]);
		}
	}
	for (int i=1;i<1<<n;i++)
	{
		ans[i]=max(ans[i-1],num[dp[i][0]]+num[dp[i][1]]);
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

ll n;
int dp[100005];
int a[105];
int rec(int rem)
{
	//cout<<rem<<endl;
	if(rem<=0)
		return 0;
	int &res=dp[rem];
	if(res!=-1)
		return res;
	res=0;
	for(int i=0;i<n;i++)
	{
		if(rem-a[i]>=0)
		{
			if(rec(rem-a[i])==0)
				res=1;
		}

	}
	return res;
}
 
int main()
{
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	memset(dp,-1,sizeof(dp));
	if(rec(k))
		cout<<"First";
	else cout<<"Second";
	

	
	
	
	
 
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>
using namespace std;
int main(){
        string str;
        cin >> str;
        string rts="";
        for(int i=0 ; i<str.size() ; i++ ){
                if(rts[rts.size()-1]==str[i])continue;
                rts+=str[i];
        }
        cout << rts.size()-1 << endl;
        return 0;
}

Measured memory_bytes: 512
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long LL;
LL a[10000+10],b[10000+10];
int n;
LL cnt=0;
int main(){
	scanf("%d",&n);
	for (int f1=1;f1<=n;f1++)scanf("%lld",&a[f1]);
	for (int f1=1;f1<=n;f1++)scanf("%lld",&b[f1]);
	for (int f1=1; f1<=n;f1++){
		if (a[f1]<b[f1]){
			cnt+=(b[f1]-a[f1]+1)/2;
			a[f1]+=(b[f1]-a[f1]+1)/2*2;
		}
		cnt-=(a[f1]-b[f1]);
		//printf("%lld\n",cnt);
	}
	if (cnt>=0) printf("Yes\n");
	else printf("No\n");
	
}


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

cpp_int gcd(cpp_int x, cpp_int y) {
  while (y > 0) {
    cpp_int tmp = x;
    x = y;
    y = tmp % y;
  }
  return x;
}

int main() {
  int n; cin >> n;
  cpp_int res = 1;
  for (int i = 0; i < n; ++i) {
    cpp_int t; cin >> t;
    res = res * t / gcd(res, t);
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	LL n, a = 0;
	string s;
	cin >> n;

	s = to_string(n);

	for (int i = 0; i < s.size(); i++) {
		a += s[i]-'0';
	}


	if (n%a == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}




	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        int ans = 0;
        int temp = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'I') {
                temp++;
            } else {
                temp--;
            }
            if (ans <= temp) {
                ans = temp;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21588
S = input()
cnt = 0
for i in range(len(S)):
    for j in range(len(S)):
        if i == j : pass
        elif S[i] == S[j]: cnt += 1
        else: pass
        if cnt != 0: break
    if cnt != 0 :break
    
print("yes" if cnt == 0 else "no")


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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int);
void init();
void printList();
void deleteNode(NodePointer);
void deleteFirst();
void deleteLast();
void delete(int);
void insert(int);

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


NodePointer listSearch(int key){
  NodePointer x;
  x=nil->next;
  while(x!=nil && x->key!=key){
    x=x->next; 
 }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
    NodePointer x;
    x=listSearch(key);
    if ( x == nil ) return;
    deleteNode(x);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

Measured memory_bytes: 31784
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

double p,e,t;

double f(int k, double l, double r){

    double m = (l+r)/2.0;
    if(k == 0){
        if(t-e < m && m < t+e) return 1.0;
        else return 0.0;
    }
    if(r < t-e || t+e < l) return 0.0;
    if(t-e < l && r < t+e) return 1.0;
    if(m > t) return (1-p)*f(k-1,l,m) + p*f(k-1,m,r);
    else return p*f(k-1,l,m) + (1-p)*f(k-1,m,r);
}

int main(void) {
    int i,j;
    int k,r,l;
    cin >> k >> r >> l;
    cin >> p >> e >> t;
    cout << shosu(10) << f(k,r,l) << endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))

int n, e, dp[22][22], s, g;
const int inf = 1<<29;

int solve() {
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  return dp[s][g] + dp[g][s];
}

int main() {
  rep (i,22) fill(dp[i], dp[i] + 22, inf);
  rep (i,22) dp[i][i] = 0;

  cin >> n >> e;
  int a, b, c, d;
  char x;
  rep (i,e) {
    cin >> a >> x >> b >> x >> c >> x >> d;
    a--; b--;
    dp[a][b] = c;
    dp[b][a] = d;
  }
  int y1, y2;
  cin >> s >> x >> g >> x >> y1 >> x >> y2;
  s--; g--;
  cout << y1 - y2 - solve() << endl;
  
  return 0;
}

Measured memory_bytes: 0
/**
 * Author: Behradm
 * Created: 03-05-2020 16:43:56
 * In the Name of God
**/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define LOCAL

#ifdef LOCAL
	#define debugi(x) cerr << "{" << #x << "}: " << (x) << '\n'
	#define debug(v, begin, end) cerr << "{ | "; for(auto i = begin; i < end; i++){cerr << #v << "[" << i << "]: " << v[i] << " | ";} cerr << " }\n"
	#define debugp(a, b) cerr << "\n{ " << a << " " << b << " }\n"
#else
	#define debugi(x) 42
	#define debug(v, begin, end) 42
	#define debugp(a, b) 42 
#endif

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	cout.tie(0);
	cout.precision(6);
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<int> g(n, 0);
	for (int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u] = max(g[u], a[v]);
		g[v] = max(g[v], a[u]);
	}


	int res = 0;
	for (int i = 0; i < n; i++){
		if (a[i] > g[i])
			res++;
	}
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 3976
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> p(n, 0);
  for (int i = 0; i < n; i++) {
    if (s[i] == '#')
      p[i] = p[i - 1] + 1;
    else
      p[i] = p[i - 1];
  }
  int ans = 1e9;
  for (int i = 0; i <= n; i++) {
    int temp = p[i - 1] + (n - i - (p[n - 1] - p[i - 1]));  //白にする＋黒にする
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1412
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

struct R {
  string s;
  int p;
  int id;
  bool operator< (const R &o) const {
    return s == o.s ? p > o.p : s < o.s;
  }
};

int N;
R rs[110];

void input() {
  cin >> N;
  string name; int p;
  loop(n,0,N) {
    cin >> name >> p;
    rs[n] = (R){ name, p, n+1 };
  }
}

void solve() {
  sort(rs, rs+N);
  for (int i=0;i<N;i++) {
    cout << rs[i].id << endl;
  }
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[1000000];
int main (void){
    while(cin>>a){
    	map<char,int>ss;
    	for(int i=0;a[i]!='\0';i++){
    		ss[a[i]]++;
		}
		char arr='a';
		for(int i=1;i<=26;i++){
			map<char,int>::iterator key = ss.find(arr); 
			if(key!=ss.end()) arr=arr+1;
			else break;
		}
		if(arr>'z')cout<<"None"<<endl;
		else cout<<arr<<endl;
		
    }
    return 0;
}


Measured memory_bytes: 384
import sys

N, M = map(int, input().split())
sys.setrecursionlimit(10**6)
I = [[] for _ in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  I[a].append(b)
  I[b].append(a)

C = [-1 for _ in range(N)] 
visited = set()

def DFS(p, c):
  C[p] = c
  flag = True
  for q in I[p]:
    #print(p,q)
    if C[q] == c:
      return False
    elif C[q] == -1:
      if not DFS(q, 1-c):
        return False
  return True

#print(DFS(0, 0))
#print(C)
print(C.count(0)*C.count(1)-M if DFS(0, 0) else N*(N-1)//2-M)
      
      
  
  
  
  

Measured memory_bytes: 36320
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
unsigned long long mod = 1e9 + 7;
unsigned long long base = 998244353;
 
vector<vector<int>> g;
vector<long long> vv;
vector<bool> c;
void dfs(int v, long long value)
{
    if (c[v])
    {
        return;
    }
    c[v] = 1;
    vv[v] += value;
    for (int i = 0; i < g[v].size(); ++i)
    {
        dfs(g[v][i], vv[v]);
    }
}
 
int main() {
    
 
    
    int n, q;
    cin >> n >> q;
    g = vector<vector<int>>(n, vector<int>());
 
    for (int i = 0; i < n - 1; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vv = vector<long long>(n);
    c = vector<bool>(n);
    for (int i = 0; i < q; ++i)
    {
        int p, x;
        cin >> p >> x;
        p--;
        vv[p] += x;
    }
    
    dfs(0, 0);
    
    for (int i = 0; i < n; ++i)
    {
        if (i == n - 1)
        {
            cout << vv[i] << endl;
            return 0;
        }
        cout << vv[i] << " ";
    }
    
    return 0;
}

Measured memory_bytes: 21120