akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;
import std.format;
import std.algorithm;
import std.array;
import std.math;

void stringsTo(string, T...)(string str, ref T t) {
  auto s = str.split();
  assert(s.length == t.length);
  foreach(ref ti; t) {
    ti = s[0].to!(typeof(ti));
    s = s[1..$];
  }
}

long INF = pow(10, 9);

struct Node {
  int   u; // :u ノードのインデックス
  ulong k; // :k u の出次数
  int[] v; // :v u に隣接する頂点の番号
  int[int] w; // :w 隣接する頂点への重み
};

class Graph {
  public int n;
  public Node[] nodes;
  public long[][] dist;

  this(int n) {
    this.n = n;
    this.nodes = new Node[n];
    foreach (int i, ref node; this.nodes) {
      node.u = i;
    }
    this.dist = new long [][](n,n);
  }

  void addGraphEdge(int u, int v, int w) {
    this.nodes[u].v ~= v;
    this.nodes[u].w[v] = w;
    this.nodes[u].k = this.nodes[u].v.length;
  }

  void warshallFloyd() {
    for (int i = 0; i < this.nodes.length; i++ ) {
      for (int j = 0; j < this.nodes.length; j++ ) {
	int* val = j in this.nodes[i].w;
	if (val != null) {
	  this.dist[i][j] = *val;
	} else {
	  this.dist[i][j] = INF;
	}
      }
      this.dist[i][i] = 0;
    }

    for (int k = 0; k < this.nodes.length; k++) {
      for (int i = 0; i < this.nodes.length; i++) {
	for (int j = 0; j < this.nodes.length; j++) {
	  if (this.dist[i][k] != INF && this.dist[k][j] != INF) {
	    this.dist[i][j] = min(this.dist[i][j], this.dist[i][k] + this.dist[k][j]);
	  }
	}
      }
    }
  }
}

void main()
{

  string lines;
  string buf;

  while (!stdin.eof) {
    buf = stdin.readln();
    lines ~= buf;
  }

  string[] array = splitLines(lines);

  int H,W;
  stringsTo(array[0], H, W);
  Graph graph = new Graph(10);

  foreach ( int i, str; array[1..10+1]) {
    foreach ( int j, int w; str.split(" ").map!(s => s.to!int).array ) {
      graph.addGraphEdge(i, j, w);
    }
  }

  graph.warshallFloyd();

  int ans = 0;

  foreach ( str; array[11..12+H-1] ) {
    //writeln(str);
    foreach ( int a; str.split(" ").map!(s => s.to!int).array ) {
      if (a != 1 && a != -1) {
	ans += graph.dist[a][1];
	//writeln(graph.dist[a][1]);
      }
    }
  }

  writeln(ans);
}


Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    string s;
    cin>>n>>s;
    int l=s.length();
    for(int i=0;i<l;i++)
    {
        int x=((int(s[i]))+n)%91;
        if(x<65)
        {
            x+=65;
        }
        printf("%c",char(x));
    }
	return 0;
}


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

int main(){
	int n;
  	ll k;
  	cin >> n >> k;
  	vector<int> a(n);
  	rep(i, n) cin >> a[i];
  
  	vector<int> s;
  	vector<int> ord(n+1, -1);
  	int cnt = 1, l = 0;
  
  	{
    	int v = 1;
      	while(ord[v] == -1){
          	ord[v] = s.size();
          	s.push_back(v);
        	v = a[v-1];
        }
      	cnt = s.size() - ord[v];
      	l = ord[v];
    }
  	
  	if(k < l) cout << s[k] << endl;
  	else {
    	k -= l;
      	k %= cnt;
      	cout << s[l+k] << endl;
    }	
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,n;cin>>a>>b>>n;
    if(n<b)cout<<a*n/b<<endl;
    else{
      ll l=a*(b-1);
      cout<<l/b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b; cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0) {
        cout << abs(a - b) / 2 << '\n';
    } else {
        cout << min(a - 1, n - b) + (b - a + 1) / 2 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;

int main() 
{
  int K;
  string S;
  cin >> K ;
  cin >> S ;
  
  if(S.length() <= K)
  {
    cout << S;
    return 0;
  }else
  {
    for(int i=0;i<K;i++)
    {      
      cout <<  S[i];
    }
    cout << "...";
    return 0;
  }
    
  return 0;  
}

Measured memory_bytes: 3624
n=int(input())
h=list(map(int, input().split()))
DP=[]
for i in range(n):
  DP.append(0)
DP[0]=0
DP[1]=abs(h[1]-h[0])
for j in range(2,n):
  DP[j]=DP[j-2]+abs(h[j-2]-h[j])
  if DP[j]>DP[j-1]+abs(h[j-1]-h[j]):
    DP[j]=DP[j-1]+abs(h[j-1]-h[j])
#print(DP)
print(DP[n-1])
  

Measured memory_bytes: 13908
function Main(input) {
  input = input.split(" ");
  const N = parseInt(input[0],10);
  const K = parseInt(input[1],10);

  if(K ===1){
    console.log(0);
    return;
  }
  console.log(N-K);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
MOD = 998244353


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


def solve(N, region):
    dp = [ModInt(0)]*(N+1)
    dp[1] += 1
    dpsum = [ModInt(0)]*(N+1)
    dpsum[1] += 1

    for i in range(2, N+1):
        for r in region:
            left = i - r[1]
            right = i - r[0]
            if right < 0:
                continue
            left = max(left, 0)
            dp[i] += (dpsum[right] - dpsum[left-1])
        dpsum[i] = dpsum[i-1] + dp[i]

    return dp[N]


if __name__ == "__main__":
    N, K = map(int, input().split())
    region = [list(map(int, input().split())) for _ in range(K)]
    print(solve(N, region))


Measured memory_bytes: 88116
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n, d, a;
    scan(n, d, a);

    auto x = new long[](n);
    auto h = new int[](n);
    foreach (i ; 0 .. n) {
        scan(x[i], h[i]);
    }

    x ~= inf6;

    sort(zip(x, h));

    debug {
        writeln(x);
        writeln(h);
    }

    h = h.map!(hi => (hi + a - 1) / a).array;

    auto b = new int[](n + 1);
    long ans, bom;
    int r;

    foreach (i ; 0 .. n) {
        bom += b[i];
        while (x[r] - x[i] <= 2 * d) r++;
        long t = max(0, h[i] - bom);
        ans += t;
        bom += t;
        b[r] += -t;
    }

    writeln(ans);
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 5372
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        String answer = "NG";
        Scanner s = new Scanner(System.in);
        int k = Integer.parseInt(s.next());
        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());

        for (int i = k; i <= b; i+=k){
            if (i >= a) {
                answer = "OK";
                break;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 35668
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int N;

int f(vector<vector<pair<int, int>>> &data, vi &bit, int n) {
    if (n == 0) {
        int ans = 0;
        bool check = false;
        for (int i = 0; i < N; i++) {
            if (bit[i] == 0) {
                continue;
            }
            ans++;
            for (pair<int, int> p : data[i]) {
                if (bit[p.first - 1] != p.second) {
                    return 0;
                }
            }
        }
        return ans;
    }
    bit[N - n] = 1;
    int a = f(data, bit, n - 1);
    bit[N - n] = 0;
    int b = f(data, bit, n - 1);
    return max(a, b);
}

int main() {
    cin >> N;
    vi a(N);
    vector<vector<pair<int, int>>> data(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        vector<pair<int, int>> v(a[i]);
        for (int j = 0; j < a[i]; j++) {
            int x, y;
            cin >> x >> y;
            v[j] = {x, y};
        }
        data[i] = v;
    }
    vi bit(N, 0);
    int ans = f(data, bit, N);
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
     int n;
     cin>>n;
     int a[n];
     rep(i,0,n)
     {
     	cin>>a[i];
     }
     int cnt=0;
     int ind=-1;
     int sum;

     rep(i,0,n-1)
     {
     	if(a[i]<a[i+1])
     	{
     		cnt=1000/a[i];ind=i+1;
     		sum=1000%a[i];
     		break;
     	}
     	
     }
     if(ind==-1)
     {
     	cout<<1000;return;
     }
     int ok=0;
     vi v;
     v.pb(a[ind]);
     //cout<<sum<<endl;
     for(int i=ind;i<n-1;++i)
     {
     	if(ok==0)
     	{
     	 if(a[i+1]>=a[i])
     	 {
     		v.pb(a[i+1]);
     	 }
     	 else
     	 {
     	 	ok=1;
     	 	sort(rall(v));
     	 	sum+=cnt*v[0];
     	 	//cout<<"sum:"<<sum<<endl;
     	 	v.clear();
     	 	v.pb(a[i+1]);
     	 }
     	}
     	else if(ok)
     	{
     		if(a[i]>=a[i+1])
     		{
     			v.pb(a[i+1]);
     		}
     		else
     		{
     			ok=0;
     			sort(all(v));
     			cnt=sum/v[0];
     			sum%=v[0];
     			//cout<<"cnt:"<<cnt<<" "<<"sum:"<<sum<<endl;
     			v.clear();
     			v.pb(a[i+1]);
     		}
     	}


     }
     if(ok==0)
     {
     	sort(rall(v));
     	//cout<<v[0]<<endl;
     	sum+=v[0]*cnt;

     }
     cout<<sum<<endl;

   

}

signed main()
{
        FIO
        // #ifndef ONLINE_JUDGE
        //   freopen("input.txt","r",stdin);
        //   freopen("output.txt","w",stdout);
        // #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

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

int main(){
	int n, k;
	long ans = 0;
	cin >> n >> k;
	for(int b = k+1; b<=n; b++){
		int p = n / b;
		int r = n % b;
		ans += p * max(0, b-k) + max(0, r - k + 1);
	}
	if(k == 0) ans -= n;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int n;
int mul(int a, int b)
	{
		return (int)(a*b)%mod;
	}
void add(int &a, int b)
{
	a+=b;
	while(a>mod)
		a-=mod;
}
struct M{
	vector<vector<int>> t;
	M(){
		t.resize(n, vector<int>(n));
	}
	M operator*(const M & b) const{
		M c = M();
		for(int i=0; i<n; ++i)
		{
			for(int j=0; j<n; ++j)
			{
				for(int k=0; k<n; ++k)
				{
					add(c.t[i][k], mul(t[i][j], b.t[j][k]));
				}
			}
		}
		return c;
	}
};
signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int k;
	cin>>n>>k;
	M m=M();
	for(int i=0; i<n; ++i)
	{
		for(int j=0; j<n; ++j)
		{
			cin>>m.t[i][j];
		}
	}
	M ans = M();
	for(int i=0; i<n; ++i)
	{
		ans.t[i][i]=1;
	}
	while(k)
	{
		if(k%2==1)
		{
			ans=ans*m;
		}
		m=m*m;
		k/=2;
	}

	int total=0;
	for(int i=0; i<n; ++i)
	{
		for(int j=0; j<n; ++j)
		{
			add(total, ans.t[i][j]);
		}
	}
	cout<<total;
	return 0;	
}

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

#define lint long long
#define P pair<int, int>

int main(){
    int N, M;
    
    cin >> N >> M;
    
    vector<int> cnt(M + 1);
    
    for(int i = 0; i < N; ++i){
        int K;
        cin >> K;
        
        for(int j = 0; j < K; ++j){
            int a;
            cin >> a;
            
            cnt[a]++;
        }
    }
    
    int ans = 0;
    for(auto e : cnt){
        if(e == N){
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(L):

    e = []
    n = 1
    l = L - 1

    r = math.floor(math.log(L, 2))
    for j in range(r):
        e.append((n, n+1, 0))
        e.append((n, n+1, 2**j))
        n += 1

    for t in range(n-1, 0, -1):
        if L - 2**(t-1) >= 2**r:
            e.append((t, n, L - 2**(t-1)))
            L -= 2**(t-1)

    print(n, len(e))
    for u, v, c in e:
        print(u, v, c)


def main():
    L = read_int()
    slv(L)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5472
// Hovalhagh
// Ya Aziz & Hakim
// AliReza Kaboli

#include <bits/stdc++.h>

using namespace std;

int main() {
	int n, tr, cnt = 1;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> tr;
		if (tr == cnt)
			++cnt;
	}
	if (cnt - 1 == 0) {
		cout << "-1\n";
		return 0;
	}
	cout << n - cnt + 1 << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
double pi = 2 * acos(0.0); 


void solve(double a, double b, int H, int M){
    double o1 = 2*pi*((double)H)/12; 
    double o2 = 2*pi*((double)M)/60;
    o1 += 2*pi*M/(12*60);
    double diff = abs(o1-o2);
    if(diff > pi){
        diff = 2*pi - diff;
    }

    double ans = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(diff));
    cout << std::fixed;
    cout << std::setprecision(12) << ans << endl;
    
}



int main()
{
 
    FastIO 
    int a, b, H, M;
    cin >> a >> b >> H >> M;
    solve(a, b, H, M);





    return 0;
        
}
 
  






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

class card{
  public:
    char mark;
    int num;
};
void selectionSort(vector<card> &a,int n);
void bubbleSort(vector<card> &a,int n);
void judge(vector<card>a,vector<card>b,int n);

int main() {
  int n;
  cin>>n;
  vector<card>a(n),b(n),c(n);
  rep(i,n){
    cin>>a[i].mark>>a[i].num;
  }
  b=a;
  c=a;
  bubbleSort(b,n);
  rep(i,n){
    if(i>0)cout<<" ";
    cout<<b[i].mark<<b[i].num;
  }
  cout<<endl;
  judge(a,b,n);

  selectionSort(c,n);
  rep(i,n){
    if(i>0)cout<<" ";
    cout<<c[i].mark<<c[i].num;
  }
  cout<<endl;
  judge(a,c,n);

}

void selectionSort(vector<card> &a,int n){
  int cou=0,minj;
  for(int i=0;i<n;i++){
    minj = i;
    for(int j=i;j<n;j++){
      if (a[j].num < a[minj].num){
        minj = j;
      }
    }
    if(a[i].num!=a[minj].num){
       swap(a[i].num,a[minj].num);
       swap(a[i].mark,a[minj].mark);
       //cout<<i<<a[i]<<a[minj]<<endl;
       //cou++;
      }
  }
  
}
void bubbleSort(vector<card> &a,int n){
  bool flag =1;  //逆の隣接要素
  int count=0;
  while(flag){
    flag=0;
    for(int i=n-1;i>0;i--){
      if(a[i].num<a[i-1].num){
        flag=1;
        swap(a[i].num,a[i-1].num);
        swap(a[i].mark,a[i-1].mark);
        //count++;
      }
    }
  }
}
void judge(vector<card>a,vector<card>b,int n){
  bool judge=true;
  rep(i,n-1){
    int na,b1,b2;
    char na1,na2;
    for(int j=i+1;j<n;j++){
      if(a[i].num==a[j].num){
        na=a[i].num;
        na1=a[i].mark;
        na2=a[j].mark;
        //cout<<na;

        rep(k,n-1){
        if(b[k].num==na&&b[k].mark==na1){
          b1=k;
          //cout<<b1;
          break;
        }
      }
        rep(l,n){
          if(b[l].num==na&&b[l].mark==na2){
            b2=l;
            //cout<<b2;
            break;
          }
        }
        break;
      }
    }
    if (b1>b2){
      judge=false;
      break;
    }
  }

  if(judge==true){
    cout<<"Stable"<<endl;
  }else{
    cout<<"Not stable"<<endl;
  }
  
}




Measured memory_bytes: 3168
#include<iostream>
using namespace std;
int main() {
    double N;
    int a, b, c, d;
    a = b = c = d = 0;
    cin >> N;
    string p;
    for (int i = 1; i <= N; i++)
    {
        cin >> p;
        if (p == "AC")
            a++;
        else if (p == "WA")
            b++;
        else if (p == "TLE")
            c++;
            else d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return 0;
}

Measured memory_bytes: 3756
class Solution:
    def solve(self, n: int, s: str) -> str:

        s1 = s[:n//2]
        s2 = s[n//2:]

        if s1 == s2:
            return "Yes"
        else:
            return "No"


if __name__ == '__main__':

    # standard input
    n = int(input())
    s = input()

    # solve
    solution = Solution()
    print(solution.solve(n, s))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

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

	vector<ll> input(n+1);
	input[0] = 0;
	for(int i = 0; i < n; i++) {
		cin >> input[i+1];
		input[i+1]+=input[i];
	}

	unordered_map<ll,int> us;
	ll s_max = 0;
	for(int i = 0; i < n; i++) {
		for(int j = i; j < n; j++) {
			ll _sum = input[j+1]-input[i];
			us[_sum]++;
			s_max = max(s_max,_sum);
		}
	}

	ll ans = 0;

	for(ll bit = 1LL<<60; bit>0; bit = bit>>1LL) {
		if(bit>=s_max) continue;
		int count = 0;
		for(pair<ll,int> p : us) {
			if((p.first&bit)!=0) {
				count += p.second;
			}
		}
		//cout << bit << "," << count << endl;
		unordered_map<ll,int> new_us;
		if(count>=k) {
			ans |= bit;
			for(pair<ll,int> p : us) {
				if((p.first&bit)!=0) {
					count += p.second;
					new_us[p.first%bit] += p.second;
				}
			}
		}else {
			for(pair<ll,int> p : us) {
				new_us[p.first%bit] += p.second;
			}
		}
		us.swap(new_us);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 24436
import java.awt.geom.*;
import java.io.*;
import java.util.*;


public class Main {
	//1011 start
	int INF = 1 << 24;
	
	class Edge{
		int from, to;
		double cost;
		public Edge(int from, int to, double cost) {
			this.from = from;
			this.to = to;
			this.cost = cost;
		}
	}
	
	class State implements Comparable<State>{
		int now;
		double cost;

		public State(int now, double cost) {
			this.now = now;
			this.cost = cost;
		}

		public int compareTo(State o) {
			if(this.cost < o.cost)return -1;
			if(this.cost > o.cost) return 1;
			return 0;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			ArrayList<ArrayList<Edge>> pass = new ArrayList<ArrayList<Edge>>();
			Point2D [] data = new Point2D[n];
			int [] number = new int[n];
			for(int i = 0 ; i < n; i++){
				number[i] = sc.nextInt() -1;
				data[i] = new Point2D.Double(sc.nextInt(), sc.nextInt());
				pass.add(new ArrayList<Main.Edge>());
			}
			
			for(int i = 0 ; i < n; i++){
				for(int j = i + 1; j < n; j++){
					double dis = data[i].distance(data[j]);
					if(dis <= 50){
						pass.get(number[i]).add(new Edge(number[i], number[j], dis));
						pass.get(number[j]).add(new Edge(number[j], number[i], dis));
					}
				}
			}
			
			int m = sc.nextInt();
			StringBuilder sb = new StringBuilder();
			for(int i = 0 ; i < m; i++){
				int s = sc.nextInt()-1;
				int g = sc.nextInt()-1;
				String res = solve(s,g,pass);
				sb.append(res + "\n");
			}
			System.out.print(sb.toString());
		}
	}

	private String solve(int s, int g, ArrayList<ArrayList<Edge>> pass) {
		PriorityQueue<State> open = new PriorityQueue<Main.State>();
		open.add(new State(s, 0.0));
		int n = pass.size();
		double [] close = new double[n];
		Arrays.fill(close, INF);
		close[s] = 0.0;
		int [] route = new int[n];
		route[s] = -1;
		boolean flg = false;
		while(! open.isEmpty()){
			State now = open.poll();
			if(now.now == g){
				flg = true;
				break;
			}
			for(int i = 0 ; i < pass.get(now.now).size(); i++){
				Edge nowe = pass.get(now.now).get(i);
				double nextcost = now.cost + nowe.cost;
				if(close[nowe.to] <= nextcost) continue;
				close[nowe.to] = nextcost;
				open.add(new State(nowe.to, nextcost));
				route[nowe.to] = nowe.from;
			}
		}
		if(! flg){
			return "NA";
		}
		StringBuilder ans = new StringBuilder();
		int prev = g;
		LinkedList<Integer> stack = new LinkedList<Integer>();
		while(prev >= 0){
			stack.add(prev + 1);
			prev = route[prev];
		}
		while(! stack.isEmpty()){
			ans.append(" " + stack.removeLast());
		}
		return ans.substring(1);
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main(){
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt[32];
    memset(cnt,0,sizeof(cnt));
    rep(i,0,4){
        cnt[s[i]-'A']++;
    }
    int c = 0;
    rep(i,0,32){
        if(cnt[i] == 2) c++;
    }
    if(c == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
N = int(input())
*A, = map(int,input().split())

ans = 0
cnt = {}
for j,a in enumerate(A[::-1]):
    j = N-1-j
    ans += cnt.get(a+j,0)
    cnt[j-a] = cnt.get(j-a,0) + 1
print(ans)

Measured memory_bytes: 41448
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

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

int main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	if (m1 != m2)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
package main

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

func main() {
	scan_init()
	n := scanInt()
	a := make([]int, n)
	for i:= 0; i<n; i++ {
		a[i] = scanInt()
	}
	mod := int(math.Pow(10,9))+7
	ans := 0
	for i:=0; i<60; i++ {
		x := 0
		for j:= 0; j<n; j++ {
			// fmt.Println("miru", a[j]>>i&1, a[j])
			if (a[j]>>i&1) == 1 {
				x++ // 桁での1をカウント
			}
		}
		now := x*(n-x)%mod
		/* 1　が1個 0がn個の組み合わせは
		1は0と触れ合うことでn個出すので 1*n
		同様に1が２個の場合 0がnこの組み合わせは
		1は1とふれあうと0となり,1は0との組み合わせなので 2*nとなる
		 */
		for j:= 0; j<i; j++ {
			// now * 2 *2 * 2 ... 2^i //桁
			now = now*2%mod
		}
		ans += now
		ans %= mod
	}
	fmt.Println(ans)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 7172
N = int(input())
import math
t, a = map(int,input().split())
for i in range(N-1):
    T, A = map(int,input().split())
    g = math.ceil(max(-(-t//T),-(-a//A)))
    t = g*T
    a = g*A
    
ans = t + a
print(ans)

Measured memory_bytes: 3060
from collections import defaultdict

D,G=map( int, raw_input().split() )
P=[ map( int, raw_input().split() ) for i in range(D) ] 

N=10**6
dp= [  float("inf") for i in range(N+1) ]
dp[0]=0

for idx, x  in enumerate(P):
	m=idx+1	#money
	p,c=x[0], x[1]/100
	for i in range(N,-1,-1):
		if dp[i]!=float("inf"):
			for j in range(p,-1,-1):	# j= problems count   , idx = score of a problem
				if j==p:
					dp[i+m*j+c]=min( dp[i+m*j+c] , dp[i]+j )
				else:
					dp[i+m*j]=min( dp[i+m*j] , dp[i]+j )



ans=float("inf")

for i in range(G/100,N):
	ans=min(ans, dp[i])

print ans
	




Measured memory_bytes: 48540
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			list.add(0);
		}
		for (int i = 1; i < n; i++) {
			int in = sc.nextInt() - 1;
			int num = list.get(in);
			list.set(in, num + 1);
		}
		list.forEach(System.out::println);
	}
}


Measured memory_bytes: 52828
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

struct edge {
    int to, id;
};

vector<vector<edge>> g;
vi res;

void dfs(int v, int p=-1, int c=-1) {
    int k = 1;
    for (auto&& e : g[v]) {
        int u = e.to, ei = e.id;
        if (u == p) continue;
        if (k == c) k++;
        res[ei] = k; k++;
        dfs(u, v, res[ei]);
    }
}

int main() {
    int n;
    cin >> n;
    g.resize(n);
    res.resize(n-1);
    rep(i, n-1) res[i] = 0;
    
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back((edge){b, i});
        g[b].push_back((edge){a, i});
    }

    dfs(0);

    int k = -1;
    rep(i, n-1) k = max(k, res[i]);
    cout << k << endl;
    rep(i, n-1) cout << res[i] << endl;

    return 0;
}


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

if sum(a) < sum(b):
    print(-1)
    exit()


ans = 0
sa = [0] * n
tmp = 0
idx = 0
for i in range(n):
    if a[i] < b[i]:
        tmp -= a[i] - b[i]
        ans += 1
    elif a[i] > b[i]:
        
        sa[idx] = a[i] - b[i]
        idx += 1

if tmp == 0:
    print(0)
    exit()



r  = sorted(sa[:idx], reverse=True)
#print("ans: ", ans)
#print("tmp",tmp)
#print(r)
for i in range(idx):
    if tmp > r[i]:
        ans += 1
        tmp -= r[i]
    else:
        ans += 1
        #print("i= ",i)
        break
print(ans)


Measured memory_bytes: 18936
#ifdef __unix__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <algorithm>
#include <math.h>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#endif

#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair
/*#define NUMTOSTR(x)  (unsigned char)((x) + 48);*/
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;
using namespace std;


int main(){
	fastIO;
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	{

		if (s[i] == '9') s[i] = '1';
		else
		if (s[i] == '1') s[i] = '9';
	}
	cout << s;
	return 0;
}


Measured memory_bytes: 3560
import { readFileSync } from "fs";

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

const getName = (n: bigint): string => {
  const alphabets = range(26).map(i => String.fromCharCode("a".charCodeAt(0) + i));

  const getName = (n: bigint, l: bigint): string => {
    const m = 26n ** l;

    return n <= m
      ? range(l).reduce(
          ({ num, str }, _) => ({
            num: num / 26n,
            str: alphabets[Number(num % 26n)] + str,
          }),
          { num: n - 1n, str: "" }
        ).str
      : getName(n - m, l + 1n);
  };

  return getName(n, 1n);
};

{
  const input = readFileSync("/dev/stdin", "utf8");
  const N = BigInt(input);
  console.log(getName(N));
}


Measured memory_bytes: 29472
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d%d",&x,&y);
	if(x==1&&y==1)
	{
		printf("%d",1);
	}
	else if(x==1)
	{
		printf("%d",y-2);
	}
	else if(y==1)
	{
		printf("%d",x-2);
	}
	else
	{
		printf("%lld",1ll*(x-2)*(y-2));
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

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

int main(){
    ll n,k,c; cin >> n >> k >> c;
    string s;cin >> s;
    vector<ll> day(n+1);
    rrep(i,n){
        chmax(day[i], day[i+1]);
        chmax(day[i], day[min(n, i + c + 1)] + (s[i] == 'o'));
    }
    vector<ll> rem_day(n+1), num(n+1);
    reps(i,n){
        rem_day[i] = max(rem_day[i-1] - 1, 0LL);
        num[i] = num[i-1];
        if(s[i-1] == 'o' && rem_day[i-1] == 0){
            num[i] = num[i-1]+1;
            rem_day[i] = c;
        }
    }
    // print(day); 
    // print(num);
    // print(rem_day);
    vector<ll> ans;
    rep(i,n){
        if(s[i] != 'o')continue;
        if(rem_day[i] == 0){
            if(num[i] + day[i+1] < k)ans.emplace_back(i+1);
        }
    }

    print(ans);
}

Measured memory_bytes: 8052
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


//複数のソート
void sort2vectors(vector<int> &av, vector<int> &bv)
{
        int n = av.size();
        vector<int> p(n), av2(n), bv2(n);
        iota(p.begin(), p.end(), 0);
        sort(p.begin(), p.end(), [&](int a, int b) { return av[a] < av[b]; });
        for (int i = 0; i < n; i++) {
                av2[i] = av[p[i]];
                bv2[i] = bv[p[i]];
        }
        av = av2;
        bv = bv2;
}

//最大公約数
int gcd(int a, int b)
{
    int c;
    if (a < b) {
        a+=b; b=a-b; a-=b;
    }
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

//最小公倍数
int lcm(int x, int y)
{
    return (x * y / gcd(x, y));
}

int isPrime(int x){
  int i;
  if(x < 2) return 0;
  else if(x == 2) return 1;
  if( x%2 == 0) return 0;
  for(i = 3; i*i <= 2; i += 2){
    if(x%i == 0) return 0;
  }
  return 1;
}


const int pmax = 10000000;
bool isPrime_table[pmax];
//constがないと配列宣言できない

void eratos(void){
  int i, j;
  double sqrtmax=sqrt(pmax);

  REP(k, pmax) isPrime_table[k] = true; /* Initialization */

  /* Sieve process  */
  isPrime_table[0] = false;
  isPrime_table[1] = false;
          /* 0 and 1 are not prime. */
  for (i=2; i <= sqrtmax; i++){
    if (isPrime_table[i]==true){   /* i is prime. */
      for (j=i; i*j<pmax; j++){
        isPrime_table[i*j] = false; /* multiples of i are not prime. */
      }
    }
  }
}

//漸化式敵に記述も可能
//abs(dx[i]+dy[j])==1で四方
int dx[3]={-1, 0, 1};
int dy[3]={-1, 0, 1};
int W0, H0;
int  masu0[100][100]={0};
int cnt0;

int dfs(int a, int b){
  masu0[a][b] = 2;
  REP(i, 3)REP(j, 3){
    a = a+dx[i];
    b = b+dy[j];
    if(masu0[a][b]== 1 && a >= 0 && a < W0 && b >= 0 && b < H0){
    dfs(a, b);
  }
  }
  return 1;
}

//文字列取り出し　str.substr(i, 5)
//文字数字変換 stoi, stod とto_string
//初期化memset
//複数配列のソート
//dp
const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
const long long int MOD = 1000000007;

int main(void){

  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;
  unordered_map <char, int> ump;
  REP(i, s.length()) ump[s[i]]++;
  for(auto &itr : ump){
    if(itr.second%2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main()
{
  int A[1000];
  int i,j;
  int num,ans,temp=0;
  int hant_num=0; /*反転回数*/

  scanf("%d",&num);
  for(i=0;i<num;i++)
    {
      ans = scanf("%d",&A[i]);
    }
  for(i=0;i<num;i++)
    {
      for(j=num-1;j>=i+1;j--)
	{
	  if (A[j-1] > A[j]) 
	    {
	      temp = A[j];
	      A[j] = A[j-1];
	      A[j-1] = temp;
	      hant_num++;
	    }
	}
    }
  for (i=0;i<num;i++)
    {
      printf("%d",A[i]);
      if (i<num-1)printf(" ");
      else printf("\n");
    }
  printf("%d\n",hant_num);
  return 0;
}

Measured memory_bytes: 608
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			long a = sc.nextLong();
			BigDecimal b = sc.nextBigDecimal();
			
			long b2 = b.multiply(new BigDecimal(100)).longValue();
			
			System.out.println((a*b2)/100);


		}catch(Exception e) {
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 37368
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
const int mod = 1000000007;
vector<vector<ll>>v;
map<pair<ll,ll>,ll> col;
ll K;
void dfs(ll cur,ll par,ll cnt=1){
    ll sz = v[cur].size(); 
    for(ll i=0;i<sz;i++){
        ll nxt = v[cur][i];
        if(nxt==par)continue;
        ll _max = max(nxt,cur);
        ll _min = min(nxt,cur);
        col[make_pair(_min,_max)] = cnt;
        cnt = cnt%K+1;
        dfs(nxt,cur,cnt);
    }
    return;
}
 
int main(){
    ll N;
    cin>>N;
    v.resize(N);
    vector<pair<ll,ll>> path(N-1);
    map<ll,ll>mp;
    for(ll i=0;i<N-1;i++){
        ll a_,b_;
        cin>>a_>>b_;
        a_--;b_--;
        v[a_].push_back(b_);
        v[b_].push_back(a_);
        if(a_>b_)swap(a_,b_);
        path[i] = make_pair(a_,b_);
        mp[a_]++;
        mp[b_]++;
    }
    for(auto p:mp){
        K = max(K,p.second);
    }
    dfs(0,-1);
    cout<<K<<endl;
    for(ll i=0;i<N-1;i++){
        cout<<col[path[i]]<<"\n";
    }
 
}

Measured memory_bytes: 20608
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long mod = 1e9 + 7;

long long big_pow(long long a, long long b) {
	long long res = 1;
	while (b) {	
		if (b & 1) {
			res = (res * a) % mod;
		}

		b >>= 1;
		a = (a * a) % mod;
	}

	return res % mod;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int x, y;
	cin >> x >> y;

	if ((x + y) % 3 != 0) {
		cout << "0\n";
		return 0;
	}

	long long m = (2 * x - y) / 3;
	long long n = x - 2 * m;

	if (n < 0 || m < 0) {
		cout << "0\n";
		return 0;
	}

	long long s = 1, t = 1;
	for (int i = 2; i <= n + m; ++i) {
		s *= i;
		s %= mod;
	}

	for (int i = 2; i <= n; ++i) {
		t *= i;
		t %= mod;
	}

	for (int i = 2; i <= m; ++i) {
		t *= i;
		t %= mod;
	}

	long long moves = (s * big_pow(t, mod - 2)) % mod;
	cout << moves << "\n";

	return 0;

}

Measured memory_bytes: 3652
sx,sy,tx,ty = map(int,input().split())
w = tx - sx 
h = ty - sy 
ans = []
ans_1 = ["R"]*w + ["U"]*h 
ans_2 = ["L"]*w + ["D"]*h
ans_3 = ["D"] + ["R"] * (w+1) + ["U"] *(h+1) + ["L"]
ans_4 = ["U"] + ["L"] * (w+1)  + ["D"]*(h+1) +["R"]
ans = ans_1 + ans_2 + ans_3 + ans_4 
ans = "".join(ans)
print(ans,end=" ")

Measured memory_bytes: 3444
#include<iostream>
int main(){
  long long a,b,c; std::cin >> a >> b >> c;
  if((a + c - b) > 0 && c > a && (a + c - b) * (a + c - b) > (4 * a  * c)){
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n,i;
    char s[10001];
    scanf("%d%s",&n,s);
    for(i=0;s[i]!='\0';i++)
        printf("%c",(s[i]-'A'+n)%26+'A');
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N;
long long M;

long long judge(int x, vector<int>& A, vector<int>& cnt) {
    long long sum = 0;
    int a;
    for (int i = 0; i < N; i++) {
        a = max(0, x - A[i]);
        if (a <= A[0]) sum += cnt[max(0, x - A[i])];
    }
    return sum;
}

int main() {
    cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());
    vector<int> cnt(A[0] + 1);
    vector<long long> S(N);
    for (int i = 0; i < N; i++) {
        cnt[A[i]]++;
        S[i] = i > 0? S[i - 1] + A[i] : A[i];
    }
    for (int i = 0; i < A[0]; i++) {
        cnt[A[0] - i - 1] = cnt[A[0] - i] + cnt[A[0] - i - 1];
    }
    int left = 0, right = A[0] * 2 + 1;
    long long j;
    while(left + 1 < right) {
        int mid = (left + right) / 2;
        j = judge(mid, A, cnt);
        if (j >= M) {
            left = mid;
        } else {
            right = mid;
        }
    }
    int mn = left;
    long long ans = (M - judge(left, A, cnt)) * mn;
    for (int i = 0; i < N; i++) {
        if (A[i] + A[0] < mn) break;
        left = 0; right = N;
        while(left + 1 < right) {
            int mid = (left + right) / 2;
            if (A[mid] < mn - A[i]) {
                right = mid;
            } else {
                left = mid;
            }
        }
        ans += 1LL * (left + 1) * A[i] + S[left];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.io.*;
class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader r =
         new BufferedReader(new InputStreamReader(System.in), 1);
         
        String s = r.readLine();    
        int i = Integer.parseInt(s);
          
        if((1 <= i )&(i<= 100)){
            System.out.println(i*i*i);
        }
        r.close();
    }
}

Measured memory_bytes: 24136
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define N 300003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll mod=1e9+7;   

signed main()
{
    warmup
    
    int h,w,n;
    cin>>h>>w>>n;
    cout<<min((n+w-1)/w, (n+h-1)/h);
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    double M = in<double>();
    vector<int> A(N);
    REP(i,N)A[i] = in();
    sort(ALL(A),greater<>());
    double sum = 0;
    REP(i,N)sum += A[i];
    cout << (A[M-1] < ceil(sum/(4*M)) ? "No" : "Yes") << "\n";
}

Measured memory_bytes: 256