akhauriyash/Code-Regression huggingface dataset:
program main
  implicit none
  integer :: X
  integer(8) :: i,j
  read(*,*) X

  do i = -118,119
     do j = -119,118
        if (X == i**5 - j**5) then
           write(*,'(i0,x,i0)') i,j
           stop
        end if
     end do
  end do
 
  
end program main


Measured memory_bytes: 2864
#include <bits/stdc++.h>
#define M 1000000007
#define endl '\n'
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
	ll n{0};
	cin>>n;

	ll cnt{0};
	bool possible=false;
	while(n--){
		ll x{0};
		ll y{0};
		cin>>x>>y;
		if(x==y){
			cnt++;
		}
		else{
			if(cnt>=3)
				possible=true;
			cnt=0;
		}
	}
	if(cnt>=3)
		possible=true;

	if(possible)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(void)
{
	int r,g,b,i;
	scanf("%d%d%d",&r,&g,&b);
	i=g*10+b;
	
	if(i%4==0)
		printf("\nYES\n\n");
	else 
		printf("\nNO\n\n");
	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main(){

	string S;

	cin >> S;
	int size;
	size = S.size();
	vector<int> count(10,0);
	int j = 0;

	for (int i = 0; i < size; i++){
		if (S[i] == 'A' or S[i] == 'T' or S[i] == 'G' or S[i] == 'C')
			count[j] += 1;
		else if(count[j] >= 1)
			j += 1;
	}

	int max = *std::max_element(count.begin(), count.end());

	cout << max << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int K;
  cin >> K;
  vector<long long> lun(K+1);
  lun.at(0)=0;
  int x; int y; long long U; int ct;
  for(int i=1;i<K+1;i++){
    U=lun.at(i-1);
    x = U % 10;
    U /= 10;
    y = U % 10;
    ct =0;
    if(x!=9 && x<=y){
      lun.at(i)=lun.at(i-1)+1;
    }else{
      while (((x==9&&y==9) || x-y==1) && U!=0) {
		x = y;
        U /= 10;
        y = U % 10;
        ct++;
	  }
      if(U!=0 || x!=9){
        x++;
        ct++;
        while(ct!=0){
          U=U*10+x;
          ct--;
          if(x!=0){
            x--;
          }
        }
        lun.at(i)=U;
      }else{
        lun.at(i)=lun.at(i-1)+1;
      }
    }
  }
  
  cout << lun.at(K) << endl;
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


ll solve(ll a, ll b){
    if(a > b) swap(a, b);
    if(a == b) return 2*a-2;
    if(a+1 == b) return 2*a-2;

    ll ok = 0, ng = b;
    while(ng - ok > 1){
        ll mid = (ng + ok) / 2;
        if(mid*mid < a*b) ok = mid;
        else ng = mid;
    }
    ll c = ok;

    if(c*(c+1) >= a*b) return 2*c-2;
    else return 2*c-1;
}



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

    int q; cin >> q;
    while(q--){
        ll a, b; cin >> a >> b;
        cout << solve(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n];
    sort(a,a+n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll ans[k+1];
    ans[0]=0;
    for(ll i=1;i<=k;i++)
    {
        for(ll j=0;j<n;j++)
        {
            if(a[j]>i) ans[i]=0;
            else if(ans[i-a[j]]==0) {ans[i]=1; break;}
            else ans[i]=0;
        }
    }
    if(ans[k]==0) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
 
	return 0;
}

Measured memory_bytes: 1024
s = int(input())

sec = [s]
count = 1
while(s):
  if sec[-1]%2 == 0:
    sec.append(sec[-1]/2)
  else:
    sec.append(3*sec[-1]+1)
  count+=1
    
  if sec[-1] in sec[:-1]:
    print(count)
    break

Measured memory_bytes: 8956
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

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

    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
}

Measured memory_bytes: 256
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table
N=int(input())
_, table = sieve(N)
d={}
for p in table:
    sum_=0
    calc=p
    while calc <= N:
        sum_ += N//calc
        calc *= p
    d[p] = sum_ + 1
def count(d,n):
    return len([i for i in d.values() if i >=n])
print((count(d,3) - 1)*count(d,25) + (count(d,5) - 1)*count(d,15) + count(d,5) * (count(d,5) - 1) * (count(d,3)-2)//2 + count(d,75))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
//int n,m;
int n;
int main() {
	cin>>n;
	//cin>>n>>m;
	if(n<1200)
		cout<<"ABC";
	else if(n<2800)
		cout<<"ARC";
	else
		cout<<"AGC"; 
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(a + b >= c ? "Yes" : "No");
	}

}


Measured memory_bytes: 23764
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
		ios_base::sync_with_stdio(0);cin.tie(0);
		int N,t=1;
		cin>>N;
		vector<int>v;
		for(int i=0;i<N;i++){int a;
		cin>>a;
		v.push_back(a);
		if(a==0){
      cout<<0;
      return 0;
		}
		}
		for(int i=0;i<N;i++){
      int a=v[i];
      if(t==0){
        cout<<0;
        return 0;
      }
      if(2e18/t<a){
        cout<<-1;
        return 0;
      }
      t*=a;
		}
		if(t>(ll)1e18)cout<<-1;
		else cout<<t;
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >>a >>b >>c;
  
  if (a==b && b==c) {
    if (a % 2 == 0)
      cout << -1 << endl;
    else
      cout << 0 << endl;
  }
  else {
    int count = 0;
    while (1) {
      if (a%2==1 || b%2==1 || c%2==1)
        break;
      int a2 = a, b2 = b, c2 = c;
      count ++;      

      a = (b2 + c2) / 2;
      b = (a2 + c2) / 2;
      c = (a2 + b2) / 2;
    }
    cout << count << endl;  
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int N,C,X;
int D[30][39];
int t[3][30];
int main() {
    scanf("%d%d",&N,&C);
    rep(i,C) rep(j,C) scanf("%d",&D[i][j]);
    rep(i,N) rep(j,N) scanf("%d",&X), t[(i+j)%3][X-1]++;
    int res =1 << 30;
    rep(i,C)rep(j,C)if(i!=j)rep(k,C)if(i!=k&&j!=k) {
        int tt =0;
        rep(l,C)tt += D[l][i]*t[0][l];
        rep(l,C)tt += D[l][j]*t[1][l];
        rep(l,C)tt += D[l][k]*t[2][l];
        if(tt<res) res=tt;
    }
    printf("%d\n",res);
}


Measured memory_bytes: 256
def main():
    """
    input:
        1 <= H <= 100
        1 <= W <= 8
        1 <= K <= W

    output:
        数列の項の最大公約数の最大値
    """
    H, W, K = map(int, input().split())

    # ans = visualize(H, W, K)
    ans = editorial(H, W, K)
    print(ans)


def f(H, W, K):
    """
    1-2の間に横棒を引く
    引き方: 0-H に引く組合せ
        x = sum(nCr(H, i) for i in range(H+1))

    2-3の間に横棒を引く
    引き方: 1-2の引いた部分以外に引くことができる
        startが1からなのでたどり方的に上に引く必要がないが
        それも正しい可能性のあるあみだくじなので考慮する

        x = 0
        for i in range(H+1):
            # i 本引いてあるなら、引いてない部分がMAX
            for j in range(H-i+1):
                x += sum(nCr(j, k) for k in range(j))

    たどり方
    1の一番高い棒から2へ向かう or なければそのまま下へ
    2から1or3の棒へ向かう or なければ下へ

    Kにたどり着くパターン or (全パターン - たどりつけないパターン)
        たぶん、縦と横を独立に考える。なんとなく
        下にH
        横にK-1, 右を+1左を-1としたとき
    """
    mod = 10 ** 9 + 7
    ans = 0

    return ans % mod


def visualize(H, W, K):
    valid_k = []
    for k in range(1 << (W - 1)):
        if not k & (k << 1):
            valid_k.append(k)

    for i in range(H):
        print("row", i+1)
        for j in range(W):
            for k in valid_k:
                h_bar = "{:08b}".format(k)[-(W-1):]
                h_bar = h_bar.replace("1", "_").replace("0", " ")

                header = " " + " ".join(str(i) for i in range(W)) + " "
                header = header.replace(" {} ".format(j), "[{}]".format(j))

                print(header)
                print(" |" + "|".join(list(h_bar)) + "| ")
                print(" " + " ".join("|" for _ in range(W)) + " ")
                print()

    return 1


def is_connected(k, W):
    # 2つの横線がつながっていないか
    ok = True
    for l in range(W - 2):
        if k >> l & 1 and k >> (l + 1) & 1:
            ok = False
            break

    ok2 = "11" not in bin(k)
    ok3 = not (k & (k << 1))
    assert ok == ok2 == ok3

    return ok


def editorial(H, W, K):
    mod = 10 ** 9 + 7
    dp = [[0] * W for _ in range(H+1)]
    dp[0][0] = 1
    # dp[H+1][W]
    # dp[i][j]: 上からicmまでの時点で、1からjに行ける数
    # dp[i + 1][a] += dp[i][j]: 下に1つ進んだとき、aに行ける数
    for i in range(H):
        for j in range(W):
            k_max = 1 << (W - 1)
            for k in range(k_max):
                # 2つの横線がつながっていないか
                ok = is_connected(k, W)
                if not ok:
                    continue

                #  pos:            L   S   R
                #  v_bar:   [j-1]_____[j]_____[j+1]
                #  h_bar:         j-1     j
                a = 0  # straight
                if j >= 1 and k >> (j - 1) & 1:  # left
                    a = - 1
                elif j < W - 1 and k >> j & 1:  # right
                    a = 1

                dp[i + 1][j + a] += dp[i][j]
                dp[i + 1][j + a] %= mod

    return dp[H][K - 1]


def a(H, W, K):
    """
    https://twitter.com/Py2K4/status/1059078331407028226
    """


def editorial_fib(H, W, K):
    """
    https://twitter.com/259_Momone/status/1059085685208956928
    導出: 棒が2本連続しない
    """


if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[2000000];
		int x=sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		System.out.println(z+" "+x+" "+y);
	}
}

Measured memory_bytes: 22612
#include <stdio.h>
#include <math.h>

int main(){
  int i,j,n,A[200000];
  int t;

  t = 1 - pow(10,9);

  scanf("%d",&n);

  for(i=0; i < n; i++){
    scanf("%d",&A[i]);
  }

  for(i=n-1; i >= 0; i--){
    if(t > A[i]){
      continue;
    }
    for(j=i-1; j >= 0; j--){
      if(t < A[i] - A[j]){
	t = A[i] - A[j];
      }
    }
  }

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

  return 0;
}



Measured memory_bytes: 2564
n = int(input())
count = [0] * (10**6)
s = 0

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            s = i * i + j * j + k * k + i * j + j * k + k * i 
            count[s - 1] += 1
for i in range(n):
    print(count[i])


Measured memory_bytes: 16904
#include <iostream>
using namespace std;
int main(){
  char a;
  int b=0;
  for(int i=0;i<3;i++){
    cin>>a;
    if(a=='7'){b=1;}
  }
  if(b==0){
    cout << "No"<<endl;
  }else{
    cout << "Yes"<<endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>

using namespace std;

#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	int q;
	cin >> q;
	while (q--) {
		int c, a, n;
		scanf("%d %d %d", &c, &a, &n);
		
		int ans = 0;
		
		int tmp = min(c, min(a, n));
		ans += tmp;
		c -= tmp; a -= tmp;
		tmp = min(c / 2, a);
		ans += tmp;
		c -= tmp * 2; a-= tmp;
		tmp = c / 3;
		ans += tmp;
		
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<vector>
#include<utility>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define inf 999999999
#define rep(i, n) for(int i = 0; i < n; i++)
#define For(i, a, n) for(int i = a; i < n; i++)
#define out(n) cout << n << endl;
#define vout(v) rep(i, v.size()) out(v[i]);

int main() {
  int a;
  cin >> a;
  vector<string> s(a);
  vvi vv(a);
  string str = "abcdefghijklmnopqrstuvwxyz";

  rep(i, a) {
    cin >> s[i];
    vector<ll> l(26, 0);
    rep(j, s[i].length()) {
      rep(k, str.length()) {
        if(s[i][j] == str[k]) {
          l[k]++;
          break;
        }
      }
    }
    vv[i] = l;
  }

  rep(i, 26) {
    int flag = inf;
    rep(j, vv.size()) {
      if(!vv[j][i]) {
        flag = 0;
        break;
      }
      if(vv[j][i] < flag) flag = vv[j][i];
    }
    rep(j, flag) {
      cout << str[i];
    }
  }

  cout << endl;

}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  priority_queue<int> goods;
  for(int i=0;i<N;++i){
    cin>>A.at(i);
    goods.push(A.at(i));
  }

  while(M>0){
    int hangaku;
    hangaku=goods.top();
    goods.pop();
    goods.push(hangaku/2);
    --M;
  }

  int64_t ans=0;
  while(!goods.empty()){
    ans=ans+goods.top();
    goods.pop();
  }
  

  cout<<ans<<endl;
}

Measured memory_bytes: 1276
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_158_c
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            int A, B;
            ReadInt(out A, out B);

            // 消費税 ８% の時 A,１０％ の時 B となる数字

            // x * 0.08 = A : y1 * 0.1 = b;
            // 消費税の計算において小数点以下は切り捨てて計算するものとします。
            // x1 = A / 0.08 ; y2 = b / 0.1 
            // x2 = (A + 1) / 0.08 ; x2 = (b + 1) / 0.1

            // [x1 .. x2] と [y1 .. y2] で重なりのある部分の最小を求める

            double x1 = ((double)A / 0.08);
            double x2 = ((double)(A + 1) / 0.08);

            double y1 = ((double)B / 0.1);
            double y2 = ((double)(B + 1) / 0.1);

            // 交わり 部分
            double s1 = Math.Max(x1, y1);
            double s2 = Math.Min(x2, y2);

            // INT 補正（誤差補正）
            int i1 = (int)(s1 + 0.5);
            int i2 = (int)(s2 - 0.5);

            if (i1 > i2)
            {
                Write("-1");
            }
            else
            {
                Write(i1.ToString());
            }

        }

#region 
        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static void ReadInt(out int a, out int b)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
        }
        private static void ReadInt(out int a, out int b, out int c)
        {
            var ar = ReadIntArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }
        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            return ss;
        }
#endregion

#if !TEST
    }
}
#endif


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(true) {
        	String cards = sc.nextLine();
        	if(cards.equals("-")) {
        		break;
        	}

            int count = Integer.parseInt(sc.nextLine());;
            for(int i = 0; i < count; i++) {
            	int shuffleNum = Integer.parseInt(sc.nextLine());
            	cards = cards.substring(shuffleNum) + cards.substring(0, shuffleNum);
            }
            System.out.println(cards);
        }
    }
}


Measured memory_bytes: 26244
class Heap:

    # 初期化
    def __init__(self):
        self.array = []

    def num(self):
        return len(self.array)
        
    # valを追加する
    def put(self, val):
        pos = len(self.array)
        # valを末尾に追加する
        self.array.append(val)
        # valを適当な位置まで上にあげる
        self.pop_up(pos)
        
    # 最大の要素を取り出す
    def get(self):
        assert len(self.array) > 0

        val = self.array[0]
        
        # 末尾の要素を0に移動してから下に下げる
        t_val = self.array[-1]
        self.array[0] = t_val
        del self.array[-1]
        self.push_down(0)
        return val

    # posの位置の要素を適当な位置まで上げる
    def pop_up(self, pos):
        while pos > 0:
            p_pos = (pos - 1) // 2
            val = self.array[pos]
            p_val = self.array[p_pos]
        
            if val > p_val:
                self.array[pos] = p_val
                self.array[p_pos] = val
                pos = p_pos
            else:
                break
            
    def push_down(self, pos):
        while True:
            l_pos = 2 * pos + 1
            r_pos = 2 * pos + 2
            n = len(self.array)
            
            if n <= l_pos:
                # 子がいない場合
                break
            
            elif n == r_pos:
                # 子が一人の場合
                val = self.array[pos]
                l_val = self.array[l_pos]
                
                if val < l_val:
                    self.array[pos] = l_val
                    self.array[l_pos] = val
                    
                break #
            
            else:
                # 子が二人いるとき
                val = self.array[pos]
                l_val = self.array[l_pos]
                r_val = self.array[r_pos]
                
                if l_val > r_val:
                    if val < l_val:
                        self.array[pos] = l_val
                        self.array[l_pos] = val
                        pos = l_pos
                    else:
                        break
                else:
                    if val < r_val:
                        self.array[pos] = r_val
                        self.array[r_pos] = val
                        pos = r_pos
                    else:
                        break

                        
h = Heap()
sn,sm = input().split(" ")
n = int(sn)
m = int(sm)
sa_list = input().split(" ")


for sa in sa_list:
  a = int(sa)  
  h.put(a)
 
for i in range(m):  
    max_a = h.get()
    h.put(max_a // 2)

    

print(sum(h.array))


Measured memory_bytes: 14336
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int n, m, count{}, last = -1, btoa[100000]{};
	scanf("%d%d", &n, &m);
	std::fill(btoa, btoa + 100000, -1);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		btoa[b - 1] = std::max(btoa[b - 1], a - 1);
	}
	for (int i = 0; i < n; i++)
	{
		if (btoa[i] < 0 || btoa[i] < last) continue;
		last = i;
		count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <numeric>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  LL N, K;
  cin >> N >> K;
  if (K >= N) {
    cout << 0 << endl;
    return 0;
  }
  vector<LL> H(N);
  for (LL i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  LL sum = accumulate(H.begin(), H.begin()+N-K, 0LL);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;

namespace Abc070d
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            List<Branch> branches = new List<Branch>();
            for (int i = 0; i < n - 1; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                branches.Add(new Branch(int.Parse(input[0]), int.Parse(input[1]), int.Parse(input[2])));
            }

            string[] query = Console.ReadLine().Split(' ');
            int qNum = int.Parse(query[0]);
            int k = int.Parse(query[1]);

            Point[] points = new Point[n + 1];
            for (int i = 0; i < n; i++)
            {
                points[i + 1] = new Point();
            }
            foreach (Branch branch in branches)
            {
                points[branch.From].Add(branch);
                points[branch.To].Add(branch);
            }

            long[] dp = new long[n + 1];
            dp[k] = 0;
            List<int> queue = new List<int>();
            queue.Add(k);
            
            while (queue.Count > 0)
            {
                int current = queue[0];
                queue.RemoveAt(0);
                Point found = points[current];
                foreach (Branch branch in found)
                {
                    int other = branch.other(current);
                    if (dp[other] != 0)
                    {
                        continue;
                    }
                    dp[other] = dp[current] + branch.Distance;
                    queue.Add(other);
                }
            }

            for (int i = 0; i < qNum; i++)
            {
                string[] q = Console.ReadLine().Split(' ');
                int x = int.Parse(q[0]);
                int y = int.Parse(q[1]);

                Console.WriteLine(dp[x] + dp[y]);
            }
        }
    }

    class Point : List<Branch>
    {
    }

    class Branch
    {
        public readonly int From;
        public readonly int To;
        public readonly int Distance;

        public Branch(int from, int to, int distance)
        {
            From = from;
            To = to;
            Distance = distance;
        }

        public int other(int current)
        {
            if (current == From)
            {
                return To;
            }

            if (current == To)
            {
                return From;
            }

            throw new Exception();
        }
    }
}

Measured memory_bytes: 39576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vii p(n);
  rep(i,n) {
    int a,b; cin >> a >> b;
    p[i] = ii(a,b);
  }
  ll ans = 0; 
  if (n&1) {
    int target = n/2;
    sort(p.begin(), p.end(), [](ii a, ii b) {return a.first < b.first;});
    int left = p[target].first;
    sort(p.begin(), p.end(), [](ii a, ii b) {return a.second < b.second;});
    int right = p[target].second; 
    ans = right-left+1;
  } else {
    sort(p.begin(), p.end(), [](ii a, ii b) {return a.first < b.first;});
    int left = p[n/2].first + p[n/2-1].first;
    sort(p.begin(), p.end(), [](ii a, ii b) {return a.second < b.second;});
    int right = p[n/2].second + p[n/2-1].second;
    ans = right - left + 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4836
H1, M1, H2, M2, K = map(int, input().split())

#print(H1, M1, H2, M2, K)

mm1 = H1*60+M1
mm2 = H2*60+M2

if mm2 > mm1:
    mmm = mm2-mm1
else:
    mmm = mm2+24*60 - mm1

if mmm > K:
    print(mmm-K)
else:
    print(0)


Measured memory_bytes: 9164
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  map<int64_t, int64_t> exist;
  rep(i, N) {
    cin >> A[i];
    exist[A[i]]++;
  }

  int64_t sum = 0;
  for (auto& n : exist) {
    int64_t num = n.second;
    if (num > 1) sum += (num * (num - 1)) / 2;
  }

  rep(i, N) {
    int64_t num0 = exist[A[i]];
    int64_t num1 = exist[A[i]] - 1;
    int64_t answer = sum;
    if (num0 > 1) answer -= (num0 * (num0 - 1)) / 2;
    if (num1 > 1) answer += (num1 * (num1 - 1)) / 2;
    cout << answer << endl;
  }
  return 0;
}


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

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

  for (int i = 1; i < 10; i++) {
	for (int j = 1; j < 10; j++) {
	  if (i * j == a) {
		cout << "Yes" << endl;
		return 0;
	  }
	}
  }

  cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,k,x,y,money;
	cin>>n>>k>>x>>y;
	if(n>k)
	{
		money=k*x+(n-k)*y;
	}
	else money=n*x;
	cout<<money;
	return 0;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))
tmp = (sum(p[0:K]) + K) / 2
ret = tmp
for i in range(N-K):
    tmp = tmp - (p[i] - p[i+K]) / 2
    ret = max(tmp, ret)
print(ret)


Measured memory_bytes: 71792
'use strict'

const main = (input) => {
    const S = input.split('\n')[0]
    const length = S.length
    const arrLength = [...new Set(S.split(''))].length
    if(length === arrLength){
        console.log('yes')
    }else{
        console.log('no')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

INF = 10 ** 10 + 7


def main():
    X, Y, Z, K = map(int, readline().split())
    A = sorted(list(map(int, readline().split())), reverse=True)
    B = sorted(list(map(int, readline().split())), reverse=True)
    C = sorted(list(map(int, readline().split())), reverse=True)

    ans = solve1(X, Y, Z, K, A, B, C)
    print('\n'.join(map(str, ans)))


def solve1(X, Y, Z, K, A, B, C):

    AB = []
    for i in range(X):
        for j in range(Y):
            AB.append(A[i] + B[j])

    AB.sort(reverse=True)
    AB = AB[:min(X * Y, K)]

    ABC = []
    for i in range(len(AB)):
        for j in range(Z):
            ABC.append(AB[i] + C[j])

    ABC.sort(reverse=True)

    return ABC[:K]


if __name__ == '__main__':
    main()


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

int main() {
    string s, t;
    cin >> s >> t;
    int N = s.size();
    for (int i = 0; i < N && s != t; i++) {
        string tmp = s.substr(0, N - 1);
        s = s[N - 1] + tmp;
    }

    if (s == t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
int n,l;scanf("%d %d",&n,&l);
int ringo[100];
int sum=0;
int min=99999999;
for(int i=1;i<=n;i++){
    ringo[i]=l+i-1;
}

for(int i=1;i<=n;i++){
    if(min>=abs(ringo[i])){min=abs(ringo[i]);}
}

for(int i=1;i<=n;i++){
    if(min==abs(ringo[i])){continue;}
    else{sum=sum+ringo[i];}
}
printf("%d\n",sum);
}

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

int main(){
	int x,y;

	for (;;) {
		cin >> x >> y;
		if (x == 0 && y == 0) {
			break;
		}
		else {
			if (x > y) cout << y << " " << x << endl;
			else cout << x << " " << y << endl;
		}
	}



}


Measured memory_bytes: 3080
#include <stdio.h>

int main(void) {

	int i, j;
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	if ((x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 2676
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int num, max, min;
    long long sum=0;
    
    scanf("%d", &num);
    
    int a[num];
    
    for (int i=0; i<num; i++) {
        scanf("%d", &a[i]);
    }
    
    max = -1000000;
    min = 1000000;
    
    for (int i=0; i<num; i++) {
        if (a[i] > max){
            max = a[i];
        }if (a[i] < min) {
            min = a[i];
        }
        sum += a[i];
    }
    
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

 

ll int power(ll int x, ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
  fastio();

 
ll int T;
T=1;

while(T--)
{
ll int n;
cin>>n;
ll int ans=1,cnt=0,i,x,y,zer=0,cnt1=0,cnt2=0,cnt3=0;
set<pair<ll int,ll int>>s,s1;

map<pair<ll int,ll int>,ll int >mp;
for(i=0;i<n;i++)
{
	cin>>x>>y;
	if(x==0&&y==0){cnt3++;continue;}
	if(x==0||y==0){if(x==0)cnt1++;else cnt2++;
		continue;}
	ll int g=__gcd(abs(x),abs(y));

	x/=g;y/=g;
	if(x*y<0)
	mp[{-1*abs(x),abs(y)}]++;
	else
		mp[{abs(x),abs(y)}]++;
}

for(auto it=mp.begin();it!=mp.end();it++)
{

	
	if(mp.find({-1*it->first.second,it->first.first})==mp.end()&&mp.find({it->first.second,-1*it->first.first})==mp.end()){
		cnt+=it->second;
		
		


	}
	else
	{	if(it->first.first>0&&s.find({-1*it->first.second,it->first.first})==s.end())
		{
			ll int temp=power(2ll,it->second,1000000007)+power(2ll,mp[{-1*it->first.second,it->first.first}],1000000007)-1;
						temp+=1000000007;
						temp%=1000000007;
						ans*=temp;
							ans%=1000000007;s.insert({it->first.first,it->first.second});s.insert({-1*it->first.second,it->first.first});}
		else if(it->first.first<0&&s.find({it->first.second,-1*it->first.first})==s.end())
		{
			ll int temp=power(2ll,it->second,1000000007)+power(2ll,mp[{it->first.second,-1*it->first.first}],1000000007)-1;
						temp%=1000000007;
						temp+=1000000007;
						ans*=temp;
							ans%=1000000007;s.insert({it->first.first,it->first.second});s.insert({it->first.second,-1*it->first.first});

		}
	}
}
if(cnt1&&cnt2)
	{ll int temp=power(2ll,cnt1,1000000007)+power(2ll,cnt2,1000000007)-1;
						temp+=1000000007;
						temp%=1000000007;
						ans*=temp;
							ans%=1000000007;}
else if(cnt1||cnt2)
{
	{ll int temp=power(2ll,cnt1+cnt2,1000000007);
						temp+=1000000007;
						temp%=1000000007;
						ans*=temp;
							ans%=1000000007;}
}

ans*=power(2,cnt,1000000007);
ans%=1000000007;

ans%=1000000007;
ans+=cnt3;
ans%=1000000007;
ans+=1000000007-1;
ans%=1000000007;
cout<<ans<<endl;

}
    return 0;
}


Measured memory_bytes: 16056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

int main() {
  ll n, m;
  string s, t;
  cin >> n >> m >> s >> t;

  // gcd, lcm
  ll g = gcd(n, m);
  ll l = n * (m / g);

  int i = 0, v = 0, w = 0;
  while (v < s.size() && w < t.size()) {
    if (s[v] == t[w]) {
      ++i;
      v = i * n / g;
      w = i * m / g;
      continue;
    }
    cout << -1 << endl;
    return 0;
  }

  cout << l << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include <iostream>
using namespace std;

struct Node
{
	int key;
	Node *right, *left, *parent;		
};

Node *root, *NIL;

Node * find(Node *u, int k)
{
	while(u != NIL && k != u->key)
	{
		if(k < u->key)
		{
			u = u->left;
		}
		else
		{
			u = u->right;
		}
	}

	 return u;
}

void insert(int k)
{
	Node *y=NIL;
	Node *x=root;
	Node *z;

	z=(Node *)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;

	while(x !=  NIL)
	{
		y=x;
		if(z->key < x->key)
		{
			x= x->left;
		}
		else
		{
			x= x->right;
		}
	}

	z->parent=y;
	if(y==NIL)
	{
		root=z;
	}
	else
	{
		if(z->key < y->key)
		{
			y->left=z;
		}
		else
		{
			y->right=z;
		}
	}
}

void inorder(Node *u)
{
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(Node *u)
{
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main()
{
	int n,i,x;
	string com;

	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> com;
		if(com[0] == 'f')
		{
			scanf("%d",&x);
			Node *t = find(root ,x);
			if(t != NIL)
			{
				printf("yes\n");
			}
			else
			{
				printf("no\n");
			}
		}
		else if(com == "insert")
		{
			scanf("%d", &x);
			insert(x);
		}
		else if(com == "print")
		{
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 22056
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val k = readInt()
    val s = readLn()
    println(if (s.length <= k) s else s.substring(0, k) + "...")
}


Measured memory_bytes: 34496
#include<bits/stdc++.h>
#define int long long
#define pb push_back
using namespace std;
const int nax = 102;
int a[nax];

vector<int>v;
signed main(){
	int n, m, sum = 0;
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		sum += a[i];
	}
	cin >> m;
	while(m--){
		int x, b;
		cin >> x >> b;
		v.pb(sum-a[x]+b);
	
	}	
	for(auto u:v){
		cout << u << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  string s, t;
  cin >> s >> t;

  cout << t << s << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;

int main(){
    vector<int> yama;
    for (int i=0; i<10; i++) {
        int hi;
        cin >>hi;
        yama.push_back(hi);
    }
    sort(yama.begin(), yama.end());
    for (int i=0; i<3; i++) {
        cout << yama[9-i]<<endl;
    }
}

Measured memory_bytes: 1216
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m=sc.nextInt();
		long[] ame=new long[n+1];
		ame[0]=0;
		for(int i=0; i<n; i++) {
			ame[i+1]=sc.nextLong();
		}
		for(int i=1; i<=n; i++) {
			ame[i]=(ame[i]+ame[i-1])%m;		//累積和
		}
		Arrays.sort(ame);		//ソート
		long sousu=0;
		long genzai=0;
		long dist=0;
		for(int i=0; i<=n; i++) {
			if(ame[i]==genzai) {
				dist++;
			}
			else if(ame[i]!=genzai) {
				sousu+=(dist*(dist-1)/2);
				genzai=ame[i];
				dist=1;
			}
		}
		sousu+=dist*(dist-1)/2;
		System.out.println(sousu);
	}

}


Measured memory_bytes: 61948
n,m=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
c.reverse()
def roop(n,m,c,check,nowans,nown,ans):
    if nowans+nown//c[check]>=ans:return ans
    if c[check]==1:
        return min(nowans+nown,ans)
    if c[check]>nown:
        ans=roop(n,m,c,check+1,nowans,nown,ans)
    elif c[check]<=nown:
        for i in range(nown//c[check],-1,-1):
            ans=roop(n,m,c,check+1,nowans+i,nown-i*c[check],ans)
    return ans
print(roop(n,m,c,0,0,n,n))


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

typedef vector <long long> vi;
typedef vector <vi> vvi;
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define ll long long
#define MAX (ll)(1e5 + 5)
#define MAXN 105
#define NIL -(ll)(1e9)

ll weight[MAXN], value[MAXN], dp[MAXN][MAX];

ll knapsack(ll n, ll w)
{
    if (w < 0)
        return NIL;
    if (n < 0)
        return 0;

    if (dp[n][w] == -1)
        dp[n][w] = max(knapsack(n - 1, w - weight[n])+ value[n], knapsack(n - 1, w));
    return dp[n][w];
}

int main(void)
{
    ll n, w;
    cin >> n >> w;
    for (int i = 0; i < n; i++)
        cin >> weight[i] >> value[i];

    memset(dp, -1, sizeof(dp));
    cout << knapsack(n - 1, w) << "\n";
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n ;
	VI p(n), sq(n);
	rep(i, n) cin >>p[i];
	rep(i, n) sq[p[i]-1] = i;
	ll ans =0;
	set<int> st;
	st.insert(-MD); st.insert(MD);

	repr(zi, n-1, 0){
		ll z = sq[zi] +1;
		st.insert(z);
		ll r1 =n+1, r2 =n+1, l1 = 0, l2 =0;
		auto it = st.find(z); it--;
		if(*it != -MD){
			l2 = *it; it--;
			if(*it != -MD) l1=*it;
		}
		it = st.find(z);
		it++;
		if(*it != MD){
			r1 = *it; it++;
			if(*it != MD) r2=*it;
		}
		
		ans += ((z-l2) * (r2-r1) + (l2-l1)*(r1-z) ) * (p[sq[zi]]);
	}
	cout << ans <<"\n";
	return 0;
	
}


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

typedef long long ll;

map<ll, ll> dp;

ll go(ll h) {
    if(h == 0) return 0;

    if(dp.count(h)) return dp[h];

    return dp[h] = 1 + go(h / 2) + go(h / 2);
}

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

    ll H;
    cin >> H;

    cout << go(H) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n;
bool flag=true;
void Main(){    
    cin>>n;
    vector<ll> b(n);
    vector<ll> rireki;
    For(i,0,n) cin>>b.at(i);
    while(b.size()){
        flag=true;
        for(ll i=b.size()-1;i>-1;i--){
            if(b.at(i)==i+1){
                rireki.push_back(i+1);
                b.erase(b.begin()+i);
                flag=false;
                break;
            }
        }
        if(flag){
            cout<<-1<<endl;
            return;
        }
    }
    reverse(rireki.begin(),rireki.end());
    For(i,0,n){
        cout<<rireki.at(i)<<endl;
    }
}
int main(){
    Main();
    return 0;
}


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  sort(a, a+3);

  int d = abs(a[1] - a[0]);
  d += abs(a[2]-a[1]);

  cout << d << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.Numerics;
using System.Collections.Generic;
using System.Linq;
 
 
namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = myRead.readLongArray();
            long a = Abs(s[0]) / s[2];
            long b = Abs(s[0]) % s[2];
            long ans = 0;
            if (a < s[1])
            {
                long n = s[1] - a;
                int hugo = s[0] > 0 ? 1 : -1;
                ans = hugo * (n % 2 == 0 ? b : -(b - s[2]));
            }
            else
            {
                ans = s[0] > 0 ? s[0] - s[1] * s[2] : s[0] + s[1] * s[2];
            }
            WriteLine(Abs(ans));
        }
    }
    public static class myRead
    {
        public static int readInt() { return int.Parse(ReadLine()); }
        public static long readLong() { return long.Parse(ReadLine()); }
        public static string reatStr() { return ReadLine(); }
        public static int[] readIntArray() { return ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        public static long[] readLongArray() { return ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        public static string[] readStrArray() { return ReadLine().Split(' '); }
    }
 
 
    public static class MyMath
    {
        public static long Factorical(long n)
        { return n <= 1 ? 1L : n * Factorical(n - 1); }
        public static long Permutation(long n, long m)
        { return m == 0 ? 1L : (m == n) ? Permutation(n, m - 1) : n * Permutation(n - 1, m - 1); }
        public static long Combination(long n, long m)
        { return n - m > m ? Permutation(n, m) / Factorical(m) : Permutation(n, n - m) / Factorical(n - m); }
        public static long Gcd(long n, long m)
        { return n % m == 0 ? m : Gcd(m, n % m); }
        public static long Lcm(long n, long m)
        { return n * m / Gcd(n, m); }
        public static long Pow(long n, long m)
        { return m == 0 ? 1L : m == 1 ? n : n * Pow(n, m - 1); }
    }
 
 
}

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

using namespace std;

const bool debug = true;
#define dbg(...) if(debug) printf(__VA_ARGS__)
#define print(var) if (debug) cout << #var << " = " << var << endl

namespace {
    /** utility functions for reading a pair or a vector from stdin. */
    template<typename K, typename V> istream& operator>>(istream& is, pair<K, V>& p) { return is >> p.first >> p.second; }
    template<typename T> istream& operator>>(istream& is, vector<T>& xs) { for (auto& x : xs) is >> x; return is; }

    int N;
    vector<string> S;
    void input() {
        cin >> N;
        S.resize(N);
        cin >> S;
    }

    void succ(string& s) {
        if (s.empty()) s = "a";
        else if (s.back() == 'z') {
            string t = s.substr(0, s.size() - 1);
            succ(t);
            s = t + 'a';
        } else {
            s.back()++;
        }
    }

    void solve() {
        string s; {
            ostringstream os;
            for (auto x : S) os << x << "|";
            s = os.str();
        }
        unordered_set<string> m;
        for (int k = 0; k <= 4; k++) {
            for (int i = 0; i + k <= s.size(); i++) {
                m.insert(s.substr(i, k));
            }
        }
        string x = "a";
        while (true) {
            //print(x);
            if (m.count(x)) {
                succ(x);
            } else {
                cout << x << endl;
                break;
            }
        }
    }
}

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




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

using ll = long long;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    int n;cin>>n;

    ll g=1;
    for(int i=0;i<n;i++)
    {
        ll t;cin>>t;
        g=lcm(g,t);
    }

    cout<<g<<"\n";

    return 0;
}


Measured memory_bytes: 3628
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll a[3002];
ll dp[3002][3002][2];
ll dequeans(ll i,ll j, ll ch)
{
	if(dp[i][j][ch]!=-1)
	{
		return dp[i][j][ch];
	}
	if(i==j)
	{
		if(ch==0)
			return a[i];
		else
			return -a[i];
	}
	else
	{
		if(ch==0)
		{
			dp[i][j][ch]=max(dequeans(i+1,j,1-ch)+a[i],dequeans(i,j-1,1-ch)+a[j]);
		}
		else{
			dp[i][j][ch]=min(dequeans(i+1,j,1-ch)-a[i],dequeans(i,j-1,1-ch)-a[j]);
		}
	}
	return dp[i][j][ch];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    for (int i = 0; i <=3000; ++i)
    {
    	/* code */
    	for (int j = 0; j <=3000; ++j)
    	{
    		/* code */
    		dp[i][j][0]=-1;
    		dp[i][j][1]=-1;
    	}
    }
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    cout<<dequeans(0,n-1,0)<<'\n';
}


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

int main()
{

	long int d , s , n , t , i , j;
	string s1,s2;
  	cin >> s1 >>s2;
    n = s1.length();
    int m = s2.length(); 
  	int min  = s1.length();
    for (i = 0 ; i < n-m+1 ; i++)
    {
        int c = 0;
			for(j = 0;j < m;j++)
            {
            		if(s2[j] != s1[i+j]) 
                  		c++;    
            }
         if(c < min )
           min  = c;
    }
	cout << min;  
  
  	return 0;
}


Measured memory_bytes: 3624