akhauriyash/Code-Regression huggingface dataset:
/**
 * auther: moririn_cocoa
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second

int main(int argc, char* argv[]) {

  int X;
  int t;
  
  cin >> X;
  cin >> t;
  
  if ( X > t ) {
    
    cout << X - t << endl;
  }
  
  else if ( X <= t ) {
    
    cout << 0 << endl;
  }
  
  return 0;
}





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

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<double> v(N);
	rep(i, N) cin >> v[i];

	double sm = 0;
	rep(i, N) sm += 1.0 / v[i];

	cout << fixed << setprecision(8);
	cout << 1.0 / sm << endl;

}


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

int cal(int a, int b){
	if(a <= b) return b-a;
	else return a-b+2;
}

int main(){
	int x, y;
	scanf("%d%d", &x, &y);
	printf("%d\n", min(min(cal(x, y), cal(-x, y)+1), min(cal(-y, x)+1, cal(x, -y)+1) ) );
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int M = GetInt();
		long[] d = new long[M];
		long[] c = new long[M];
		for(int i = 0; i < M; i++)
		{
			d[i] = GetLong();
			c[i] = GetLong();
		}

		long sum = 0;
		for(int i = 0; i < M; i++)
			sum += d[i] * c[i];

		long ans = c.Sum() - 1;
		long rest = sum;
		while(rest > 9)
		{
			long q = rest / 10;
			ans += q;
			rest -= q * 9;
		}

		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main() {
	int n_col;
	cin >> n_col;
	int* p_currency;
	p_currency = new int[n_col];

	for(int i=0; i<n_col; i++){
		cin >> p_currency[i];
	}

	int max_profit = p_currency[1] - p_currency[0];
	//cout << "first max_profit: " << max_profit << "\n";
	int minimum = p_currency[0];
	//cout << "first min: " << min << "\n";

	for(int i=1; i<n_col; i++){
		int diff = p_currency[i] - minimum;

		max_profit = max(max_profit, diff);

		minimum = min(minimum, p_currency[i]);

		//cout << "min:" << min << "\n";
		//cout << "max_profit: " << max_profit << "\n";
	}
	cout << max_profit << "\n";
	delete[] p_currency;
	return 0;
}


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int lcs(string s,string t){
    int l = s.size(),r = t.size();
    s += '#';
    t += '=';
    vector<vector<int>> dp(l+2,vector<int>(r+2,-(l+r)));
    dp[0][0] = 0;
    rep(i, l+1)
    {
        rep(j, r+1)
        {
            if(dp[i+1][j]<dp[i][j])dp[i+1][j]=dp[i][j];
            if(dp[i][j+1]<dp[i][j])dp[i][j+1]=dp[i][j];
            if(dp[i+1][j+1]<(dp[i][j]+(s[i]==t[j])))dp[i+1][j+1]=dp[i][j]+(s[i]==t[j]);
        }
    }
    return dp[l][r];
}
int main()
{
    int n;
    string s, t;
    cin >> n;
    vector<int> ans;
    rep(i, n)
    {
        cin >> s >> t;
        ans.push_back(lcs(s, t));
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   
   ll n,ans=0,x;
   cin>>n;
   
   map<ll,ll> m;
   
   for(ll i=1;i<=n;i++)
   {
    cin>>x;
    
    if(m[i-x]>0)
    ans+=m[i-x];
    
    m[i+x]++; 
     
   }
   
   cout<<ans<<endl;
   
   return 0;
}


Measured memory_bytes: 26284
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%5; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[])
{
    long long key,i,h;
    key = getKey(str);
    for(i =0;;i++)
    {
        h = (h1(key) + i*h2(key)) % M;
        if(strcmp(H[h],str) == 0) return 1;
        else if(strlen(H[h]) == 0) return 0;
    }
    
    return 0;
}

int insert(char str[])
{
    long long key,i,h;
    key = getKey(str);
    for(i =0;;i++)
    {
        h = (h1(key) + i*h2(key)) % M;
        if(strcmp(H[h],str) == 0) return 1;
        else if(strlen(H[h]) == 0)
        {
            strcpy(H[h],str);
            return 0;
        }
    }
        return 0;

    /* your task */
    
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 15456
#include <bits/stdc++.h>
#pragma GCC optimize("O3")  
#define pb push_back
#define F first
#define S second
using ll = long long;
using namespace std;



void solve(){
	  int n;
	  cin>>n;
	  unordered_map<string,int> m;
	  m.reserve(131072);
	  m.max_load_factor(0.25);
	  for(int i=0;i<n;i++){
	  	string f;
	  	cin>>f;
	  	m[f]++;
	  }
	  cout<<"AC"<<" x "<<m["AC"]<<endl;
	  cout<<"WA"<<" x "<<m["WA"]<<endl;
	  cout<<"TLE"<<" x "<<m["TLE"]<<endl;
	  cout<<"RE"<<" x "<<m["RE"]<<endl;
	
	






	
}


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






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

#define REP(i,n) for(decltype(n) i=0; i<(n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

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

int P[1001];
int X[1001];
int dp[1001];
vector<int> G[1001];
constexpr int INF = 10000000;

int backpack(int v){
    int D[G[v].size()+1][X[v]+1];
    D[0][0] = 0;
    fill(D[0]+1, D[0]+X[v]+1, INF);
    for(unsigned i=1;i<=G[v].size();++i){
        int u = G[v][i-1];
        fill(D[i], D[i]+X[v]+1, INF);
        for(int j=dp[u];j<=X[v];++j)
            D[i][j] = min(D[i][j], D[i-1][j-dp[u]]+X[u]);
        for(int j=X[u];j<=X[v];++j)
            D[i][j] = min(D[i][j], D[i-1][j-X[u]]+dp[u]);
    }
    return *min_element(D[G[v].size()], D[G[v].size()]+X[v]+1);
}

bool calc(int v){
    for(int u : G[v]) if(!calc(u)) return false;
    dp[v] = backpack(v);
    return dp[v] != INF;
}

void solve(){
    int n;
    cin>>n;
    for(int i=2;i<=n;++i) {cin>>P[i];G[P[i]].pb(i);}
    for(int i=1;i<=n;++i) cin>>X[i];
    cout<<(calc(1)?"POSSIBLE\n":"IMPOSSIBLE\n");
}

int main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int main(void){
    int n, m;
    cin >> n >>m;
    priority_queue<int> q;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        q.push(a);
    }
    for(int i = 0; i < m; i++){
        int a = q.top(); q.pop();
        q.push(a/2);
    }
    long long ans = 0;
    for(int i = 0; i < n; i++){
        ans += q.top(); q.pop();
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N, M; cin >> N >> M;
    int A[30][30] = {0};
    int sol=0;
    for(int i=0;i<N;i++) {
        int K;cin >> K;
        for(int j=0;j<K;j++){
            int magic; cin>>magic;magic--;
            A[i][magic]=1;
        }
    }
    for(int i=0;i<M;i++){
        int judge=0;
        for(int j=0;j<N;j++){
            if(A[j][i]==0){
                judge=1;
                break;
            }
        }
        if(judge==0){
            sol++;
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N, long[] A)
        {
            long min = long.MaxValue;
            long max = 0;
            long[] mins = new long[N - 1];
            long[] maxs = new long[N - 1];
            for (int i = 0; i < N - 1; ++i)
            {
                int j = N - 1 - i;
                min = Math.Min(A[i], min);
                max = Math.Max(A[j], max);
                mins[i] = min;
                maxs[j - 1] = max;
            }
            var range = Enumerable.Range(0, N - 1).Max(i => maxs[i] - mins[i]);
            var set = new HashSet<long>();
            for (int i = 0; i < N - 1; ++i)
            {
                if (maxs[i] - mins[i] == range) { set.Add(mins[i]); }
            }
            return set.Count;
        }
        static void Main(string[] args)
        {
            int[] v = ReadInts();
            long[] A = ReadLongs();
            Console.WriteLine(Solve(v[0], A));
        }
    }
}


Measured memory_bytes: 24288
#include<stdio.h>
int main ()
{
    int a,b,c;
    char x,y;
    scanf("%d%c%d%c%d",&a,&x,&b,&y,&c);

    if(b<=4)
    printf("Heisei\n");
    else
        printf("TBD\n");
    return 0;
}


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

int main(){
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for (int i = 0; i < n; i++){
        if (c * (n - 1 - i) - d * i <= b - a && b - a <= d * (n - 1 - i) - c * i){
            cout << "YES" << endl;
            exit(0);
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())

def keta(m):
    an=0
    while m>0:
        an+=m%10
        m=m//10
    return an

ans=0
for i in range(1,n+1):
    j=keta(i)
    if j<=b and j>=a:
        ans+=i
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
 
int main() {
  int s;
  int i = 0;
  int j = 0;
  int cnt = 0;
  int a[1000000];
   
  scanf("%d",&s);
  a[i] = s;
   
   while (1) {
     j = 0;
     cnt = 0;
     while (j <= i) {
        if (a[i] == a[j] ) {
           cnt++;
           if(cnt == 2) {
              printf("%d",j + 1);
              return 0;
           }
        }
        j++;
     }
     if (a[i] % 2 == 0)  {
        a[i + 1] = a[i] / 2;
     }
     else if (a[i] % 2 != 0)  {
        a[i + 1] = 3 * a[i] + 1;
     }
     i++;
   }
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main() {
    int n,a[101]={} , b[101]={} , c[101]={} ,s=0;
    cin>>n;

    for(int i=1;i<=n;i++) cin>>a[i];

    for(int i=1;i<=n;i++) cin>>b[i];

    for(int i=1;i<n;i++) cin>>c[i];

    for(int i=1;i<=n;i++)
    {

        s+=b[a[i]];
    }

    for(int i=1;i<n;i++)
    {

        if(a[i+1]==a[i]+1) s+=c[a[i]];
    }




    cout<<s;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main(){
	int N;
	cin  >> N;
	double x[N];
	string u[N];
	for(int i = 0;i<N;i++){
		cin >> x[i] >> u[i];
	}
	double sum = 0;
	for(int i = 0;i<N;i++){
		if(u[i] == "JPY"){
			sum = sum + x[i];
		}
		else{
			sum = sum + (x[i] * 380000.0);
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
#スペース区切りの整数入力
N, M  = map(int, input().split())


if N >= 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M >= 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

int n, freq[109];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for (int i=1; i<=n; ++i) {
        int x;
        cin >> x;
        ++freq[x];
    }

    ll mn=1e18+18;
    for (int i=1; i<=100; ++i) {
        ll can=0;
        for (int j=1; j<=100; ++j) {
            can+=freq[j]*(ll)(i-j)*(ll)(i-j);
        }

        mn=min(mn ,can);
    }

    cout << mn;

    return 0;
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n, k;
	cin >> n >> k;

	int a[200010];
	for(int i = 0;i < n;i++) cin >> a[i];

	for(int i = k;i < n;i++){
		if(a[i-k] < a[i]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c; while(isspace(c = getchar()));
	bool neg = false;
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }
template <class... Args> inline void rf(Args&... args) { (cin >> ... >> args); }
template <class... Args> inline void pr(Args&&... args) { (cout << ... << args); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	int n, m, k; cin >> n >> m >> k;

	vector<string> a(n);
	for (string& s : a) cin >> s;

	auto paint_row = [&](vector<string>& a, int r) {
		for (int i = 0; i < m; i++) a[r][i] = 'R';
	};
	auto paint_col = [&](vector<string>& a, int c) {
		for (int i = 0; i < n; i++) a[i][c] = 'R';
	};
	auto count = [&](vector<string>& a) {
		int ret = 0;
		for (int i = 0; i < n; i++) for (int j = 0; j < m; j++)
			ret += a[i][j] == '#';
		return ret;
	};

	int row = 1 << n;
	int col = 1 << m;

	int ans = 0;
	for (int i = 0; i < row; i++) {
		for (int j = 0; j < col; j++) {
			vector<string> b = a;
			for (int k = 0; k < n; k++) if (i & (1 << k)) paint_row(b, k);
			for (int k = 0; k < m; k++) if (j & (1 << k)) paint_col(b, k);
			ans += count(b) == k;
		}
	}

	cout << ans << "\n";
}

Measured memory_bytes: 3632
import java.awt.*;
import java.io.*;
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestA().doIt();
	}
	class TestA{
		void doIt() {
			int n = sc.nextInt();
			if(n == 0)System.out.println(1);
			else System.out.println(0);
		}
	}
}

Measured memory_bytes: 35604
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1,0,-1,0};
static const int dir[4] = {'r','u','l','d'};
int MDT[N2][N2];
struct Puzzle {int f[N2],space,MD;};

Puzzle state;
int limit;
int path[LIMIT];

int getALLMD(Puzzle pz){
    int sum=0;
    for(int i=0;i<N2;i++){
        if(pz.f[i]==N2)continue;
        sum+=MDT[i][pz.f[i]-1];
    }
    return sum;
}
bool isSolved(){
    for(int i=0;i<N2;i++)if(state.f[i] != i+1)return false;
    return true;
}
bool dfs(int depth,int prev){
    if(state.MD==0)return true;
    if(depth+state.MD > limit)return false;
    
    int sx = state.space/N;
    int sy = state.space%N;
    Puzzle tmp;
    for(int r=0;r<4;r++){
        int tx=sx+dx[r];
        int ty=sy+dy[r];
        if(tx<0||ty<0||tx>=N||ty>=N)continue;
        if(max(prev,r)-min(prev,r)==2)continue;
        tmp=state;
        state.MD-=MDT[tx*N+ty][state.f[tx*N+ty]-1];
        state.MD+=MDT[sx*N+sy][state.f[tx*N+ty]-1];
        swap(state.f[tx*N+ty],state.f[sx*N+sy]);
        state.space=tx*N+ty;
        if(dfs(depth+1,r)){path[depth]=r;return true;}
        state=tmp;
    }
    return false;
}

string iterative(Puzzle in){
    in.MD=getALLMD(in);
    for(limit=in.MD;limit<=LIMIT;limit++){
        state=in;
        if(dfs(0,-100)){
            string ans="";
            for(int i=0;i<limit;i++)ans+=dir[path[i]];
            return ans;
        }
    }
    return "unsolvable";
}
int main(){
    for(int i=0;i<N2;i++)
    for(int j=0;j<N2;j++)
    MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
    Puzzle in;
    for(int i=0;i<N2;i++){
        cin >> in.f[i];
        if(in.f[i]==0){
            in.f[i]=N2;
            in.space=i;
        }
    }
    string ans=iterative(in);
    cout << ans.size() << endl;
    
    return 0;
}


Measured memory_bytes: 3204
import java.util.Scanner;

// 再帰を用いた解法
public class Main {
    private static String s;
    
    private static long solve(long decided, long left, int i){
        if(i==s.length()){
            return decided + left;
        }
        // 左側に+を入れる場合→int(s[i])がleftに。
        long ret1 = solve(decided + left, Character.getNumericValue(s.charAt(i)), i+1);
        // +を入れない→leftが10倍+int(s[i])される
        long ret2 = solve(decided, left*10 + Character.getNumericValue(s.charAt(i)), i+1);
        return ret1 + ret2;
    }
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        s=sc.next();
        System.out.println(solve(0,Character.getNumericValue(s.charAt(0)), 1));
    }
}


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

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
const i64 MOD = 1e9+7;
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a%MOD, n /= 2) { if(n%2) ret = ret*a%MOD; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

const int MAXN = 1e2;
int n, ar[MAXN];
void input() {
	cin >> n;
	FOR(i, 0, n) cin >> ar[i], --ar[i];
}

vi ans;
void f(int s, int e) {
	if(ar[e] > e) {
		cout << -1 << ENDL;
		exit(0);
	}
	if(s > e) return;
	if(s == e) {
		ans.pb(e+1);
		return;
	}
	f(s, ar[e]);
	ans.pb(ar[e]+1);
	f(ar[e]+1, e-1);
}

int solve() {
	vi ans;
	FOR(i, 0, n) {
		if(ar[i] > ans.size()) {
			cout << -1 << ENDL;
			return 0;
		}
		ans.insert(ans.begin() + ar[i], ar[i]);
	}
	for(int x : ans) cout << x+1 << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

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

int main(){
    int A, B;
    cin >> A >> B;
    vector<int> ans(3);

    ans.at(A-1)++;
    ans.at(B-1)++;

    int ansnum = 0;

    for(int i = 0; i < 3; i++){
        if(ans.at(i) == 0) ansnum = i + 1;
    }

    cout << ansnum << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a;
    int cnt = 0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(a%2 == 1){
            cnt++;
        }
    }
    string ans = "YES";
    if(cnt%2 == 1){
        ans = "NO";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 1e9+7;
const int N = 2e5+205;
void solve(){
	int n; 
	cin>>n;
	vector<ll>v; 
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		v.pb(x);
	}
	sort(v.begin(),v.end());
	ll ans = 0;
	for(int i=0;i+1<n;i+=2){
		if(v[i]+v[i+1]>-v[i]-v[i+1]){
			ans+=v[i]+v[i+1];
		}
		else{
			ans+=(-v[i]-v[i+1]);
		}
	}
	if(n&1)ans+=v[n-1];
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}
/// 2:3 /// 2,3
/// 1:1 /// 3,3
/// aa/bb =x/y
/// bb*x/y = aa
/// bb = aa*y/x


Measured memory_bytes: 4264
#include<bits/stdc++.h>
using namespace std;
long long gcd(int a,int b){
    if(b==0)
        return a;
    return 
        gcd(b,a%b);
}
int main(){
	int a,b;
	cin>>a>>b;
	printf("%lld\n",a/gcd(a,b)*b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define l long int 
#define ll long long int 
vector<int>adj[1000001];
int vis[1000001];
int n=2005;
#define mod 1000000007 
int main()
{
    ll n;
    cin>>n;
    vector<vector<ll>>dp(4,vector<ll>(n));
    ll x,y;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        dp[0][i]=x+y;
        dp[1][i]=-x+y;
        dp[2][i]=x-y;
        dp[3][i]=-x-y;
    }
    for(int i=0;i<4;i++)
    {
        sort(dp[i].begin(),dp[i].end());
    }
    ll ans=-1e18;
    for(int i=0;i<4;i++)
    {
        ans=max(ans,dp[i][n-1]-dp[i][0]);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 34388
import math
from functools import reduce
import fractions
def lcm_base(x, y):
    return (x * y)//fractions.gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
nums= list(map(int,input().split()))
ans = 0
lcmnum= lcm(nums)-1
for num in nums:
    ans+=(int(lcmnum)%num)
print(ans)

Measured memory_bytes: 5524
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  ll a,b,ans;
  ll c = 0;
  cin >> a >> b;
  ans = b;
  
   a--;
  while(a>c){
   ans *= b-1;
   a--;
  }
  cout << ans;
}


Measured memory_bytes: 3572
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    int ct[N],sum[N];
    int ans[N];
	void main()
	{
        int n=qread();fo(i,1,n) ct[qread()]++;sort(ct+1,ct+n+1);fo(i,1,n) sum[i]=sum[i-1]+ct[i];
        fo(now,1,n)
        {
            int pos=upper_bound(ct+1,ct+n+1,now)-ct;
            ans[(sum[pos-1]+(n-pos+1)*now)/now]=now;
        }
        fd(now,n,1) chmax(ans[now],ans[now+1]);fo(i,1,n) write2(ans[i]);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 10240
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define ll long long

using namespace std;

int n;
ll k;
ll maxa = 0;
ll g;

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

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        maxa = max(a, maxa);
        if (i == 0) g = a;
        else g = gcd(a, g);
    }
    if (k <= maxa && k % g == 0) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

int main(){
	int n,k;cin >> n >> k;
	Vint s(n,0);
	REP(i,k){
		int d;cin >> d;
		REP(j,d){
			int t;cin >> t;
			s[--t]++;
		}
	}

	int cnt = 0;
	REP(i,n)if(s[i]==0)cnt++;

	cout << cnt << endl;

	return 0;
}
 



Measured memory_bytes: 3636
while(True):
  n = int(input())
  if n == 0:
    break
  else:
    lis = list(map(int,input().split()))
    lis.sort()
    min = 10**9+7
    i = 0
    while(i<len(lis)-1):
      if lis[i+1] - lis[i] < min:
        min = lis[i+1] - lis[i]
      i += 1
    print(min)


Measured memory_bytes: 5624
#include <iostream>
#include <queue>
#include <algorithm>
#include <climits>
#include <stack>
#include <vector>
#include <random>
#include <string.h>
#include <stdio.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef pair<int, int> ii;
typedef pair<long double, int> id;
typedef pair<long long, long long> llp;
const int N = 1e5+1;
int n, m;
int dp[N];
bool visit[N];
vector<int> a[N];
void dfs(int u) {
    visit[u] = 1;
    for(int v:a[u]) {
        if (!visit[v]) dfs(v);
        dp[u] = max(dp[u], dp[v]+1);
    }
}
int main() {
    //freopen("ee.inp", "r", stdin);
    //freopen("ee.OUT", "w", stdout);
    fastIO;
    cin>>n>>m;
    int u, v, ans = 0;
    for(int i=1;i<=m&&cin>>u>>v;i++) a[u].push_back(v);
    for(int i=1;i<=n;i++) if (!visit[i]) dfs(i);
    for(int i=1;i<=n;i++) ans = max(ans, dp[i]);
    cout << ans;
}


Measured memory_bytes: 12236
#include <algorithm>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int n, x;
    char com[20];
    list<int> v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com[0] == 'i') {
            cin >> x;
            v.push_front(x);
        } else if (com[6] == 'L') {
            v.pop_back();
        } else if (com[6] == 'F') {
            v.pop_front();
        } else if (com[0] == 'd') {
            cin >> x;
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }

    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (i++) cout << " ";
        cout << *it;
    }
    cout << endl;
}


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

namespace ABC142
{
    class C
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
            {
                ans[A[i] - 1] = i + 1;
            }
            for (int i = 0; i < n-1; i++)
            {
                Console.Write(ans[i] + " ");
            }
            Console.WriteLine(ans[n - 1]);
        }
    }
}


Measured memory_bytes: 25560
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  return ~~(strShift().split("").filter((a)=>a=="o").length*100+700);
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
oxo
`);

Measured memory_bytes: 20424
import qualified Data.ByteString.Char8 as B

solv bs = go bs [] 0 where
  go bs stk n
    | B.null bs = n
    | null stk = go (B.tail bs) [B.head bs] n
    | B.head bs/=head stk = go (B.tail bs) (tail stk) (n+2)
    | otherwise = go (B.tail bs) (B.head bs:stk) n

main = do
  xs <- B.getLine
  print $ solv xs


Measured memory_bytes: 4092
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define exit(x)     cout<<x<<"\n",return
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
ll T=1;
//cin>>T;
while(T--)
  {
  string s;
  ll n,m,k,x=0,y=0,c=0,q,ans=0;
  cin>>s;

  for (ll i = 0; i < s.length(); ++i)
  {
    if(s[i]=='A' or s[i]=='T' or s[i]=='G' or s[i]=='C')
    {
      c++;
    } 
    else
    {   
       ans= max(ans,c);c=0;
     
    }

  }
   ans= max(ans,c);
  
  cout<<ans<<" ";

 }
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      solve();
      return 0;
    }


Measured memory_bytes: 256
# 2019/01/13
# KEYENCE Programming Contest 2019 - B

# Input
s = input()

# Init
key_str = "keyence"
ans = "NO"
search_idx = 0

# Search
if s[0] == key_str[0]:
    # Pattern 2 or 3
    for idx in range(len(s)):
        if s[idx] == key_str[search_idx]:
            search_idx += 1
            if search_idx == len(key_str):
                # Pattern 3
                ans = "YES"
                break

        else:
            # Pattern 2
            for idx2 in range(len(s) - len(key_str) + search_idx, len(s)):
                if s[idx2] == key_str[search_idx]:
                    search_idx += 1
                    if search_idx == len(key_str):
                       ans = "YES"
            break
else:
    # Pattern 1
    for idx in range(len(s) - len(key_str), len(s)):
        if s[idx] == key_str[search_idx]:
            search_idx += 1
            if search_idx == len(key_str):
                ans = "YES"
                break

# Output
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <limits.h>

int main(void) {
	long long int a[1000][1000];
	long long int b[1000][1000];
	long long int c[1000][1000];
	int n,m,l;
	scanf("%d%d%d",&n,&m,&l);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%lld",&a[i][j]);
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < l; j++){
			scanf("%lld",&b[i][j]);
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < l; j++){
			c[i][j] = 0;
			for(int k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
	for(int i = 0; i < n; i++){
		printf("%lld",c[i][0]);
		for(int j = 1; j < l; j++){
			printf(" %lld",c[i][j]);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 3204
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<std::string> W;
  tools::read(W, N);

  for (i64 i = 1; i < N; ++i) {
    if (W[i - 1].back() != W[i].front()) goto FAILED;
  }
  if (std::unordered_set<std::string>(W.begin(), W.end()).size() < W.size()) goto FAILED;
  std::cout << "Yes" << std::endl;
  return 0;

FAILED:
  std::cout << "No" << std::endl;
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().ToCharArray();
        
        List<char> list = new List<char>();
        var len = 0;
        for (var i = 0; i < input.Length; i++) {
            if (input[i] == 'A' || input[i] == 'C'
                || input[i] == 'G' || input[i] == 'T') {
                list.Add(input[i]);
                if (len < list.Count) {
                    len = list.Count;
                }
            } else {
                list.Clear();
            }  
        }
        Console.WriteLine(len);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main() {
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K) {
        cout << S << endl;
    }
    else {
        for (int i = 0; i < K; i++) {
            cout << S[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int r = 0, g = 0, b = 0;
  ivec a(n);
  REP(i, n) {
    if (s[i] == 'R') {
      a[i] = 0;
    } else if (s[i] == 'G') {
      a[i] = 1;
    } else if (s[i] == 'B') {
      a[i] = 2;
    }
  }

  lvec cnt(3);
  REP(i, n) cnt[a[i]]++;
  ll ans = 1;
  REP(i, 3) ans *= cnt[i];
  REP(j, n) REP(i, j) {
    int k = 2 * j - i;
    if (k >= n) continue;
    if (a[i] == a[j]) continue;
    if (a[j] == a[k]) continue;
    if (a[i] == a[k]) continue;
    ans--;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int N,M;cin>>N>>M;
    tuple<ll,ll,ll>t[1010];
    for(int i=0;i<N;i++){
        ll a,b,c;cin>>a>>b>>c;
        t[i]=make_tuple(a,b,c);
    }

    ll a[1010],ans=0;
    for(int bit=0;bit<8;bit++){
        for(int i=0;i<N;i++){
            a[i]=0;
            ll l[3];
            l[0]=get<0>(t[i]);
            l[1]=get<1>(t[i]);
            l[2]=get<2>(t[i]);
            for(int k=0;k<3;k++){
                if(bit & (1<<k))
                    a[i]+=l[k];
                else a[i]-=l[k];
            }
        }
        sort(a,a+N,greater<ll>());
        ll sum=0;
        for(int i=0;i<M;i++)
            sum+=a[i];
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N;
	cin >> N;
	cout << (N - 2) * 180 << endl;

//"Hiroakimm0415"
	return 0;
}

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

typedef long long ll;

ll calc(ll a, ll b) {
	return (a + b - 1) / 2;
}

int main() {
	ll N, A, B;
	scanf("%lld%lld%lld", &N, &A, &B);
	if ((B - A) % 2)
		printf("%lld\n", min(calc(A, B), calc(N - A + 1, N - B + 1)));
	else
		printf("%lld\n", (B - A) / 2);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int a,b;cin>>a>>b;
    int cnt=0;
    for(int i=a;i<=b;i++){
        string s1=to_string(i);
        string s2=to_string(i);
        reverse(s2.begin(),s2.end());
        if(s1==s2)cnt++;
    }
    co(cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
    
    const int LIMIT = 1000000256;
    const int tenfive = 100000;
    
    
}

using namespace atcoder;

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


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << a * b / 2 << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
N=int(input())
b=list(map(int, input().split()))
ans=[]
while len(b)>0:
    x=-1
    for i in range(len(b)):
        if b[i]==i+1:
            x=i
    if x==-1:
        break
    else:
        ans.append(b.pop(x))
if x==-1:
    print("-1")
else:
    ans.reverse()
    [print(ans[i]) for i in range(len(ans))]

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        char[] chars = s.toCharArray();
        int ans = Integer.MAX_VALUE;
        for(int i = 2; i < s.length(); i++) {
            int num = 0;
            num = num * 10 + (chars[i-2] - 48);
            num = num * 10 + (chars[i-1] - 48);
            num = num * 10 + (chars[i] - 48);
            ans = min(ans, (num > 753 ? num - 753 : 753 - num));
        }
        System.out.println(ans);
    }
  	static int min(int a, int b) {
    	return a < b ? a : b;
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pie 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-7
#define mod ((ll)1e9+7)
#define maxlg 18
const int maxn = ((int) 2e5) +5 ;
#define left(i) ((i)<<1)
#define right(i) ((i)<<1)+1
int capacity[maxn];
map<ll,set<ii>> m;
set<string> strings;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input", "r", stdin);
    //freopen("/home/arasmus/output", "w", stdout);
#endif
    string s;
    int k;
    cin>>s>>k;
    rep (i,0,s.length()) {
        string temp="";
        rep (j,i,s.length()) {
            temp.push_back(s[j]);
            if (strings.size() <=5) {
                strings.insert(temp);
            } else if (temp < *strings.rbegin()) {
                strings.insert(temp);
                auto it = strings.end();
                advance(it, -1);
                strings.erase(it);
            }
        }

    }
    rep (i,0,k-1) {
        strings.erase(strings.begin());
    }
    cout<<*strings.begin();
}




//cout<<"Case #"<<++T<<": ";

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

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int count = 0;

    for(int i = L; i < R + 1; i++) {
        if(i % d == 0) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3628