akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
struct edge { int to, cost; };

struct UnionFind {
    vector<int> parent;
    UnionFind(int n) {
        parent.assign(n, -1);
    }
    int find(int x) {
        if (parent[x] < 0) return x;
        return (parent[x] = find(parent[x]));
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (size(x) < size(y)) swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
    }
    int size(int x) {
        return -parent[find(x)];
    }
};


int main() {
    int n, q; cin >> n >> q;
    UnionFind uf(n);
    rep(loop, q) {
        int t, u, v; cin >> t >> u >> v;
        if (t) {
            cout << (uf.same(u, v) ? 1 : 0) << endl;
        } else {
            uf.unite(u, v);
        }
    }
}


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

int main(void){
    int n,k;
    cin >> n >> k;
    if(n%k == 0)cout << "0" << endl;
    else cout << "1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

using ll = long long int;

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

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

int main(){
    ll n, sum = 0;
    cin >> n;
    vector<ll> a(n + 1), b(n);
    in_arr(ll, a, n + 1);
    in_arr(ll, b, n);
    for(int i = n - 1; i >= 0; --i){
        int sub = min(a[i + 1], b[i]);
        a[i + 1] -= sub;
        b[i] -= sub;
        sum += sub;
        sub = min(a[i], b[i]);
        a[i] -= sub;
        b[i] -= sub;
        sum += sub;
    }
    cout << sum + min(a[0], b[0]) << endl;
    return 0;
}


Measured memory_bytes: 1792
// E - Red Scarf
#include <bits/stdc++.h>
using namespace std;

int main(){
	int s=0, N; cin>>N;
	vector<int> A(N);
	for(int i=0; i<N; ++i){ cin>>A[i]; s^=A[i]; }
	for(int a:A) cout<< (s^a) <<" ";
}


Measured memory_bytes: 4040
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e13

using namespace std;
typedef long long  ll;

int main(){
    ll n;
    cin >> n;
    ll ans = INF;
    ll a = 1, b = 1;
    while (double(a) <=sqrt(n)){
//        p(pow(n, 0.5));
//        p(float(a));
        if(n%a != 0){
            a++;
            continue;
        }
        b = n/a;
        ans = min(ans, a + b - 2);
        a++;
    }

    p(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;




int main() {
    set<ll> s;
    ll q,x;
    ll n;
    cin>>n;
    rep(i,n){
        scanf("%lld %lld",&q,&x);
        if(q==1){
            fin(s.count(x));
        } else if(q==0){
            s.insert(x);
            fin(s.size());
        }
        else if(q==2){
            s.erase((x));
        } else {
            int r;
            cin>>r;
            for(auto i=s.lower_bound(x);i!=s.end()&&*i<=r;i++){
                if(*i>=x)cout<<*i<<endl;
            }
        }
        
    }
    
}




Measured memory_bytes: 12512
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(true){
        int count=0,S[1000]={};
        double m,sigma=0,a;
        cin>>n;
        if(n==0) break;
        for(int i=0;i<n;i++){
            cin>>S[i];
            count+=S[i];
        }
        m=1.0*count/n;
        for(int i=0;i<n;i++){
            sigma+=(S[i]-m)*(S[i]-m);
        }
        a=sqrt(sigma/n);
        printf("%f\n",a);
    }
    return 0;
}


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

using namespace std;

const int MAX_N = 1 << 10 | 5;

char a[MAX_N][MAX_N];

void solve(int x, int y, int k) {
    int m = 1 << k - 1;
    a[x + m][y + m] = 1;
    if (k > 1) {
        solve(x, y, k - 1);
        solve(x, y + m, k - 1);
        solve(x + m, y, k - 1);
        solve(x + m, y + m, k - 1);
    }
}

int main() {
    int n, m, k;
    scanf("%d%d", &n, &m);
    solve(0, 0, max(n, m));
    for (int i = 1; i < 1 << n; i ++) {
        for (int j = 1; j < 1 << m; j ++) {
            printf("%d", (int) a[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
long long a[45];
int main()
{
    long long s,i,ans=1;
    cin>>s;
    for(i=0;i<=42;i++)
        a[i]=pow(2,i);
//    for(i=0;i<=42;i++)
//        cout<<a[i]<<" ";
    for(i=0;i<=42;i++)
    {
        if(a[i]==s)
        {
            break;
        }
        else if(a[i]>s)
        {
            i--;
            break;
        }
    }

    cout<<a[i+1]-1<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=200000+5;
int n,k,a[N];
bool check(int val){
   ll tot=0;
   for(int i=0;i<n;i++){
      int len=a[i];
      int F= (len/val+ (len%val!=0))-1;
      if(tot+F>k) return 0;
      tot+=F;
   }
   return (tot<=k);
}
int BS(int l,int r){
   int res=0;
   while(l<=r){
    ll mid=(l+r)/2;
    if(check(mid)){
        r=mid-1;
        res=mid;
    }
    else{
        l=mid+1;
    }
   }
   return res;
}
int main(){
    GO();

    int T;
    T=1;
   // cin>>T;
    while(T--){

        cin>>n>>k;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        cout<<BS(1,1000000000)<<"\n";
    }
}


















































Measured memory_bytes: 4284
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int N, M, X, Y, max = -100, min = 100, Battlefield = 1;
	int x[101], y[101];

	scanf("%d%d%d%d", &N, &M, &X, &Y);
	for (int i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}
	for (int j = 0; j < M; j++) {
		scanf("%d", &y[j]);
	}

	for (int i = 0; i < N; i++) {
		if (max < x[i])
			max = x[i];
	}
	for (int j = 0; j < M; j++) {
		if (min > y[j])
			min = y[j];
	}

	for (int k = X + 1; k <= Y; k++) {
		if (k > max && k <= min) {
			Battlefield = 0;
			break;
		}
	}

	if (Battlefield == 0)
		puts("No War");
	else if (Battlefield == 1)
		puts("War");

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	string s;
	int len,count,flag,count2;
	while(cin>>s)
	{
		len=s.size();
		count=0;
		count2=0;
		if(s[0]!='A')
		{
			cout<<"WA"<<endl;
			continue;
		}
		else
		{
			for(int i=2;i<len-1;i++)
			{
				if(s[i]=='C')
				{
					count++;
					flag==i;
				}
			}
			if(count!=1)
			{
				cout<<"WA"<<endl;
				continue;
			}
			for(int i=1;i<len;i++)
			{
				if(i!=flag)
				{
					if(s[i]>=97&&s[i]<=122)
					count2++;
				}
			}
			if(count2!=len-2)
			{
				cout<<"WA"<<endl;
				continue;
			}
		}
		cout<<"AC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long mod=1e9+7,B,W,fac[2<<17],inv[2<<17];
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long C(long a,long b){return fac[a]*inv[a-b]%mod*inv[b]%mod;}
main()
{
	cin>>B>>W;
	fac[0]=inv[0]=1;
	for(int i=1;i<2<<17;i++)fac[i]=fac[i-1]*i%mod;
	inv[(2<<17)-1]=power(fac[(2<<17)-1],mod-2);
	for(int i=(2<<17)-1;--i;)inv[i]=inv[i+1]*(i+1)%mod;
	long L=0,R=0,p=1,q=1;
	for(int i=0;i<B+W;i++)
	{
		if(i>=B)
		{
			L=L*2-(i>B)*C(i-1,i-1-B)+C(i,i-B);
			L=(L%mod+mod)%mod;
		}
		if(i>=W)
		{
			R=R*2-(i>W)*C(i-1,i-1-W)+C(i,i-W);
			R=(R%mod+mod)%mod;
		}
		cout<<(p-L+R+mod)%mod*inv[2]%mod*q%mod<<endl;
		p=p*2%mod;q=q*inv[2]%mod;
	}
}

Measured memory_bytes: 6272
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
char s[200010];
int main(){
	scanf("%s",s+1);int ret=0,n=strlen(s+1);
	for(int i=1;i<=n;i++)if(s[i]=='o')ret++;
	if(ret+15-n<=7)puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()){
        cout << "GREATER" <<"\n";
        return 0;
    }else if(a.size() < b.size()){
        cout << "LESS" <<"\n";
        return 0;
    }else{
        REP(i, a.size()){
            if(a[i] > b[i]){
                cout << "GREATER" <<"\n";
                return 0;
            }else if(a[i] < b[i]){
                cout << "LESS" <<"\n";
                return 0;
            }
        }
        
    }
    cout << "EQUAL" <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main(){
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  if ((a < b) && (b < c)) {
    printf("%s\n", "Yes");
  } else {
    printf("%s\n", "No");
  }
  return 0;
}



Measured memory_bytes: 2592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	s := getNextLine(scanner)
	l := len(s)
	counts0 := 0
	counts1 := 0
	for i := 0; i < l; i++ {
		if i%2 == 0 {
			if s[i] == '0' {
				counts1++
			} else {
				counts0++
			}
			continue
		}
		if s[i] == '1' {
			counts1++
		} else {
			counts0++
		}
	}
	if counts0 > counts1 {
		fmt.Println(counts1)
		return
	}
	fmt.Println(counts0)
}


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

int main()
{
  int64_t x, y;
  cin >> x >> y;
  if (x >= 0 && y >= 0)
  {
    if (y > x)
      cout << y - x << endl;
    else
      cout << (y == 0 ? abs(y - x) + 1 : abs(y - x) + 2) << endl;
  }
  else if (x >= 0 && y < 0)
  {
    cout << abs(abs(y) - abs(x)) + 1 << endl;
  }
  else if (x < 0 && y >= 0)
  {
    cout << min(y - x, abs(abs(y) - abs(x)) + 1) << endl;
  }
  else
  {
    if (y < x)
      cout << abs(y) - abs(x) + 2 << endl;
    else
      cout << abs(abs(x) - abs(y)) << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int x,y;
   while(3){
    scanf("%d",&x);
    scanf("%d",&y);
    if(x==0&&y==0){break;}
    if(x>y){printf("%d %d\n",y,x);}
    else if(x<y){printf("%d %d\n",x,y);}
    else if(x==y){printf("%d %d\n",x,y);}


   }

    return 0;
}

Measured memory_bytes: 1720
import std.stdio, std.string, std.conv, std.range, std.algorithm, std.regex;

void main() {
  auto HW = readln.chomp.split.map!(to!int);
  auto H = HW[0];

  foreach (_; 0 .. H) {
    auto C = readln;
    C.write;
    C.write;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int h,w;
string ss[100];
bool x[100][100];
int ans1=0,ans2=0;
bool ans=true;
bool f(){
	while(true){
		if(ss[ans1][ans2]=='.')return true;
		else if(!x[ans1][ans2])return false;
		else if(ss[ans1][ans2]=='>'){
			x[ans1][ans2]=false;
			ans2++;
			f();
		}
		else if(ss[ans1][ans2]=='<'){
			x[ans1][ans2]=false;
			ans2--;
			f();
		}
		else if(ss[ans1][ans2]=='v'){
			x[ans1][ans2]=false;
			ans1++;
			f();
		}
		else{
			x[ans1][ans2]=false;
			ans1--;
			f();
		}
	}
}
int main()
{
	while(true){
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)return 0;
		for(int i=0;i<h;i++)cin >> ss[i];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)x[i][j]=true;
		ans1=0,ans2=0;
		ans=true;

		if(f()){
		    cout << ans2 << " " << ans1 << "\n";
		}
		else cout << "LOOP" << "\n";
	}
	return 0;
}

Measured memory_bytes: 1276
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let hw = read_vec::<u64>();
    let (h,w)  = (hw[0],hw[1]);
    let mut v = Vec::new();
    for _ in 0..h{
        v.push(read::<String>());
    }
    // let v = read_vec2::<String>(h as u32);
    printShrap(&w);
    for s in &v{
        println!("#{}#",s);
    }
    printShrap(&w);
}
fn printShrap(w:&u64){
    for _ in 0..2+*w{
        print!("#");
    }
    println!("")
}

Measured memory_bytes: 4352
fn atcoder_beginner_contest_111() -> Result<i32, &'static str> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input)
        .map_err(|_e| "input failed")?;
    let mut num = input.trim_right().parse::<i32>()
        .map_err(|_e| "parse error")?;

    Ok((num..).find(|&x| x % 111 == 0)
       .ok_or("Not found")?)
}

fn main() {
    println!("{}", atcoder_beginner_contest_111().unwrap());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int sx, sy, tx, ty; 
	cin >> sx >> sy >> tx >> ty; 
	int X = tx - sx; int Y = ty - sy; 
	for(int i = 0; i < X; i++){
		cout << 'R'; 
	}
	for(int i = 0; i < Y; i++){
		cout << 'U'; 
	}
	for(int i = 0; i < X; i++){
		cout << 'L'; 
	}
	for(int i = 0; i < Y; i++){
		cout << 'D'; 
	}
	cout << 'D'; 
	for(int i = 0; i < X+1; i++){
		cout << 'R'; 
	}
	for(int i = 0; i < Y+1; i++){
		cout << 'U'; 
	}
	cout << 'L'; 
	cout << 'U'; 
	for(int i = 0; i < X+1; i++){
		cout << 'L'; 
	}
	for(int i = 0; i < Y+1; i++){
		cout << 'D'; 
	}
	cout << 'R' << endl; 
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	s := nextString()
	if s == "Sunny" {
		s = "Cloudy"
	} else if s == "Cloudy" {
		s = "Rainy"
	} else {
		s = "Sunny"
	}

	_, _ = fmt.Fprintf(writer, "%s", s)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a,b,n;
    cin>>n>>a>>b;
    ll ans=0,dummy=0,sum;
    for(int i=1;i<=n;i++)
    {
        dummy=i;
        sum=0;
        while(dummy)
        {
            sum+=(dummy%10);
            dummy/=10;
        }
        if(sum>=a&&sum<=b)
        {
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <utility>
#include <vector>

using namespace std;

//????????¢??°???

#define nmax 10005

int Countingsort( int A[], int B[], int n){

    int i, j;

    int C[ nmax ] = {};

    //C[i]???i???????????°????¨????

    for( j = 0 ; j < n ; j++ ){

        C[ A[j] ]++;

    }


    //C[i]????´???????

    for( j = 1; j < nmax ; j++ ){

        C[j] = C[j] + C[j-1];

    }

    for( j = n-1; j >= 0; j-- ){

        B[ C[ A[j] ] ] = A[j];

        C[ A[j] ]--;

    } 


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

        if( i > 1 ) printf(" ");

        printf("%d", B[i]);

    }

    printf("\n");

}


//??¬???

int main(){

    int n, i;

    scanf("%d", &n);

    int A[n], B[n+1] = {};

    for( i = 0; i < n ; i++ ){

        scanf("%d", &A[i]);
        
    }

    Countingsort( A, B, n);

    return 0;

}

Measured memory_bytes: 18348
void main()
{
    auto sieve = Sieve!long(10^^5);
    long[] dp = new long[10^^5+1];
    foreach (i; 1 .. 10^^5+1)
    {
        dp[i] = dp[i-1];
        if (sieve.isPrime(i) && sieve.isPrime((i+1)/2))
        {
            ++dp[i];
        }
    }

    long q = readln.chomp.to!long;
    foreach (i; 0 .. q)
    {
        long[] tmp = readln.split.to!(long[]);
        long l = tmp[0] - 1, r = tmp[1];
        writeln(dp[r] - dp[l]);
    }
}

struct Sieve(T)
{
    bool[] flags;

    this(T limit)
    {
        flags = sieve(limit);
    }

    bool[] sieve(T limit)
    {
        long len = (limit - 1) / 2;
        bool[] result = new bool[len];
        result[] = true;
        foreach (i; 0 .. len)
        {
            if (!result[i]) continue;

            long prime = 3 + 2 * i;
            foreach (j; iota(prime+i, len, prime))
            {
                result[j] = false;
            }
        }
        return result;
    }

    size_t length() @property
    {
        return flags.length;
    }

    bool isPrime(T x)
    {
        if (x < 2)
        {
            return false;
        }
        else if (x == 2)
        {
            return true;
        }
        else if (x % 2 == 0)
        {
            return false;
        }
        else
        {
            return flags[(x-3)/2];
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4348
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll x,n;
cin >> x >> n;
vector<ll> p(n);
set<ll> st;
rep(i,n){
    cin >> p[i];
    st.insert(p[i]);
}
ll ans = 10000;
ll k = 10000;
rep(i,102){
    if(abs(x - i) < k && !st.count(i)){
        ans = i;
        k = abs(x - i);
    }
}
cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n) {
        cin >> p[i];
    }

    vector<int> ml(n);
    int m = INF;
    REP(i, n) {
        chmin(m, p[i]);
        ml[i] = m;
    }

    int c = 0;
    REP(i, n) {
        if(p[i] <= ml[i]) c++;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;

int main()
{
    int k;
    string s;
    cin >> s >> k;
    int n = s.size();
    vector<string> v;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= k; j++){
            string tmp = s.substr(i,j);
            v.push_back(tmp);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[k-1];
}

Measured memory_bytes: 1660
from itertools import permutations
from bisect import bisect_left

n = int(input())
p = int(input().replace(" ", ""))
q = int(input().replace(" ", ""))

temp_list = [int("".join(temp)) for temp in permutations([str(x) for x in range(1, n + 1)])]
temp_list.sort()

ans = abs(bisect_left(temp_list, p) - bisect_left(temp_list, q))
print(ans)

Measured memory_bytes: 4760
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int first=0,second=0,third=0;
		
		for(int i = 0;i < 10;i++){
			int temp = scan.nextInt();
			if(first <= temp){
				third = second;
				second = first;
				first = temp;
			}else if(second <= temp){
				third = second;
				second = temp;
			}else if(third < temp){
				third = temp;
			}
		}
		System.out.println(first + "\n" + second + "\n" + third);
	}
}

Measured memory_bytes: 12000
#include <cstdio>

using namespace std;
const int Max_N(100050);

int N;

struct Perm
{
	int P[Max_N];
	inline Perm Inv() const
	{
		Perm c;
		for (int i = 1;i <= N;++i)
			c.P[P[i]] = i;
		return c;
	}
};

inline Perm operator*(const Perm &a, const Perm &b)
{
	Perm c;
	for (int i = 1;i <= N;++i)
		c.P[i] = b.P[a.P[i]];
	return c;
}

Perm operator^(Perm a, int n)
{
	Perm Ret;
	for (int i = 1;i <= N;++i)
		Ret.P[i] = i;
	while (n)
	{
		if (n & 1)
			Ret = Ret * a;
		a = a * a, n >>= 1;
	}
	return Ret;
}

/*
设F(P, Q) = X，有X[P[i]] = Q[i]。那么X[i] = Q[P^(-1)[i]]，故X = P^(-1) * Q
然后找规律：
A[1] = P
A[2] = Q
A[3] = P^(-1) * Q
A[4] = Q^(-1) * P^(-1) * Q
A[5] = Q^(-1) * P * Q^(-1) * P^(-1) * Q
A[6] = Q^(-1) * P * Q * Q^(-1) * P * Q^(-1) * P^(-1) * Q = Q^(-1) * P * P * Q^(-1) * P^(-1) * Q
A[7] = Q^(-1) * P * Q * P^(-1) * Q * Q^(-1) * P * P * Q^(-1) * P^(-1) * Q = Q^(-1) * P * Q * P * Q^(-1) * P^(-1) * Q
A[8] = Q^(-1) * P * Q * P^(-1) * P^(-1) * Q * Q^(-1) * P * Q * P * Q^(-1) * P^(-1) * Q = Q^(-1) * P * Q * P^(-1) * Q * P * Q^(-1) * P^(-1) * Q
设B = P * Q^(-1) * P^(-1) * Q，B^(-1) = Q^(-1) * P * Q * P^(-1)，观察可得A[i > 6] = B^(-1) * A[i - 6] * B。然后直接做即可
*/

int K;
Perm A[6], P, Q, B, IP, IQ, IB, Ans;

int main()
{
	scanf("%d%d", &N, &K), --K;
	for (int i = 1;i <= N;++i)
		scanf("%d", &P.P[i]);
	for (int i = 1;i <= N;++i)
		scanf("%d", &Q.P[i]);
	IP = P.Inv(), IQ = Q.Inv();
	A[0] = P, A[1] = Q;
	for (int i = 2;i < 6;++i)
		A[i] = A[i - 2].Inv() * A[i - 1];
	IB = (B = P * IQ * IP * Q).Inv();
	IB = (IB ^ (K / 6)), B = (B ^ (K / 6));
	Ans = IB * A[K % 6] * B;
	for (int i = 1;i <= N;++i)
		printf("%d ", Ans.P[i]);
	return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1000000007;
 
int main(void){
    int N; cin >> N;
    vector<ll> div(N+5, 0);

    for(int i=2; i<=N; i++){
        int d = i;
        for(int j=2; j*j<=d; j++){
            if(d%j == 0){
                while(d%j == 0){
                    div[j]++;
                    d /= j;
                }
            }
        }
        if(d > 1) div[d]++;
    }

    ll res = 1;
    for(int i=2; i<=N; i++) res = res*(div[i]+1)%mod;
    cout << res << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        char[] arr = sc.next().toCharArray();
        long count = 0;
        long blackCount = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 'B') {
                blackCount++;
            } else {
                count += blackCount;
            }
        }
        System.out.println(count);
    }
}


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

int main()
{
	int n;
	cin>>n;
	
	int t[n];
	int suma=0;
	
	for(int i=0;i<n;i++)
	{
		cin>>t[i];
		suma+=t[i];	
	}
	
	
	int b;
	cin>>b;
	int be[b];
	
	int aux1,aux2;
	
	
	for(int i=0;i<b;i++)
	{
		cin>>aux1>>aux2;	
		be[i]=suma-t[aux1-1]+aux2;	
	}
	
	for(int i=0;i<b;i++)
		cout<<be[i]<<endl;
	
	
	return 0;
}

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

double round_d(double x) {
    if ( x >= 0.0 ) {
        return floor(x + 0.5);
    } else {
        return -1.0 * floor(fabs(x) + 0.5);
    }
}

int main(){
double num1[10000],num2[10000],num3[10000],num4[10000],num5[10000],num6[10000],x=0.0,y=0.0;
int i,count=0;
for(i=0;i<10000;i++){
if(scanf("%lf %lf %lf %lf %lf %lf",&num1[i],&num2[i],&num3[i],&num4[i],&num5[i],&num6[i])==EOF)break;
count++;
}
for(i=0;i<count;i++){
x=(num2[i]*num6[i]-num3[i]*num5[i])/(num2[i]*num4[i]-num1[i]*num5[i]);
x=round_d(x*1000.0)/1000.0;
y=(num1[i]*num6[i]-num3[i]*num4[i])/(num1[i]*num5[i]-num2[i]*num4[i]);
y=round_d(y*1000.0)/1000.0;
printf("%.3f %.3f\n",x,y);
}
return 0;
}

Measured memory_bytes: 684
N,Q = map(int,input().split())

ab = []

link = {} 

for i in range(N-1):

    a,b = map(int,input().split())

    if a-1 not in link : link[a-1] = []
    if b-1 not in link : link[b-1] = []


    link[a-1].append(b-1)
    link[b-1].append(a-1)



plus = [0] * N

for i in range(Q):

    p,x = map(int,input().split())

    plus[p-1] += x


Q = []

ans = [0] * N
end = [0] * N
p = [-1] * N
p[0] = 0

nowq = 0
Q.append(0)

end[0] = 1


while nowq < N:

    nowpo = Q[nowq]
    #print (nowpo)
    ans[ nowpo ] = ans[p[ nowpo ]] + plus[nowpo]

    for i in link[nowpo]:

        if end[i] == 0:

            Q.append(i)
            p[i] = nowpo
            #print (i,nowpo)


            end[i] = 1


    nowq += 1

#print (Q,p,link)

for i in ans:
    print (i)


Measured memory_bytes: 120024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int N = s.size();

  int a = 0, b = 0;
  REP(i, N){
    if(i%2){
      if(s[i] == '0') a++;
      if(s[i] == '1') b++;
    }else{
      if(s[i] == '1') a++;
      if(s[i] == '0') b++;
    }
  }

  cout << min(a, b) << "\n";

  return 0;
}

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

int main() {
    int n, d, x;
    cin >> n >> d >> x;

    int cnt = x;
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        cnt += (d-1) / tmp + 1;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
char ch;
int main()
{
	ios::sync_with_stdio(false);
	cin>>ch;
	if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')cout<<"vowel";
	else cout<<"consonant";
	
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if (b % a == 0) {
      System.out.println(a + b);
    } else {
      System.out.println(b - a);
    }
  }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> Sa(n);
    Sa[0] = a[0];
    repi(i, n) Sa[i] = Sa[i-1] + a[i];

    ll sum = 0;
    ll MOD = 1000000007;
    rep(i, n) {
        ll v = a[i] * ((Sa[n - 1] - Sa[i]) % MOD);
        sum = (sum + (v % MOD)) % MOD;
    }
    put(sum);
    return 0;
}

Measured memory_bytes: 6408
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    SUM = sum(A)
    if N >= SUM:
        print(N-SUM)
    else:
        print(-1)

if __name__ == '__main__':
    main()


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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var M = sc.ReadInt();
        var A = sc.ReadStrArray(N);
        var B = sc.ReadStrArray(M);

        for (int i = 0; i <= N - M; i++)
        {
            var s = A[i];
            for (int j = 0; j <= N - M; j++)
            {
                var t1 = B[0];
                if (s.Substring(j, M) == t1)
                {
                    // 1行目のデータが一致するとき
                    var ok = true;
                    for (int k = 1; k < M; k++)
                    {
                        var tn = B[k];
                        var sn = A[i + k].Substring(j, M);
                        if (tn != sn) ok = false;
                    }
                    if (ok)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
        }
        Console.WriteLine("No");
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N, K;
int main() {
    std::cin >> N >> K;

    int ans = 1;
    REP(i, N) {
        ans = std::min(ans*2, ans+K);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  int l=0, r=S.size()-1;
  int ans = 0;
  bool can = true;
  while(l<r) {
    if(S[l]==S[r]) {
      l++;
      r--;
    }
    else {
      if(S[l]=='x') {
        ans++;
        l++;
      }
      else if(S[r]=='x') {
        ans++;
        r--;
      }
      else {
        can = false;
        break;
      }
    }
  }
  if(can) cout<<ans<<endl;
  else cout<<-1<<endl;
}



Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		String s = in.next();
		int ans = 0;
		int num = 1;
		for(int i=1;i<n;i++) {
			if(s.charAt(i-1)==s.charAt(i)) {
				ans++;
			}else {
				num++;
			}
		}
		if(num%2==1) {
			if(num/2<=k) ans = n-1;
			else ans += 2*k;
		}else {
			if(num/2<=k) ans = n-1;
			else if(num/2==k+1) ans = n-2;
			else ans += 2*k;
		}
		System.out.print(ans);
		in.close();

	}

}


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

namespace DPG9
{
    class Program
    {
        static List<int>[] Node;
        static int[] dp;
        static int[] indeg;
        static int ans = 0;
        static void Main(string[] args)
        {
            //List<int> T_List = new List<int>();//トポロジカルリスト
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);//新しい入力処理の書き方
            int N = input[0];
            Node = new List<int>[N];
            dp = new int[N];
            for (int i = 0; i < N; i++)
            {
                Node[i] = new List<int>();
            }
            indeg = new int[N];
            //リストのほうが処理時間がかかった
            int M = input[1];
            int[] input2;//for文の外で宣言した方が少しだけ速い
            for (int i = 0; i < M; i++)
            {
                input2 = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);//新しい入力処理の書き方
                Node[input2[0] - 1].Add(input2[1] - 1);// 出力先を各リストに記録する　ノード番号を０番からに変更した
                indeg[input2[1] - 1]++;//各ノードへの入力辺の数
                dp[input2[1] - 1] = 1;
            }
            for (int i = 0; i < N; i++)
            {
                if (indeg[i] == 0)//入力がないノードが見つかったらdpを計算する
                {
                    indeg_Handle(i, N);
                }
            }
            Console.WriteLine(ans);
        }
        static void indeg_Handle(int i, int N)
        {
            indeg[i] = -1;//訪問済みの印
            foreach (var item in Node[i])
            {
                dp[item] = Math.Max(dp[i] + 1, dp[item]);
                ans = Math.Max(ans, dp[item]);
                indeg[item]--;//出力先への辺を削除
            }
            foreach (var item in Node[i])
            {
                if (indeg[item] == 0)
                {
                    indeg_Handle(item, N);
                }
            }
        }
    }
}


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

int x[10000000];
int G[20];
int v;
int w;
int cnt=0;
int m;
int n;

void sort1(int x[],int n,int g){
	for(int i=g;i<n;i++){
		v=x[i];
		w=i-g;
		while(w>=0 && x[w]>v){
			x[w+g]=x[w];
			w=w-g;
			cnt++;
		}
		x[w+g]=v;
	}
}

void sort2(int x[],int n){
	cnt=0;
	for(int h=0;h<20;h++){
		if(G[h]>n){
			m=h;
			break;
		}
	}
	cout<<m<<endl;
	for(int h=m-1;h>=0;h--){
		cout<<G[h];
		if(h){
			cout<<' ';
		}
		sort1(x,n,G[h]);
	}
	cout<<endl;
}

int main(){
	G[0]=1;
	for(int i=1;i<20;i++){
		G[i]=G[i-1]*3+1;
	}
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	sort2(x,n);
	cout<<cnt<<endl;
	for(int i=0;i<n;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}

Measured memory_bytes: 7124
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b;
  cin >> a >> b;
  if(2*b-a>=0)cout << 0 << endl;
  else cout << a-2*b << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
  int n;
  cin >> n;
  double v[n],a;
  for(int i=0; i<n; i++) {
    cin >> v[i];
  }
  sort(v,v+n);
  for(int i=0; i<n-1; i++) {
    a=(v[i]+v[i+1])/2;
    v[i+1]=a;
  }
  cout << fixed << setprecision(10) << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 1;
const int inf = 1e9 + 7;
signed main () {
    int n, k;
    int ans ;
    cin >> n;
    vector <pair <int, int> > v;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v.push_back({x, i + 1});
    }      
    sort(v.begin(), v.end());
    for (auto it : v) cout << it.second << ' ';

}


Measured memory_bytes: 2544
#include <iostream>
#include <vector>

using namespace std;
const int NIL = -1;
const int INF = 1001001001;
int root = 0;

int dfs(const vector< vector<int> >& tree, vector<int>& parent, vector<int>& prenum, vector<int>& lowest, int node)
{
    int l = prenum[node];
    int count = 0;
    for(int v : tree[node])
    {
        if(parent[v] == NIL)
        {
            parent[v] = node;
            prenum[v] = prenum[node] + 1;
            l = min(l, dfs(tree, parent, prenum, lowest, v));
            ++count;
        }
        else{
            l = min(l, prenum[v]);
        }
    }
    if(node == root)
    {
        if(count > 1) cout << root << endl;
    }
    return lowest[node] = l;
}

int main()
{
    int n, m, s, t;
    cin >> n >> m;
    vector< vector<int> > tree(n);
    vector<int> parent(n, NIL), prenum(n, INF), lowest(n, INF), color(n, 0);
    for(int i=0;i<m;++i)
    {
        cin >> s >> t;
        tree[s].push_back(t);
        tree[t].push_back(s);
    }
    prenum[root] = 0;
    parent[root] = 0;
    dfs(tree, parent, prenum, lowest, root);

    for(int i=0;i<n;++i)
    {
        if(i == root) continue;
        int p = parent[i];
        if(prenum[p] <= lowest[i] && !color[p]){
            color[p] = 1;
        }
    }
    for(int i=0;i<n;++i)
    {
        if(i != root && color[i]) cout << i << endl;
    }
}



Measured memory_bytes: 4988
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
ll chmax(ll &a, ll b){ return a = (a>b) ? a : b;}
ll chmin(ll &a, ll b){ return a = (a<b) ? a : b;}

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}

////////////////////////////////////////////////////////////////
#define PI 3.14159265359
int main(void) {
	int N, W;
	cin >> N >> W;
	vector<int> w(N+3, 0);
	vector<ll> v(N+3, 0);
	
	for(int i=1; i<=N; i++) cin >> w[i] >> v[i];

	//dp[m][g]: 品物1~mまで考え，重さがgになった時の最大価値  
	vector<vector<ll>> dp(N+3, vector<ll>(W+100005, 0));
	for(int g=0; g<=W; g++) dp[0][g] = 0;
	
	// for(int m=0; m<=N+2; m++){
	// 	cout << "dp["<<m<<"][";
	// 	for(int g=0; g<=10; g++){
	// 		if(g==0) cout<<g<<"]: ";
	// 		cout << dp[m][g] << "  ";
	// 	}
	// 	cout << endl;
	// }

	for(int m=0; m<=N; m++){
		for(int g=0; g<=W; g++){
			//cout << "(m, g) = (" << m << ", " << g << "): " << endl; 
			dp[m+1][g] = max(dp[m+1][g], dp[m][g]+0);//品物m+1番目を入れない
			//cout << "(m, g) = (" << m << ", " << g << "): " << endl; 
			//cout << v[m] << " hey" << w[m] << " hey2" << dp[m+1][g+w[m]] << endl;
			dp[m+1][g+w[m+1]] = max(dp[m+1][g+w[m+1]], dp[m][g]+v[m+1]);//品物m+1番目を入れる
			//cout << "(m, g) = (" << m << ", " << g << "): " << endl; 
		}
	}

	// for(int m=0; m<=N+2; m++){
	// 	cout << "dp["<<m<<"][";
	// 	for(int g=0; g<=10; g++){
	// 		if(g==0) cout<<"g]: ";
	// 		cout << dp[m][g] << "  ";
	// 	}
	// 	cout << endl;
	// } cout << "dp[" << N << "][" << W << "]: " << dp[N][W] << endl;

	ll ans = 0;
	for(int g=0; g<=W; g++) ans = max(ans, dp[N][g]);
	cout << ans << endl;

}



Measured memory_bytes: 162944
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

H,N = map(int,F.readline().split())
a = list(map(int,F.readline().rstrip().split()))
a_sum = 0
for num in a:
    a_sum += num

if a_sum >= H:
    print('Yes')
    sys.exit()

print('No')


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

int main(void){
    int i, week;
    int ans = 100000;
    cin >> week;
    for(i = 0; i < week; i++){
        ans = ans * 1.05;
        if(ans % 1000 != 0)ans = ans + (1000 - ans % 1000);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3008
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long
#define mod 1000000007

int N;

int main() {
	cin>>N;
	N%=10;
	if(N==3)cout<<"bon"<<endl;
	else if(N==0||N==1||N==6||N==8)cout<<"pon"<<endl;
	else cout<<"hon"<<endl;

	return 0;
}


Measured memory_bytes: 3624