akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

int N,Q;
struct data{
  string name;
  int start,end;
};
vector<data> V;


void init(){
  V.clear();
}

void solve(int n){
  for(int i = 0; i < V.size(); i++){
    if(V[i].start <= n && n <= V[i].end){
      cout << V[i].name << " " << n-V[i].start+1 << endl;
      return;
    }
  }
  cout << "Unknown" << endl;
}

int main(){
  while(cin >> N >> Q && N+Q){
    init();
    for(int i = 0; i < N; i++){
      data d;
      int a,b;
      cin >> d.name >> a >> b;
      d.start = b-a+1;
      d.end = b;
      V.push_back(d);
    }

    for(int i = 0; i < Q; i++){
      int num;
      cin >> num;
      solve(num);
    }
  }
  
  return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>
void copy(int a[],int n){
    int i;
    for(i=0;i<n;i++){
        if(i>0)
            printf(" ");
        printf("%d",a[i]);
    }
    printf("\n");
}

int main(){
    int n;scanf("%d",&n);
    int i,j,v,a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    copy(a,n);
    for(i=1;i<n;i++){
        v=a[i];
    j=i-1;
    while(j>=0&&a[j]>v){
        a[j+1]=a[j];
        j--;
    }
    a[j+1]=v;
        copy(a,n);
    }
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    char S[3];
    cin >> S;
    sort(S,S+3);
    if(S[0]=='a'&&S[1]=='b'&&S[2]=='c')cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3624
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = 22, MOD = (int)1e9 + 7;

int dp[1 << N];
int ar[N][N];
int n;

inline int add (int a, int b) { return ((a%MOD) + (b%MOD)) % MOD; };

void solve() {
   dp[0] = 0;

   for (int k = 0; k < n; ++k) {
      if (ar[1][k+1]) dp[1 << k] = 1;
   }

   for (int i = 2; i <= n; ++i) {
      for (int j = (1 << n)-1; j >= 1; --j) {
         if (__builtin_popcount(j) != i) continue;
         for (int k = 0; k < n; ++k) {
            if (ar[i][k+1] && (j & (1 << k))) dp[j] = add(dp[j], dp[j - (1 << k)]);
         }
      }
   }
   int total = dp[(1 << n)-1];
   cout << total << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
         cin >> ar[i][j];
   solve();

   return EXIT_SUCCESS;
}




Measured memory_bytes: 11844
# 10bitごとに3等分して、Toom-3する。
# どうやら50bit弱の整数を答えとするFFTでも精度が怪しいようなので、
# 40bit程度で持てるように10bitごとで3分割した。(このとき結果の最大値は (log2(fft_len) + 10 * 2) bitほど)
# fft_lenが2 ** 30になることは時間計算量の都合からまずないので、10bit分割で精度が十分出る。

import numpy as np

fft_len = 2 ** 20   # == 1048576　答えの配列の長さ以上である必要があり、小さい素数の積であるとよい。(2の累乗など)
MOD = 998244353     # これが2 ** 30程度からそれ以下であることを前提に組んでいる。

def convolve10(As, Bs):
    "As, Bsの要素が10bitに入る(つまり2**10 = 1024以下)なら誤差はまず平気そう。"
    return np.round(np.real(np.fft.irfft(np.fft.rfft(As, fft_len) * np.fft.rfft(Bs, fft_len), fft_len))).astype(np.int64)

def convolve30(As, Bs):
    """
    10bitで3分割してToom-3
    参考: https://en.wikipedia.org/wiki/Toom%E2%80%93Cook_multiplication
    """
    mask = (1 << 10) - 1
    
    m0 = As & mask
    m1 = (As >> 10) & mask
    m2 = As >> 20

    p_tmp = m0 + m2 # Wikipediaではp_0
    p0 = m0
    p1 = p_tmp + m1
    pm1 = p_tmp - m1
    pm2 = ((pm1 + m2) << 1) - m0
    pinf = m2

    n0 = Bs & mask
    n1 = (Bs >> 10) & mask
    n2 = Bs >> 20

    q_tmp = n0 + n2 # Wikiqediaではq_0
    q0 = n0
    q1 = q_tmp + n1
    qm1 = q_tmp - n1
    qm2 = ((qm1 + n2) << 1) - n0
    qinf = n2

    r0   = convolve10(  p0,   q0)
    r1   = convolve10(  p1,   q1)
    rm1  = convolve10( pm1,  qm1)
    rm2  = convolve10( pm2,  qm2)
    rinf = convolve10(pinf, qinf)

    r_0 = r0
    r_4 = rinf
    r_3 = (rm2 - r1) // 3
    r_1 = (r1 - rm1) >> 1
    r_2 = (rm1 - r0)
    r_3 = ((r_2 - r_3) >> 1) + (rinf << 1)
    r_2 += r_1 - r_4
    r_1 -= r_3
    
    ret = ((r_4 << 20) + (r_3 << 10) + r_2) % MOD
    ret = ((ret << 20) + (r_1 << 10) + r_0) % MOD

    return ret


if __name__ == "__main__":  
    import sys
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    fft_len = 1 << (N + M - 1).bit_length()
    As = np.array(list(map(int, input().split())), dtype = np.int64)
    Bs = np.array(list(map(int, input().split())), dtype = np.int64)
    Cs = convolve30(As, Bs)
    print(*list(Cs[:N + M - 1]))

Measured memory_bytes: 217200
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

Node * treeMinimum(Node *x){
  while(x->left != NIL) x=x->left;
  return x;
}

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

Node * treeSuccessor(Node *x){
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y!=NIL && x == y->right){
    x = y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

  if(z->left == NIL || z->right ==NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left!=NIL){
    x = y->left;
  }else{
    x = y->right;
  }
  if(x!=NIL){
    x->parent = y->parent;
  }

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



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

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

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

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

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

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

  scanf("%d",&n);

  for(i = 0;i < n; i++){
    cin >> com;

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

  return 0;
}



Measured memory_bytes: 22088
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	LL a;
	double b;
	cin>>a>>b;
	
	b = b*100;
	string bs = to_string(b);
	
	int x = 1;
	int bb = 0;
	for(int i=0;i<bs.length();i++) {
		if(bs[i] == '.') break;
		bb = bb*x + (bs[i]-'0');
		x = 10;
	}
	
	cout<<(a*bb)/100<<endl;
	

    return 0;
}



Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
const int MN = 200;
int ep[2][MN][MN][MN];
int pr[MN][MN];
int gr[MN][MN];
int get(int ar, int ac, int br, int bc) {
	br++;bc++;
	return pr[br][bc]-pr[br][ac]-pr[ar][bc]+pr[ar][ac];
}
bool poop(int ar, int ac, int br, int bc) {
	int ru = get(ar,ac,br,bc);
	return ru == 0 || ru == (br-ar+1)*(bc-ac+1);
}
int main() {
	int n,m;
	cin >> n >> m;
	for(int i=0;i<n;i++) {
		string s;
		cin >> s;
		for(int j=0;j<m;j++) {
			if(s[j] == '.') {
				gr[i][j] = 1;
			} else {
				gr[i][j] = 0;
			}
		}
	}
	memset(pr,0,sizeof(pr));
	memset(ep,0,sizeof(ep));
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			pr[i+1][j+1] = pr[i][j+1]+pr[i+1][j]-pr[i][j]+gr[i][j];
		}
	}
	int cu = 0;
	for(int i=0;i<m;i++) {
		for(int j=i;j<m;j++) {
			int d = 0;
			for(int k=0;k<n;k++) {
				d = max(d,k);
				while(d < n && poop(k,i,d,j)) {
					d++;
				}
				ep[cu][i][j][k] = d-k;
			}
		}
	}
	int res = 0;
	while(1) {
		if(ep[cu][0][m-1][0] == n) {
			break;
		}
		int nu = 1-cu;
		memset(ep[nu],0,sizeof(ep[nu]));
		for(int k=0;k<n;k++) {
			for(int i=0;i<m;i++) {
				int ok = i+1;
				for(int j=i;j<m;j++) {
					int r = ep[cu][i][j][k];
					int ru = ep[cu][i][j][k]+ep[cu][i][j][k+r];
					ep[nu][i][j][k] = max(ep[nu][i][j][k],ru);
					ok = max(ok,j+1);
					while(ok < n && ep[cu][j+1][ok][k] >= r) {
						ep[nu][i][ok][k] = max(ep[nu][i][ok][k],r);
						ok++;
					}
				}
				ok = m-1;
				for(int j=m-1;j>=i;j--) {
					while(ok > j && ep[cu][j+1][ok][k] <= ep[cu][i][j][k]) {
						ep[nu][i][ok][k] = max(ep[nu][i][ok][k],ep[cu][j+1][ok][k]);
						ok--;
					}
				}
			}
		}
		cu = nu;
		res++;
	}
	cout << res << '\n';
}


Measured memory_bytes: 66440
#include<iostream>
using namespace std;
int cal(int n, int x){
    int exi = 0;
    for(int i = 1; i <= n - 2; i++){
        for(int j = i + 1; j <= n - 1; j++){
            for(int k = j + 1; k <= n; k++){
                if(i + j + k == x)exi += 1;
            }
        }
    }
    return exi;
}

int main(){
    while(1){
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0)break;
        
        cout << cal(n, x) << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

#define rep(i, n)      for (int i=0; i<int(n); i++)
#define rep3(i, s, n)  for (int i=int(s); i<int(n); i++)
#define rev_rep(i, n)  for (int i=int(n)-1; i>=0; i-=1)

int N;
int x[3100];
int y[3100];
bool map[5100][5100];
int m(int x, int y) {
  if (x < 0 || y < 0 || x > 5000 || y > 5000) return false;
  return map[x][y];
}
int main() {
  while (cin >> N) {
  if (N == 0) break;
  rep(i, 5100) {
    rep(j, 5100) {
      map[i][j] = false;
    }
  }
  rep(i, N) {
    cin >> x[i] >> y[i];
    map[x[i]][y[i]] = true;
  }
  int ans = 0;
  for (int i=0; i<N; i++) {
    for (int j=i+1; j<N; j++) {
      int xd = x[j] - x[i];
      int yd = y[j] - y[i];
      int t = xd*xd + yd*yd;
      if ((m(x[i] + yd, y[i] - xd) && m(x[j] + yd, y[j] - xd ))
        ||(m(x[i] - yd, y[i] + xd) && m(x[j] - yd, y[j] + xd ))) {
        ans = max(ans, t);
      }
    }
  }
  cout << ans << "\n";
  }
  return 0;
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int n, i;
  cin >> n >> i;
  
  cout << n - i + 1;
}

Measured memory_bytes: 256
import math
import sys

(N,A,B) = list(map(int,input().split()))
# print(N,A,B)
IFN = 10 ** 19 
if (A - B) % 2 == 0:
    P1 = abs(A-B) // 2
else: 
    P1 = IFN

P2  = ((A-1) + (B-1) + 1) // 2
P3  = ((N-A) + (N-B) + 1) // 2
print(min(P1,P2,P3))

Measured memory_bytes: 3064
var1 = int(input()) + 1
list3 = []
for i in range(1, var1):
    list3.append(input())
for m in range(0, var1-1):
    str1 = list3[m]
    list1 = str1.split(" ")
    list1 = list(map(int, list1))
    var2 = max(list1)
    list1.remove(max(list1))
    var2 = var2 * var2
    var3 = list1[0]*list1[0]
    var4 = list1[1]*list1[1]
    if var4 + var3 == var2:
        print("YES")
    else:
        print("NO")
    list1.clear()
    str1 = None



Measured memory_bytes: 5712
#include <stdio.h>
#include <stdlib.h>

int partition(int *A,int p,int r){
	int x = A[r];
	int i = p-1;
	int j = 0;
	int temp = 0;
	for(j = p;j < r;j++){
		if(A[j] <= x){
			i = i+1;
			temp = A[i];
			A[i] = A[j];
			A[j] = temp;
		}
	}
	temp = A[i+1];
	A[i+1] = A[r];
	A[r] = temp;
	return i+1;
}

int main(int argc, char **argv){
	int n = 0;
	int i = 0;
	int r = 0;
	scanf("%d",&n);

	int *A = malloc(sizeof(int) * n);

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

	r = partition(A,0,n-1);
	for(i = 0;i < n;i++){
		if(i == r){
			printf("[%d]",A[i]);
		}
		else{
			printf("%d",A[i]);
		}
		if(i < n-1){
			printf(" ");
		}
	}
	printf("\n");
}


Measured memory_bytes: 2140
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX 300000

int n, pm, pe, pj;

int main() {
	while (1) {
		scanf("%d", &n);
		if (n == 0)
			return 0;

		while(n-- > 0) {
			scanf("%d %d %d", &pm, &pe, &pj);
			if(max(pm, max(pe, pj)) == 100 || pm + pe >= 180 || pm + pe + pj >= 240)
				puts("A");
			else if(pm + pe + pj >= 210 || pm + pe + pj >= 150 && max(pm, pe) >= 80)
				puts("B");
			else
				puts("C");
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n, k; cin >> n >> k;
    vector<ld> a(n), e(n), sum(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        e[i] = (a[i] + 1.0) / 2.0;
    }
    ld ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += e[i];
    }
    ld tmp = ans;
    for (int i = k; i < n; ++i) {
        tmp += e[i];
        tmp -= e[i-k];
        ans = max(ans, tmp);
    }
    cout << fixed << setprecision(10)  << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b == c + d)
    {
        cout << "Balanced" << endl;
        return 0;
    }
    cout << (a + b > c + d ? "Left" : "Right") << endl;
    return 0;
}

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

using namespace std;

// #. -> NG
// ....##### -> OK

int w[200010];
int b[200010];

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

    for(int i = 1; i <= N; i++) {
        w[i] = w[i-1] + (S[i-1] == '.' ? 1 : 0);
        b[i] = b[i-1] + (S[i-1] == '#' ? 1 : 0);
    }
    w[N+1] = w[N];
    b[N+1] = b[N];

    int ans = 2e5+1;

    for(int i = 0; i <= N+1; i++) {
        ans = min(
            ans,
            b[i]+w[N+1]-w[i]
        );
    }

    cout << ans << endl;
}

Measured memory_bytes: 2180
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int X, Y;
int ans;

int main(){
	cin >> X >> Y;
	if (Y % 2 == 0 && 2 * X <= Y && 4 * X >= Y){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3596
class UnionFindTree:
    """Disjoint-Set Data Structure
       Union-Find Tree
       complexity:
          init: O(n)
          find, unite, same: O(alpha(n))
       used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ)
    """
    def __init__(self, n):
        self.par = list(range(n))  # parent
        self.rank = [0] * n  # depth of tree

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


class Kruskal:
    """ Kruskal's algorithm: find minimum spanning tree
        Complexity: O(E log(V))
        used in GRL2A(AOJ)
    """

    def __init__(self, V, E, start=0, INF=10**9):
        """ V: the number of vertexes
            E: adjacency list (undirected graph)
        """
        self.kruskal(V, E)

    def kruskal(self, V, E):
        edges = []
        for v1 in range(V):
            for v2, cost in E[v1]:
                if v1 < v2:
                    edges.append((cost, v1, v2))
        edges.sort(reverse=True)
        self.mincost = 0
        self.minSpanningTree = []
        uf = UnionFindTree(V)
        while len(self.minSpanningTree) < V-1:
            cost, v1, v2 = edges.pop()
            if uf.same(v1, v2) == False:
                self.mincost += cost
                uf.unite(v1, v2)
                self.minSpanningTree.append((v1, v2, cost))

    def minCost(self):
        return self.mincost

    def getMinSpanningTree(self):
        return sorted(self.minSpanningTree)

V = int(input())
edge = [[] for _ in range(V)]
for i in range(V):
    for j, d in enumerate(map(int, input().split())):
        if d != -1:
            edge[i].append((j, d))
mst = Kruskal(V, edge)
print(mst.minCost())

Measured memory_bytes: 8612
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            for(int i = 0; i < H; i++){
                for(int j = 0; j < W;j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 63956
#include <bits/stdc++.h>
#define N 100010
#define cmax(a,b) a=max(a,b);
using namespace std;
int n,m,x,y;
vector<int> g[N];
int mem[N]={};
int dfs(int x)
{
	int i;
	if(mem[x]>0)
	{
		return mem[x];
	}
	for(i=0;i<g[x].size();i++)
	{
		cmax(mem[x],1+dfs(g[x][i]));
	}
	return mem[x];
}
int main(){
	int i,j,ans=0;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		g[x-1].push_back(y-1);
	}
	for(i=0;i<n;i++)
	{
		cmax(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int N,H,maxa=0,ans;

int main(){
    cin>>N>>H;
    int a[N],b[N];
    rep(i,N){
        cin>>a[i]>>b[i];
        maxa=max(maxa,a[i]);
    }
    sort(b,b+N,greater<int>());
    rep(i,N){
        if(maxa<=b[i]){
            H-=b[i];
            ans++;
            if(H<=0){
                out(ans);
                return 0;
            }
        }
        else{
            b[i]=0;
        }
    }
    out((H%maxa==0?0:1)+H/maxa+ans);
}


Measured memory_bytes: 1024
#include<queue>
#include<cstdio>

#define	mp	make_pair

using namespace std;

enum LR{L,R};

struct Info{
	int x,y;
	LR bef;
	Info(int _x,int _y,LR _bef){ x=_x,y=_y,bef=_bef; }
};

bool operator<(const Info &i1,const Info &i2){
	return true;
}

char clif[60][30];
int tmin[60][30][2];
bool visited[60][30][2];
const int dx[]={1,1,1,1,1,2,2,2,3};
const int dy[]={-2,-1,0,1,2,-1,0,1,0};

int main(){
	for(int w,h;scanf("%d%d ",&w,&h),w;){
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)	scanf("%c ",clif[i]+j);

		priority_queue< pair<int,Info> > pq;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			if(clif[i][j]=='S'){
				pq.push(mp(0,Info(j,i,L)));
				pq.push(mp(0,Info(j,i,R)));
				clif[i][j]='0';
			}
			for(int k=0;k<2;k++){
				tmin[i][j][k]=1<<30;
				visited[i][j][k]=false;
			}
		}
		int ans=-1;
		while(!pq.empty()){
			pair<int,Info> a=pq.top();	pq.pop();
			int t=-a.first,x=a.second.x,y=a.second.y;
			LR bef=a.second.bef;
			if(visited[y][x][bef])	continue;
			visited[y][x][bef]=true;

			if(clif[y][x]=='T'){ ans=t; break; }

			for(int i=0;i<9;i++){
				int xx,yy;
				if(bef==L)	xx=x+dx[i],yy=y+dy[i];
				else		xx=x-dx[i],yy=y-dy[i];
				LR foot=(bef==L?R:L);
				if(0<=xx && xx<w && 0<=yy && yy<h
				&& clif[yy][xx]!='X' && !visited[yy][xx][foot]){
					int nextt=t+(clif[yy][xx]=='T'?0:clif[yy][xx]-'0');
					if(nextt<tmin[yy][xx][bef]){
						pq.push(mp(-nextt,Info(xx,yy,foot)));
						tmin[yy][xx][bef]=nextt;
					}
				}
			}
		}

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

	return 0;
}

Measured memory_bytes: 0
/********   In the name of Allah, the most gracious, the most merciful ********/
#include <bits/stdc++.h>

using namespace std;
typedef long long int lli;
#define inf 1e9L + 7
#define sci(a) scanf("%d", &a)
#define pri(a) printf("%d", a)
#define line printf("\n")

#define mx 1e5 + 9

vector<vector<int>> adj(mx);
vector<bool> vis(mx, false);
vector<int> dis(mx, 0), in_deg(mx, 0);
int n, m;

void visit(int i);
void dfs()
{
    for (int i = 1; i <= n; i++)
    {
        if (!vis[i] && in_deg[i] == 0)
            visit(i);
    }
}
void visit(int u)
{
    vis[u] = true;
    for (int v : adj[u])
    {
        dis[v] = max(dis[v], dis[u] + 1);
        in_deg[v]--;
        if (in_deg[v] == 0)
            visit(v);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    sci(n), sci(m);
    for (int i = 0; i < m; i++)
    {
        int x, y;
        sci(x), sci(y);
        in_deg[y]++;
        adj[x].push_back(y);
    }
    dfs();
    int ans = 0;
    for (int i = 1;i<=n;i++)
        ans = max(ans, dis[i]);
    pri(ans), line;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// ll kaijo(ll n){
//     ll ans = 1;
//     for (ll i = 1; i <= n; i++){   
//         ans *= i;
//         ans %= MOD;
//     }
//     return ans;
// }

// ll facto(ll n, ll k){
//     ll tmp = kaijo(n);
//     tmp *= modpow(kaijo(n-k), MOD-2);
//     tmp %= MOD;
//     tmp *= modpow(kaijo(k), MOD-2);
//     tmp %= MOD;
//     return tmp;
// }

int main(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }
    
    sort(a, a+n);


    ll fac[n];
    fac[k-1] = (ll)1;
    for (ll i = k; i < n; i++) {
        fac[i] = fac[i-1] * i;
        fac[i] %= MOD;
        fac[i] *= modpow((i-k+1), MOD-2);
        fac[i] %= MOD;
    }

    ll ans = 0;
    for (ll i = k-1; i < n; i++){
        ans += fac[i] * a[i];
        ans %= MOD;
    }
    for (ll i = k-1; i < n; i++){
        ans -= fac[i] * a[n-i-1];
        ans %= MOD;
    }

    cout << ans%MOD << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 1408
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var odd = "";
            for(var i = 1; i <= s.Length; i++){
                if(i % 2 != 0){
                    odd += s[i - 1];
                }
            }

            Console.WriteLine(odd);
        }
    }
}


Measured memory_bytes: 34772
// https://atcoder.jp/contests/abc153/tasks/abc153_d
import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val H = scn.nextDouble()

    var a = 1.0
    var sum = 0.0
    var cnt = 1
    while(H>=a){
        sum += a
        a *= 2
        cnt++
    }

    println(String.format("%.0f",sum))
}

Measured memory_bytes: 31276
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    int N, Lmax=0, Lsum=0;
    cin >> N;
    vector<int> L(N);
    for(int i=0; i<N; i++){
        cin >> L[i];
        Lsum += L[i];
        if(L[i] > Lmax){
            Lmax = L[i];
        }
    }
    if(Lsum-Lmax > Lmax) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    int n,m; cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    for(int i = 0; i <= n-m; i ++) {
        for(int j = 0; j <= n-m; j ++) {
            for(int k = j; k < j+m; k ++) {
                if(a[k].substr(i,m) != b[k-j]) break;
                if(k==j+m-1) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  cout << fixed << setprecision(10);
  cout << double((n+1)/2) / double(n) << endl;
  return 0;
}


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

using namespace std;

using ll = long long int;

ll doubling(const vector<ll>& A, ll K, ll start) {
    const int N = 64;
    vector<vector<ll>> memory(N, vector<ll>(A.size()));

    copy(A.begin(), A.end(), memory[0].begin());
    rep(i, N - 1) {
        rep(j, A.size()) {
            ll before = memory[i][j];
            if (before == -1) {
                memory[i + 1][j] = -1;
            } else {
                memory[i + 1][j] = memory[i][before];
            }
        }
    }

    ll p = start;
    rep(i, N) {
        ll k = K >> i;
        if (k == 0)
            break;
        else if (k & 1)
            p = memory[i][p];
    }

    return p;
}

int main() {
    // Input
    int N;
    ll K;
    vector<int> A;

    cin >> N >> K;
    A = vector<int>(N);
    rep(i, N) cin >> A[i];

    // Process
    vector<ll> next(N);
    rep(i, N) next[i] = A[i] - 1;

    ll ans = doubling(next, K, 0) + 1;

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 107276
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;

int dp[1<<14][21];

int dfs(int total_players,int upto[21],
	int current_stones,int player_idx){
  if(dp[current_stones][player_idx] != -1){
    return dp[current_stones][player_idx];
  }
  if(current_stones == 0){
    return 1;
  }

  int res = 0;

  for(int use = 1; 
      use <= upto[player_idx] 
	&& current_stones - use >= 0; 
      use++){
    if(dfs(total_players,upto,
	   current_stones - use,
	   (player_idx + 1) % total_players) == 0){
      res = 1;
    }
  }
  return (dp[current_stones][player_idx] = res);
}

int main(){
  int total_players;
  while(~scanf("%d",&total_players)){
    if(total_players == 0) break;

    int initial_stones;
    scanf("%d",&initial_stones);

    int upto[21];
    memset(upto,0,sizeof(upto));
    for(int player_idx=0;player_idx < total_players * 2;player_idx++){
      scanf("%d",upto + player_idx);
    }

    memset(dp,-1,sizeof(dp));
    printf("%d\n",dfs(total_players * 2,upto,initial_stones,0));
  }
}

Measured memory_bytes: 2968
#include<cstdint>
#include<limits>
#include<cstdbool>
#include<cmath>
#include<iostream>
#include<vector>
#include<array>
#include<list>
#include<string>
#include<sstream>
#include<algorithm>

int main(){
	int n;
	std::cin>>n;
	std::vector<int> a;
	a.reserve(n);
	int temp;
	for(int i = 0; i < n; ++i){
		std::cin>>temp;
		a.push_back(temp);
	}
	std::vector<int> b(n);
	for(int i = 0; i < n; ++i)
		b[a[i]-1]=i+1;
	for(int i = 0; i < n; ++i)
		std::cout<<b[i]<<' ';
	return 0;
}


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

const int N = 200010;
const int M = 40;
using pii = std::pair <int, int>;
using ll = long long;

char s[N];

pii parse(){
    double x;
    scanf("%lf", &x);
    ll num = ll(std::round(x * 1e9));
    int two = -9, five = -9;
    while (num % 2 == 0){
        ++ two;
        num /= 2;
    }
    while (num % 5 == 0){
        ++ five;
        num /= 5;
    }
    return {two, five};
}

int cnt[M << 1][M << 1];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        pii p = parse();
        ++ cnt[p.first + M][p.second + M];
    }
    ll ans = 0;
    for (int i = 0; i < M << 1; ++ i){
        for (int j = 0; j < M << 1; ++ j){
            for (int k = 0; k < M << 1; ++ k){
                for (int u = 0; u < M << 1; ++ u){
                    int two = i + k - 2 * M, five = j + u - 2 * M;
                    if (two < 0 || five < 0){
                        continue;
                    }
                    if (i == k && j == u){
                        ans += 1ll * cnt[i][j] * (cnt[i][j] - 1);
                    }
                    else{
                        ans += 1ll * cnt[i][j] * cnt[k][u];
                    }
                }
            }
        }
    }
    printf("%lld\n", ans / 2);
    return 0;
}

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

#define MM 2000000

int A[MM], a=0;
int B[MM], b=0;

int n, m, k, i, j;
char S[2*MM+1];

void printS(void){
	int i=MM;
	while((S[i]&1)==0) i--;
	for(; i>=0; i--){
		putchar((S[i]&1)==0?'0':'1');
	}putchar(10);
}

void printT(void){
	int i=MM;
	while((S[i]&2)==0) i--;
	for(; i>=0; i--){
		putchar((S[i]&2)==0?'0':'1');
	}putchar(10);
}

int main(void){
	scanf("%d%d%d\n", &n, &m, &k);
	for(i=n-1; i>=0; i--){
		S[i]=(getchar()=='1')?1:0;
	}
	while(getchar()!=10);
	for(i=m-1; i>=0; i--){
		if(getchar()=='1') S[i]|=2;
	}
	int l = n>m?n:m;
	for(i=l; i>=0; i--){
		if(S[i]==3){
			S[i]=0;
			int z=k; j=i;
			char x=3;
			while(1){
				int p=(a>0?A[--a]:INT_MAX);
				if(p>j+1){
					if(x==3){
						if(p>j+z){
							if(p!=INT_MAX) A[a++]=p;
							S[j+z]=3; break;
						}else{
							z-=p-j-1;
						}
					}else{
						if(p!=INT_MAX) A[a++]=p;
						S[j+1]=x;
						B[b++]=j+1; break;
					}
				}
				if(S[p]==1){
					if(x==3){
						S[p]=2; x=1;
						B[b++]=p;
					}else if(x==1){
						S[p]=0; x=1;
					}else{
						z--;
						if(z>=0){
							S[p]=0; x=3;
						}else{
							S[p]=3; break;
						}
					}
				}else if(S[p]==2){
					if(x==3){
						S[p]=1; x=2;
						B[b++]=p;
					}else if(x==2){
						S[p]=0; x=2;
					}else{
						z--;
						if(z>=0){
							S[p]=0; x=3;
						}else{
							S[p]=3; break;
						}
					}
				}
				j=p;
			}
			while(b) A[a++]=B[--b];
		}else if(S[i]!=0){
			A[a++]=i;
		}
	}
	printS();
	printT();
}


Measured memory_bytes: 13184
import sys
sys.setrecursionlimit(1000000)

N = int(input())

P = [n for n in range(N)]
points = []

def root(a):
  if P[a] == a:
    return a
  P[a] = root(P[a])
  return P[a]

def is_same_set(a, b):
  return root(a) == root(b)

def unite(a, b):
  P[root(a)] = root(b)


for i in range(N):
  x, y = [int(n) for n in input().split()]
  points.append((i, x, y))

xs = sorted([(x, i) for i, x, y in points], key=lambda p: p[0])
xedges = [(xs[n][1], xs[n+1][1], xs[n+1][0]-xs[n][0] ) for n in range(N-1)]
ys = sorted([(y, i) for i, x, y in points], key=lambda p:p[0])
yedges = [(ys[n][1], ys[n+1][1], ys[n+1][0]-ys[n][0]) for n in range(N-1)]

edges = xedges + yedges
edges.sort(key=lambda x: x[2])
res = 0
for edge in edges:
  i, j, cost = edge
  if not is_same_set(i, j):
    unite(i, j)
    res += cost

print(res)

Measured memory_bytes: 136992
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;

int dp[2097152];
vector<vector<int>> v;

int bitCount(int x) {
	int res = 0;
	while (x) { x = x & (x - 1); res++; }
	return res;
}

int main() {
	int n; cin >> n; v.resize(n, vector<int>(n));
	for (auto &x : v) for (auto &y : x) cin >> y;
	fill(dp, dp + (1 << 21), 0); dp[0] = 1;
	for (int mask = 1; mask < (1 << n); mask++) {
		int boy = bitCount(mask) - 1;
		for (int i = 0; i < n; i++)
			if ((mask & (1 << i)) && v[boy][i])
				dp[mask] = (dp[mask] + dp[mask ^ (1 << i)]) % mod;
	}
	cout << dp[(1 << n) - 1] << '\n';
	cin.ignore(2); return 0;
}

Measured memory_bytes: 11796
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,i,j;
    cin>>n;
    vector<string> v(n);
    for(i=0;i<n;i++){
        cin>>v[i];
    }
    vector<string> t(n);
    vector<string> s(n);
    for(i=0;i<n;i++){
        t[i]=v[i];
        s[i]=v[i];
    }
    /*BUBBLE*/
    for(i=0;i<n;i++){
        for(j=n-1;j>=i+1;j--){
            if(t[j][1]<t[j-1][1])
                swap(t[j],t[j-1]);
        }
    }
    for(i=0;i<n;i++){
        cout<<t[i]<<((i<n-1)?' ':'\n');
    }
    cout<<"Stable"<<'\n';
    
    /*SELECTION*/
    for(i=0;i<n;i++){
        int min=i;
        for(j=i;j<n;j++){
            if(s[j][1]<s[min][1]){
                min=j;
            }
        }
        swap(s[i],s[min]);
    }
    for(i=0;i<n;i++){
        cout<<s[i]<<((i<n-1)?' ':'\n');
    }
    cout<<((t==s)?"Stable":"Not stable")<<endl;
    return 0;
}


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

int main(){
    int n; cin >> n;
    int a = 0, b = 0, c = 0, ab = 0;
    for (auto i = 0; i < n; i++) {
        string s; cin >> s;
        if(s.front() == 'B' and s.back() == 'A') c++;
        if(s.front() == 'B' and s.back() != 'A') b++;
        if(s.front() != 'B' and s.back() == 'A') a++;
        for (auto j = 1; j < (int)s.size(); j++) if(s[j - 1] == 'A' and s[j] == 'B') ab++;
    }

    cout << ab + ((a + b > 0) ? min(a, b) + c : ((c == 0) ? 0 : c - 1)) << endl;
    return 0;
}

Measured memory_bytes: 3580
//#pragma GCC optimize(2)				//O2优化 
//#pragma GCC optimize(3)				//O3优化 
#include<bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define ME 0x7f
#define FO(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout)
#define fui(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define fdi(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define fel(i,a) for(register int i=hd[a];i;i=dg[i].nxt)
#define ll long long
#define MEM(a,b) memset(a,b,sizeof(a))
string s,s2;
template<class T>
inline T read(T &n){
	n=0;int t=1;double x=10;char ch;
	for(ch=getchar();!isdigit(ch)&&ch!='-';ch=getchar());(ch=='-')?t=-1:n=ch-'0';
	for(ch=getchar();isdigit(ch);ch=getchar()) n=n*10+ch-'0';
	if(ch=='.') for(ch=getchar();isdigit(ch);ch=getchar()) n+=(ch-'0')/x,x*=10;
	return (n*=t);
}
template<class T>
T write(T n){
	if(n<0) putchar('-'),n=-n;
	if(n>=10) write(n/10);putchar(n%10+'0');return n;
}
template<class T>
T writeln(T n){write(n);putchar('\n');return n;}
int main(){
	cin>>s;
	fui(i,0,s.size()-9,1)s2=s2+s[i];
	cout<<s2;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        char[] S = in.next().toCharArray();
        char[] T = in.next().toCharArray();
        int ans = T.length;
        for (int i = 0; i + T.length <= S.length; i++) {
            int diff = 0;
            for (int j = 0; j < T.length; j++) if (T[j] != S[i + j]) {
                diff++;
            }
            ans = Math.min(ans, diff);
        }
        out.println(ans);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}


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

int main() {
  string s, t; cin >> s >> t;
  int n = s.length();

  int ans = 0;
  rep(i, n) {
    if (s[i] != t[i]) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3892
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int x[1000],y[1000];
int main(){
	int n,r,a,b;
	while(true){
		cin>>n>>r;
		if(n==0 && r==0){break;}
		for(int i=1;i<=n;i++){
			x[i]=n+1-i;
		}
		for(int i=0;i<r;i++){
			cin>>b>>a;
			for(int i=b;i<a+b;i++){
				y[i-b+1]=x[i];
			}
			for(int i=1;i<b;i++){
				y[i+a]=x[i];
			}
			for(int i=a+b;i<=n;i++){
				y[i]=x[i];
			}
			for(int i=1;i<=n;i++){
				x[i]=y[i];
			}
		}
		cout<<x[1]<<endl;
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    double a, b, h, m;

    cin >> a >> b >> h >> m;

    double pi = acos(-1);

    double hx = a * cos(((h / 6.0) + (m / 360.0)) * pi);
    double hy = a * sin(((h / 6.0) + (m / 360.0)) * pi);
    double mx = b * cos((m / 30.0) * pi);
    double my = b * sin((m / 30.0) * pi);

    printf("%.20lf\n", sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my)));

    return 0;
}

Measured memory_bytes: 4164
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
typedef long long ll;
#define rep(i,n) for(int i = 0;i<n;++i)
#define repr(i,n) for(int i = n;i>=0;--i)
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;
int main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);

  ll n,y;
  cin >> n >> y;
  y/=1000;
  ll ans[3] = {-1,-1,-1};
  repr(i, n){
    ll rest = n-i;
    ll sum = y-10*i;
    if(sum>=0){
      repr(j, rest){
        ll temp = 4*j+rest;
        if(temp==sum){
          ans[0] = i;
          ans[1] = j;
          ans[2] = rest-j;
        }
      }
    }
  }
  cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << '\n';

        return 0;
}

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

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a == 5 && b == 5 && c == 7)
  {
    cout << "YES" << endl;
  }
  else if(a == 5 && b == 7 && c == 5)
  {
    cout << "YES" << endl;
  }
  else if(a == 7 && b == 5 && c == 5)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
挿入ソート
*/
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
	"strings"
)

type ints []int

func (s ints) String() string {
	var buf bytes.Buffer
	sep := ""
	for _, v := range s {
		buf.WriteString(fmt.Sprintf("%s%d", sep, v))
		sep = " "
	}
	return buf.String()
}

func insertionSort(a ints) {
	fmt.Println(a)
	for i := 1; i < len(a); i++ {
		// 着目する要素を"よける"
		v := a[i]
		// 着目する要素を入れるスペースを空けながら探す
		j := i - 1
		for j >= 0 && a[j] > v {
			a[j+1] = a[j]
			j--
		}
		// 空けたスペースに格納
		a[j+1] = v

		fmt.Println(a)
	}
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	eGetInt(reader)
	a := eGetInts(reader)
	insertionSort(a)
}
func eGetLine(r *bufio.Reader) string {
	s, err := r.ReadString(byte('\n'))
	if err != nil {
		if err != io.EOF {
			log.Fatal(err.Error())
		}
		return s
	}
	return strings.TrimRight(s, "\r\n")
}
func eGetInt(r *bufio.Reader) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInts(r *bufio.Reader) []int {
	line := eGetLine(r)
	fields := strings.Split(line, " ")
	var ints []int
	for _, f := range fields {
		ints = append(ints, eAtoi(f))
	}
	return ints
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}



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

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();
		x /= a;

		double ang = 0;
		if (b >= 2 * x / a) {
			ang = Math.atan2(b, 2 * x / b);
		} else {
			ang = Math.atan(2 * (a * b - x) / (a * a));
		}
		System.out.println(ang * 180 / Math.PI);
	}

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

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
constexpr int INF = 1000000000;

int main() {
  int n,z,w;
  cin>>n>>z>>w;
  vector<int> a(n);
  REP(i,n) cin>>a[i];
  vector<int> dpx(n);
  vector<int> dpy(n);
  for (int i = n-1; i >= 0; --i) {
    int mx = abs(((i == 0) ? w : a[i-1]) - a[n-1]);
    int my = abs(((i == 0) ? z : a[i-1]) - a[n-1]);
    FOR(j,i+1,n) {
      mx = max(mx, dpy[j]);
      my = min(my, dpx[j]);
    }
    dpx[i] = mx;
    dpy[i] = my;
  }
  cout << dpx[0] << endl;
  return 0;
}


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

int main() {
	
	//vector<int> a(n);  sort(a.begin(),a.end());
	//cout << "test" << endl;

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//string ans="YES";


	int n,k,q;
	cin >> n >> k >> q;
	
	vector<int> a(q);
	vector<int> b(n,k);
	
	
	rep(i,q) cin >> a[i];
	
	rep(i,q){
		int win=a[i];
		b[win-1]++;
	}
	rep(i,n) {
		b[i]-=q;
		if(b[i]>0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	
	//cout << ans << "\n";
	
	
	return 0;

    }

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;



int main() {
    int n; string c; cin >> n >> c;
    vector<int> a(n);
    if(c[0] == 'R') a[0]++;
    rp(i, 1, n) {
        if(c[i] == 'R') a[i] = a[i-1] + 1;
        else a[i] = a[i-1];
    }
    int r = a[n-1];  // 赤石の数
    int res1 = r;  // 全て白にする場合
    int res2 = n-r;  // 全て赤にする場合
    int res3 = r - a[r-1];
    cout << min({res1, res2, res3}) << endl;
    return 0;

}

Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define MOD (int)1e9+(int)7
#define INF 2147483647
typedef long long ll;
typedef unsigned long long ull;

//dark power
//#define int ll
//define Error、大抵は、セミコロン忘れとか、Defineは関係ない
/*
vector<int> d(100000);
vector<int> b(100000);
class UnionFind{
	public:
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	signed find(signed x){
		if(d[x]==x){
			return x;
		}else{
			return d[x]=find(d[x]);
		}
	}
	UnionFind(signed n){rep(i,n){d[i]=i;b[i]=0;}}
	void unite(signed x,signed y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(b[x]<b[y]){
			d[x]=y;
		}else{
			d[y]=x;
			if(b[x]==b[y])b[x]++;
		}
	}
	bool same(signed x,signed y){return (find(x)==find(y));}
};
*/
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int b=0;
	b=int(s.find('A'));
	int e=0;
	reverse(all(s));
	e=int(s.find('Z'));
	e=int(s.length())-e;
	cout<<e-b<<endl;

	return 0;
}


Measured memory_bytes: 720
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
var obj={};
for(var i=2;i<=100001;i++)obj[i]=1;
for(var i=0;i<n;i++){
   var ab=(Arr.shift()).split(" ").map(Number);
   for(var j=ab[0];j<=ab[1];j++)obj[j]++;
}
var max=1;
for(var i=2;i<=100001;i++){
   if(obj[i]>=i)max=i;
}
console.log(max-1);

Measured memory_bytes: 55384