akhauriyash/Code-Regression huggingface dataset:
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    ll x, y; cin >> x >> y;
    ll ans = 0;
    ans = abs(abs(x) - abs(y));
    if(ans == 0 && x != y) ans++;
    else if(ans == 0);
    else if(x >= 0 && y >= 0){
        if(x > y && y == 0) ans++;
        else if(x > y) ans += 2;
    }
    else if(x == 0 && y < 0) ans++;
    else if(x < 0 && y == 0);
    else if(x > 0 && y == 0) ans++;
    else if((x < 0 && y > 0) || (x > 0 && y < 0)){
        ans++;
    }
    else if((x < 0 && y < 0) && x < y);
    else {
        ans += 2;
    }
    cout << ans << endl;
}


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

int main()
{
	int i,j,k;
	string s;
	bool cek[30];
	memset(cek,0,sizeof(cek));
	cin>>s;
	for (i=0;i<s.length();i++)
	{
		int asc=(int)s[i];
		asc-=96;
		cek[asc]=1;
	}
	for (i=1;i<=26;i++)
	{
		if (!cek[i])
		{
			char ch=(char)i+96;
			cout<<ch<<"\n";
			return 0;
		}
	}
	cout<<"None\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<vector>
#include<string>

using namespace std;

int binarySearch(vector<int> &vec,int value){
  int left=0;
  int mid;
  int right=vec.size();
  while(left<right){
    mid=(left+right)/2;
    if(vec.at(mid)==value) return mid;
    else if(vec.at(mid)<value) left=mid+1;
    else right=mid;
  }
  return -1;
}

int main(void){
  int size,searchsize,count=0;
  cin>>size;
  vector<int> vec(size);
  for(int i=0;i<size;i++) cin>>vec.at(i);
  cin>>searchsize;
  vector<int> search(searchsize);
  for(int i=0;i<searchsize;i++) cin>>search.at(i);

  for(int i=0;i<searchsize;i++){
    if(binarySearch(vec,search.at(i))!=-1) count++;
  }
  cout<<count<<endl;
  return 0;

}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long

struct union_find{
	int N;
	vector<int> parent;
	vector<int> siz;

	union_find(int N) : parent(N), siz(N, 1){
		for (int i = 0; i < N; i++) parent[i] = i;
	}

	int root(int x){
		if(parent[x] == x) return x;
		else return parent[x] = root(parent[x]);
	}

	void merge(int x, int y){
		x = root(x), y = root(y);
		if(x == y) return;
		if(siz[x] < siz[y]) swap(x, y);
		parent[y] = x;
		siz[x] += siz[y];
		siz[y] = 0;
	}

	bool are_same(int x, int y){
		return root(x) == root(y);
	}

	int size(int x){
		return siz[root(x)];
	}
};

signed main(){
	int N, M, Q, i;
	scanf("%lld%lld%lld", &N, &M, &Q);
	vector<int> A0(0), B0(0), A1(0), B1(0);
	union_find uf(N);
	int M0 = 0, M1 = 0;
	for(i = 0; i < Q; i++){
		int A, B, C;
		scanf("%lld%lld%lld", &A, &B, &C);
		if(C == 0){
			A0.push_back(A);
			B0.push_back(B);
			uf.merge(A, B);
			M0++;
		}
		else{
			A1.push_back(A);
			B1.push_back(B);
			M1++;
		}
	}
	for(i = 0; i < M1; i++){
		if(uf.are_same(A1[i], B1[i])){
			printf("No\n");
			return 0;
		}
	}
	for(i = 0; i < N; i++){
//		printf("(i, root(i)) = (%d, %d)\n", i, uf.root(i));
		if(i != uf.root(i)){
//			printf("test5\n");
			M--;
		}
	}
//	printf("M = %lld\n", M);
/*	set<pair<int, int>> s;
	vector<int> A2(0), B2(0);
	for(i = 0; i < M1; i++){
		int ra = uf.root(A1[i]), rb = uf.root(B1[i]);
		if(s.count(pair<int, int>(ra, rb)) == 1 || s.count(pair<int, int>(rb, ra)) == 1){

		}
		else{
			A2.push_back(A1[i]);
			B2.push_back(B1[i]);
			s.insert(pair<int, int>(ra, rb));
		}
	}
	int M2 = A2.size();
*/	int elenum = 0;
	for(i = 0; i < N; i++){
		if(i == uf.root(i)){
			elenum++;
		}
	}
	vector<int> cnt(N, 0);
	for(i = 0; i < M1; i++){
		cnt[uf.root(A1[i])] = 1;
		cnt[uf.root(B1[i])] = 1;
	}
	int sum = 0;
	for(i = 0; i < N; i++){
		sum += cnt[i];
	}
//	printf("elenum = %lld\n", elenum);
//	printf("sum = %lld\n", sum);
	if(sum == 0){
		if(elenum - 1 <= M && M <= (elenum * (elenum - 1)) / 2){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
		return 0;
	}
	if(elenum <= M && M <= (elenum * (elenum - 1)) / 2){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;

/*	if(elenum == 1){
		printf("Yes\n");
		return 0;
	}
	if(elenum == 2){
		if(M2 > 0){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}
		return 0;
	}
	vector<int> my_count(N, 0), root_count(N, 0);
	for(i = 0; i < M1; i++){
		my_count[A2[i]]++;
		root_count[uf.root(A2[i])]++;
		my_count[B2[i]]++;
		root_count[uf.root(B2[i])]++;
	}
	int f = 1;
	for(i = 0; i < N; i++){
		if(my_count[i] != root_count[uf.root(i)]){
			f = 0;
		}
	}
	if(f == 1){
		printf("Yes\n");
		return 0;
	}
	union_find uf2(N);
	if(rand() % 2 == 0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
*/
}

Measured memory_bytes: 4332
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(0, x+100):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break
    else:
        continue
    break


print(ans)


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

int main()
{
    int a[100];
    int n;
    int ans=1000000000;
    int temp;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=1;i<=100;i++)
    {
        temp=0;
        for(int j=0;j<n;j++)
            temp=temp+(a[j]-i)*(a[j]-i);
        if(ans>temp)
            ans=temp;
    }
    printf("%d",ans);
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  if(S=="a"||S=="e"||S=="i"||S=="o"||S=="u"){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }  
}


Measured memory_bytes: 256
n,k = map(int,input().split())
d = list(map(str,input().split()))
d = set([str(x) for x in range(0,10)])-set(d)

while 1:
    can = set(list(str(n)))
    if all(x in d for x in can):
        print(n)
        break


    n+=1


Measured memory_bytes: 42348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }

ll gcd(ll m, ll n){
  if(m<n) swap(m,n);
  if(n==0) return m;
  return gcd(n, m%n);
}

int main() {
  cout<<fixed<<setprecision(10);


  ll n;cin>>n;
  vint a(n);
  rep(i,n){
    cin>>a[i];
  }

  ll ans = a[0];
  rep(i,n){
    ans = gcd(ans,a[i]);
  }


  cout << ans << endl;



}

















//


Measured memory_bytes: 1024
function Main(input) {
  const lines = input.split('\n');
  const N = lines[0];
  const A = lines[1].split(' ').map(i => parseInt(i));
  let prevHeight = 0;
  let steps = 0
  A.forEach((a, i) => {
    if (i === 0) {
      prevHeight = a;
    } else {
      if (prevHeight < a) {
        prevHeight = a;
      } else {
        steps += (prevHeight - a);
        prevHeight = prevHeight
      }
    }
  });
  console.log(steps);
}

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


Measured memory_bytes: 49964
#include<cstdio>
//dp[i][j]=i番目まで書き込んだあみだくじでjに到達する場合の数
//validway[i]=1行i列のあみだくじの作り方の総数
long long dp[101][9],validway[9]={1,1,2,3,5,8,13,21,34};
int main(){
    int h,w,k;
    scanf("%d%d%d",&h,&w,&k);
    dp[0][1]=1;
    for(int i=2;i<=w;i++)dp[0][i]=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            //jとj-1,j+1のあいだに線を引かないとき
            dp[i][j]=validway[j-1]*validway[w-j]*dp[i-1][j];
            //jとj-1のあいだに線を引くとき
            if(j>1)dp[i][j]+=validway[j-2]*validway[w-j]*dp[i-1][j-1];
            //jとj+1のあいだに線を引くとき
            if(j<w)dp[i][j]+=validway[j-1]*validway[w-j-1]*dp[i-1][j+1];
            dp[i][j]%=1000000007;
        }
    }
    printf("%lld",dp[h][k]);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
         Scanner sc = new Scanner(System.in);          
         int x = sc.nextInt();
         int y = sc.nextInt();
         int z = sc.nextInt();
         if(x<y && y<z){
             System.out.println("Yes");
         
         }else{
             System.out.println("No");
         }
}
}


Measured memory_bytes: 26380
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    p_lis=LIST()
    ct=0
    for i in range(1,n-1):
        if p_lis[i]>p_lis[i-1] and p_lis[i]<p_lis[i+1]:
            ct+=1
        elif p_lis[i]<p_lis[i-1] and p_lis[i]>p_lis[i+1]:
            ct+=1

    print(ct)



if  __name__=='__main__':
    main()


Measured memory_bytes: 5712
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A,B;
    cin>>A>>B;
    int x=__gcd(A,B);
    int cnt=1;
    for(int i=2;i*i<=x;i++){
        if(x%i==0){
            cnt++;
            while(x%i==0){
                x/=i;
            }
        }
    }
    if(x!=1)cnt++;
    cout<<cnt;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))

visit = [0] * n
visit[0] = 1
keiro = [1]

s = 1
now = 1

while True:
    x = a[now - 1]
    if visit[x - 1] == 1:
        break
    now = x
    visit[x - 1] = 1
    keiro.append(x)

l1 = len(keiro)
l2 = keiro.index(x)

if k < l1:
    print(keiro[k])
else:
    p = (k - l2) % (l1 - l2)
    print(keiro[l2 + p])

Measured memory_bytes: 95084
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        long M = 2019;
        long L = nlong();
        long R = nlong();
        
        long ans = Long.MAX_VALUE;
        for (long i = L; i < R && i < L+2019; i++) {
            for (long j = i+1; j <= R && j <= L+2019; j++) {
                long mod = ((i%M) * (j%M)) % M;
                ans = Math.min(ans, mod);
            }
        }
        so.println(ans);
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h+2);
	vector<int> tate(w+2);
	vector<int> yoko(h+2);

	for (int i = 0; i < h; i++) {
		cin >> a.at(i);
	}
	for (int i = 0; i < h; i++) {
		char p = '.';
		for (int j = 0; j <= w; j++) {
			if (j == w) {
				yoko.at(i) = 1;
				break;
			}
			if (p != a.at(i).at(j)) {
				break;
			}
		}
	}
	for (int i = 0; i < w; i++) {
		char p = '.';
		for (int j = 0; j <= h;j++) {
			if (j == h) {
				tate.at(i) = 1;
				break;
			}
			if (p != a.at(j).at(i)) {
				break;
			}
		}
	}
	vector<string> b;
	for (int i = 0; i < h; i++) {
		if (yoko.at(i) == 0) {
			for (int j = 0; j < w; j++) {
				if (tate.at(j) == 0) {
					cout << a.at(i).at(j);
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
N=int(input())
prime=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
primeCount=[0 for i in range(25)]

def searchSingle():
  res=0
  for i in range(len(primeCount)):
    if primeCount[i] >= 74:
      res+=1
  return res

def searchDouble():
  res=0
  for i in range(len(primeCount)):
    for j in range(len(primeCount)):
      cnt_i=primeCount[i]
      cnt_j=primeCount[j]
      if cnt_i >= 14 and cnt_j >= 4 and i != j:
        res+=1
      if cnt_i >=24 and cnt_j >=2 and i!=j:
        res+=1
  return res

def searchTriple():
  res=0
  for i in range(len(primeCount)):
    for j in range(len(primeCount)):
      for k in range(j+1,len(primeCount)):
        if primeCount[i] >=2 and primeCount[j] >=4 and primeCount[k] >=4 and i!=j and j!=k and i!=k:
          res+=1
  return res

for i in range(2,N+1):
  cnt=i
  for j in range(len(prime)):
    if cnt % prime[j] == 0:
      while cnt % prime[j] == 0:
        cnt//=prime[j]
        primeCount[j]+=1
        
print(searchSingle() + searchDouble() + searchTriple())

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

int find(vector<int> &p, int x){
  if(p[x] == x)  return x;
  return p[x] = find(p, p[x]);
}
void unite(vector<int> &p, int x, int y){
  x = find(p, x), y = find(p, y);
  p[x] = y;
}
bool same(vector<int> &p, int x, int y){
  x = find(p, x);
  y = find(p, y);
  return (x == y);
}

int main(){
  int n, m;  cin >> n >> m;
  vector<int> p(n+1);
  vector<pair<int, int>> e(m);
  for(int i=0; i<m; i++)  cin >> e[i].first >> e[i].second;

  int ans = 0;
  for(int i=0; i<m; i++){
    for(int i=1; i<=n; i++)  p[i] = i;
    for(int j=0; j<m; j++){
      if(j == i)  continue;
      unite(p, e[j].first, e[j].second);
    }
    bool hasi = false;
    
    for(int j=2; j<=n; j++)
      if(!same(p, 1, j))  hasi = true;
    if(hasi)  ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <iomanip>
#include <bits/stdc++.h>

using namespace std;

double DtoR(double r)
{
    double R = r * M_PI / 180;
    return R;
}

int main()
{
   int a, a1, a2, b, C;
   double S, L, h;
   
   cin >> a >> b >> C;
   
   h = sin(DtoR(C)) * b;
   
   a1 = sqrt(b * b - h * h);
   a2 = a - a1;
   L = a + b + (sqrt(a * a + b * b -2 * a * b * cos(DtoR(C))));
   S = a * h / 2;
   
  cout << setprecision(15) << S << " " << L << " " << h << endl;
   
   return 0;
}


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

struct bellford
{
    const ll INF=LONG_LONG_MAX;
    struct edge {int u, v; ll w;};
    int nv, ne;
    vector<ll> d;
    vector<int> p;
    vector<edge> E;

    bellford(int nv, int ne) : nv(nv), ne(ne)
    {
        d.resize(nv, INF);
        p.resize(nv,-1);
    }

    void relax(int u, int v, ll w)
    {
        if(d[u]!=INF && d[v]>d[u]+w)
        {
            d[v]=d[u]+w;
            p[v]=u;
        }
    }

    bool get(int s)
    {
        d[s]=0; 
        for(int i=0; i<nv-1; i++)
            for(auto &e : E)
                relax(e.u, e.v, e.w);

        vector<bool> path(nv, false);
        path[nv-1]=true;
        int v=p[nv-1];
        while(v!=-1 && !path[v])
        {
            path[v]=true;
            v=p[v];
        }
        if(v!=-1 && path[v]) return false;
        return true;
    }
};


int main()
{
    int N, M;
    scanf("%d%d", &N, &M);
    bellford g(N, M);
    for(int i=0; i<M; i++)
    {
        int a, b;
        ll c;
        scanf("%d%d%lld", &a, &b, &c);
        g.E.push_back({a-1, b-1, -c});
    }

    if(g.get(0)) printf("%lld\n", -g.d[N-1]);
    else printf("inf\n");
    return 0;
}

Measured memory_bytes: 3824
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
bool isprime(int n) { //素数判定
    if(n==1)return false;
    if(n==2)return true;
    for(int i = 2;i<=sqrt(n);i++) {
        if(n%i==0) return false;
    }
    return true;
}
/* ----------------------end----------------------- */
#pragma endregion

signed main() {
    int n;cin >> n;
    int count = 0;
    rep1(i, n) {
        for(int j = 1;i*j<=n;j++) {
            if(n-i*j>0) count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3676
using System;
using System.IO;///
using System.Linq;///

public class A{
    public static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h = input[0];int a = input[1];
    
        int ans = h/a;
        if (h%a>0){
            ans += 1;
        }
    Console.Write(ans);
    }
}


Measured memory_bytes: 13268
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FS r = new FS();
		long a = r.nextLong();
		long b = r.nextLong();
		long x = r.nextLong();
		long ans = b/x-a/x;
		if(a%x==0) ans++;
		System.out.println(ans);
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 8148
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int d, c;
    cin >> d >> c;
    cout << (d * c) << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdbool.h>

bool judge(int year)
{
    bool flag = false;
    if (year % 400 == 0) {
        flag = true;                
    } else if (year % 100 == 0) {
        flag = false;
    } else if (year % 4 == 0) {
        flag = true;
    }
    return flag;
}

int main(void)
{ 
    int number = 0;
    while (true) {
        int x, y;
        bool exist = false;
        scanf("%d%d", &x, &y);
        if (x == 0 && y == 0) {
            break;
        }
        if (number != 0) {
            printf("\n");
        }
        for (int i = x;i <= y; ++i) { 
            bool flag = judge(i);
	    if (flag == true) {
                printf("%d\n", i);
                exist = true;
            }
        }
        if (exist == false) {
            printf("NA\n");
        }  
        number++;     
    }
    return 0;        
}

Measured memory_bytes: 1044
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
 
int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll>h(n);
    vector<bool>good(n);
    REP(i,n)good[i]=true;
    REP(i,n)cin >> h[i];
    Graph G(n);
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    REP(i,n){
        REP(j,G[i].size()){
            if(h[i] > h[G[i][j]]){
                good[G[i][j]]=false;
            }
            else if(h[i] < h[G[i][j]]){
                good[i] = false;
            }
            else{
                good[i] = false;
                good[G[i][j]]=false;
            }
        }
    }
    ll answer = 0;
    REP(i,n)if(good[i])answer ++;
    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 9268
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# N =I()
N,M= LI()
if M==0:
    print(0,0)
    exit()
pS = [LS() for _ in range(M)]
# print(pS)

_p,S = zip(*pS)

p = list(map(int,_p))

WA = np.zeros(N+1)
AC = np.full(N+1,False, dtype=bool)

penalty = 0
for i in range(M):
    if AC[p[i]]:
        continue
    if S[i]=='WA':
        WA[p[i]] += + 1
    else:
        AC[p[i]]=True
        penalty += WA[p[i]]        

AC_count = np.count_nonzero(AC)        

# space output
print(AC_count,int(penalty))

#Ap = np.array(A)



# if ans:
#     print('Yes')
# else:
#     print('No')

Measured memory_bytes: 55764
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

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

    int count=0;
    for(int i = 1; i <= N; i++) {
        int digit = log10(i) + 1;
        if((digit % 2) == 1) count++;
    }

    cout << count  << endl;





}

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

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

    if (a <= 8 && b <= 8) puts("Yay!");
    else puts(":(");
}


Measured memory_bytes: 256
s = input()
if s[:7] == "keyence":
  print("YES")
  exit()
elif s[-7:] == "keyence":
  print("YES")
  exit()
elif s[:6] == "keyenc":
  if s[-1] == "e": 
    print("YES")
    exit()
elif s[:5] == "keyen":
  if s[-2:] == "ce":
    print("YES")
    exit()
elif s[:4] == "keye":
  if s[-3:] == "nce":
    print("YES")
    exit()
elif s[:3] == "key":
  if s[-4:] == "ence":
    print("YES")
    exit()
elif s[:2] == "ke":
  if s[-5:] == "yence":
    print("YES")
    exit()
elif s[:1] == "k":
  if s[-6:] == "eyence":
    print("YES")
    exit()
print("NO")

Measured memory_bytes: 3064
import math
N=int(input())
n=N
p=2
dp=1
thrP=math.sqrt(N)
dcmp={}
while n>1:
    if n%p==0:
        dcmp[p]=1+(dcmp[p] if p in dcmp else 0)
        n//=p
    else:
        p+=dp
        dp=2
    if p>thrP:
        if n>1:
            dcmp[n]=1
        break
cnt=0
for k,v in dcmp.items():
    i=1
    while True:
        dcmp[k]-=i
        if dcmp[k]<0:
            break
        i+=1
        cnt+=1

print(cnt)


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int num = 0;
  
  for (int i = 0; i <= 100; i++) {
  	if (a <= i && i <= b && c <= i && i <= d) num++;
  }
  if (num == 0) num++;
  cout << num - 1 << endl;
}


Measured memory_bytes: 3528
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


#A
"""
a,b = LS()
if a == b:
    print("H")
else:
    print("D")
"""

#B
"""
w,a,b = LI()
print(max(max(a,b)-min(a,b)-w,0))
"""

#C
"""

x = I()
a = 0
i = 1
while a < x:
    a += i
    i += 1
print(i-1)
"""

#D
"""
iが必要←→iを使わずに[k-ai,k)内の和を作れる→累積和問題(O(nk))
必要性は単調性を満たす(iが必要→jも必要(aj>ai))→二部探索(O(logn))
後は高速化をがんばる
合計O(nklogn)
"""
n,k = LI()
a = LI()
a.sort()
a = a[:bisect.bisect_left(a,k)]
n = len(a)
a = a[::-1]
l = -1
r = n
while r-l > 1:
    m = (l+r)//2
    k_ = k-a[m]
    dp = [0]*k
    dp[0] = 1
    ma = 0
    for i in range(n):
        if i == m:continue
        ai = a[i]
        for j in range(min(ma+1,k-ai))[::-1]:
            j_ = j+ai
            if dp[j]:
                if k_ <= j_:
                    l = m
                    break
                dp[j_] = 1
                if j_ > ma:
                    ma = j_
        else:
            continue
        break
    else:
        r = m
print(n-r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 43868
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll a;
    long double b;
    cin >> a >> b;
    cout << ll(floor(a*b)) << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    ios();
    int n;
    ll k;
    cin >> n >> k;
    k++;

    vector<ll> v(n);
    for(auto& i : v){
        cin >> i;
    }
    
    int d;
    if(k == 0){
        d = 0;
    }else{
        d = (int)log2(k);
    }

    vector<ll> digit(d+1);
    REP(i, d+1){
        ll cnt = 0;
        for(auto e : v){
            if(e & (1LL << i)){
                cnt++;
            }else{
                cnt--;
            }
        }
        digit[i] = (cnt <= 0 ? 1LL : 0LL);
    }

    ll ans = 0;

    for(int i=0; i<=d; i++){
        ll x = 0;
        REP(j, i){
            x += digit[j] << j;
        }
        x += (k >> (i+1)) << (i+1);
        if(x >= k){
            continue;
        }
        ll f = 0;
        for(auto e : v){
            f += e ^ x;
        }
        ans = max(ans, f);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REP1(i,n) for(ll i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 1000010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

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

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll nCr(ll n, ll r){
    ll ans;
    ll bunsi = 1;
    ll bunbo = 1;

    if(n / 2 < r) r = n - r;
    for(ll i = n; i > n - r; i--){
        bunsi *= i;
        //bunsi %= MOD;
    }
    for(ll i = 1; i <= r; i++){
        bunbo *= i;
       // bunbo %= MOD;
    }
    ans = bunsi / bunbo;

    return ans;
}
 
int main() {
 
    ll N, M;
    cin >> N >> M;
    map<ll, ll> yaku; 

    ll num = M;

    // 前処理
    COMinit();

    //素因数分解
    for(ll i = 2; i < sqrt(num)+1; i++){
        while(num % i == 0){
            num /= i;
            yaku[i]++;
        }    
    }
    if(num > 1){yaku[num]++;}

    ll ans = 1;
    ll tmp;
    for( auto i = yaku.begin(); i != yaku.end() ; ++i ) {
        //cout << i->first << " " << i->second << "\n";
        tmp = COM(N + i->second-1 ,  i->second) % MOD;
        //cout << tmp << endl;
        ans = ans * tmp;
        ans %= MOD;
    }

    cout << ans << endl;

 
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




Measured memory_bytes: 23680
n = int(input())
lis = [input() for _ in range(n)]
cnt = sum([l.count('AB') for l in lis])
ab_cnt = sum([l[-1] == 'A' and l[0] == 'B' for l in lis])
a_cnt = sum([l[-1] == 'A' for l in lis]) - ab_cnt
b_cnt = sum([l[0] == 'B' for l in lis]) - ab_cnt
if ab_cnt:
  cnt += ab_cnt - 1
  if a_cnt or b_cnt:
    a_cnt += 1
    b_cnt += 1
print(cnt + min(a_cnt, b_cnt))

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, m;
    std::cin >> n >> m;
    std::vector<std::string> s(n);
    for (int i = 0; i < n; ++i)
        std::cin >> s[i];
    std::vector<std::vector<int>> dp(n, std::vector<int>(m));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i == 0 && j == 0) {
                dp[0][0] = s[0][0] == '#';
            } else if (i == 0) {
                dp[0][j] = dp[0][j - 1] + (s[0][j] == '#' && s[0][j - 1] == '.');
            } else if (j == 0) {
                dp[i][0] = dp[i - 1][0] + (s[i][0] == '#' && s[i - 1][0] == '.');
            } else {
                dp[i][j] = std::min(dp[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] == '.'), dp[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] == '.'));
            }
        }
    }
    std::cout << dp[n - 1][m - 1] << "\n";
    return 0;
}

Measured memory_bytes: 384
package main

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

const BUFSIZE = 10000000

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

var ANext [200001]int
var NFlag [200001]bool
var NCount int

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)
	A := NextLineInt()

	for k := 0; k < K; k++ {
		for i := 0; i < N; i++ {
			ANext[i] = 0
		}

		for x, a := range A {
			ANext[Max(0, x-a)] += 1
			ANext[Min(N, x+a+1)] -= 1
		}

		for i := 0; i < N; i++ {
			ANext[i+1] += ANext[i]
			A[i] = ANext[i]
			if A[i] == N && !NFlag[i] {
				NFlag[i] = true
				NCount += 1
			}
		}

		if NCount == N {
			break
		}
	}

	for _, a := range A {
		fmt.Printf("%d ", a)
	}
}

func NextLineInt() []int {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int, l)

	for i := range str {
		// ret[i], ok = strconv.Atoi(str[i])
		v, ok := strconv.Atoi(str[i])

		if ok == nil {
			ret[i] = int(v)
		}
	}

	return ret
}

func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func Min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance(a, b int) int {
	return Abs(a - b)
}


Measured memory_bytes: 15172
import sys
N = int(input())
pre_t, pre_x, pre_y = 0, 0, 0
for _ in range(N):
    tmp_t, tmp_x, tmp_y = map(int,input().split())
    t, x, y = tmp_t - pre_t, tmp_x - pre_x, tmp_y - pre_y
    pre_t, pre_x, pre_y = tmp_t, tmp_x, tmp_y
    if x >= 0:
        if y >= 0 and not (x + y <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
        elif y < 0 and not (x - y <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
    else:
        if y >= 0 and not (y - x <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
        elif y < 0 and not (- x - y <= t and (x + y - t) % 2 == 0):
            print('No')
            sys.exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N, A;
    cin >> N >> A;
    cout << (N * N) - A << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int k;
	int a,b;
	cin>>k>>a>>b;
	
	bool ans=false;
	for(int i=a;i<=b;++i){
		if(i%k==0) ans=true;
	}
	
	cout<<(ans?"OK":"NG")<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int n, m;
std::vector<long> x, y, z;
std::vector<std::pair<long, int>> vec;

long func(bool p, bool q, bool r) {
	std::vector<std::pair<long, int>> vec;
	for(int i = 0; i < n; i++) {
		vec.push_back({x[i] * (p ? 1 : -1)
						+ y[i] * (q ? 1 : -1)
						+ z[i] * (r ? 1 : -1), i});
	}
	sort(begin(vec), end(vec));
	
	long X = 0, Y = 0, Z = 0;
	for(int i = 0; i < m; i++) {
		X += x[vec[i].second];
		Y += y[vec[i].second];
		Z += z[vec[i].second];
	}
	
	return llabs(X) + llabs(Y) + llabs(Z);
}

int main(){
	cin >> n >> m; x.resize(n); y.resize(n); z.resize(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> z[i];
		
		vec.push_back({x[i] + y[i] + z[i], i});
	}
	
	long ans = 0;
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 2; j++) {
			for(int k = 0; k < 2; k++) {
				ans = std::max(ans, func(i, j, k));
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
double n,m,d,ans=0;
int main()
{
	scanf("%lf %lf %lf",&n,&m,&d);
	double ans=(m-1)/(n*n),o=0.0;
	if(d==0)
	{
		o=n;
	}
	else
	{
		o=2*(n-d);
		if(o<=0.0)
			o=0.0;
	}
	printf("%.10f",o*ans);
}

Measured memory_bytes: 128
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(int n=sc.nextInt(); n>0; n--){
			String s=sc.next();
			// debug(s);
			Matcher m=Pattern.compile("^>'(=+)#(=+)~$").matcher(s);
			if(m.find()){
				// debug(m.group(1), m.group(2));
				if(m.group(1).length()==m.group(2).length()){
					// debug("A");
					println("A");
					continue;
				}
			}
			m=Pattern.compile("^>\\^(Q=)+~~$").matcher(s);
			if(m.find()){
				// debug("B");
				println("B");
				continue;
			}
			// debug("NA");
			println("NA");
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct train{ ll l,r,v;};

int main(){
    ll n;cin>>n;
    train T[n+2];
    ll t[n],v[n];
    ll sum=0;
    rep(i,0,n-1){
        cin>>t[i];
        T[i].l=sum;
        sum+=t[i];
        T[i].r=sum;
    }
    rep(i,0,n-1){
        cin>>v[i];
        T[i].v=v[i];
    }
    T[n].r=0;T[n].l=0;T[n].v=0;
    T[n+1].r=sum;T[n+1].l=sum;T[n+1].v=0;
    double mini[2*(sum+1)];fill(mini,mini+2*(sum+1),10000000);
    ll l,r;
    rep(i,0,n+1){
        l=T[i].l;r=T[i].r;
        rep(j,0,sum*2){
            if(j<=l*2){
                mini[j]=min(mini[j],(double)T[i].v+(double)(2*l-j)/2);
            }else if(j>=2*r){
                mini[j]=min(mini[j],(double)T[i].v+(double)(j-r*2)/2);
            }else{
                mini[j]=min(mini[j],(double)T[i].v);
            }
        }
    }
    double total=0;
    rep(i,0,sum-1){
        if(fabs(mini[i*2]-mini[i*2+2])<0.000001){
            if(fabs(mini[i*2+1]-mini[i*2])<0.0000001){
                total+=mini[i*2];
                //cout<<mini[i*2]<<endl;
            }else{
                total+=(mini[i*2]+0.25);
                //cout<<(mini[i*2]+0.25)<<endl;
            }
        }else{
            total+=((mini[i*2]+mini[i*2+2])/2);
            //cout<<((mini[i*2]+mini[i*2+2])/2)<<endl;
        }
        
    }
    cout<<setprecision(20)<<total<<endl;
    
    return 0;
}


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

int main() {
int x,y,z;
cin >> x >> y>> z;
swap(x,y);
swap(x,z);
cout << x <<" "<< y <<" "<< z <<endl;


}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
ans = []
while len(b):
    tmp = len(b)
    # len(b) - 1 - pointa
    for i in reversed(range(len(b))):
        if b[i] == i+1:
            ans.append(b[i])
            b.pop(i)
            break
    if len(b) == tmp:
        print(-1)
        exit()
ans.reverse()
for a in ans:
    print(a)


Measured memory_bytes: 3060