akhauriyash/Code-Regression huggingface dataset:
r,c,k = map(int, input().split())
rckl = [ [0]*c for _ in range(r) ]

for _ in range(k):
    r_,c_,v_ = map(int, input().split())
    rckl[r_-1][c_-1] = v_

dp0 = [ [0]*c for _ in range(r) ]
dp1 = [ [0]*c for _ in range(r) ]
dp2 = [ [0]*c for _ in range(r) ]
dp3 = [ [0]*c for _ in range(r) ]


dp1[0][0] = rckl[0][0]

for i in range(r):
    for j in range(c):
        if j+1 < c: 
            dp0[i][j+1] = max(dp0[i][j], dp0[i][j+1]) 
            dp1[i][j+1] = max(dp1[i][j], dp1[i][j+1]) 
            dp2[i][j+1] = max(dp2[i][j], dp2[i][j+1]) 
            dp3[i][j+1] = max(dp3[i][j], dp3[i][j+1]) 
            if rckl[i][j+1] > 0:
                v = rckl[i][j+1] 
                dp1[i][j+1] = max(dp1[i][j+1], dp0[i][j] + v)
                dp2[i][j+1] = max(dp2[i][j+1], dp1[i][j] + v)
                dp3[i][j+1] = max(dp3[i][j+1], dp2[i][j] + v)

        if i+1 < r: 
            dp0[i+1][j] = max(dp0[i][j], dp1[i][j], dp2[i][j], dp3[i][j], dp0[i+1][j]) 
            if rckl[i+1][j] > 0:
                v = rckl[i+1][j] 
                dp1[i+1][j] = max(dp1[i+1][j], dp0[i][j]+v, dp1[i][j]+v, dp2[i][j]+v, dp3[i][j]+v)


ans = max(dp0[-1][-1], dp1[-1][-1], dp2[-1][-1], dp3[-1][-1])
print(ans)


Measured memory_bytes: 432260
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3],sum;
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    sum=2*a[2]-a[0]-a[1];
    if(sum%2==0)cout<<sum/2;
    else cout<<sum/2+2;
    return 0;
}

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

int main()
{
    int a=0,b=0,o=0,ab=0;
    string str,tmp;
    while (cin >> str)
    {
	tmp = str.erase(0,str.find(",")+1);
	if (tmp == "A")
	{
	    a++;
	} else if (tmp == "B") {
	    b++;
	} else if (tmp == "AB") {
	    ab++;
	} else if (tmp == "O") {
	    o++;
	}
    }
    cout << a << endl << b << endl << ab << endl << o << endl;
    return 0;
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!



N, W = map(int, input().split())
v = [None] * N
w = [None] * N
for i in range(N):
    v[i], w[i] = map(int, input().split())
    
dp = [[0] * (W+1) for i in range(N)]
ans = 0

for i in range(0, N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]]+v[i])
        elif i >= 1:
            dp[i][j] = dp[i-1][j]
        ans = max(ans, dp[i][j])

print(ans)







Measured memory_bytes: 15644
if __name__ == '__main__':
    # ??????????????\???
    # T = 'abc'
    # P = 'xyz'
    T = input()
    P = input()

    # ???????????????
    results = []

    for i in range(len(T) - len(P) + 1):
        temp = T[i:i+len(P)]
        if temp == P:
            results.append(i)

    # ???????????¨???
    for r in results:
        print(r)

Measured memory_bytes: 49580
#include <iostream>
using namespace std;
int A[3][3];
bool b[101];

int main(void) {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i <= 100; i++) b[i] = false;
	
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int B;
		cin >> B;
		b[B] = true;
	}

	bool ans = false;
	if (b[A[0][0]] && b[A[0][1]] && b[A[0][2]]) ans = true;
	if (b[A[1][0]] && b[A[1][1]] && b[A[1][2]]) ans = true;
	if (b[A[2][0]] && b[A[2][1]] && b[A[2][2]]) ans = true;
	if (b[A[0][0]] && b[A[1][0]] && b[A[2][0]]) ans = true;
	if (b[A[0][1]] && b[A[1][1]] && b[A[2][1]]) ans = true;
	if (b[A[0][2]] && b[A[1][2]] && b[A[2][2]]) ans = true;
	if (b[A[0][0]] && b[A[1][1]] && b[A[2][2]]) ans = true;
	if (b[A[0][2]] && b[A[1][1]] && b[A[2][0]]) ans = true;

	if (ans) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
while True :
    m,f,r = map(int,input().split())
    if m == f == r == -1 : break
    if m == -1 or f == -1 : ans = "F"
    elif (m+f >= 80) : ans = "A"
    elif (m+f >= 65) : ans = "B"
    elif (m+f >= 50) : ans = "C"
    elif (m+f >= 30) :
        if (r >= 50) : ans = "C"
        else : ans = "D"
    else : ans = "F"
    print(ans)
    


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

int main() {
  int A, B;
  cin >> A >> B;
  
  for(int i;i < B + 2;i++){
    cout << "#";
  }
  
  cout << endl;
  
  for(int i;i < A;i++){
    cout << "#";
      string pic;
      cin >> pic;
      cout << pic;
    cout << "#" << endl;
  }
  
  for(int i;i < B + 2;i++){
    cout << "#";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,K,S;
    cin>>N>>K>>S;
    for(ll i=0;i<N;i++){
        if(S!=INF){
            if(i<K) cout<<S;
            else cout<<S+1;
        }else{
            if(i<K) cout<<S;
            else cout<<"1";
        }
        if(i!=N-1) cout<<" ";
    }
    cout<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,q;
vl stx[e5];
ll d[e5];
set<ll> s;

int main(){
  cin >> n >> q;
  for(ll i = 0;i < n;i++){
    ll s,t,x;
    cin >> s >> t >> x;
    stx[i*2] = vl({s-x,x});
    stx[i*2+1] = vl({t-x,-x});
  }
  for(ll i = 0;i < q;i++){
    ll d;
    cin >> d;
    stx[2*n+i] = vl({d,INF});
  }
  // cerr << "---------" << endl;
  sort(stx,stx+(2*n+q));
  for(ll i = 0;i < 2*n+q;i++){
    // cerr << stx[i][0] << " " << stx[i][1] << endl;
    if(stx[i][1] == INF){
      if(s.size() == 0) cout << -1 << endl;
      else cout << *s.begin() << endl;
    }else if(stx[i][1] > 0){
      s.insert(stx[i][1]);
    }else{
      s.erase(stx[i][1]*(-1));
    }
  }
}


Measured memory_bytes: 54016
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    println!("{}", (n-1)*n/2);
}


Measured memory_bytes: 8572
#include<stdio.h>
#define MAX 2000000

int n, tree[MAX+1];

void maxHeapify(int i){
  int l, r, large, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= n && tree[l] > tree[i] ) large = l;
  else large = i;
  if ( r <= n && tree[r] > tree[large] ) large = r;
  if ( large != i ){
    t = tree[i]; tree[i] = tree[large]; tree[large] = t;
    maxHeapify(large);
  }
}

int main(){
  int i;
  scanf("%d", &n);
  for ( i = 1; i <= n; i++ ) scanf("%d", &tree[i]);

  for ( i = n/2; i >= 1; i-- ) maxHeapify(i);

  for ( i = 1; i <= n; i++ ) {
    printf(" %d", tree[i]);
  }
  printf("\n");



  return 0;
}



Measured memory_bytes: 3648
/**
 * @author Video Vocabulary
 * @date 2020-05-31 18:43:19
 */
#include <bits/stdc++.h>

using namespace std;

long long biggest = pow(10, 18);

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

    int n;
    cin >> n;
    long long a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    long long sum = 1;
    for (int i=0; i<n; i++) {
        if (biggest / sum < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        sum *= a[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 4428
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
#define REP(i,n) for (int i = 0; i < n; ++i)

int N;
vector<int> A;
map<int, int> m;

int main () {
    cin >> N;
    A = vector<int>(N);
    REP (i, N) {
       cin >> A[i];
        m[A[i]]++;
    }
    sort(A.rbegin(), A.rend());

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (m[A[i]] == 0) continue;
        m[A[i]]--;
        int target = 1;
        while (target <= A[i]) target *= 2;
        target -= A[i];
        if (m[target] > 0) {
            m[target]--;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 19712
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

while True:
    n,p = inpl()
    if n == 0:
        break
    else:
        x = 0
        S = p
        temoto = [0]*n
        while True:
            if p != 0:
                p -= 1
                temoto[x] += 1
                if p == 0 and temoto[x] == S:
                    print(x)
                    break
            else:
                p += temoto[x]
                temoto[x] = 0

            x += 1
            if x == n:
                x = 0
        



Measured memory_bytes: 7456
#include<bits/stdc++.h>
    #include<string.h>
    using namespace std;
    int main(){
        char a[100];
        long long int b;
        cin>>a>>b;
        for(int i=0;i<b;i++){
            if(a[i]!='1') {
                cout<<a[i]<<endl;
                return 0;
            }

        }
        cout<<'1'<<endl;
    }


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

int main() {
	int taro = 0;
	int hana = 0;
	int card;
	cin >> card;
	string tani, hani;

	for (int i = 0; i < card; i++) {
		cin >> tani >> hani;

		if (tani > hani) taro = taro + 3;
		else if (tani < hani) hana = hana + 3;
		else taro++, hana++;
	}

	cout << taro << " " << hana << endl;

	return 0;
}


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

int main(){
    ll a;
    cin >> a;
    ll s = a * (a - 1) / 2;
    cout << s << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int m = int.Parse(Console.ReadLine());
    var sb = new StringBuilder();
    while (m-- > 0) {
      var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
      int p = arr[0] - 1;
      int x = arr[1];
      int tmp = t[p];
      t[p] = x;
      sb.AppendLine(t.Sum().ToString());
      t[p] = tmp;
    }
    Console.Write(sb);
  }
}

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

int smallest(int a, int b, int c) {
    int s = min(a, b);
    s = min(s, c);
    return s;
}

int main() {
    int h, w;
    cin >> h;
    cin >> w;
    int tile[h+1][w+1];
    int dp[h+1][w+1];
    int ans = 0;
    rep(i, h+1) {
        rep(j, w+1) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            }
            else {
                cin >> tile[i][j];
                if (tile[i][j] == 0) {
                    dp[i][j] = 1 + smallest(dp[i-1][j], dp[i-1][j-1], dp[i][j-1]);
                    ans = max(ans, dp[i][j]);
                } else {
                    dp[i][j] = 0;
                }
            }
        }
    }
    printf("%d\n", ans * ans);
}


Measured memory_bytes: 18556
// https://atcoder.jp/contests/abc089/tasks/abc089_c
#include <cstdio>
#include <vector>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int SZ = 5;
char s[20];

signed main() {
    int n;
    scanf("%lld", &n);
    vector<int> cnt(SZ);

    for (int i = 0; i < n; i++) {
        scanf("%s", s);
        if (s[0] == 'M')
            cnt[0]++;
        else if (s[0] == 'A')
            cnt[1]++;
        else if (s[0] == 'R')
            cnt[2]++;
        else if (s[0] == 'C')
            cnt[3]++;
        else if (s[0] == 'H')
            cnt[4]++;
    }
    int ans = 0;
    REP(i, SZ) FOR(j, i + 1, SZ) FOR(k, j + 1, SZ) {
        ans += (cnt[i] * cnt[j] * cnt[k]);
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
	long long int n;
	scanf ("%lld", &n);

	long long int arr[n];
	for (long long int i = 0; i < n; i++){
		scanf ("%lld", &arr[i]);
	}

	for (long long int i = 0; i < n; i++){
		if (arr[i] == 0){
			printf("0\n");
			return 0;
		}
	}

	long long int sum = 1;
	for (long long int i = 0; i < n; i++){
		if (arr[i] <= 1000000000000000000 / sum){
			sum *= arr[i];
		}
		else {	
		printf ("-1\n");
		return 0;
		}
	}
	
	printf ("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 2484
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ll x,k,d;
	cin>>x>>k>>d;
	x = abs(x);
	ll t = x/d;
	if(t>=k)
	{
		x-=k*d;
		cout<<x<<"\n";
		return 0;
	}
	x = x%d;
	k-=t;
	if(k%2)
		x-=d;
	x = abs(x);
	cout<<x<<endl;
	return 0;
}

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

int main(){
	string s,t,Result;
	getline(cin,s);
	s.insert(s.begin(),'\0');
	//cout<<"DEBUG: String s is "<<s<<" with size "<<s.size()<<endl;
	getline(cin,t);
	t.insert(t.begin(),'\0');
	//cout<<"DEBUG: String t is "<<t<<" with size "<<t.size()<<endl;
	int Table[3100][3100];
	int i,j;
	for(i=0;i<s.size();i++){
		for(j=0;j<t.size();j++){
			if(s[i]=='\0'||t[j]=='\0'){
				Table[i][j]=0;
				//cout<<"DEBUG: Null character, ("<<i<<","<<j<<") is "<<Table[i][j]<<endl;
			}
			else if(s[i]==t[j]){
				Table[i][j]=1+Table[i-1][j-1];
				//cout<<"DEBUG: Same character, ("<<i<<","<<j<<") is "<<Table[i][j]<<endl;
			}
			else{
				Table[i][j]=max(Table[i-1][j],Table[i][j-1]);
				//cout<<"DEBUG: Different characters, ("<<i<<","<<j<<") is "<<Table[i][j]<<endl;
			}
		}
	}
	//cout<<"DEBUG: The longest subsequence is "<<Table[s.size()-1][t.size()-1]<<" characters long"<<endl;
	i=s.size()-1;
	j=t.size()-1;
	while(Table[i][j]>0){
		if(Table[i][j]==Table[i][j-1]){
			j--;
			//cout<<"DEBUG: Current result="<<Result<<", i="<<i<<", j="<<j<<endl;
		}
		else if(Table[i][j]==Table[i-1][j]){
			i--;
			//cout<<"DEBUG: Current result="<<Result<<", i="<<i<<", j="<<j<<endl;
		}
		else if(Table[i][j]==Table[i-1][j-1]+1){
			Result.insert(Result.begin(),s[i]);
			i--;
			j--;
			//cout<<"DEBUG: Current result="<<Result<<", i="<<i<<", j="<<j<<endl;
		}
	}
	cout<<Result;
	return 0;
}


Measured memory_bytes: 37760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	vector<double> a(n);
	double sum = 0;

	for(int i = 0 ; i < n; i++)
	{
		cin>>a[i];
		// sum+=(1.0/(1.0*a[i]));

	}
	sort(a.begin(), a.end());
	sum = a[0];
	for(int i = 1; i < n; i++)
	{
		sum=(sum+a[i])/2.0;
	}
	double ans = (1.0/sum);
	cout<<fixed<<setprecision(6)<<sum<<endl;
}
	

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


int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    set<int> waterS, sugarS;

    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 30; j++) {
            int water = 100 * A * i + 100 * B * j;
            if (water <= F)
                waterS.insert(water);
        }
    }

    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            int sugar = i * C + j * D;
            if (sugar <= F)
                sugarS.insert(sugar);
        }
    }
    double max_v = -1e20;
    int max_s=0, max_f = 0;

    for (auto water : waterS) {
        for (auto sugar : sugarS) {
            int sum = water + sugar;
            if (sum > F)
                continue;
            double per = ((double) (100 * sugar)) / (double) (sum);
            if (per > max_v && (water / 100 * E) >= sugar) {
                max_s = sugar;
                max_f = sum;
                max_v = per;
            }
        }
    }
    cout << max_f << " " << max_s << endl;
}

Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=100;
int n,v[N],c[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=1;i<=n;i++)scanf("%d",&c[i]),v[i]-=c[i];
	int ans=0;
	for(int i=1;i<=n;i++)if(v[i]>0)ans+=v[i];
	cout<<ans;
}

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

namespace ABC143D
{
    class Program
    {
        static int ans = 0;
        static void Main(string[] args)
        {
            int N=int.Parse(Console.ReadLine());
            string[] Linput = Console.ReadLine().Split(' ');
            int[] L = new int[N];
            for(int i = 0; i < N; i++)
            {
                L[i] = int.Parse(Linput[i]);
            }
            Array.Sort(L);
            //Console.WriteLine(string.Join(" ",L));
            for (int i = 0; i < N - 2; i++)
            {
                for(int j = i + 1; j < N-1; j++)
                {
                    nibun(j + 1, N - 1, L, L[i] + L[j], j);
                    //Console.WriteLine(ans);
                }
                //Console.WriteLine(ans);
            }
            Console.WriteLine(ans);
        }
        static void nibun(int min, int max, int[] L, int ab, int j)
        {
            int center = (min + max) / 2;
            if (min == center)
            {
                if (L[min] == ab)
                {
                    while (L[min] == L[min - 1]&&min>j)
                    {
                        min -= 1;
                    }
                    ans += min - j - 1;
                    //Console.WriteLine("a");
                    //Console.WriteLine(ans);
                }
                else if(L[min]<ab)
                {
                    //

                    if (L[max] >= ab)
                    {
                        ans += min - j;
                        //Console.WriteLine("b");
                        //Console.WriteLine(ans);
                    }
                    else
                    {
                        ans += max - j;
                        //Console.WriteLine("c");
                        //Console.WriteLine(ans);
                    }
                }
                return;
            }
            else
            {
                if (L[center] <= ab)
                {
                    nibun(center, max, L, ab, j);
                }
                else
                {
                    nibun(min, center, L, ab, j);
                }
            }
        }
    }
}


Measured memory_bytes: 27956
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean ans = true;
        if(s.indexOf("W")!=-1&&s.indexOf("E")==-1){
            ans = false;
        }
        if(s.indexOf("E")!=-1&&s.indexOf("W")==-1){
            ans = false;
        }
        if(s.indexOf("N")!=-1&&s.indexOf("S")==-1){
            ans = false;
        }
        if(s.indexOf("S")!=-1&&s.indexOf("N")==-1){
            ans = false;
        }
        System.out.println(ans?"Yes":"No");
    }
}

Measured memory_bytes: 23764
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scan(&S)

	var a int
	a, _ = strconv.Atoi(S[0:2])
	var b int
	b, _ = strconv.Atoi(S[2:])

	if a >= 1 && a <= 12 {
		if b > 12 || b == 0 {
			fmt.Println("MMYY")
		} else {
			fmt.Println("AMBIGUOUS")
		}
	} else if b >= 1 && b <= 12 {
		if a > 12 || a == 0 {
			fmt.Println("YYMM")
		} else {
			fmt.Println("AMBIGUOUS")
		}
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 1772
#include<iostream>

using namespace std;

int main() {
	int num;
	cin >> num;
	cout << "Christmas";
	switch (num)
	{

	case 22:cout << " Eve";
	case 23:cout << " Eve";
	case 24:cout << " Eve";
	default:
		break;
	}
	cout << endl;
}


Measured memory_bytes: 256
parseInt(x)=parse(Int,x)

function main()
	n = readline() |> parseInt
	s = String["" for i in 1:n]
	p = Array{Int}(n)
	for i in 1:n
		a,b = readline() |> split
		s[i] = a
		p[i] = parseInt(b)
	end
	t = String[]
	for i in 1:n
		if !(s[i] in t)
			push!(t,s[i])
		end
	end
	t = sort(t)
	d = Dict{String,Int}()
	for i in 1:length(t)
		d[t[i]] = i
	end
	a = Array{Int}(3,n)
	for i in 1:n
		a[1,i] = i
		a[2,i] = d[s[i]]
		a[3,i] = p[i]
	end
	a = sortcols(a,by=x->x[3],rev=true)
	a = sortcols(a,by=x->x[2])
	for i in 1:n
		println(a[1,i])
	end
end

main()


Measured memory_bytes: 124972
uses math;
var
	N,A,ans,p,now,tmp:int64;
	j,k:Longint;
begin
	read(N,A);
	ans:=N;
	for k:=1 to 39 do begin
		p:=floor(power(N/1,1/(k+1)));
		now:=1;
		for j:=1 to k do now:=now*p;
		for j:=0 to k do begin
			tmp:=A*k+p*k+j+(N+now-1)div now;
			if ans>tmp then ans:=tmp;
			now:=now div p*(p+1);
		end;
	end;
	writeln(ans);
end.

Measured memory_bytes: 128
h, w = map(int, input().split())
t = ["#"] * (w + 2)
s = [["#"] + list(input()) + ["#"] for _ in range(h)]
s.append(t)
s.insert(0, t)
dp_n = [[0] * (w + 2) for _ in range(h + 2)]
dp_s = [[0] * (w + 2) for _ in range(h + 2)]
dp_e = [[0] * (w + 2) for _ in range(h + 2)]
dp_w = [[0] * (w + 2) for _ in range(h + 2)]
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if s[i][j] == ".":
            dp_n[i][j] += dp_n[i - 1][j] + 1
        if s[h + 1 - i][j] == ".":
            dp_s[h + 1 - i][j] += dp_s[h + 2 - i][j] + 1
for j in range(1, w + 1):
    for i in range(1, h + 1):
        if s[i][j] == ".":
            dp_w[i][j] += dp_w[i][j - 1] + 1
        if s[i][w + 1 - j] == ".":
            dp_e[i][w + 1 - j] += dp_e[i][w + 2 - j] + 1
ans = 0
for i in range(1, h + 1):
    for j in range(1, w + 1):
        c = dp_n[i][j] + dp_s[i][j] + dp_e[i][j] + dp_w[i][j] - 3
        if c > ans:
            ans = c
print(ans)

Measured memory_bytes: 312712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define Pr pair<ll,ll>
#define mp make_pair
#define ll long long
using namespace std;
const int N=2*(1e5)+10;
int h[N],ch[N][2],dis[N][2];
ll rec[N];
vector<Pr> f[N];
int n,tot;
ll sum,Mx;
bool cmp1(Pr x,Pr y){return x.first<y.first;}
bool cmp2(Pr x,Pr y){return x.second<y.second;}
void merge(int x){
	int lch=ch[x][0],rch=ch[x][1];
	if (f[lch].size()>f[rch].size()) swap(lch,rch);
	int lsz=f[lch].size(),rsz=f[rch].size();

	sort(f[lch].begin(),f[lch].end(),cmp2);
	sort(f[rch].begin(),f[rch].end(),cmp1);
	rec[0]=f[rch][0].second;
	for (int i=1;i<rsz;++i) rec[i]=min(rec[i-1],f[rch][i].second);
	for (int i=0,j=rsz-1;i<lsz;++i){
		while (j>=0&&f[lch][i].second+f[rch][j].first>Mx) --j;
		if (j>=0) f[x].push_back(mp(f[lch][i].first,rec[j]));
	}

	sort(f[lch].begin(),f[lch].end(),cmp1);
	sort(f[rch].begin(),f[rch].end(),cmp2);
	rec[0]=f[rch][0].first;
	for (int i=1;i<rsz;++i) rec[i]=min(rec[i-1],f[rch][i].first);
	for (int i=0,j=rsz-1;i<lsz;++i){
		while (j>=0&&f[rch][j].second+f[lch][i].first>Mx) --j;
		if (j>=0) f[x].push_back(mp(rec[j],f[lch][i].second));
	}
}
void dfs(int x){
	int u,sz;
	f[x].clear();
	if (ch[x][0]==0&&ch[x][1]==0){
		f[x].push_back(mp(0,0));
		return;
	}
	dfs(ch[x][0]);
	dfs(ch[x][1]);
	sz=f[ch[x][0]].size();
	for (int i=0;i<sz;++i) 
		f[ch[x][0]][i].first+=dis[x][0],f[ch[x][0]][i].second+=dis[x][0];
	sz=f[ch[x][1]].size();
	for (int i=0;i<sz;++i) 
		f[ch[x][1]][i].first+=dis[x][1],f[ch[x][1]][i].second+=dis[x][1];
	merge(x);
}
bool check(ll x){
	Mx=x;
	dfs(1);
	return f[1].size()>0;
}
void solve(){
	ll l=0,r=sum,mid,ans=0;
	while (l<=r){
		mid=l+r>>1;
		if (check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
}

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	int x,y;
	scanf("%d",&n);
	memset(h,-1,sizeof(h));
	tot=0; sum=0;
	for (int i=1;i<n;++i){
		scanf("%d%d",&x,&y);
		if (ch[x][0]) ch[x][1]=i+1,dis[x][1]=y;
		else ch[x][0]=i+1,dis[x][0]=y;
		sum+=y;
	}
	solve();
}

Measured memory_bytes: 31988
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double pi= acos(-1);
  double ans=0;
  if(x>=a*a*b/2){
    double triangle_space = a*b - x/a;
    double b_space = triangle_space*2/a;
    ans = atan(b_space/a)*180/pi;
  }
  
  else{
    double a_water = x*2/(a*b);
    ans = atan(b/a_water)*180/pi;
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
def main():

    q = int(input())
    s = set()

    for _ in range(q):
        para = [int(a) for a in input().split()]

        if para[0] == 0:
            s.add(para[1])
            print(len(s))
        elif para[0] == 1:
            if para[1] in s:
                print("1")
            else:
                print("0")
        elif para[0] == 2:
            s.discard(para[1])
        elif para[0] == 3:

            if len(s) > (para[2] - para[1]):
                for i in range(para[1], para[2] + 1):
                    if i in s:
                        print(i)
            else:
                s = sorted(s)
                for e in s:
                    if para[1] <= e <= para[2]:
                        print(e)
                s = set(s)
main()



Measured memory_bytes: 23300
#include <iostream>

using namespace std;
char field[8][8];

void solve()
{
	for(int i = 0; i < 8; ++i)
	{
		for(int j = 0; j < 8; ++j)
		{
			cin >> field[i][j];
		}
	}
	cout << 90 << endl;
	for(int i = 0; i < 8; ++i)
	{
		for(int j = 7; j >= 0; --j)
		{
			cout << field[j][i];
		}
		cout << endl;
	}
	cout << 180 << endl;
	for(int i = 7; i >= 0; --i)
	{
		for(int j = 7; j >= 0; --j)
		{
			cout << field[i][j];
		}
		cout << endl;
	}
	cout << 270 << endl;
	for(int i = 7; i >= 0; --i)
	{
		for(int j = 0; j < 8; ++j)
		{
			cout << field[j][i];
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1136
x=list(map(int,input()))
if x[-1]==2 or x[-1]==4 or x[-1]==5 or x[-1]==7 or x[-1]==9:
  print("hon")
elif x[-1]==0 or x[-1]==1 or x[-1]==6 or x[-1]==8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 61820
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main(){
    int n;
    cin>>n;
    vector<int> abc(26,0);
    rep(i,n){
        string s;
        cin>>s;
        if(i==0){
            rep(j,s.size()) abc[(int)s[j]-'a']++;
        }
        else{
            vector<int> temp(26,0);
            rep(j,s.size()) temp[(int)s[j]-'a']++;
            rep(j,26)
                abc[j]=min(abc[j],temp[j]);
        }
        //rep(j,26) cout<<abc[j]<<" ";
        //cout<<endl;
    }
    
    rep(i,26) rep(j,abc[i]) cout<<char('a'+i);
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


def MI(): return map(int,input().split())


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

#####segfunc#####
def segfunc(x, y):
    return x*y
#################

#####ide_ele#####
ide_ele = 1
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

def main():
	n=II()
	s=input()
	S=[]
	for i in s:
		S.append(ord(i)-ord("a"))
	
	seg=[SegTree([1]*n,segfunc,ide_ele) for _ in range(26)]
	
	#print(S)
	#print(seg)
	for i in range(n):
		seg[S[i]].update(i,0)
	
	q=II()
	for _ in range(q):
		a,b,c=input().split()
		if int(a)==1:
			b=int(b)
			seg[S[b-1]].update(b-1,1)
			t=ord(c)-ord("a")
			seg[t].update(b-1,0)
			S[b-1]=t
		
		else:
			#print(S)
			b=int(b)
			c=int(c)
			cnt=0
			for se in seg:
				if se.query(b-1,c)==0:
					cnt+=1
			print(cnt)
			
	
	

if __name__=="__main__":
	main()


Measured memory_bytes: 325152
using System;
using System.Collections.Generic;
using System.Linq;

namespace PalindromePhilla
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = Console.ReadLine().ToCharArray();
            int hugs = 0;
            for (int i = 0; i < S.Count() / 2; i++)
            {
                if (S[i] != S[S.Count() - i - 1])
                {
                    hugs++;
                }
            }
            Console.WriteLine(hugs);
        }
    }
}


Measured memory_bytes: 11220
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
auto solve() -> void {
    string s; cin >> s;
    if (s.back() == 's') cout << s << "es\n";
    else cout << s << "s\n";
}
auto main() -> int {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    while (tc--) {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 3648
N, W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0]*100010 for i in range(N+10)]
for i in range(N):
    for now_w in range(W+1):
        if (now_w >= w[i]):
            dp[i+1][now_w] = max(dp[i][now_w-w[i]] + v[i], dp[i][now_w])
        else:
            dp[i+1][now_w] = dp[i][now_w]

print(dp[N][W])

Measured memory_bytes: 120728
from collections import defaultdict
N = int(input())
A = [int(input()) for _ in range(N)]
d = defaultdict(int)

for i in range(N):
  d[A[i]] += 1

ans = 0
for val in d.values():
  if val % 2 == 1:
    ans += 1
    
print(ans)

Measured memory_bytes: 16608
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def saiki(a,x,y)
  return if(x < 0)
  return if(y < 0)
  return if(y >= @h)
  return if(x >= @w)
  return if(a[y][x] == @bad)
  a[y][x] = @bad
  saiki(a,x+1,y)
  saiki(a,x,y+1)
  saiki(a,x-1,y)
  saiki(a,x,y-1)
  
  saiki(a,x+1,y+1)
  saiki(a,x-1,y+1)
  saiki(a,x-1,y-1)
  saiki(a,x+1,y-1)
end
@bad = 0
while true
  @w,@h = inp
  d = []
  break if @w == 0
  @h.times do |i|
    d.push(inp)
  end
  c = 0
  @h.times do |y|
    @w.times do |x|
      if(d[y][x] == 1)
        saiki(d,x,y)
        c += 1
      end
    end
  end
  puts c
end
=begin

=end

Measured memory_bytes: 8880
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int w = sc.nextInt();
    //問題の条件より大きめに初期値を取る
    static long[] weight = new long[110];
    static long[] value = new long[110];
    static long[][] dp = new long[110][101000];
    public static void main(String[] args) {
        //標準入力取得
        for (int i = 0; i < n; i++){
            weight[i] = sc.nextInt();
            value[i] = sc.nextInt();
        }
        //dp初期化
        for (int i = 0; i < 110; i++) {
            for (int j = 0; j < 101000; j++) {
                dp[i][j] = 0;
            }
        }
        for (int i = 0; i < n; i++){
            for (int j = 0; j <= w; j++){
                if (j - weight[i] >= 0) {
                    dp[i + 1][j] = chmax(dp[i + 1][j], dp[i][j - (int)weight[i]] + value[i]);
                }
                dp[i + 1][j] = chmax(dp[i + 1][j], dp[i][j]);
            }
        }
        System.out.println(dp[n][w]);

    }

    public static long chmax(long a, long b){
        if (a < b){
            return b;
        } else {
            return a;
        }
    }
}


Measured memory_bytes: 129108
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(sc.next());
        }
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        long sum = 0;
        for (int i = 0; i < n; i++) {
            if (min > nums[i]) min = nums[i];
            if (max < nums[i]) max = nums[i];
            sum += nums[i];
        }
        System.out.println(min + " " + max + " " + sum);
    }
}


Measured memory_bytes: 41120
#include <cassert>
#include <cctype>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
string S = "";
int cur;
int digit(){
	assert(isdigit(S[cur]));
	int n = S[cur] - '0';
	cur = cur+1;
	return n;
}
int number(){
	int n = digit();
	while(cur < S.size() && isdigit(S[cur]))
		n = n*10 + digit();
	return n;
}
int factor();

int term(){
	int a = factor();
	while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')){
		char op = S[cur++];
		int b = factor();
		if(op == '*'){
			a *= b;
		}else{
			a /= b;
		}
	}
	return a;
}

int expression(){
	int sum = term();
	while (cur < S.size() && (S[cur] == '+' || S[cur] == '-')){
		char op = S[cur];
		cur++;
		int b = term();
		if(op == '+'){
			sum += b;
		}else{
			sum -= b;
		}
	}
	return sum;
}

int factor(){
	if(S[cur] != '('){
		return number();
	}
	cur += 1;
	int n = expression();
	assert(S[cur] == ')');
	cur += 1;
	return n;
}

int main(){
	int N;
	cin >> N;
	for(int i = 0;i<N;i++){
		cur = 0;
		cin >> S;
		S.erase(S.size()-1);
		cout << expression() << endl;
	}
}

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

int g[15][15];
int main() {
    int n;
    cin >> n;
    rep(i, n) rep(j, n) g[i][j] = -1;
    rep(i, n) {
        int m;
        cin >> m;
        rep(j, m) {
            int a, x;
            cin >> a >> x;
            --a;
            g[i][a] = x;
        }
    }
    int ans = 0;
    rep(i, 1 << n) {
        vector<int> d(n);
        rep(j, n) {
            if(i >> j & 1)
                d[j] = 1;
        }
        bool ok = true;
        rep(j, n) {
            if(d[j]) {
                rep(k, n) {
                    if(g[j][k] == -1)
                        continue;
                    if(g[j][k] != d[k])
                        ok = false;
                }
            }
        }
        if(ok)
            ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    return 0;
}


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

class DisjointSet{
    public:
        vector<int> rank, p;
        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for(int i=0; i<size; i++) makeSet(i);
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }
        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }
        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }
            else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main(){
    int n, a, b, q;
    int t;

    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);

    for(int i=0; i<q; i++){
        cin >> t >> a >> b;
        if(t==0) ds.unite(a,b);
        else if(t==1){
            if(ds.same(a,b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	string s;
	cin>>s;
	if(s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{
    int h, a, attacks;
    scanf("%d%d", &h, &a);
    
    while(h > 0)
    {
		h = h - a;
		attacks++;
    }
    
    printf("%d\n", attacks);  
}

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

int main() {
  int N;
  cin >> N;
  bool c = true;
  for (int i = 0;i < N;i++) {
    int n;
    cin >> n;
    if (n%2 == 0) {
      if (n%3 != 0 && n%5 != 0) {
        c = false;
        break;
      }
    }
  }
  cout << ((c) ? "APPROVED" : "DENIED") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(998244353)
#define INF (9e18)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	int x,n; cin>>x>>n;
	set<int> st;
	while(n--){
		int t; cin>>t;
		st.insert(t);
	}
	int ans=101;
	for(int i=100;i>=0;i--){
		if(st.count(i)) continue;
		if(abs(i-x)<=abs(ans-x)) ans=i;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int n,ans;
	ans=0;
	cin >>n;
	vector<int>L(n);
	rep(i,n) cin >>L[i];
	for (int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for (int k=j+1;k<n;k++){
				if (L[i]==L[j] || L[i]==L[k] || L[j]==L[k]) continue;
				if ((L[i]>L[j]) && (L[i]>L[k]) && (L[i]<L[j]+L[k])){
					ans++;
//					cout << L[i] <<" " << L[j] << " " << L[k]<< " " << i<<j<<k<<endl;
				}
				if ((L[j]>L[i]) && (L[j]>L[k]) && (L[j]<L[i]+L[k])){
//					cout << L[i] <<" " << L[j] << " " << L[k]<< " " << i<<j<<k<<endl;
					ans++;
				}
				if ((L[k]>L[i]) && (L[k]>L[j]) && (L[k]<L[j]+L[i])){
//					cout << L[i] <<" " << L[j] << " " << L[k]<< " " << i<<j<<k<<endl;
					ans++;
				}
			}
		}
	}
	cout <<ans<<endl;
	return 0;
}


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

using namespace std;
int long long f(int long long n)
{
	n=n-1;
	int long long r=1;
	r=(n*(n+1))/2;
	return r;
}
int long long fm(int long long n)
{
	int long long r=1;
	r=(n*(n+1))/2;
	return r;
}
int main()
{
	int long long n;
	cin>>n;
	int long long k;
	cin>>k;
	int long long ts=(n*(n+1))/2;
	int long long c=0;
	int long long maxs=0,mins=0;
	unordered_set<int long long> s;
	if(k-n==1)
	{
		c=0;
	}
	else
	{
		for(int long long i=k;i<=n;i++)
		{
			mins=f(i);
			maxs=fm(n-i);
			maxs=ts-maxs;
			
			c+=(maxs-mins+1);
		}
		
	}
	c++;
	c=c%(int)((pow(10,9))+7);
	cout<<c;
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
H = list(map(int, input().split()))

if(N<=K):
    print("0")
else:
    H.sort()
    for _ in range(K):
        H.pop()

    kaisuu = 0
    for i in range(len(H)):
        kaisuu += H[i]

    print(kaisuu)

Measured memory_bytes: 26180
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <time.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i, a) for(i = 0; i < (a); i++)
#define FORM(i, a) for(i = (a) i >= 0; i--)
#define INF 100000
using namespace std;
int c[1000], odd[1000];
int mini[1000001];
int miniodd[1000001];
int main(){
int i, j, W, minimumc, minimumodd, l;
 

   for(i = 1; i <= 200; i++){
	   c[i] = (i*(i+1)*(i+2))/6;
   }
   j = 1;
   for(i = 1; i <= 200; i++){
	   if(c[i] % 2 == 1){
		   odd[j] = c[i];
		   j += 1;
	   }
   }

  FOR(i, 1000000){
	  mini[i] = 10000000;
	  miniodd[i] = 10000000;
  }
  mini[0] = 0;
  miniodd[0] = 0;
   for(j = 1; j <= 180; j++){
	 for(i = c[j]; i <= 1000000; i++){
	   mini[i] = min(mini[i], mini[i - c[j]] + 1);
	 }
   }
      for(j = 1; j <= 50; j++){
	 for(i = odd[j]; i <= 1000000; i++){
	   miniodd[i] = min(miniodd[i], miniodd[i - odd[j]] + 1);
	 }
   }
   
	  cin >> W;

	  while(W != 0){
		  cout << mini[W] << " " << miniodd[W] << endl;

		  cin >> W;
	  }

   

return 0;
}

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

int main() {
  ll n;cin>>n;
  ll mod=1e9+7,cnt1=1,cnt2=1,cnt3=1;
  rep(i,n){
    cnt1*=10;
    cnt1%=mod;
    cnt2*=9;
    cnt2%=mod;
    cnt3*=8;
    cnt3%=mod;
  }
  ll ans=(cnt1-2*cnt2%mod+cnt3)%mod;
  if(ans<0)ans+=mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
import math
N = input()
A = [100, 101, 102, 103, 104, 105]
if len(str(N))  <= 2:
  print(0)
  quit()
last = int(N[-2] + N[-1])
head = int(N[0:-2])
if 105 * head >= int(N):
  print(1)
else:
  print(0)

Measured memory_bytes: 3064
# Aizu Problem ALDS_1_10_A: Fibonacci Number
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


n = int(input())
if n < 2:
    print(1)
else:
    a, b = 1, 1
    for k in range(n - 1):
        a, b = b, a + b
    print(b)

Measured memory_bytes: 7644
while true
  n, r = gets.chomp.split(" ").map(&:to_i)
  break if n == 0 && r == 0
  a =  n.downto(1).to_a
  r.times do
    p_, c = gets.chomp.split(" ").map(&:to_i)
    a1 = a[0...(p_-1)]
    a2 = a[(p_-1)...(p_+c-1)]
    a3 = a[(p_+c-1)...n]
    a = a2 + a1 + a3
  end
  puts a[0]
end
 

Measured memory_bytes: 9040