akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

"""考え方
累積の移動距離を順番に計算しておく。
その後、累積距離とAの配列から「対象地域をスキップした場合」の総移動距離を出力する。
"""

## 1.累積距離の計算
## accmには初期位置、最後に0に戻る、という2要素が追加されている
accm = [0]+[0 for i in range(N)]
accm[1] = abs(A[0])
for n in range(1,N):
  accm[n+1] = abs(A[n]-A[n-1]) + accm[n]

accm.append(accm[-1]+abs(A[-1]))
base_cost = accm[-1]

## 2.総移動距離を出力
## 「対象インデックスをスキップすることで省略できるコスト」をaccm[-1]から減算する
## この計算は対象インデックスをnとすると、下記の計算式で求められる
## abs(A[n+1]-A[n])+abs(A[n]-A[n-1])-abs(A[n+1]-A[n-1])
for n in range(0,N):
  if n == N-1:
    bene = abs(A[-1])+abs(A[-1]-A[-2])-abs(A[-2])
  elif n == 0:
    bene = abs(A[1]-A[0])+abs(A[0])-abs(A[1])
  else:
    bene = abs(A[n+1]-A[n])+abs(A[n]-A[n-1])-abs(A[n+1]-A[n-1])
  
  ans = base_cost - bene
  print(ans)

Measured memory_bytes: 13928
N, M = map(int, input().split(' '))
X = []
for i in range(M):
    X.append(list(map(int, input().split(' '))))

num_b = [1 for i in range(N+1)]
num_b[0] = 0
psb = [0]*(N+1)
psb[1] = 1
for i in range(M):
    num_b[X[i][0]] -= 1
    num_b[X[i][1]] += 1
    if psb[X[i][0]] == 1:
        psb[X[i][1]] = 1 
    if num_b[X[i][0]] == 0:
        psb[X[i][0]] = 0

print(psb.count(1))

Measured memory_bytes: 29028
N = int(input())
MINF = float('-inf')
As = (map(int, input().split()))

dp = [[[0 for ___ in range(2)] for __ in range(2)] for _ in range(N+3)]

if N % 2 == 0:
    for i, a in enumerate(As):
        if i % 2 == 0:
            dp[i][0][0] = max(dp[i-2][1][1], dp[i-1][1][1])
            dp[i][0][1] = MINF
            dp[i][1][0] = MINF
            dp[i][1][1] = dp[i-2][1][1] + a
        else:
            dp[i][0][0] = MINF
            dp[i][0][1] = MINF
            dp[i][1][0] = dp[i-1][1][1]
            dp[i][1][1] = max(dp[i-3][1][1], dp[i-2][1][1]) + a
else:
    for i, a in enumerate(As):
        if i % 2 == 0:
            dp[i][0][0] = max(dp[i-1][1][0], dp[i-1][1][1])
            dp[i][0][1] = dp[i-1][0][0] + a
            dp[i][1][0] = MINF
            dp[i][1][1] = dp[i-1][1][0] + a
        else:
            dp[i][0][0] = max(dp[i-1][0][0], dp[i-1][0][1])
            dp[i][0][1] = MINF
            dp[i][1][0] = dp[i-1][1][1]
            dp[i][1][1] = dp[i-1][0][0] + a
print(max(dp[N-1][0][0], dp[N-1][0][1], dp[N-1][1][0], dp[N-1][1][1]))

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define se second
#define fi first
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef vector<ll>  vi;
typedef pair<ii, ll>  iii;
typedef pair<double, double>  iidb;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(nodo*2)+1,mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define offset 9000

const ll MOD=1e9+7;

#define cmplog 20
#define tam 600000


using namespace std;
ll ans[tam][3];

int main()
{	
	memset(ans,-1,sizeof ans);
	ios::sync_with_stdio(false);cin.tie(0);
	ll n,q;
	cin>>n>>q;
	ll valx,valy=n-1;
	valx=valy=n-1;
	vector<ii> lst;
	ll tipo,x;
	set<ll> primer,segund;
	forr(i,0,q)
	{
		cin>>tipo>>x;
		x--;
		if (tipo==1)
			primer.insert(x);
		else
			segund.insert(x);
		if (tipo==1)
		{
			if (x>valx)continue;
			ans[x][1]=valy-1;
			valx=x;
		}
		else
		{
			if (x>valy)continue;
			ans[x][2]=valx-1;
			valy=x;
		}
		//cout<<valx<<'-'<<valy<<endl;
		
	}
	ll c=0;
	
	ll maxx=0;
	//cout<<endl;
	forr(x,1,n-1)
	{
		while(c<x)
			maxx=max(maxx,ans[c++][1]);
		if (ans[x][1]==-1 && primer.find(x)!=primer.end())
			ans[x][1]=maxx;
		//cout<<ans[x][1]<<"xd "<<(primer.find(x)!=primer.end())<<endl;
	}
	//cout<<endl;
	c=maxx=0;
	forr(x,1,n-1)
	{
		while(c<x)
			maxx=max(maxx,ans[c++][2]);
		if (ans[x][2]==-1 && segund.find(x)!=segund.end())
			ans[x][2]=maxx;
		//cout<<ans[x][2]<<' ';
	}
	//cout<<endl;
	ll tot=0;
	forr(i,1,n-1)
		tot+=max(0LL,ans[i][1])+max(0LL,ans[i][2]);
	tot=(n-2)*(n-2)-tot;
	cout<<tot<<endl;
		
}

Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() { 
    fastIO;
     int t=1 ;
      
     while(t--){unsigned ll a,b,n;
         cin>>a>>b>>n;
       unsigned ll t=a/b;
         unsigned ll r=a%b;       
         unsigned ll q=min(n,b-1);
          unsigned ll ans=q*t+(q*r)/b;
                cout<<ans<<endl;
     }
	 
	return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
   
   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      long a = in.nextLong();
      long b = in.nextLong();
      long c = in.nextLong();
      long d = in.nextLong();

      long ans = a * c;
      ans = Math.max(ans, a * d);
      ans = Math.max(ans, b * c);
      ans = Math.max(ans, b * d);
      out.println(ans);
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 33068
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v,pick[200000];
map<string, vector<LL>>ma;
multiset<LL>st[3];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	cout << "01"[n<=m] << endl;
	return 0;
}



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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

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

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const int inf = (int)1e9;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 300500;

int m, n;
pii dp[N];

inline pii operator +(pii p1, pii p2) {
	int a[4] = {p1.F, p1.S, p2.F, p2.S};
	sort(a, a + 4);
	return {a[3], a[2]};
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

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

	//cout << setprecision(10) << fixed;

	cin >> m;

	n = (1 << m);
	
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		dp[i] = {x, -1};
	}

	for (int i = 0; i < m; i++) {
		for (int mask = 1; mask < n; mask++) {
			if (mask >> i & 1)
				dp[mask] = dp[mask] + dp[mask ^ (1 << i)];
		}
	}

	for (int i = 1, mx = 0; i < n; i++) {
		mx = max(mx, dp[i].F + dp[i].S);
		cout << mx << "\n";
	}
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

if n==1:
  print(0)
  exit()  
  
f=factorization(n)
cnt=0
for i in range(len(f)):
  m=2 # 強引
  while f[i][1]>0:
    f[i][1]-=m
    m+=1
    cnt+=1
#    print(f)
print(cnt)

Measured memory_bytes: 9328
use proconio::{input, fastout};
use ascii::{AsciiString, AsciiChar};

#[fastout]
fn main() {
    //おわり
    let al = [
        'a',
        'b',
        'c',
        'd',
        'e',
        'f',
        'g',
        'h',
        'i',
        'j',
        'k',
        'l',
        'm',
        'n',
        'o',
        'p',
        'q',
        'r',
        's',
        't',
        'u',
        'v',
        'w',
        'x',
        'y',
        'z'
    ];
    input! {
        n: usize
    }
    let mut num = n;
    let mut ans = Vec::new();
    loop {
        if num <= 0 {
            break;
        }
        num -= 1;
        let m = num % 26;
        ans.push(m);
        num = num / 26;
    }
    ans.reverse();
    let mut moji = AsciiString::new();
    for a in ans {
        moji.push(AsciiChar::new(al[a]));
    }
    println!("{}",  moji);
}


Measured memory_bytes: 2200
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		for (char c = 'a'; c <= 'z'; c++) {
			boolean flag = false;
			for (int i = 0; i < s.length(); i++) {
				if (s.charAt(i) == c) {
					flag = true;
					break;
				}
			}
			if (!flag) {
				System.out.println(c);
				return;
			}
		}
		System.out.println("None");
	}
}


Measured memory_bytes: 26788
#include<bits/stdc++.h>
using namespace std;
#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(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,h,w;
  cin>>n>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;
	return 0;
}

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

int main(){
    int n, r, p, c;
    int card[50];
    int ncard[50];
    cin >> n >> r;
    while(n || r){
        for(int i=0;i<n;++i){
            card[i] = i;
            ncard[i] = i;
        }
        for(int i=0;i<r;++i){
            cin >> p >> c;
            for(int j=0;j<c;++j){
                ncard[j] = card[p+j-1];
            }
            for(int j=c;j<c+p-1;++j){
                ncard[j] = card[j-c];
            }
            for(int j=c+p-1;j<n;++j){
                ncard[j] = card[j];
            }
            for(int j=0;j<n;++j){
                card[j] = ncard[j];
            }
        }
        cout << n-card[0] << endl;
        cin >> n >> r;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int a[N], p[N], n;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n;
	For(i, 1, n + 1) cin >> a[i];
	For(i, 1, n + 1) p[a[i]] = i;
	For(i, 1, n + 1) cout << p[i] << (i == n ? '\n' : ' ');
}



Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}

		long[] cum = new long[n + 1];
		for (int i = 0; i < n; i++) {
			cum[i + 1] = cum[i] + a[i];
		}
		long min = Long.MAX_VALUE;
		for (int i = 1; i < cum.length - 1; i++) {
			long diff = cum[cum.length - 1] - cum[i];
			if (Math.abs(diff - cum[i]) < min) {
				min = Math.abs(diff - cum[i]);
			}
		}
		System.out.println(min);
		in.close();
	}
}

Measured memory_bytes: 65680
#include<stdio.h>
#include<string.h>
char a[4001];
char b[4001];
short dp[4001][4001];
int max(int a,int b){return a>b?a:b;}
int main(){
	while(scanf(" %s",a)!=EOF){
	scanf(" %s",b);
	int n=strlen(a);
	int m=strlen(b);
	int i,j;
	for(i=0;i<=n;i++)for(j=0;j<=m;j++)dp[i][j]=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(a[i]==b[j])dp[i+1][j+1]=dp[i][j]+1;
		}
	}
	int ans=0;
	for(i=0;i<=n;i++)for(j=0;j<=m;j++)ans=max(ans,dp[i][j]);
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 32244
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int INF = 1e9, MOD = 998244353; /// think
const ll LINF = 1e15;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << fixed;
    cout.precision(10);
    cout << (ld)((n + 1) / 2) / (n) << '\n';
}


Measured memory_bytes: 3796
//#pragma GCC optimize("trapv")
#include <iostream>
#include <vector>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cassert>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#include <functional>
//#define int long long
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()

using namespace std;

const int MOD = 1e9 + 7;
//const int INF = 1e9 + 10;

void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const int szz = 2e6 + 20;

long long comp[szz];
long long sz[szz];

long long find(int v) 
{
	if (comp[v] == v) 
		return v;
	else 
		return comp[v] = find(comp[v]);
}

void unite(int v, int u) 
{
	v = find(v);
	u = find(u);
	if (u != v) 
	{
		sz[v] += sz[u];
		comp[u] = v;
	}
}

int main()
{
	fast();

	long long n, m;
	cin >> n >> m;

	for (int i = 0; i < n; ++i) 
	{
		comp[i] = i;
		sz[i] = 1;
	}

	for (int i = 0; i < m; ++i) 
	{
		long long u, v;
		cin >> u >> v;
		unite(u - 1, v - 1);
	}

	long long ans = 0;
	for (int i = 0; i < n; ++i) 
	{
		ans = max(ans, sz[find(i)]);
	}

	cout << ans << '\n';
	return 0;
}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;



int main(){
    int N;
    cin>>N;
    int a[100009];
    for(int i=1;i<=N;++i) cin>>a[i];

    int count=0;
    int now=1;
    int seen[100009]={-1};
    bool check=true;
    seen[1]=1;
    while(now!=2){
        now=a[now];
        ++count;
        if(seen[now]==1){
            check=false;
            break;
        }
        seen[now]=1;
    }
    check?cout<<count<<endl:cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
const int N = 2e6;
const int inf = 1e9;
const double eps = 1e-8;
using namespace std;
int n,k,ans,a[N + 5],Ans;
bool check(int x)
{
    long long sm = 0;
    for (int i = 1;i <= n;i++)
        if (a[i] > x)
            sm += ceil(1.0 * a[i] / x) - 1;
    if (sm <= k)
        return 1;
    return 0;
}
int main()
{
    scanf("%d%d",&n,&k);
    for (int i = 1;i <= n;i++)
        scanf("%d",&a[i]);
    int l = 1,r = inf,mid;
    while (l < r)
    {
        mid = (l + r) >> 1;
        if (check(mid))
            r = mid;
        else
            l = mid + 1;
    }
    printf("%d\n",l);
    return 0;
}

Measured memory_bytes: 4516
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int main()
{
	int i, j;

	ll N, M;

	sll(N);	sll(M);

	ll limit = N;
	
	ll iniAns = min(limit, M / 2LL);

	M -= (iniAns * 2LL);

	// cout << iniAns << " " << M << "\n";

	iniAns += (M / 4LL);

	cout << iniAns;



	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    string s;cin>>s;
    ll cnt=1,cur=0;
    ll n = s.size();
    while(cur<n-1){
        if(s[cur]==s[cur+1]){
            if(cur<n-2){
                cnt++;
            }
            cur += 3;
            if(cur<=n-1){
                cnt++;
            }
        }else{
            cur++;cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip()
def check(E):
    L = []
    n = len(E)
    done = [0] * n
    checking = [0] * n
    Q = []
    for i in range(n)[::-1]:
        Q.append(~i)
        Q.append(i)
    while Q:
        j = Q.pop()
        if j < 0:
            if done[~j]: continue
            done[~j] = 1
            L.append(~j)
            checking[~j] = 0
            continue
        if done[j]: continue
        checking[j] = 1
        for k in E[j]:
            if checking[k]:
                return 1
            Q.append(~k)
            Q.append(k)
    return 0

N, M = map(int, input().split())
S = [ord(a)-65 for a in input()]
X = [[] for _ in range(N*2)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if S[a] == S[b]:
        X[a].append(b+N)
        X[b].append(a+N)
    else:
        X[a+N].append(b)
        X[b+N].append(a)

print("Yes" if check(X) else "No")

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

using namespace std;

inline int read() {
    int cnt = 0, opt = 1;
    char ch = getchar();

    for (; ! isalnum(ch); ch = getchar())
        if (ch == '-')  opt = 0;
    for (; isalnum(ch); ch = getchar())
        cnt = cnt * 10 + ch - 48;

    return opt ? cnt : -cnt;
}

int n, m;

int main() {
	n = read(), m = read();
	for (int i = 1; i <= ((n < m) ? m : n); ++ i)
		cout << ((n < m) ? n : m);
    return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

int person[50];
int pos;
int wan;
int n;
int p;

void solve() {
    while(true) {
        if(wan) {
            person[pos]++;
            wan--;
            if(person[pos]==p) {
                cout << pos << endl;
                return;
            }
        }
        else {
            wan = person[pos];
            person[pos] = 0;
        }
        pos++;
        if(pos==n) pos = 0;
    }
}

int main()
{
    while(cin>>n>>p, n) {
        rep(i,n) person[i] = 0;
        pos = 0;
        wan = p;
        solve();
    }
    return 0;
}

Measured memory_bytes: 2952
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>
#include <cassert>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

// int N, A[100005], dp[1005][1005];
// int x = 1;

int main() {
    // int N, M;
    // scanf("%d %d", &N, &M);
    // printf("%d\n", (N - 1) * (M - 1));
    string s;
    cin >> s;
    cout << s[0] << s.length() - 2 << s.back() << endl;

    // scanf("%d", &N);
    // for (int i = 1; i <= N; i++) {
    //     scanf("%d", &A[i]);
    // }
    // do {
    //     for (int i = N; i >= 1; i--) {
    //         for (int j = i; j <= N; j++) {
    //             if (i == j) {
    //                 dp[i][j] = A[i];
    //             } else if (j - i == 1) {
    //                 dp[i][j] = max(A[i], A[j]);
    //             } else {
    //                 int lp = min(dp[i + 2][j], dp[i + 1][j - 1]) + A[i];
    //                 int rp = min(dp[i + 1][j - 1], dp[i][j - 2]) + A[j];
    //                 dp[i][j] = max(lp, rp);
    //             }
    //         }
    //     }
    //     // printf("%d\n", dp[1][N]);
    //     for (int i = 1; i <= N; i++) {
    //         for (int j = 1; j <= N; j++) {
    //             printf("%d ", dp[i][j]);
    //         }
    //         printf("\n");
    //     }
    //     printf("===\n");
    // } while (next_permutation(A + 1, A + 1 + N));
}

Measured memory_bytes: 256
def can_load(num_baggages, baggages, num_truck, max_load):
    bag_no = 0

    for i in range(num_truck):
        load_cap = max_load
        while load_cap > 0:
            if bag_no >= num_baggages:
                #print(max_load, "True")
                return True
            if load_cap >= baggages[bag_no]:
                load_cap -= baggages[bag_no]
                bag_no += 1
            else:
                break
    #print(max_load, bag_no >= num_baggages)
    return bag_no >= num_baggages

def main():
    num_baggages, num_trucks = map(int, input().split())
    baggages = [int(input()) for x in range(num_baggages)]

    start = max(sum(baggages) // num_trucks, min(baggages))
    end = sum(baggages)

    while start < end:
        mid = (start + end) // 2
        if can_load(num_baggages, baggages, num_trucks, mid):
            end = mid
        else:
            start = mid + 1

    print(start)
    return


main()


Measured memory_bytes: 9564
a, b, c, k = map(int, input().split())

if a-k <= 0:
    a_ans = a
    k = k-a
else:
    a_ans = k
    k=0
if b-k <= 0 and k>0:
    b_ans = b
    k = k-b
else:
    b_ans = k
    k=0
if c-k <= 0 and k>0:
    c_ans = c
    k = k-b
else:
    c_ans = k
    
ans = a_ans*1 + b_ans*0 + c_ans*(-1)
print(ans)


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

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

int main() {
  int n;
  cin >> n;
  
  int total = 1000000;
  for (int a = 1; a < n; a++) {
    int b = n - a;
    int sum = number(a) + number(b);
    if (sum < total) total = sum;
  }
  cout << total << endl;
}



Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int D[100001];
int to[200001], ne[200001], he[100001];
void dfsA(int A, int d) {
	D[A] = d;
	for (int t = he[A]; t; t = ne[t]) {
		if (!D[to[t]]) dfsA(to[t], d + 1);
	}
}

int saidai = -1;
void dfsT(int A, int d) {
	chmax(saidai, D[A]);
	D[A] = 0;
	for (int t = he[A]; t; t = ne[t]) {
		if (D[to[t]] > d + 1) dfsT(to[t], d + 1);
	}
}

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


	int N = getint();
	int u = getint(), v = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}
	dfsA(v, 1);
	dfsT(u, 1);
	if (saidai - 2 <= 0) printf("0");
	else printf("%d", saidai - 2);

	Would you please return 0;
}

Measured memory_bytes: 3968
s = input()

# 最初の文字を0にするケース
ptn1 = s[::2].count("1") + s[1::2].count("0")
# 最初の文字を1にするケース
ptn2 = s[::2].count("0") + s[1::2].count("1")

print(min(ptn1, ptn2))



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

using namespace std;

int i,k,t,x,xmax;
int main()
{
    cin>>k>>t;
    for(i=1;i<=t;i++){
        cin>>x;
        xmax=max(xmax,x);
    }
    cout<<max(2*xmax-k-1,0)<<'\n';
    return 0;
}


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

int main(){
    int S;
    cin >> S;
    int h, m, s;
    h=S/3600;
    m=(S/60)-h*60;;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 3220
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    a.sort()
    ans1,ans2=0,0
    j=-1
    for i in range(n-1,-1,-1):
        if i==n-1:
            m=a[i]
        else:
            if a[i]!=m:
                m=a[i]
            else:
                ans1=m
                j=i
                break

    for i in range(j-1,-1,-1):
        if i==j-1:
            m=a[i]
        else:
            if a[i]!=m:
                m=a[i]
            else:
                ans2=m
                break

    print(ans1*ans2)

if __name__=="__main__":
    main()

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

bool kaibun(string str) {
    int l = str.length();
    for (int i = 0; i < l; ++i) {
        if (str[i] != str[l-i-1]) {
            return false;
        }
    }
    return true;
}

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

    int N = S.length();
    bool ok = kaibun(S)
        && kaibun(S.substr(0, (N-1)/2))
        && kaibun(S.substr((N+3)/2-1));
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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


int main() {
 int A,B,C;
  cin >> A >> B >> C;
  if ((A == B && A != C) || (A == C && A != B) || (B == C && A != C) ){
	cout<< "Yes"<<endl;
  }
  else {
  cout <<"No"<<endl;  
  }
  
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define int long long
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
multiset<int> st;
string s;
vector<int> v;

main(void){
	scanf("%lld %lld",&n,&m);
	FOR{
		scanf("%lld",&a[i]);
		st.insert(-a[i]);
	}
	while(m--){
		auto it=st.begin();
		int at=-*it;
		st.erase(it);
		st.insert(-(at/2));
	}
	for(auto it=st.begin();it!=st.end();it++)cev+=-*it;
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 5760
import sys
input=sys.stdin.readline
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N = int(input())
A = {}
B = {}
for i in range(N):
    a,b = map(int,input().split())
    A[i] = a
    B[i] = b
B = sorted(B.items(),key = lambda x:x[1])
time = 0
c = 0
for i in range(N):
    index = B[i][0]
    a = A[index]
    time += a
    if B[i][1] < time:
        c = 1
        break
if c == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62516
//
//  abc150_a.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll INF = 1000000007;
#define PI 3.14159265

const int MAX = 110000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i=2; i<MAX; i++) {
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll COM(int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k]* finv[n-k] % mod) % mod;
}

ll HCOM(int n, int k) {
    return (n == 0 && k == 0) ? 1 : COM(n+k-1, k);
}


int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;

  int sum  = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      sum++;
    }
  }

  std::cout << sum << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include<math.h>
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
using namespace std;


int main(){
	int k;
	cin >> k;
	int i, j;
	int A[k];
	rep(i, k)
		cin >> A[i];

	long long l[k+1], r[k+1];
	l[k] = 2;
	r[k] = 2;
	bool flag = true;
	long long x, y;

	RREP(i,k-1,0){
		x = A[i] * ((l[i+1] - 1) / A[i] + 1);
		y = A[i] * ((r[i+1] - 0) / A[i]);
		if (x > y){
			cout << -1 << endl;
			return 0;
		}

		l[i] = x;
		r[i] = y + A[i] - 1;
	}
	if(flag)
		cout << l[0] <<" " << r[0] << endl;
	else
		cout << -1 <<endl;
	return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
using namespace std;
const int N=100005;
int n,x,y,z,head[N],sum,s,t,maxx;
int step[N],next[N][2],cnt[N],p[N],q[N];
struct edge
{	int to,next;}a[N<<1];
int read()
{	char x=getchar();
	while(x<48||x>57) x=getchar();
	int ans=0;
	while(x>=48&&x<=57)
	{	ans=(ans<<1)+(ans<<3)+(x^48);
		x=getchar();
	}
	return ans;
}
void insert(int x,int y)
{	sum++;a[sum].to=y;a[sum].next=head[x];head[x]=sum;}
void find(int num,int fa)
{	step[num]=step[fa]+1;
	if(step[num]>maxx){maxx=step[num];s=num;}
	int x;
	for(int i=head[num];i;i=a[i].next)
	{	x=a[i].to;
		if(x!=fa) find(x,num);
	}
}
bool judge(int num,int fa)
{	next[num][0]=fa;
	int x;
	for(int i=head[num];i;i=a[i].next)
	{	x=a[i].to;
		if(x==fa) continue;
		if(judge(x,num)) return true;
		cnt[num]++;
		if(cnt[x])
		{	if(next[num][1]) return true;
			next[num][1]=x;
		}
	}
	if(cnt[num]&&!next[num][1]) t=num;
	return false;
}
int main()
{	n=read();
	for(int i=1;i<n;i++)
	{	x=read();y=read();
		insert(x,y);insert(y,x);
	}
	find(1,0);
	if(judge(s,0)){printf("-1\n");return 0;}
	s=next[s][1];next[s][0]=0;
	p[1]=1;x=1;p[n]=n;
	while(s)
	{	for(int i=1;i<cnt[s];i++)
		p[x+i]=x+i+1;
		p[x+cnt[s]]=x+1;
		x+=cnt[s];s=next[s][1];
	}
	q[1]=1;x=1;q[n]=n;
	while(t)
	{	for(int i=1;i<cnt[t];i++)
		q[x+i]=x+i+1;
		q[x+cnt[t]]=x+1;
		x+=cnt[t];t=next[t][0];
	}
	for(int i=1;i<=n;i++)
	{	if(p[i]<q[i])
		{	for(int i=1;i<=n;i++) printf("%d ",p[i]);
			return 0;
		}
		if(q[i]<p[i])
		{	for(int i=1;i<=n;i++) printf("%d ",q[i]);
			return 0;
		}
	}
	for(int i=1;i<=n;i++) printf("%d ",p[i]);
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N, M;
	cin >> N >> M;

	vector<int> a( N+1 ), b( M+1 );
	cin >> a[0] >> b[0];

	for( int i = 1; i <= N; ++i ) { cin >> a[i]; }
	for( int i = 1; i <= M; ++i ) { cin >> b[i]; }

	sort( a.begin(), a.end() );
	sort( b.begin(), b.end() );

	cout << (a.back() < b.front() ? "No " : "") << "War" << endl;
	return 0;
}


Measured memory_bytes: 256
import scala.io.Source.stdin

object Main {
  def hand(i:Int,j:Int,k:Int,l:Int,m:Int):String = {
    if( (j,k,l) == (i,i,i) || (k,l,m) == (j,j,j) ) "four card"
    else if( (j,l,m) == (i,k,k) || (j,k,m) == (i,i,l) ) "full house"
    else if( (j,k) == (i,i) || (k,l) == (j,j) || (l,m) == (k,k) ) "three card"
    else if( (j,l) == (i,k) || (j,m) == (i,l) || (k,m) == (j,l) ) "two pair"
    else if( i== j || j == k || k == l || l == m ) "one pair"
    else if( (i,j,k,l,m) == (i,i+1,i+2,i+3,i+4) || (i,j,k,l,m) == (1,10,11,12,13) ) "straight"
    else "null"
  }

  def main(args:Array[String]) = {
    stdin.getLines.foreach { s=>
      val l = s.split(",").map(_.toInt).sorted
      println(hand(l(0),l(1),l(2),l(3),l(4)))
    }
  }
}

Measured memory_bytes: 44048
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int dp[1100][5000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    auto c = make_vec<int>(M);
    REP(i, M) {
        int b;
        cin >> a.at(i) >> b;
        REP(j, b) {
            int tmp;
            cin >> tmp;
            tmp--;
            int mask = 1 << tmp;
            c[i] = c[i] | mask;
        }
    }

    REP(i, 1100) {
        REP(j, 5000) { dp[i][j] = INF; }
    }
    REP(i, 1100) { dp[i][0] = 0; }

    REP(i, M) {
        REP(j, 1 << N) {
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | c[i]], dp[i][j] + a[i]);
        }
    }
    /*
        REP(i, 1 << N) { cout << std::bitset<4>(i) << " "; }
        cout << endl;
        REP(i, M) {
            REP(j, 1 << N) { cout << dp[i][j] << " "; }
            cout << endl;
        }
    */
    if (dp[M][(1 << N) - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << dp[M][(1 << N) - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 21760
package main

import "fmt"

func main() {
	var a, b, k, c int
	fmt.Scan(&a, &b, &k)
	for i := a; i >= 1; i-- {
		if a%i == 0 && b%i == 0 {
			c++
			if c == k {
				fmt.Println(i)
			}
		}
	}
}


Measured memory_bytes: 512
import itertools
n = int(input())
a = list(map(int,input().split()))
sum = list(itertools.accumulate(a))
#'+-+-...'と'-+-+...'でそれぞれ求める
res1 = 0
res2 = 0
dif1 = 0
dif2 = 0
for i in range(n):
    s = sum[i] + dif1
    t = sum[i] + dif2
    if i%2==0:
        if s<1:
            dif1 += 1 - s
            res1 += 1 - s
        if t>-1:
            dif2 -= 1 + t
            res2 += 1 + t
    else:
        if s>-1:
            dif1 -= 1 + s
            res1 += 1 + s
        if t<1:
            dif2 += 1 - t
            res2 += 1 - t
    #print(dif1,res1,dif2,res2)
print(min(res1,res2))
#print(res1,res2)


Measured memory_bytes: 14212
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
int main(){
	int n,t,a;
	cin>>n>>t>>a;
	vector<int> v(n,0);
	rep(i,n) cin>>v[i];
	int kai;
	double sa=1000000000;
	rep(i,n){
		if(abs(a-(t-v[i]*0.006))<sa){
			sa=abs(a-(t-v[i]*0.006));
			kai=i+1;
		}
	}
	cout<<kai<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <limits.h>
using namespace std;
typedef long long ll;


int main()
{
	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC";
	else cout << "ABC";
}

Measured memory_bytes: 3624
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define SIZE(a) (int)((a).size())
#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())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cap, rev;
};

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

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  return s;
}

void add_edge(vector< vector<edge> >& G, int from, int to, int cap) {
  G[from].push_back((edge){ to, cap, SIZE(G[to])   });
  G[to].push_back((edge){ from, 0, SIZE(G[from])-1 });
}

int dfs(vector< vector<edge> >& G, vector<bool>& used, int v, int t, int flow)
{
  if (v == t) {
    return flow;
  }
  used[v] = true;

  rep(i, 0, G[v].size()) {
    edge& e = G[v][i];
    if (used[e.to] || e.cap == 0) {
      continue;
    }
    int d = dfs(G, used, e.to, t, min(e.cap, flow));
    if (d > 0) {
      e.cap -= d;
      G[e.to][e.rev].cap += d;
      return d;
    }
  }

  return 0;
}

int max_flow(vector< vector<edge> >& G, int s, int t)
{
  int flow = 0;
  vector<bool> used(G.size());
  for (;;) {
    fill(used.begin(), used.end(), false);
    int f = dfs(G, used, s, t, INF);
    if (f == 0) {
      return flow;
    }
    flow += f;
  }
}


signed main()
{
  int N; cin >> N;
  vector< vector<edge> > G(N+2, vector<edge>());

  int sum = 0;
  rep(i, 0, N) {
    int a; cin >> a;
    if (a < 0) {
      add_edge(G, 0, i+1, -a);
    } else {
      add_edge(G, i+1, N+1, a);
      sum += a;
    }
  }

  rep(i, 1, N+1) {
    for(int j=2; i*j <= N; ++j) {
      add_edge(G, i, i*j, INF);
    }
  }

  cout << sum - max_flow(G, 0, N+1) << endl;

  return 0;
}


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

// input
int N, K;


void input() {
    cin >> N >> K;
}


int main() {
    input();
    int ans = 1;
    rep(i, N) {
        if (ans < K) ans *= 2;
        else ans += K;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
//
//  main.c
//  1_9 a
//
//  Created by x17037xx on 2018/06/12.
//  Copyright © 2018年 x17037xx. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, const char * argv[]) {
    char W[11];
    char T[1001];
    char E[20]="END_OF_TEXT";
    
    int i=0,j;
    
    scanf("%s",W);
    
    while(1){
        scanf("%s",T);
        
        if(strcmp(T,E)==0){
            break;
        }
        
        for(j = 0; T[j] != '\0'; j++){
            
            T[j] = tolower(T[j]);
            
        }
        
//        printf("%s",T);
        
        if(strcmp(W,T) == 0){// 比較した文字列が一致した場合の処理
            i++;
        }
        
        
        
    }
    
    printf("%d\n",i);
    
    return 0;
}


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

int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  int ans;
  if(x>=y){
    ans=2*c*x;
    ans=min(ans, 2*c*y+(x-y)*a);
    ans=min(ans, a*x+b*y);
  }else{
    ans=2*c*y;
    ans=min(ans, 2*c*x+(y-x)*b);
    ans=min(ans, a*x+b*y);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256