akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<cstring>    //for memset
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define lli                      int long long
#define ull                      unsigned long long
#define ld                       long double
#define pi                       acos(-1)
#define pb                       push_back
#define pbk                      pop_back
#define mp                       make_pair
#define ff                       first
#define ss                       second
#define pii                      pair<int,int>
#define gcd(a,b)                 __gcd(a,b)
#define lcm(a,b)                (a/gcd(a,b))*b
#define READ                     freopen("in.txt","r",stdin);
#define WRITE                    freopen("outer.txt","w",stdout);
//#define sort(t)                  sort(t.begin(),t.end())
#define mem(a,b)                 memset(a,b,sizeof a)
#define TEST_CASE(t)             for(int z=1;z<=t;z++)
#define PRINT_CASE               printf("Case %d: ",z)
#define LINE_PRINT_CASE          printf("Case %d:\n",z)
#define ordered_set              tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sf                       scanf
#define pf                       printf
#define dist(ax,ay,bx,by)        sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define EQUAL_RANGE(set)    pair<set<int>::const_iterator,set<int>::const_iterator> ret; ret=myset.equal_range(30);
#define MX                       100003
#define inf                      10000000000000000+7
#define M                        1000000002
#define MINI                     -1000000003
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move

//int kx[]={+2,+2,-2,-2,+1,+1,-1,-1};     //Knights move
//int ky[]={+1,-1,+1,-1,+2,-2,+2,-2};     //Knights move


//#define for(i,a,n)    for(int i=a;i<n;i++)
//it=myset.find(20);
//int a[8]= {0,0,-1,1,-1,1,-1,1};
//int b[8]= {-1,1,0,0,-1,1,1  ,-1};

int main()
{
    int n,i,j;
    cin>>n;
    int a[n+5];
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1]<<endl;
        return 0;
}



Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();

            for (int i = 0; i < 1000; i++)
            {
                for (int j = 0; j < 1000; j++)
                {
                    if(4 * i + 7 * j == n)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }

            Console.WriteLine("No");
        }        
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n == 0 )break;
			else calc(n);
			
		}
	}
	public void calc(int n){
		String[] as = new String[n];
		String[] bs = new String[n];
		for(int i = 0; i < n; i++){
			as[i] = sc.next();
			bs[i] = sc.next();
		}
		String y = sc.next();
		String f = sc.next();
		
		
		HashMap<String, Integer> hash = new HashMap<String, Integer>();
		ArrayList<String> list = new ArrayList<String>();
		
		hash.put(y, 0);
		list.add(y);
		
		while(list.size() != 0){
			String now = list.get(0);
			list.remove(0);
			
			for(int i = 0; i < n; i++){
				String after = substitute(now, as[i], bs[i]);
				if(after.equals(f)){
					hash.put(after, hash.get(now) + 1);
					list = new ArrayList<String>();
					break;
				}
				else if(after.length() < f.length() && !hash.containsKey(after)){
					hash.put(after, hash.get(now) + 1);
					list.add(after);
				}
			}
		}
		
		if(hash.containsKey(f)) System.out.println(hash.get(f));
		else System.out.println(-1);
	}

	public String substitute(String input, String a, String b){
		input = input + "!";
		String[] list = input.split(a);
		String ans = list[0];
		for(int i = 1; i < list.length; i++){
			ans += b;
			ans += list[i];
		}
		return ans.substring(0, ans.length()-1);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 63432
#include<string>
#include<iostream>
using namespace std;
int main(){
  string rank[11]={"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
  double d;
  double RANK[11]={0,48.00,51.00,54.00,57.00,60.00,64.00,69.00,75.00,81.00,91.00};
  while(cin>>d){
    for(int i=10;i>=0;i--){
      if(d>RANK[i]){
	cout<<rank[i]<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string S;
  cin >> S;

  int y,m,d;
  y = atoi(S.substr(0, 4).c_str());
  m = atoi(S.substr(5, 2).c_str());
  d = atoi(S.substr(8, 2).c_str());

  if(y <= 2019){
    if(m <= 4){
      if(d <= 30){
        cout << "Heisei" << endl;
        return 0;
      }
    }
  }
  cout << "TBD" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = 998244353;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


ll dfs(Graph& g, ll v,Array& c) {
	bool flag = true;
	for (auto e : g[v]) {
		if (c[e.to] == -1) {
			c[e.to] = !c[v];
			if (!dfs(g, e.to, c)) flag = false;
		}
		else {
			if (c[e.to] == c[v]) flag = false;
		}
	}
	return flag;
}

void solve() {
	ll n, m;
	cin >> n >> m;
	
	Graph g(n);
	
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		add_edge(g, a, b, 1, true, 1);
	}
	Array c(n, -1);
	c[0] = 0;
	if (dfs(g, 0, c)) {
		ll con = 0;
		for (auto i : c)if (i == 0) con++;
		cout << con * (n - con) - m << en;
	}
	else {
		cout << n * (n - 1) / 2 - m << en;
	}
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 12544
use std::io::prelude::*;
use std::io;
use std::str::FromStr;
#[cfg(local)]
use std::fs::File;
#[cfg(local)]
use std::io::BufReader;

#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = String;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    let mut s = input_vectors[0][0].clone();
    loop {
        if s.is_empty() {
            println!("YES");
            break;
        } else if s.find("dreameraser") == Some(0) {
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            continue;
        } else if s.find("dreamerase") == Some(0) {
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            continue;
        } else if s.find("dreamer") == Some(0) {
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            continue;
        } else if s.find("eraser") == Some(0) {
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            continue;
        } else if s.find("dream") == Some(0) {
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            continue;
        } else if s.find("erase") == Some(0) {
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            s.remove(0);
            continue;
        } else {
            println!("NO");
            break;
        }
    }
}


Measured memory_bytes: 636
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X,Y=MI()
    if(Y-2*X>=0 and (Y-2*X)%2==0 and (Y-2*X)/2<=X):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 10852
#include<stdio.h>
#include<string.h>
int main(void){
  char str[10];
  int i=1,j,f=0;
  scanf("%s",str);
  if(str[0]=='A'){
    if(str[1]<'a'||str[1]>'z'){
      f=2;
    }
    for(i=2;i<(strlen(str)-1);i++){
      if(str[i]=='C'){
        f++;
      }else{
        if(str[i]<'a'||str[i]>'z'){
          f=2;
        }
      }
    }
    if(str[i]<'a'||str[i]>'z'){
      f=2;
    } 
  }
  if(f==1){
      printf("AC");
  }else{
    printf("WA");
  }
  return 0;
}

Measured memory_bytes: 128
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
    R int res=1;
    for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
    return res;
}
const int N=2e5+5,M=5005,S=2005;
int a[N],b[N],fac[N],ifac[N],f[M][M],xmx,ymx,n,res;
inline int C(R int n,R int m){return m>n?0:1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
void init(int n){
	fac[0]=ifac[0]=1;
	fp(i,1,n)fac[i]=mul(fac[i-1],i);
	ifac[n]=ksm(fac[n],P-2);fd(i,n-1,1)ifac[i]=mul(ifac[i+1],i+1);
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	fp(i,1,n)scanf("%d%d",&a[i],&b[i]),cmax(xmx,a[i]),cmax(ymx,b[i]);
	init((xmx+ymx)<<1);
	fp(i,1,n)++f[S-a[i]][S-b[i]];
	fp(i,S-xmx,S+xmx)fp(j,S-ymx,S+ymx)if(f[i][j])upd(f[i+1][j],f[i][j]),upd(f[i][j+1],f[i][j]);
	fp(i,1,n)upd(res,f[S+a[i]][S+b[i]]);
	fp(i,1,n)res=dec(res,C((a[i]+b[i])<<1,a[i]<<1));
	printf("%d\n",mul(res,(P+1)>>1));
	return 0;
}

Measured memory_bytes: 84736
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    double w,h;
    int x,y;
    cin >> w >> h >> x >> y;
    cout << w*h / 2 << " ";
    if( w/2 == (double)x and h/2== (double)y) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	cout << a + b + c - max({ a, b, c }) + (max({a, b, c}) << k) << endl;
	return 0;
}

Measured memory_bytes: 256
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c = readInts()
    d = max(a,b,c)*3 - a - b - c
    if d % 2 == 0:
        print(d//2)
    else:
        print(d//2 + 2)

if __name__ == '__main__':
  main()


Measured memory_bytes: 5532
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

before = -1
s = 0
for i in a:
    if before == i-1:
        s+= b[i-1] + c[i-2]
    else:
        s+= b[i-1]
    before = i
print(s)


Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll n, k;
	cin >> n >> k;
	
	vector<ll> as(n);
	for (ll i = 0; i < n; ++i) {
		cin >> as[i];
		--as[i];
	}

	vector<ll> is_visited(n, -1);
	ll count = 0;
	ll idx = 0;
	while (is_visited[idx] == -1) {
		is_visited[idx] = count++;
		idx = as[idx];
	}
	ll loop_start = is_visited[idx];
	ll loop_cycle = count - is_visited[idx];

	if (k >= loop_start) {
		k = (k - loop_start) % loop_cycle + loop_start;
	}

	for (ll i = 0; i < n; ++i) {
		if (is_visited[i] == k) {
			cout << i + 1 << endl;
			break;
		}
	}

	return 0;
}

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

	solve();

	return 0;
}


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

using namespace std;

int n;
vector<vector<int>> ships(1);

bool solve(int i){
	vector<int> vec=ships.at(i);

	bool ret=false;

	for(auto a:vec){
		if(a==n){
			ret=true;
			return ret;
		}
	}

	for(auto a:vec){
		vector<int> hoge=ships.at(a);
		sort(hoge.begin(),hoge.end());

		if(*lower_bound(hoge.begin(),hoge.end(),n)==n){
			ret=true;
			return ret;
		}
	}

	return ret;
}

int main(){
	int m;
	cin>>n>>m;
	vector<int> v;
	for(int i=0;i<n;i++) ships.push_back(v);

	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;

		ships.at(a).push_back(b);
		ships.at(b).push_back(a);
	}

	cout<<(solve(1) ? "POSSIBLE" : "IMPOSSIBLE")<<endl;

	return 0;
}


Measured memory_bytes: 12908
#include <stdio.h>
#include <algorithm>

using namespace std;


int N;
int M[100];
int p[100][100];
int K;
int l[100];

bool input() {
  int i, j;

  scanf("%d", &N);
  if (!N) return false;
  for (i = 0; i < N; i++) {
    scanf("%d", &M[i]);
    for (j = 0; j < M[i]; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  scanf("%d", &K);
  for (i = 0; i < K; i++) {
    scanf("%d", &l[i]);
  }

  return true;
}

int main() {
    int i, j, k, out;

    while (input()) {
      out = -1;
      for (i = 0; i < N; i++) {
        for (j = 0; j < K; j++) {
          for (k = 0; k < M[i]; k++) {
            if (l[j] == p[i][k]) break;
          }
          if (k == M[i]) break;
        }
        if (j == K) {
          if (out == -1) out = i + 1;
          else {
            out = -1;
            break;
          }
        }
      }
      printf("%d\n", out);

    }
    return 0;
}

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

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  if (a - b > w) {
    cout << a - b - w << endl;
  }
  else if (b - a > w) {
    cout << b - a - w << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

int main() {
	int N;
	cin >> N;

	vector<int> D(N);
	for (int i = 0; i < N; i++) cin >> D.at(i);

	int answer = 0;

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			answer += D.at(i) * D.at(j);
		}
	}

	cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[20005][20005],ans;
int fd(int x){
	stringstream ss;
	string st;
	ss<<x;
	ss>>st;
	return st[0]-'0';
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		a[fd(i)][i%10]++;
	}
	for(int i=1;i<=n;i++){
		if(a[i%10][fd(i)]>=1){
			ans+=a[i%10][fd(i)];
			//a[i%10][fd(i)]--;
		} 
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
int main(){
  
  int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,
1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  
  int k;
  cin>>k;
  
  cout<<arr[k-1]<<endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int H,W; cin >> H >> W;
    int cnt[26] = {};

    REP(i,H * W) {
        char c; cin >> c;
        cnt[c - 'a']++;
    }

    if (H % 2 == 1 && W % 2 == 1) {
        int one = 0;
        REP(i,26) {
            if (cnt[i] % 2 == 1) {
                cnt[i]--;
                one++;
            }
        }
        if (one > 1) {
            cout << "No" << endl;
            return 0;
        }
        int even = 0;
        REP(i,26) {
            if (cnt[i] % 4 == 2) even++;
        }
        if (even > H / 2 + W / 2) {
            cout << "No" << endl;
            return 0;
        }
    } else {
        REP(i,26) {
            if (cnt[i] % 2 == 1) {
                cout << "No" << endl;
                return 0;
            }
        }
        int even = 0;
        REP(i,26) {
            if (cnt[i] % 4 == 2) even++;
        }
        if (H % 2 == 1) {
            if (even > W / 2) {
                cout << "No" << endl;
                return 0;
            }
        } else if (W % 2 == 1) {
            if (even > H / 2) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (even > 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int result = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            result++;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
ll DP[N+1], n, m;
bool z[N+1];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m){
    int a;
    cin >> a;
    z[a] = true;
  }
  DP[0]=1;
  FOR(i, 1, n+1){
    DP[i] = (DP[i-1]+(i>1?DP[i-2]:0)) % MOD;
    if(z[i]) DP[i] = 0;
  }
  cout << DP[n] << endl;
}

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

int main(){
    int N;
    cin >> N;
    
    int cnt1 = 0;
    for (int i = 1; i <= N; i++){
        if (i % 2 == 0) continue;
        
        int cnt2 = 0;
        for (int j = 1; j <= i; j++){
            if (i % j == 0) cnt2++;
        }
        if (cnt2 == 8) cnt1++;
    }
    
    cout << cnt1 << endl;
    
    return 0;
}

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

int INF=0x3f3f3f3f;


int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

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

int main()
{
    long int n;
    cin >> n;

    vector <long int> vec;
    long int input;

    for(long int i=0; i<n; i++)
    {
        cin >> input;
        vec.push_back(input);
    }

    sort(vec.begin(),vec.end());

    for(long int j=1; j<vec.size(); j++)
    {
        if(vec[j] == vec[j-1])
        {
            vec.erase(vec.begin() + (j - 1));
            vec.erase(vec.begin() + (j - 1));

            j--;
        }
    }

    cout << vec.size();
    return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  vector<char>r(200, 0);
  for(int i=0; i<s.length(); i++){
    if(r[t[i]]!=0 && r[t[i]]!=s[i]){
      cout << "No";
      return 0;
    }
    else r[t[i]]=s[i];
  }
  r.resize(0);
  r.resize(200, 0);
  for(int i=0; i<t.length(); i++){
    if(r[s[i]]!=0 && r[s[i]]!=t[i]){
      cout << "No";
      return 0;
    }
    else r[s[i]]=t[i];
  }
  cout << "Yes";
  return 0;
}

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

int main(){
    unsigned long k,a,b;
    cin >> k >> a >> b;
    if(a >= b || a+1 == b || k <= a){
        cout << k+1 << endl;
        return 0;
    }
    unsigned long yenExchangeNum = (k-a+1)/2;
    unsigned long result = a + yenExchangeNum*(b-a);
    if((k-a+1)%2 == 1) result++;
    cout << result << endl;
    return 0;
}

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

int a();
void b();
int c[1000],top=0;

int main() {

  int d,e;
  char s[100];

  while(scanf("%s",s)!=EOF) {
    if(s[0]=='+') {
      d = a();
      e = a();
      b(d+e);
    }
    else if(s[0]=='*') {
      d = a();
      e = a();
      b(d*e);
    }
    else if(s[0]=='-') {
      d = a();
      e = a();
      b(e-d);
    }
    else b(atoi(s));
  }
  printf("%d\n",a());

  return 0;
}

int a() {
  top--;
  return c[top+1];
}

void b(int x) {
  c[++top] = x;
}

Measured memory_bytes: 548
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <cstdlib>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<string, int> si;
const int INF = 1 << 29;
const int MAX = 100000;
#define mp make_pair
#define fi first
#define se second

int main() {
    ios::sync_with_stdio(false);
    int n, sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        sum += i;
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

// solve {x_i - x_j = c | (i, j, c) in E}
class Potential {
    vector<ll> par, h;
public:
    vector<ll> pot;
    Potential(ll size) : par(size, 0), h(size, 0), pot(size, 0) {
        rep(i, size) par[i] = i;
    }
    // u - v = cost?
    bool check(ll u, ll v, ll cost) {
        return pot[u] - pot[v] == cost;
    }
    // add: u - v = cost
    bool add(ll u0, ll v0, ll cost) {
        // cout << u0 << " " << v0 << " " << cost << endl;
        ll u = root(u0), v = root(v0);
        if (u == v) {
            // cout << u0 << " " << v0 << " " << cost << " " << check(u0, v0, cost) << endl;
            if (!check(u0, v0, cost)) return false;
            return true;
        }
        if (h[u] > h[v]) {
            pot[v] = -cost + pot[u0] - pot[v0];
            par[v] = u;
        }
        else {
            pot[u] = cost + pot[v0] - pot[u0];
            par[u] = v;
        }
        if (h[u] == h[v]) ++h[u];
        return true;
    }
    bool isUnited(ll u, ll v) {
        return root(u) == root(v);
    }
    ll root(ll v) {
        if (par[v] == v) return v;
        ll r = root(par[v]);
        pot[v] += pot[par[v]];
        return par[v] = r;
    }
};

bool solve() {
    ll n, m; cin >> n >> m;
    Potential pot(n);
    rep(i, m) {
        ll a, b, d; cin >> a >> b >> d; --a, --b;
        if ( !pot.add(b, a, d) ) return false;
    }
    return true;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 2560
h, w = gets.split.map(&:to_i)
pixels = h.times.map { gets.chomp }

valid = true

h.times do |i|
  break unless valid

  w.times do |j|
    next if pixels[i][j] == "."

    next if pixels[i][j - 1] == "#"
    next if pixels[i][j + 1] == "#"
    next if pixels[i - 1][j] == "#"
    next if pixels[i + 1][j] == "#"

    valid = false
    break
  end
end

puts valid ? "Yes" : "No"


Measured memory_bytes: 14368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define comp(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define infile freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvli;
const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    FOR(i,l,r+1){
        if(i%d==0) ans++;
    }
    cout<<ans<<"\n";
    
}





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
	return 0;
	
	
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}


Measured memory_bytes: 3636
n=int(input())
a=[]
for i in range(n):
    s=int(input())
    a.append(s)
A=sum(a)
mi=A
for i in range(n):
    if a[i]%10!=0 and mi>a[i]:
        mi=a[i]
if A%10==0:
    print(A-mi)
else:
    print(A)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
 public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int k=sc.nextInt();
	
	int r=0;
	for(int i=0;i<n;i++)if(sc.nextInt()>=k)r++;		
	System.out.println(r);
 }
}

Measured memory_bytes: 46792
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int const MAXN=3100;
int n, v[MAXN]; 
ll pre[MAXN], memo[MAXN][MAXN];
ll sum(int l, int r){
	return (l==0?pre[r]:pre[r]-pre[l-1]);
}
ll dp(int l, int r){
	if(memo[l][r]!=-1) return memo[l][r];
	if(l==r) return v[l];
	return memo[l][r]=max(v[l]+sum(l+1,r)-dp(l+1,r), v[r]+sum(l,r-1)-dp(l,r-1));
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>v[i];
		pre[i]=v[i];
		if(i!=0) pre[i]+=pre[i-1];	
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			memo[i][j]=-1;
	cout<<dp(0,n-1)-(pre[n-1]-dp(0,n-1));
}

Measured memory_bytes: 74112
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	string s;
	cin >> s;
	int r = 0;
	for (int i = 0; i < s.size(); i++)if (s[i] == 'p')r--;
	r += s.size() / 2;
	printf("%d\n", r);
}

Measured memory_bytes: 512
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split(' ');
        var n = int.Parse(s[0] + s[1]);

        var sqrt = (int)Math.Sqrt(n);
        if (sqrt * sqrt == n)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#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>;

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

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

ll exec(ll a, ll b) {
  if (a == 0) return a;

  ll diff = abs(a - b);
  if (diff >= a) {
    return a;
  }
  return exec(diff, b);
}

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  cout << exec(n, k) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(reader.readLine());
		int[] dp = new int[n+1];
		for(int i =1;i<n;i++){
			for(int j = 1;j<n;j++){
				for(int k = 1;k<=n;k++){
					long p = ((i+j)*(i+j) + (j+k)*(k+j) + (i+k)*(i+k))/2; 
					if( p>n){
						break;
					}
					else{
						dp[(int)p]++;
					}
				}
			}
		}
		for(int i = 1;i<=n;i++){
			writer.write(dp[i]+"\n");
		}
		writer.flush();
	}
}


Measured memory_bytes: 36900
#include <bits/stdc++.h>
using namespace std;
#define UF_SIZE 1 // 1/0: 同値類のサイズを記録する/しない

struct UnionFind{
// 同値関係をサポートするデータ構造
// 併合,所属する同値類の代表元:O(logN), 集合の分割はNG
// 経路圧縮する場合,各クエリはO(a(n)) (a(n): アッカーマン関数A(m,n)について,f(n)=A(n,n)としたときの逆関数)
  int Ncomp;
  vector<int> m_root;
#if (UF_SIZE==1)
  vector<int> m_size;
#endif

  UnionFind(int N)
  : m_root(N)
  , Ncomp(N)
#if (UF_SIZE==1)
  , m_size(N,1)
#endif
  { iota(m_root.begin(), m_root.end(), 0); }

  int find(int a){
    if(m_root.at(a)==a){
      return a;
    }
    else{
      return m_root.at(a)= find(m_root.at(a));
    }
  }

  void unify(int a, int b){
    int r_a= find(a);
    int r_b= find(b);
#if (UF_SIZE==1)
    if(r_a != r_b){
      Ncomp--;
      if(m_size.at(r_a) < m_size.at(r_b)){
        m_root.at(r_a)= r_b;
        m_size.at(r_b)+= m_size.at(r_a);
        return;
      }
      else{
        m_root.at(r_b)= r_a;
        m_size.at(r_a)+= m_size.at(r_b);
        return;
      }
    }
#else
    if(r_a != r_b){
      m_root.at(r_b)= r_a;
      return;
    }
#endif
  }
  
  bool are_comrade(int a, int b){
    return find(a)==find(b);
  }

#if (UF_SIZE==1)
  int get_size(int a){
    return m_size.at(find(a));
  }
#endif
  int get_Ncomp(){
    return Ncomp;
  }
};

int main(){
  int N,M;
  cin >> N >> M;

  UnionFind uf(N);
  int idx1,idx2,buf;
  for(int i=0; i<M; i++){
    cin >> idx1 >> idx2 >> buf;
    idx1--; idx2--; // 1-indexed -> 0-indexed
    uf.unify(idx1, idx2);
  }

  cout << uf.get_Ncomp() << endl;
}

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

int main() {
	long long H, W;
	cin >> H >> W;
	if ((1 == H) || (1 == W)) {
		cout << 1 <<endl;
		return 0;
	}
	long long S = H * W;
	cout << (S + 1) / 2 << endl;
	return 0;
}

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

const int INF = 1e9;

//2次元ベクトルを表示
void printVec(const vector<vector<int>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool isMulti = false;
  for (int i = A; i <= B; ++i) {
    if (i % K == 0) {
      isMulti = true;
      break;
    }
  }
  isMulti ? cout << "OK" << endl : cout << "NG" << endl; 
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
14111
とかは、4が4番目以降にでないとNG
N100少ない
[1] 1 1 2 2 1 2 3 2
[1] 1 2 2 1 2 3 2
1 [2] 2 1 2 3 2
1 [2] 1 2 3 2
[1] 1 2 3 2
1 2 [3] 2
1 [2] 2
1 [2]
1
n番目とnが合致してるうち、最大のものをとればいいのね
毎回100通り確認。100*100で余裕
*/
int main(){
  ll N; cin>>N;
  vector<ll> A(0,0), B(0,0);
  for(int i=0; i<N; i++){
    ll b; cin>>b;
    B.emplace_back(b);
  }
  for(ll i=0; i<N; i++){
    ll change=-1;
    ll Bsz=B.size();
    for(ll j=0; j<Bsz; j++)
      if(j+1==B[j]) change=max(change, j);
    if(change==-1){
      cout<<-1<<endl;
      return 0;
    }
    A.emplace_back(B[change]);
    B.erase(B.begin()+change);
  }
  for(int i=N-1; i>=0; i--)
    cout<<A[i]<<endl;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	[a', b'] <- words <$> getLine
	let a = read a' :: Int
	let b = read $ filter Char.isNumber b' :: Int
	print $ (a * b) `div` 100

Measured memory_bytes: 3904
import Data.List

ans' :: (Double,Double) -> Double -> [Double] -> (Double,Double)
ans' (c0,p0) _ [] = (c0,p0)
ans' (c0,p0) p1 (x:xs) =
  if (x/p1) > (c0/p0)
  then ans' (c0+x,p0+p1) p1 xs
  else (c0,p0)

ans :: [String] -> Int
ans (_:p:c:l) =
  let [p0,p1] = map read $ words p :: [Double]
      c0 = read c :: Double
      (ca,pa) = ans' (c0,p0) p1 $ reverse $ sort $ map read l :: (Double,Double)
  in
    floor (ca / pa)

main = do
  c <- getContents
  let o = ans $ lines c
  print o
  

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int h;
  cin >> h;
  double ans = (double)((h+1)/2)/h;

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int num[100000];
	int n, ans = 0, m = 0;
	cin >> n;

	rep(i, 0, n) {
		cin >> num[i];
		m = max(m,num[i]);
	}

	sort(num, num + n);

	int c = 0;
	int p = 0;

	for (int i = 1; i <= m; i++) {
		c = 0;
		while (num[p] == i) {
			c++;
			p++;
		}
		if (c!=0&&c < i) {
			ans += c;
		}
		else if(c>i){
			ans += c - i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		boolean possible = true;
		int beforet = 0;
		int beforex = 0;
		int beforey = 0;
		for(int i=0;i<n;i++) {
			int t=sc.nextInt();
			int x=sc.nextInt();
			int y=sc.nextInt();
			
			int step = Math.abs(x-beforex) + Math.abs(y-beforey);
			int time = t-beforet;
			if((step-time)%2 != 0 || step > time) {
				possible = false;
			}
			
			beforet = t;
			beforex = x;
			beforey = y;
		}
		
		System.out.println(possible? "Yes" : "No");

	}

}


Measured memory_bytes: 85380
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

int main() {
	string n;
	int num, cnt;
	cin >> n;
	if(n[0] == n[1] && n[1] == n[2])
		cout << "Yes" << endl;
	else if(n[1] == n[2] && n[2] == n[3])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n;
int c[550],s[550],f[550];
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++)cin>>c[i]>>s[i]>>f[i];
    for(int i=0;i<n;i++){
        int cnt=0;
        for(int j=i;j<n-1;j++){
            if(cnt<s[j])cnt=s[j];
          	else if(cnt%f[j]==0);
          	else cnt+=f[j]-cnt%f[j];
          	cnt+=c[j];
        }
       cout<<cnt<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    while (cin >> n) {
        bool first = true;
        for (int i=1; i<=512; i*=2) {
            if (n & i) {
                if (first) {
                    first = false;
                    cout << i;
                } else {
                    cout << " " << i;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160