akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000007
#define MOD 1000000007
#define ARRAY_MAX 100005


int main(){

    ll n,k;
    cin >> n >> k;
    vector<ll> a(ARRAY_MAX,0);
    vector<ll> dp(ARRAY_MAX,INF);
    REP(i,n){
        cin >> a[i+1];
    }
    
    dp[0] = 0;
    dp[1] = 0;

    for(ll i = 1;i <= n;i++){//n段に行く
        for(ll j = 1;j <= k;j++){//k段前から
            if(i - j > 0){
                dp[i] = min(dp[i],dp[i-j] + abs(a[i]-a[i-j]));
            }            
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1792
N,K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
rui = [0]*(N+1)
for i in range(1,N+1):
    rui[i] = rui[i-1] + l[i-1]
maxwa = 0
for i in range(N-K+1):
    wa = rui[K+i]-rui[i]
    maxwa = max(maxwa,wa)
print((maxwa+K)/2)

Measured memory_bytes: 25188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (1e9 + 7)

int main(void){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll res = 0;
    if(K<A){
        res = K;
    }
    else if(K>=A && K<=A+B){
        res = A;
    }
    else{
        res = 2*A - K + B;
    }
    cout << res << endl;
}


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

int main(void){
    string s;
    cin >> s;
    int count = 700;
    if(s[0] == 'o')count += 100;
    if(s[1] == 'o')count += 100;
    if(s[2] == 'o')count += 100;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
       printf("a < b\n");
       }
    if(a>b){
      printf("a > b\n");
      }
    if(a==b){
      printf("a == b\n");
      }
	return 0;
}

Measured memory_bytes: 580
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <stdio.h>
#include <sys/time.h>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef pair<int, PP> IPP;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define LREP(i,n) LFOR(i,0,n)
#define LRFOR(i,a,b) for(ll i=(b)-1;i>=(a);--i)
#define LRREP(i,b,a) LRFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define REACH(i,c) RREP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define BR cout << "\n"

#define dump(x) if(DEBUG)cerr<<"[" << __LINE__ << "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
			<<" , "<<#y<<"="<<(y)<<"\n"\
			<<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr << "[" << __LINE__ << "] " << (x) << "\n"

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

ll ans;

VI es[30];
int tabl[30][100000];

int main() {
	omajinai;
	int n,c;
	cin>>n>>c;
	REP(i, n){
		int s,t,k;
		cin>>s>>t>>k;
		k--;
		FOR(x,s,t+1)
		tabl[k][x]=1;
	}
	ans = 0;
	REP(i, 100000){
		int t=0;
		REP(j,c){
			if(tabl[j][i])t++;
		}
		ans=max(ans,(ll)t);
	}

	cout << ans << endl;


//	if(n%s==0){
//		cout << "Yes" << endl;
//	}else{
//		cout << "No" << endl;
//	}
}


Measured memory_bytes: 12032
#include <iostream>

using namespace std;

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

    }
    cout<<flag;
    return 0;
}


Measured memory_bytes: 3612
// res = 0
// for i in 1 ... N
//      for j in 1 ... N
//          if i%j == 0     res += i;
// これを入れ替えると、
// for j in 1 ... N
//      for i in 1 ... N
//          if i%j == 0     res +- i
#include <bits/stdc++.h>
using namespace std;

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

    long long res = 0;
    for (int j = 1; j <= N; ++j) {
        // j + 2*j + ... + N/j * j = (1 + 2 + ... + N/j)*j = N/j*(N/j + 1) * j / 2
        long long Y = N / j;
        res += Y * (Y + 1LL) * (long long)j / 2LL;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> L(2*N);
    for (int i = 0; i < 2*N; i++) {
        cin >> L[i];
    }
    sort(ALL(L));
    int ans = 0;
    for (int i = 0; i < 2*N; i+=2) {
        ans += L[i];
    }

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

}

Measured memory_bytes: 3700
/* ex4_3
   Acro  */

#include <stdio.h> 
int stone_monument(int height_w,int height_e);

int main(void){
    int height_w,height_e;
    scanf("%d %d",&height_w,&height_e);
    printf("%d\n",stone_monument(height_w,height_e));
    return 0;
}

int stone_monument(int height_w,int height_e){
    int diff,height_true,i;
    height_true = 0;
    /* 差を計算 */
    diff = height_e - height_w;
    /* 元の高さを計算 */
    for(i=1; i < diff; i++){
        height_true += i;
    }
    return height_true - height_w;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    list<char> s;
    string str; cin >> str;
    int ju{0};
    REP(i, str.length())
    {
        s.push_back(str[i]);
    }
    lol q; cin >> q;
    REP(i, q)
    {
        int t; cin >> t;
        if(t == 1)
            ju++;
        else if(t == 2)
        {
            int f; cin >> f;
            char ch; cin >> ch;
            if(ju%2 == 0)
            {
                if(f == 1)
                    s.push_front(ch);
                else
                    s.push_back(ch);
            }
            else
            {
                if(f == 2)
                    s.push_front(ch);
                else
                    s.push_back(ch);
            }
            
        }
    }

    if(ju%2 == 0)
        for(list<char>::iterator itr = s.begin(); itr != s.end(); itr++)
        {
            cout << *itr;
        }
    else
    {
        //list<char>::const_reverse_iterator itEnd = s.rend();
        for(list<char>::const_reverse_iterator it = s.rbegin(); it != s.rend(); it++)
            cout << *it;
    }
    cout << endl;
    return 0;
}

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

typedef pair<int, int> P;

int main() {
  int n;
  while ( cin >> n, n ) {
    vector<P> dat[n+1];    
    for ( int i = 0; i < n+1; i++ ) {
      int m;
      cin >> m;
      vector<int> x(m), y(m);
      for ( int j = 0; j < m; j++ ) {
	cin >> x[j] >> y[j];
	if ( j == 1 ) dat[i].push_back(P(max(abs(x[1]-x[0]), abs(y[1]-y[0])), -1));
	else if ( j > 1 ) {
	  if ( (y[j-2]>y[j-1] && x[j-1]<x[j]) || (x[j-2]<x[j-1] && y[j-1]<y[j]) ||
	       (y[j-2]<y[j-1] && x[j-1]>x[j]) || (x[j-2]>x[j-1] && y[j-1]>y[j]) ) {	    
	    dat[i].push_back(P(max(abs(x[j]-x[j-1]), abs(y[j]-y[j-1])), 0));    
	  } else {
	    dat[i].push_back(P(max(abs(x[j]-x[j-1]), abs(y[j]-y[j-1])), 1));    
	  }
	}
      }
    }

    vector<P> tmp0, tmp0_, dat0_;    
    {
      tmp0 = dat[0];
      int sz = tmp0.size();
      reverse(tmp0.begin(), tmp0.end());
      tmp0[0].second = -1;
      for ( int i = 1; i < (int)tmp0.size(); i++ ) tmp0[i].second = !dat[0][sz-i].second;
      tmp0_ = tmp0;
      for ( int i = 1; i < (int)tmp0.size(); i++ ) tmp0_[i].second = !tmp0[i].second;
      dat0_ = dat[0];      
      for ( int i = 1; i < (int)tmp0.size(); i++ ) dat0_[i].second = !dat[0][i].second;      
    }

    /*
    cout << endl;
    for ( P p: dat[0] ) cout << p.first << " " << p.second << endl;
    cout << endl;
    cout << endl;
    for ( P p: tmp0 ) cout << p.first << " " << p.second << endl;
    cout << endl;
    */
    
    for ( int i = 1; i < n+1; i++ ) {
      /*
      cout << endl;
      for ( P p: dat[i] ) cout << p.first << " " << p.second << endl;
      cout << endl;
      */

      if ( dat[0] == dat[i] || tmp0 == dat[i] /*|| tmp0_ == dat[i] *//*|| dat0_ == dat[i]*/ ) cout << i << endl;      
    }
    cout << "+++++" << endl;
  }
  
  return 0;
}



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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N, K;
vector<ll> A;

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

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

  cin >> N >> K;
  ll before = N;

  // 自分解答
  //if (N%K == 0) cout << 0 << endl;
  //else if (N%K>double(K)/2) {
  //  cout << abs(N%K-K) << endl;
  //}else{
  //  cout << N << endl;
  //}
  //
  //
  // 模範解答
  cout << min(N%K, abs(K-N%K)) << endl;
  //
  
  return 0;
}


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

int main()
{
	long long H, W; cin >> H >> W;

	if (H % 3 == 0 || W % 3 == 0)cout << 0 << endl;
	else {
		long long ans = 1000000;

		ans = min(ans, W);
		for (long long h = 1; h < H; h++) {
			vector<long long>s(3);
			s[0] = W*h;
			s[1] = W / 2 * (H-h);
			s[2] = (W - W / 2) * (H-h);
			sort(s.begin(), s.end());
			ans = min(ans,s[2]-s[0]);
		}

		ans = min(ans, H);
		for (long long w = 1; w < W; w++) {
			vector<long long>s(3);
			s[0] = H*w;
			s[1] = H / 2 * (W-w);
			s[2] = (H - H / 2) * (W-w);
			sort(s.begin(), s.end());
			ans = min(ans, s[2] - s[0]);
		}

		cout << ans << endl;
	}


    return 0;
}



Measured memory_bytes: 256
while(1):
    h, w = map(int, input().split())
    if h==0 & w==0:
        break
    for i in range(h):
        line = ""
        for j in range(w):
            if (j%2+i%2)%2:
                line += "."
            else:
                line += "#"
        print(line)
    print("")


Measured memory_bytes: 5612
#include<iostream>
#include<algorithm>
#include<climits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int NMAX=1<<17;
ll fast_pow(ll x,ll n){
  ll res=1;
  while(n>0){
    if(n&1) res*=x;
    x*=x;
    n>>=1;
  }
  return res;
}
ll a,b;
ll bit[45];
int main(){
  scan(a);scan(b);
  ll x=1,y=0;
  while(x<=b){
    x*=2;
    y++;
  }
  /* prin(y);
     prin(fast_pow(2,0));*/
  if(a!=0)a-=1;
  ll ans=0;
  rep(i,y){
    ll cna,cnb;
    ll pp=fast_pow(2,i);
    if((a/pp)%2==0){
      cna=((a/pp)/2)*pp;
    }
    else{
      cna=a%pp+1+((a/pp)/2)*pp;
    }
    if((b/pp)%2==0){
      cnb=((b/pp)/2)*pp;
    }
    else{
      cnb=b%pp+1+((b/pp)/2)*pp;
    }
    ans+=pp*((cnb-cna)%2);
  }
  prin(ans);

  

  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(311111)
    # import numpy as np
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    tmp = ini()
    print(("ACL"*tmp))

    
    



    


        
        
        


    
        


        


    




















if __name__ == "__main__":
    main()


Measured memory_bytes: 61700
import java.io.*;
import java.util.*;

public class Main {
	// ------------------------
	
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		// ------------------------
		long r=sc.nextLong();
		System.out.println(3*r*r);
		// ------------------------
		out.close();
	}
	//------------------------
	
	public static PrintWriter out;
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 21332
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	ls := nextIntSlice(sc, 3)
	min := math.MaxInt64
	for i := range ls {
		v := ls[(i+1)%len(ls)] * ls[(i+2)%len(ls)]
		if ls[i%len(ls)]%2 == 0 {
			v = 0
		}
		if v < min {
			min = v
		}
	}
	return min
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    String s=sc.next();

    if (k>1) {
      if (s.charAt(k-1)=='A') {
        String str1=s.substring(0,k-1);
        String str2="a";
        String str3=s.substring(k);
        System.out.println(str1+str2+str3);
      }
      if (s.charAt(k-1)=='B') {
        String str1=s.substring(0,k-1);
        String str2="b";
        String str3=s.substring(k);
        System.out.println(str1+str2+str3);
      }
      if (s.charAt(k-1)=='C') {
        String str1=s.substring(0,k-1);
        String str2="c";
        String str3=s.substring(k);
        System.out.println(str1+str2+str3);
      }
      // System.out.println(str1+str2+str3);
    }else{
      if (s.charAt(k-1)=='A') {
        String str1="a";
        String str2=s.substring(1);
        System.out.println(str1+str2);
      }
      if (s.charAt(k-1)=='B') {
        String str1="b";
        String str2=s.substring(1);
        System.out.println(str1+str2);
      }
      if (s.charAt(k-1)=='C') {
        String str1="c";
        String str2=s.substring(1);
        System.out.println(str1+str2);
      }
      // System.out.println(str1+str2);
    }
  }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main(){
  double n,a[100],ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
      ans+=1/a[i];
  }
  cout<<1/ans<<endl;
  return(0);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> ka[101010];

ll rec(ll x){
	if(ka[x].size()==0) return 0;
	vector<ll> list;
	REP(i, ka[x].size()){
		list.push_back(rec(ka[x][i]));
	}
	sort(list.rbegin(), list.rend());
	ll res = -1;
	REP(i, list.size()){
		res = max(res, list[i]+i+1);
	}
	return res;
}

int main(){
	ll N;
	cin >> N;
	REP(i, N-1){
		ll a;
		cin >> a;
		a--;
		ka[a].push_back(i+1);
	}

	cout << rec(0) << endl;
    return 0;
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    for (ll i = 0; i < n; i++) cin >> p[i];
    vector<ll> sums(n + 1);
    sums[0] = 0;
    for (ll i = 0; i < n; i++) sums[i + 1] = sums[i] + p[i];
    ll ans = 0;
    for (ll i = 0; i < n - k + 1; i++) {
        ll tmp = sums[k + i] - sums[i];
        ans = max(ans, tmp);
    }
    cout << fixed << setprecision(15) << (ans + double(k)) / 2;
}


Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
    int N,A[101];
    cin >> N;
    int v, j;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    for(int i = 0; i < N; i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        for(int k = 0; k < N; k++){
            if(k < N - 1)
                cout << A[k] << " ";
            else
                cout << A[k] << endl;;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3096
import sys
input = sys.stdin.readline

_n = int(input())
_s = input()[:-1]
slist = [item for item in _s]


def chker(sl):
    if len(sl) == 1:
        print(1)
        return

    cnt = 1
    for i in range(1, len(sl)):
        if sl[i] != sl[i - 1]:
            cnt += 1

    print(cnt)


chker(slist)


Measured memory_bytes: 4212
N = int(input())
K = int(input())

xi = input().split()


if N != len(xi):
    print('err')
    exit()

sum = 0

for i in range(N):
    if int(xi[i]) >= K - int(xi[i]):
        add = K - int(xi[i])
    else:
        add = int(xi[i])
    sum += add * 2

print(sum)

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

using namespace std;

#define LL long long
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int n;
LL val[1000002],weight[1000002],dp[100002][1025];

int main()
{
    FAST();
    int i,j,k,l,q,x;
    LL w,ans,cur,check;
    cin >> n;
    l=min(1023,n);
    for(i=1;i<=n;i++)cin >> val[i] >> weight[i];
    for(i=1;i<=1e5;i++)
    {
        for(j=1;j<=l;j++)
        {
            if(weight[j] <= i)dp[i][j]=max(dp[i][j/2],val[j]+dp[i-weight[j]][j/2]);
            else dp[i][j]=dp[i][j/2];
        }
    }
    cin >> q;
    while(q--)
    {
        cin >> x >> w;
        if(x <= l)cout << dp[w][x] << '\n';
        else
        {
            vector<int>v;
            while(x > l)v.emplace_back(x),x/=2;
            ans=dp[w][x],k=1 << (int)v.size();
            for(i=1;i<k;i++)
            {
                cur=check=0;
                for(j=0;j<v.size();j++)
                {
                    if((i >> j) & 1)cur+=val[v[j]],check+=weight[v[j]];
                }
                if(check <= w)
                {
                    cur+=dp[w-check][x];
                    ans=max(ans,cur);
                }
            }
            cout << ans << '\n';
        }
    }
    return 0;
}


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

int N, S;
vector<int> A;

int main(){
    cin >> N >> S;
    A.resize(N);
    for(auto &v: A)
        cin >> v;
    
    int s = 0;
    int l = 0, r = 0;
    
    int ans = 1<<30;
    while(r<N){
        while(r<N && s<S){
            s += A[r++];
        }
        while(l<N && s>=S){
            ans = min(ans, r-l);
            s -= A[l++];
        }
    }
    cout << (ans==1<<30? 0: ans) << endl;
    
    return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int Value[N];
    int Cost;
    int answer=0;
    for(int i=0; i<N; i++){
        cin >> Value[i];
    }
    for(int i=0; i<N; i++){
        cin >> Cost;
        if(Cost<Value[i]) answer+=(Value[i]-Cost);
    }
    cout << answer;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

min_degree = 10000

for i in range(len(H)):
  temp = T - H[i]*0.006
  if abs(A-temp) < min_degree:
    min_degree = abs(A-temp)
    ans = i+1
    
print(ans)

Measured memory_bytes: 9232
#include <stdio.h>
int main()
{
  int n,i,j,a,b;
  for(;;){
    scanf("%d",&n);
    if(n == 0) break;
    a = 0; b = 0;
    while(n>0){
      scanf("%d%d",&i,&j);
      if(i>j) a += i+j;
      else if(j>i) b += i+j;
      else {
	a += i;
	b += j;
      }
      n--;
    }
    printf("%d %d\n",a,b);
  }
  return 0;
}

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

#include <iostream>

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#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, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
  lint k,n;
  cin >> k >> n;
  vector<lint> A(n);
  REP(i,n){
   cin >> A[i]; 
  }
  lint max = 0;
  REP(i,n){
   if(i == n-1){
     if(max < k - A[n-1] + A[0]){
    	max = k - A[n-1] + A[0];
     }
   }else{
     if(max < A[i+1] - A[i]){
    	max = A[i+1] - A[i];
     }
   }
  }
  cout << k - max;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define N 10000
typedef long long ll;
using namespace std;
int main()
{
    char a[100];
    int flag=0;
    scanf("%s",a);
    for (int i=0;i<strlen(a);i++)
    {
        if (a[i]=='A'&&a[i+1]=='C')
          {
               flag=1;
               break;
          }
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

class Main{
    public static void main(String[] args) throws IOException{
        final PrintWriter out = new PrintWriter(System.out);
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final List<process> pl = new LinkedList<process>();
        String[] in = br.readLine().split(" ");
        final int n = Integer.parseInt(in[0]);
        final int q = Integer.parseInt(in[1]);
        int now = 0;
        for(int i = 0; i<n; i++){
            in = br.readLine().split(" ");
            final String name = in[0];
            final int time = Integer.parseInt(in[1]);
            if(time<=q){
                now += time;
                out.print(name);
                out.print(' ');
                out.println(now);
            }else{
                now += q;
                pl.add(new process(name, time-q));
            }
        }
        while(!pl.isEmpty()){
            final Iterator<process> i = pl.iterator();
            while(i.hasNext()){
                final process p = i.next();
                if(p.getTime()<=q){
                    now += p.getTime();
                    out.print(p.getName());
                    out.print(' ');
                    out.println(now);
                    i.remove();
                }else{
                    now += q;
                    p.setTime(p.getTime()-q);
                }
            }
        }
        out.flush();
    }
}

class process{
    private final String name;
    private int time;
    process(String name, int time){
        this.name = name;
        this.time = time;
    }
    public final String getName(){
        return name;
    }
    public final int getTime(){
        return time;
    }
    public final void setTime(int time){
        this.time = time;
    }
}

Measured memory_bytes: 52856
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

#define INF 10000000
const int n_max = 100050;
vector<vector<int>> root(n_max);
vector<int> dist(n_max, INF);
vector<int> from(n_max);


void bfs(int st){
    queue<int> q;
    q.push(st);
    dist[st] = 0;

    while(!q.empty()){
        int now = q.front(); q.pop();
        for(auto next : root[now]){
            if (dist[next] != INF) continue; //既に探索
            q.push(next);
            dist[next] = dist[now]+1;
            from[next] = now+1;
        }
    }
}


int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b; a--; b--;
        root[a].push_back(b);
        root[b].push_back(a);
    }
    
    bfs(0);

    bool isok = true;
    for (int i = 1; i < n; i++)
    {
        if (dist[i] == INF) isok = false;
    }
    if (!isok){
        cout << "No"  << endl;
        return 0;
    } else {
        cout << "Yes" << endl;
    }

    for (int i = 1; i < n; i++)
    {
        cout << from[i] << endl;
    }
    return 0;
}



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

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); 

	string n;
	cin >> n;
	if (n[n.size()-1] == '3'){
		cout << "bon";
	} else if (n[n.size()-1] == '0' || n[n.size()-1] == '1' || n[n.size()-1] == '6' || n[n.size()-1] == '8'){
		cout << "pon";
	} else {
		cout << "hon";
	}

}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int arr[3001] = {0};
	arr[0] = 1; 
	REP(i, r, n+1) arr[i] += arr[i-r];
	REP(i, g, n+1) arr[i] += arr[i-g];
	REP(i, b, n+1) arr[i] += arr[i-b];
	cout << arr[n];

}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main() 
{
	int cntC = 0;
	string s;
	cin >> s;

	if (s[0] != 'A')
	{
		cout << "WA" << endl;
		return 0;
	}

	if (isupper(s[1]) || isupper(s[s.size() - 1]))
	{
		cout << "WA" << endl;
		return 0;
	}

	for (int i = 2; i < s.size() - 1; i++)
	{
		if (s[i] == 'C')
		{
			cntC++;
			if (cntC > 1)
			{
				cout << "WA" << endl;
				return 0;
			}
		}
		else
		{
			if (isupper(s[i]))
			{
				cout << "WA" << endl;
				return 0;
			}
		}
	}

	if (cntC == 0)
	{
		cout << "WA" << endl;
		return 0;
	}

	cout << "AC" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <math.h>
#include <string>
using namespace std;
int main() {
    int num1, num2;

    scanf("%d", &num1);
    scanf("%d", &num2);

    if (num1 % 2 == 0 || num2 % 2 == 0) {
        printf("Even\n");
        return 0;
    }

    printf("Odd\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 1002;
const int mo = 1e9 + 7;

int n, m;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n >> m;
    vector<int> f(m);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        vector<int> g = f;

        for (int j = 0; j < m; ++j) {
            if (i == 0 && j == 0) {
                f[j] = 1;
                continue;
            }
            f[j] = 0;
            if (s[j] == '.') {
                if (j > 0)
                    f[j] += f[j-1];
                if (i > 0)
                    f[j] += g[j];

                f[j] %= mo;
            }
        }
    }

    cout << f[m-1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int a,b;
  cin>>a>>b;
  int counter=1;
  int cnt=0;
 while(counter<b){
  counter--; 
 counter+=a;
 cnt++;
 }
  cout<<cnt<<endl;
}

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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mx 3000
ll n,m;
ll dp[100005];//dp[i]=len of longest path starting at i node
vector<ll>graph[100005];//at graph[i] th node vector neighbour nodes
ll solve(ll src){
   if(dp[src]!=-1)return dp[src];
    ll leaf=1;
  ll bestchild=0;
  for(ll child: graph[src]){
    leaf=0;
    bestchild=max(bestchild,solve(child));
  }
  return dp[src]=leaf?0:1+bestchild;
}
int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ans,ck,k,p,q,r,t,add=0,w,x,y,z;
    cin>>n>>m;
    memset(dp,-1,sizeof dp);

    for(int i=0;i<m;i++)
        {
            ll u,v;
             cin>>u>>v;
             graph[u].pb(v);}
   ans=0;
   for(int i=1;i<=n;i++){
    ans=max(ans,solve(i));

   }
    cout<<ans<<endl;





    return 0;
}



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

int main() {
  string S;
  cin >> S;
  int count = 0;

  for (int i = 0; i < S.length() - 1; i++) {    
    for (int j = i + 1; j < S.length(); j++) {
      if (S[i] == S[j]) count++;
    }
  }
  if (count == 0) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            String S = in.next();
            StringBuilder sb = new StringBuilder(S);
            sb.replace(K - 1, K, S.substring(K - 1, K).toLowerCase());
            out.println(sb.toString());
        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<int> A(n);
    vector<int> B(m);
    for(int i=0;i<n;i++) cin >> A[i];
    for(int i=0;i<m;i++) cin >> B[i];

    vector<ll> A_cum(n+1);
    vector<ll> B_cum(m+1);
    for(int i=1;i<=n;i++){
        A_cum[i]=A_cum[i-1]+A[i-1];
    }
    for(int i=1;i<=m;i++){
        B_cum[i]=B_cum[i-1]+B[i-1];
    }

    int ans=0;
    int j=m;
    for(int i=0;i<=n && A_cum[i]<=k;i++){
        while(A_cum[i]+B_cum[j]>k && j>=0){
            j--;
        }
        ans=max(ans,i+j);
    }
    cout << ans << endl;
}

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

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    int d = n%10;
    if (d==2 or d==4 or d==5 or d==7 or d==9) cout<<"hon";
    else if (d==0 or d==1 or d==6 or d==8) cout<<"pon";
    else cout<<"bon";

    return 0;
}

Measured memory_bytes: 3652
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    k = ni()

    check = set()

    for left in range(0, len(s)):
        for right in range(left+1, left+k+1):
            check.add(s[left:right])
    
    print(sorted(list(check))[k-1])

if __name__ == '__main__':
    main()

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

int main()
{
  int n,m,k;
  cin >> n >> m >> k;
  
  vector<int> a(n);
  for(int i=0; i<n; ++i) {
    cin >> a.at(i);
  }
  
  vector<int> b(m);
  for(int i=0; i<m; ++i) {
    cin >> b.at(i);
  }
  
  int bestNum = 0;
  int numA = 0;
  int numATime = k;
  
  int numB = 0;
  int numBTime = 0;
  
  {
    int tempK = k;
  	for(int i=0; i<n; ++i) {
    	tempK -= a[i];
    	if (tempK < 0 ) {
          tempK += a[i];
      		break;
    	}
      	++bestNum;

  	}
    numA = bestNum;
    numATime = tempK;
    numBTime = numATime;
    
    for(int i=0; i<m; ++i) {
    	tempK -= b[i];
    	if (tempK < 0 ) {
      		break;
    	}
      ++bestNum;
  	}
  }
  
  while(numA > 0) {
    --numA;
    int tempK = numBTime;
    int tempNum = 0;
    
    numATime += a[numA];
    tempK += a[numA];
    tempNum = numA; 
    
    tempNum += numB;
    
    for(int mi = numB; mi < m; ++mi){
      tempK -= b[mi];
      if(tempK < 0) {
        tempK += b[mi];
        break;
      }
      ++numB;
    }
    
    numBTime = tempK;
    tempNum = numA + numB;
    
    if(tempNum > bestNum ){
      bestNum = tempNum;
    }
  }
  
  cout << bestNum;  
  
    return 0;
}


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

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

    int a[M];
    int b[M];
    for (int j = 0; j < M; ++j) {
        cin >> a[j] >> b[j];
    }

    vector<int> order;
    for (int i = 1; i <= N ; ++i)  order.push_back(i);

    int sum = 0;
    do {
        int a_t = *order.begin();
        if (a_t != 1) {
            continue;
        }

        bool allok = true;
        for (auto b_e = ++order.begin(); b_e != order.end(); ++b_e) {
            bool ok = false;
            for (int i = 0; i < M; ++i) {
                if ((a_t == a[i] && *b_e == b[i]) || (a_t == b[i] && *b_e == a[i])) {
                    ok = true;
                    break;
                }
            }
            if (ok) {
                a_t = *b_e;
            } else {
                allok = false;
                break;
            }
        }
        if (allok) sum++;
    } while (next_permutation(order.begin(), order.end()));
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
int gcd(int x, int y) {
    int r;
    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    int ans = a[0];
    for (int ai : a) ans = gcd(ans, ai);
    cout << ans << '\n';
}


Measured memory_bytes: 640
m,d = map(int, input().split())
if d < 10:
    print(0)
    exit()
ans = 0
for i in range(1,m+1):
    for j in range(10,d+1):
        j = str(j)
        c = int(j[0])
        g = int(j[1])
        if c > 1 and g > 1 and c*g == i:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    double a, b, h, m, ht, mt, t;
    cin >> a >> b >> h >> m;
    ht = 2*M_PI * (h / 12 + m / 60 / 12);
    mt = 2*M_PI * m / 60;
    t = min(abs(ht - mt), 2*M_PI - abs(ht - mt));
    printf("%.16lf\n", sqrt(a*a + b*b - 2*a*b*cos(t)));
    return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

// トポロジカルソート　O(V+E)
// depend:edge
// 失敗した場合res[0]=-1
vector<int> tolological_sort(vector<vector<edge>>& g) {
    int n = g.size();
    vector<int> res;
    vector<int> indeg(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (int)g[i].size(); j++) {
            indeg[g[i][j].to]++;
        }
    }
    stack<int> s;
    for (int i = 0; i < n; i++) {
        if (indeg[i] == 0) s.push(i);
    }
    while (!s.empty()) {
        int now = s.top();
        s.pop();
        res.push_back(now);
        for (int i = 0; i < (int)g[now].size(); i++) {
            indeg[g[now][i].to]--;
            if (indeg[g[now][i].to] == 0) s.push(g[now][i].to);
        }
    }
    if ((int)res.size() < n) res[0] = -1;
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<edge>> g(n), indeg(n);
    for (int i = 0; i < n - 1 + m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(edge(b));
        indeg[b].push_back(edge(a));
    }
    vector<int> topo = tolological_sort(g);
    // topo_order[i]:頂点iがトポロジカルソートの何番目に現れるか
    vector<int> topo_order(n);
    for (int i = 0; i < n; i++) {
        topo_order[topo[i]] = i;
    }
    //初期値用にオーダー-1の頂点nを追加しておく
    topo_order.push_back(-1);
    vector<int> ans(n, n);
    //オーダーが一番若いやつが根
    //最後の処理の都合で-1
    ans[topo[0]] = -1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < indeg[i].size(); j++) {
            if (topo_order[indeg[i][j].to] > topo_order[ans[i]]) {
                ans[i] = indeg[i][j].to;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] + 1 << endl;
    }
}

Measured memory_bytes: 12916
fun main(args: Array<String>) {
    val (a, b) = readStringList()
    val aa = a.toLong()
    val bb = b.replace(".", "").toLong()
    println((aa * bb / 100L).toString())
}



fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 39932
#include<stdio.h>
#include<stdlib.h>
#define M 2000001
#define AM 10000

int main(){
  unsigned short *A,*B;
  int in[AM+1];
  int lo,i,s;
  
  scanf("%d",&lo);

  A=malloc(sizeof(short)*lo+1);

  B=malloc(sizeof(short)*lo+1);

  for(i=0;i<=AM;i++){
    in[i]=0;
      }

  for(i=0;i<lo;i++){
    scanf("%hu",&A[i+1]);
    in[A[i+1]]++;
  }

  for(i=1;i<=AM;i++){
    in[i]=in[i]+in[i-1];
  }

  for(i=lo;i>=1;i--){
    B[in[A[i]]]=A[i];
    in[A[i]]--;
  }

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


  return 0;
}
    
  



Measured memory_bytes: 9652
// C - Grand Garden
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,n) for(int i=0;i<(n);i++)

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

	vi H(N);
	rp(i, N) cin>>H[i];

	int ans = 0, active = 0;
	rp(i, N){
		ans += H[i] - min(active, H[i]);
		active = H[i];
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
typedef struct vec {
    double x;
    double y;
}vec;

int main(void){
   struct vec vec[20];
   int n=0;
   while(scanf("%lf,%lf",&vec[n].x,&vec[n].y)!=EOF){
       n++;
   }

   double s=0;
   for(int i=1;i<n-1;i++){
       double a=0,b=0,c=0,z=0;
       a=sqrt(pow((vec[0].x-vec[i].x),2)+pow((vec[0].y-vec[i].y),2));
       b=sqrt(pow((vec[0].x-vec[i+1].x),2)+pow((vec[0].y-vec[i+1].y),2));
       c=sqrt(pow((vec[i].x-vec[i+1].x),2)+pow((vec[i].y-vec[i+1].y),2));
       z=(a+b+c)/2;
       s+=sqrt(z*(z-a)*(z-b)*(z-c));
   }
   printf("%lf\n",s);
   
    return 0;
}



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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	a *= 100, b *= 100;
	vector<int> X(0);
	vector<int> Y(0);
	for(int i = 0; i <= f; i++){
		for(int j = 0; j <= f; j++){
			int x = a * i + b * j;
			if(x < f){
				X.push_back(x);
			}
		}
	}
	for(int i = 0; i <= f; i++){
		for(int j = 0; j <= f; j++){
			int y = c * i + d * j;
			if(y < f){
				Y.push_back(y);
			}
		}
	}

	double noudo = -1;
	int situryo = 0; int sato = 0;
	for(int i = 0; i < X.size(); i++){
		for(int j = 0; j < Y.size(); j++){
			int x = X[i], y = Y[j]; //  水x, 砂糖yが作れるかどうか。
			if(x + y > f) continue;
			if(100*y > x * e) continue;
			double now = (double)((1.*(100*y))/(1.*(x+y)));
			if(chmax(noudo,now)){
				situryo = x + y;
				sato = y;
			}
		}
	}
	cout << situryo << " " << sato << endl;
}


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

int main() {

	int a,b,c;
  	cin >> a >> b >> c;
  	b = abs(a-b);
  	c = abs(a-c);
  	if(b > c)cout << "B" << endl;
  	else cout << "A" << endl;
      
}

   


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

typedef long long ll;
typedef long double ld;
using namespace std;
//mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

const int maxn = 100005;
map<int,int> mp;
int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    ii {
        int x;
        cin >> x;
        sum += x;
        mp[x]++;
    }
    int q;
    cin >> q;
    while(q--) {
        int b, c;
        cin >> b >> c;
        sum += 1ll * (c - b) * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }

}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    if ((s[2] == s[3]) && (s[4] == s[5]))
    {
        cout << "Yes" << endl;
    }
    else
    {

        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const ll MOD = 998244353;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;
  
int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    ll ans = 0;
    for(int i=1;i<n;i++){
        ll diff = x[i]-x[i-1];
        if(diff*a<b) ans+=diff*a;
        else ans+=b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3992