akhauriyash/Code-Regression huggingface dataset:
import bisect

def choosebait(Eloc,Clist,catinE,idinE,i):
#    dist=[abs(Clist[i][0]-x) for x in Eloc]
#    closestbaitid=dist.index(min(dist))
#    catinE[closestbaitid]+=Clist[i][2]
#    idinE[closestbaitid].append(i)


     baitid=bisect.bisect_left(Eloc,Clist[i][0])
     if baitid==0:
         leftclose=-1e10
         rightclose=Eloc[baitid]
     elif baitid==len(Eloc):
         leftclose=Eloc[baitid-1]
         rightclose=1e10
     else:
         leftclose=Eloc[baitid-1]
         rightclose=Eloc[baitid]
     if abs(Clist[i][0]-leftclose)<=abs(Clist[i][0]-rightclose):
         catinE[baitid-1]+=Clist[i][2]
         idinE[baitid-1].append(i)
     else:
         catinE[baitid]+=Clist[i][2]
         idinE[baitid].append(i)
while(1):
    [N,M]=[int(x) for x in raw_input().split()]
    if M==0:
        break
    else:
        Clist=[]
        Eloc=[]
        catinE=[0 for x in range(M)]
        idinE=[[] for x in range(M)]
        for i in range(N):
            [x,y,c]=[int(z) for z in raw_input().split()]
            Clist.append([x,y,c])
        for j in range(M):
            x=int(raw_input())
            Eloc.append(x)
        Eloc.sort()
        ans=sum([Clist[i][2] for i in range(N)])
        for i in range(N):
            choosebait(Eloc,Clist,catinE,idinE,i)
        for j in range(M-1):
            ans=min(ans,max(catinE))
            btd=catinE.index(max(catinE))
            cattomove=idinE[btd]
            Eloc=Eloc[:btd]+Eloc[btd+1:]
            catinE=catinE[:btd]+catinE[btd+1:]
            idinE=idinE[:btd]+idinE[btd+1:]
            for i in cattomove:
                choosebait(Eloc,Clist,catinE,idinE,i)
        print ans

Measured memory_bytes: 4632
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    int d = 2*gi()+1;
    printf("%d\n", (n+d-1)/d);

    return 0;
}


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

int main(){
  while(1){
    int s,n,t,p,m;
    string week, time;
    string wee[8] = {"All", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
    string tim[3] = {"All", "Day", "Night"};
    cin >> s >> n >> t >> week >> time >> p >> m;
    if(s == 0)break;
    int weeknum, timenum;
    for(int i=0;i<8;i++)if(week == wee[i])weeknum = i;
    for(int i=0;i<3;i++)if(time == tim[i])timenum = i;
    int starttime;
    int henikai = 0;
    if(weeknum == 0){
      if(timenum == 0)henikai = m;
      else{
        for(int k=0;k<24*60;k++){
          int tmp = 0;
        starttime = k;
        for(int i=0;i<m;i++){
          if(starttime%(24*60) < 12 * 60 && (starttime + s)%(24*60) < 12 * 60)tmp++;
          starttime += t;
        }
        if(tmp > henikai)henikai = tmp;
      }
    }
    }
    else{
      if(timenum == 0){
        for(int k=0;k<7*24*60;k++){
          int tmp = 0;
        starttime = k;
        for(int i=0;i<m;i++){
          if(starttime % (7 * 24 * 60) < 24 * 60 && (starttime + s) % (7 * 24 * 60) < 24 * 60)tmp++;
          starttime += t;
        }
        if(tmp > henikai)henikai = tmp;
      }
      }
      else if(timenum == 1){
        for(int k=0;k<7*24*60;k++){
          int tmp = 0;
        starttime = k;
        for(int i=0;i<m;i++){
          if(starttime % (7 * 24 * 60) < 12 * 60 && (starttime + s) % (7 * 24 * 60) < 12 * 60)tmp++;
          starttime += t;
        }
        if(tmp > henikai)henikai = tmp;
      }
      }
      else{
        for(int k=0;k<7*24*60;k++){
          int tmp = 0;
        starttime = k;
        for(int i=0;i<m;i++){
          if(starttime % (7 * 24 * 60) < 6 * 60 && (starttime + s) % (7 * 24 * 60) < 6 * 60)tmp++;
          else if(starttime % (7 * 24 * 60) >= 18 * 60 && (starttime + s) % (7 * 24 * 60) < 24 * 60 && (starttime + s) % (7 * 24 * 60) > starttime % (7 * 24 * 60))tmp++;
          starttime += t;
        }
        if(tmp > henikai)henikai = tmp;
      }
      }
    }
    long double po = 1.0 - (long double)(1.0 / p);
    long double po2 = 1.0;
    for(int i=0;i<n*henikai; i++)po2 *= po;
    //cout << 1.0 - powl(po, (long double)(n * henikai)) << endl;
    printf("%.10Lf\n", 1.0 - pow(po, (n * henikai)));
  }
  return 0;
}



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

#define f first
#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define inp(x) cin>>x
#define print(x) cout<<x
#define pii pair<int,int>
#define pll pair<ll,ll>
#define gcd(a,b) __gcd(a,b)
#define reset(d,val) memset(d,val,sizeof(d))
#define sort(v) sort(v.begin(),v.end())
#define sort_arr(arr,i,f) sort(arr+i,arr+f)
#define pq priority_queue<int,vector<int>,greater<int> >
#define pq1 priority_queue<pll,vector<pll>,greater<pll> >

const int mod = 1e9+7;



int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long double b;
	ll a;
	cin>>a>>b;
	ll c= (ll) round(b*100);
	cout<<(a*c)/100;
	return 0;
}


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

int main() {
  vector<char> vec(6);
  for(int i=0;i<6;i++){
    cin >> vec.at(i);
  }
  if(vec.at(0) == vec.at(5) && 
     vec.at(1) == vec.at(4) &&
     vec.at(2) == vec.at(3) ) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
i = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[i-1])

Measured memory_bytes: 2940
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];;

ll gcd(long long a,long long b){

  if(b == 0)
    return a;
  else return gcd(b,a%b);
}


bool sortByVal(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second < b.second);
}

int main(){

 int a;
 cin>>a;

 cout<<a+a*a+a*a*a<<endl;


return 0;
}


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

int H,W,Ch,Cw,Dh,Dw;
queue<pair<int,int>> que;

int dfs(vector<vector<char>> &S, int x, int y,vector<vector<int>> &num, int mg){
	// 通ったことある場合はスルー
	if(num[x][y]!=-1) return 0;
	// 通ったチェック
	num[x][y]=mg;
	que.push(pair(x,y));
	// ４方向移動
	if(x-1>=0 && S[x-1][y]=='.') dfs(S, x-1, y, num, mg);
	if(x+1<H && S[x+1][y]=='.') dfs(S, x+1, y, num, mg);
	if(y-1>=0 && S[x][y-1]=='.') dfs(S, x, y-1, num, mg);
	if(y+1<W && S[x][y+1]=='.') dfs(S, x, y+1, num, mg);
	return 0;

}

bool wdfs(vector<vector<char>> &S,vector<vector<int>> &num, int mg){
	bool flg = true;
	queue<pair<int,int>> wque=que;
	while(que.size()) que.pop();
	while(wque.size()){
		auto z = wque.front(); wque.pop();
		int i=z.first, j=z.second;
		if(num[i][j]!=mg) continue;
		// if(mg==1) cerr << "i;j " << i << " " << j << endl;
		// ワープ移動
		vector<int> wp={-2,-1,0,1,2};
		for(int wx:wp){
			for(int wy:wp){
				if(i+wx<0 || i+wx>=H || j+wy<0 || j+wy>=W) continue; //範囲外
				if(S[i+wx][j+wy]=='#') continue; //壁
				if(num[i+wx][j+wy]!=-1) continue;

				// num[i+wx][j+wy]=mg+1;
				dfs(S, i+wx, j+wy, num, mg+1);
				flg = false;
			}

		}
	}

	return flg;
}




int main(){
	ios::sync_with_stdio(false);
	cin>>H>>W;
	cin>>Ch>>Cw;
	cin>>Dh>>Dw;
	vector<vector<char>> S(H,vector<char>(W));
	vector<vector<int>> num(H,vector<int>(W,-1));
	rep(i,H)rep(j,W) cin>> S[i][j];

	
	int ans = dfs(S, Ch-1, Cw-1, num, 0);
	bool flg = wdfs(S,num, 0);
	// while(que.size()) que.pop();
	int mg=0;
	while(!wdfs(S,num,mg+1)){
		mg++;
	}

	cout << num[Dh-1][Dw-1] << endl;
	// rep(i,H){
	// 	rep(j,W){
	// 		cerr<<num[i][j];
	// 	}cerr << endl;
	// }
	
}


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve()
{
	ll d,t,s;
	cin>>d>>t>>s;
	double ss=(double)d/(double)t;
	if((double)s>=ss) cout<<"Yes";
	else cout<<"No";
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

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

string s;

int main() {
    cin >> s;
    int ans = s.length(), len = s.length();
    for(int i = 0; i < s.length() - 1; i++)
        if(s[i] != s[i + 1]) ans = min(ans, max(i + 1, len - i - 1));
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N;
    cin >> N;
    valarray<int> A(N+1), ans(N+1), boll(N+1);
    rep(i, N) cin >> A[i+1];

    for(int i = N; i > 0; i--){
        if(boll[i] % 2 == A[i]) continue;
        ans[i] = 1;
        for(int k = 1; k*k <= i; k++){
            if((i % k) == 0){
                boll[k]++;
                if(k*k != i) boll[i/k]++;
            }
        }
    }
    
    int sum = ans.sum();
    cout << sum << endl;
    if(sum == 0) return 0;
    for(int i = 1; i <= N; i++){
        if(ans[i]) cout << i << " ";
    }
    cout << endl;
}


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

using namespace std;

int main() {

	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	cout << min(abs(a2 - a1) + abs(a3 - a2), min(abs(a3 - a1) + abs(a3 - a2), abs(a3 - a1) + abs(a1 - a2))) << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if(B/A>=C){
      System.out.println(C);
    }else{
      System.out.println(B/A);
    }
  }
}


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

int main() {
  ll n;
  cin >> n;
  ll d[100001];
  d[0]=0;
  for(int i=1; i<100001; i++) d[i]=d[i-1]+i;
  for(int i=1; i<100001; i++) {
    if(d[i]>=n) {
      string s="";
      for(int j=0; j<i; j++) s+=")";
      int k=s.size();
      for(int j=0; j<i; j++) s+="(";
      int x=d[i]-n;
      swap(s[k-x],s[k]);
      cout << s << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4124
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>


#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define scan(x) scanf("%lld",&x);
#define inf 5555555555555555555
#define mod 1000000007
#define pi 3.14159265358979323846
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k % 2 == 1) {
	cout << b - a << endl;
  }
  else {
	cout << a - b << endl;
  }


  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int L,R,d; cin >> L >> R >> d;
  int ans = 0;
  for(int i=L;i<=R;i++){
    if(i%d==0) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

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

    vector<ll> X(N);
    ll sum = 0;
    REP(i,N){
        ll w, b;
        cin >> w >> b;
        X[i] = (100-P)*w + P*b;
        sum += b;
    }

    if(P == 100){
        cout << N << endl;
        return 0;
    }

    sort(X.rbegin(), X.rend());

    int ans = 0;
    double val = 0;
    while(val < P*sum){
        val += X[ans];
        ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a,b,c,i,count=0;
	
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0) count++;
	}
	
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 596
n = int(input())
a = list(map(int, input().split()))
cnt = 0
while True:
	is_odd = False
	for i in range(len(a)):
		if a[i] % 2 == 1:
			is_odd = True
			break
		else:
			a[i] /= 2
	if is_odd:
		break
	cnt += 1

print(cnt)

Measured memory_bytes: 9184
n,x,m=map(int,input().split())
s=set()
p=[]
while x not in s:
  s.add(x)
  p+=[x]
  x=(x*x)%m
  if len(p)>=n:print(sum(p));quit()
r=b=t=v=0
a=[0]
for i in p:
  if i==x:b=1
  r+=1-b
  t+=b*i
  v+=i
  a+=[a[-1]+i]*b
l=len(p)
print(v+t*((n-l)//(l-r))+a[(n-l)%(l-r)])

Measured memory_bytes: 15260
from queue import Queue

N = int(input())
X = [list(map(int, input().split())) for _ in range(N-1)]
X = list(map(lambda x: (x[0]-1, x[1]-1, x[2]), X))
# [u番目の頂点, v番目の頂点, 距離w]
# インデックスは0,...,N-1

# 頂点iの隣接情報を保持
node = [[] for i in range(N)]
for x in X:
    u, v, w = x
    node[u].append((v, w))
    node[v].append((u, w))

# 頂点iの色, 未彩色は-1
color = [-1] * N

# 幅優先探索で全頂点の色を決定
# 頂点0の色を0とする
q = Queue()
color[0] = 0
q.put((0, color[0]))
while not q.empty():
    q0 = q.get()

    n = q0[0]
    c = q0[1]
    neighbors = node[n]
    for p in neighbors:
        if color[p[0]] == -1:
            color[p[0]] = (c + p[1]) % 2
            q.put((p[0], color[p[0]]))

for c in color:
    print(c)

Measured memory_bytes: 57996
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> d1(n), d2(n);
  REP(i, n) cin >> d1[i] >> d2[i];
  int cnt = 0;
  bool f = false;
  REP(i, n) {
    if (d1[i] == d2[i])
      cnt++;
    else
      cnt = 0;
    if (cnt >= 3) f = true;
  }
  if (f)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#include <functional>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MOD1 1000000007;
#define MOD2 1000007
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */

ull pow(ull x,ull n) {
  ull res = 1;
  while(n > 0) {
    if(n&1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
int dic_op(char str[14])
{
  int j;
  long long f = 1;
  long long g = 0;
  for(j = 0;;j++) {
    if(str[j] == 'A')
      g += f * 1;
    else if(str[j] == 'C')
      g += f * 2;
    else if(str[j] == 'G')
      g += f * 3;
    else if(str[j] == 'T')
      g += f * 4;
    else break;
    f *= 5;
  }
  return g; 
}

int main()
{
  static long i,j,k,l;
  long n;
  long cnt = 0;
  int f,g;
  long left,right,mid;
  long ans = 0;
  static int dic[200000000];
  char opstr[14];
  char str[13];
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%s %s",opstr,str);
    if(opstr[0] == 'i') {
      dic[dic_op(str)] = 1;
    }
    else if(opstr[0] == 'f') {
      if(dic[dic_op(str)] == 1)
        puts("yes");
      else
        puts("no");
      j++;
    }
  }
  return 0;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;

  unordered_map<int, int> mp;
  rep(i, n) {
    int a; cin >> a;
    mp[a]++;
  }

  if (mp.size() > 3) {
    cout << "No" << endl;
    return 0;
  }

  if (mp.size()==3) {
    if (n%3!=0) {
      cout << "No" << endl;
      return 0;
    }
    vector<int> vec;
    for(auto e: mp) {
      vec.push_back(e.first);
      if (e.second != n/3) {
        cout << "No" << endl;
        return 0;
      }
    }
    if ((vec[0]^vec[1]) == vec[2]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }

  if (mp.size() == 2) {
    if (n%3!=0) {
      cout << "No" << endl;
      return 0;
    }
    bool flag1 = false;
    bool flag2 = false;
    for(auto e: mp) {
      if (e.first==0 && e.second==n/3) {
        flag1 = true;
      }
      if (e.first!=0 && e.second==n*2/3) {
        flag2 = true;
      }
    }
    if (flag1&&flag2) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }


  if (mp.size() == 1) {
    for(auto e: mp) {
      if (e.first == 0) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
      return 0;
    }
  }

}

Measured memory_bytes: 3724
n = int(input())
t, a = map(int,input().split())
h = list(map(int,input().split()))

answer = [0]
min = abs(t - 0.006 * max(h) - a) 
for i in range(len(h)):
  if abs(t - 0.006*h[i] -a) <= min:
    min = abs(t - 0.006 * h[i] -a)
    answer.remove(answer[0])
    answer.append(i)
print(answer[0]+1) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
void YesNo(bool);
void YESNO(bool);


int main(){
    int a;
    cin >> a ;
    YESNO(a == 7|| a == 5 || a == 3);
    
}


void YesNo(bool x){
    if (x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

void YESNO(bool x){
    if (x) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int x, y, ans;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&x ,&y);
	if(x == 1)
		ans += 300000;
	if(x == 2)
		ans += 200000;
	if(x == 3)
		ans += 100000;
	if(y == 1)
		ans += 300000;
	if(y == 2)
		ans += 200000;
	if(y == 3)
		ans += 100000;
	if(x == 1 and y == 1)
		ans += 400000;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=1e18;

int main(){
    int N;
    cin >> N;
    for(int i=1;i<=N;i++){
        int sum=(i*(i+1))/2;
        if(N<=sum){
            for(int j=1;j<=i;j++){
                if(j==sum-N) continue;
                cout << j << endl;
            }
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


VB is_prime_numbers(int N) {
    ll root_n = (ll)(sqrt(N) + 0.5);
    VB is_prime(N + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 4; i <= N; i += 2) is_prime[i] = false;
    for(int f = 3; f <= root_n; f += 2) {
        for(int i = 2 * f; i <= N; i += f) is_prime[i] = false;
    }
    return is_prime;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int Q; cin >> Q;

    static const int MAX_N = 1e+5;
    VB is_like_2017(MAX_N + 1, false);
    auto is_prime = is_prime_numbers(MAX_N);
    for (int i = 1; i <= MAX_N; i += 2) {
        if (is_prime[i] && is_prime[(i + 1) / 2]) {
            is_like_2017[i] = true;
        }
    }

    VI S(MAX_N + 1, 0);
    FOR(i, 1, MAX_N + 1) S[i] = S[i - 1] + is_like_2017[i];

    REP(_, Q) {
        int l, r; cin >> l >> r;
        cout << S[r] - S[l - 1] << '\n';
    }

    return 0;
}


Measured memory_bytes: 3680
#(6,6)周期
#36種の希望

import numpy as np
N,K = map(int,input().split())
KK = 2*K
hope = np.zeros((KK,KK),dtype=np.int32)

XYC = [input().split() for _ in range(N)]

for x,y,c in XYC:
  x = int(x)
  y = int(y)
  if c == 'B':
    x -= K
  x %= KK
  y %= KK
  hope[x,y] += 1
# (x,y)を希望された場合、[x,x+K), [y,y+K)に終点があるべき
# 区間の重なってる枚数を集計。1,0,0,-1, cumsum
A = np.zeros((KK+K,KK+K),dtype=np.int32)
A[:-K,:-K] = hope[:]
A[K:,:-K] += -hope[:]
A[:-K,K:] += -hope[:]
A[K:,K:] += hope[:]
A = A.cumsum(axis = 0).cumsum(axis = 1)

# 実質同じ場所をまとめる
B = A[:,:KK]
B[:,:K] += A[:,KK:] #(3K,2K)
A = B[:KK,:]
A[:K,:] += B[KK:,:] #(2K,2K)
B = A[:K,:] #(K,2K)
B[:,:K] += A[K:,K:]
B[:,K:] += A[K:,:K]

answer = B.max()
print(answer)


Measured memory_bytes: 249816
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <unordered_set>
//#include <unordered_map>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=INT_MAX-10000;
int dp[151][1001][76];
void mainmain(){
	int n,m;
	while(cin>>n>>m,n||m){
		vvint vv;
		initvv(vv,n,1001,-1);
		rep(i,151) rep(j,1001) rep(k,76) dp[i][j][k]=INF;
		rep(i,n){
			int t;
			cin>>t;
			rep(j,t){
				int a,b;
				cin>>a>>b;
				vv[i][a-1]=b;
			}
		}
		// puts("hoge");
		// rep(i,n){
			// rep(j,n){
				// printf("%2d",vv[i][j]);
			// }
			// cout<<endl;
		// }
		rep(i,2){
			rep(j,1001){
				if(vv[i][j]!=-1) dp[i][j][i]=0;
			}
		}
		// return;
		rep(i,n-1){
			rep(j,1001){
				if(vv[i][j]==-1) continue;
				rep(o,76){
					if(dp[i][j][o]==INF) continue;
					rep(k,2){
						if(o+k>75) continue;
						rep(l,1001){
							if(vv[i+k+1][l]==-1) continue;
							dp[i+k+1][l][o+k]=min(dp[i+k+1][l][o+k],dp[i][j][o]+abs(j-l)*(vv[i][j]+vv[i+k+1][l]));
						}
						if(i==n-2) break;
					}
				}
			}
		}
		int ans=INF;
		// rep(i,n){
			// rep(j,n){
				// if(dp[i][j][0]!=INF) printf("%2d",dp[i][j][0]);
				// else cout<<"  ";
			// }
			// cout<<endl;
		// }
		// cout<<endl;
		// rep(i,n){
			// rep(j,n){
				// if(dp[i][j][1]!=INF) printf("%2d",dp[i][j][1]);
				// else cout<<"  ";
			// }
			// cout<<endl;
		// }
		// cout<<endl;
		reep(i,n-2,n){
			rep(j,1001){
				rep(k,m){
					ans=min(ans,dp[i][j][k]);
				}
			}
		}
		// cout<<ans<<endl;
		rep(i,1001){
			rep(k,m+1){
				ans=min(ans,dp[n-1][i][k]);
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 46468
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
const ll LINF = 1e18;
ll n;

int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> num(k,0);
  for(int i=1;i<=n;i++) num[i%k]++;//num[x] = kで割ってxあまる数が1以上N以下に何個あるか 
  ll res = 0;
  for(int a=0;a<k;a++){
    int b = (k-a) % k;
    int c = (k-a) % k;
    if((b+c) % k != 0) continue;
    res += num[a] * num[b] *num[c];
  }
  cout << res <<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long ret5(long long num){
  return num*num*num*num*num;
}
int main()
{
  long long X;
  cin>>X;
  for(long long i=-200;i<200;i++){
    for(long long j=-200;j<200;j++){
      if(ret5(i)==X+ret5(j)){
        cout<<i<<" "<<j;
        return 0;
      }
    }
  }
  cout<<0;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int S=1;
  sort(vec.begin(),vec.end());
  for (int j =0; j<N-1;j++){
    if (vec.at(j+1) != vec.at(j))
      S++;
  }
  cout << S << endl;
}
      
    
    
    
  

Measured memory_bytes: 256
n = int(raw_input())
g = [[10000 for i in range(n)]for j in range(n)]
c = [0 for i in range(n)]
d = [10000 for i in range(n)]
p = [-1 for i in range(n)]
d[0] = 0
for i in range(n):
        g[i] = map(int,raw_input().split())

while 1:
    min = 10000
    u = -1
    for i in range(n):
        if c[i] != 2 and d[i] < min:
            min = d[i]
            u = i
    if min == 10000:
        break
    c[u] = 2
    
    for v in range(n):
        if c[v] != 2 and g[u][v] != -1:
            if g[u][v] < d[v]:
                d[v] = g[u][v]
                p[v] = u
                c[v] = 1
    sum = 0
    for i in range(n):
        if p[i] != -1:
            sum += g[i][p[i]]
print sum

Measured memory_bytes: 6484
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

type ElementKey int
type Node struct {
	key    ElementKey
	parent *Node
	rank   int
}

func newNode(key ElementKey) *Node {
	node := Node{}
	node.key = key
	node.parent = &node
	node.rank = 0

	return &node
}

func union(x, y *Node) {
	xSet := findSet(x)
	ySet := findSet(y)
	link(xSet, ySet)
}

func link(x, y *Node) {
	if x.rank > y.rank {
		y.parent = x
	} else {
		x.parent = y

		if x.rank == y.rank {
			y.rank++
		}
	}
}

func findSet(x *Node) *Node {
	if x != x.parent {
		x.parent = findSet(x.parent)
	}
	return x.parent
}

func newDisjointSets(nSets int) *DisjointSets {
	sets := DisjointSets{}
	sets.keyToNode = map[ElementKey]*Node{}
	for i := 0; i < nSets; i++ {
		key := ElementKey(i)
		sets.keyToNode[key] = newNode(key)
	}
	return &sets
}

type DisjointSets struct {
	keyToNode map[ElementKey]*Node
}

func (sets *DisjointSets) union(x, y ElementKey) {
	xNode := sets.keyToNode[x]
	yNode := sets.keyToNode[y]
	union(xNode, yNode)
}

func (sets DisjointSets) findSet(x ElementKey) *Node {
	xNode := sets.keyToNode[x]
	return findSet(xNode)
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	nQueries := nextInt()
	sets := newDisjointSets(n)
	for i := 0; i < nQueries; i++ {
		// sets.print()

		queryType := nextInt()
		x := ElementKey(nextInt())
		y := ElementKey(nextInt())
		// fmt.Println("queryType=", queryType, x, y)
		if queryType == 0 { // unite
			sets.union(x, y)
		} else if queryType == 1 { // same
			if sets.findSet(x) == sets.findSet(y) {
				fmt.Println(1)
			} else {
				fmt.Println(0)
			}
		}
	}
}



Measured memory_bytes: 3248
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define G() Cr=getchar()
int Xr;char Cr;
inline int  rd(){
	Xr=0;G();
	while(Cr<'0'||Cr>'9')G();
	while(Cr>='0'&&Cr<='9')Xr=(Xr<<1)+(Xr<<3)+Cr-'0',G();
	return Xr;
}
int n,Ma,Mb,ans=99999999;
int dp[405][405];
int a[100],b[100],c[100];
int main(){
	n=rd(),Ma=rd(),Mb=rd();
	for(int i=1;i<=n;i++)
		a[i]=rd(),b[i]=rd(),c[i]=rd();
	
	for(int i=0;i<=400;i++)
		for(int j=0;j<=400;j++)
			dp[i][j]=99999999;
	dp[0][0]=0;	
	
	for(int k=1;k<=n;k++)
		for(int i=400;i>=a[k];i--)
			for(int j=400;j>=b[k];j--)
				dp[i][j]=min(dp[i][j],dp[i-a[k]][j-b[k]]+c[k]);		
				
			
	for(int i=1;i<=400;i++)
		for(int j=1;j<=400;j++)
			if(i*Mb==j*Ma)
				ans=min(ans,dp[i][j]);
	
	printf("%d\n", (ans==99999999)?-1:ans );		
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c && a%2==0){
      cout<<-1<<endl;
    }else{
      ll ans=0;
      while(a%2==0 && b%2==0 && c%2==0){
        ans++;
        ll x=a/2,y=b/2,z=c/2;
        a=y+z;
        b=z+x;
        c=x+y;
      }
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
	int n, x; cin >> n >> x;
	
	vector<int> m(n);
	
	int min_m = 10000;
	int min_index;
	for (int i = 0; i < n; i++) { 
		cin >> m[i];
		if (chmin(min_m, m[i])) min_index = i;
	}

	for (int i = 0; i < n; i++) x -= m[i];

	cout << n + x / m[min_index] << endl;
			
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<random>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<unordered_map>
#include<time.h>
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
//#define int long long
using namespace std;
typedef long long ll;
typedef long double ld;
using namespace std;
int h, w;
int dp[100][100][2][100];//???????¨??????±??????????????????????????§?????????????????\??????
int solve(int i, int j, bool dir, int dis) {
	if (i == h - 1 && j == w - 1)
		return 1;
	if (dp[i][j][dir][dis] != -1)
		return dp[i][j][dir][dis];
	int ans = 0;
	for (int z = 0; z < 2; z++) {
		int x = (z == 0 ? i + 1 : i), y = (z == 1 ? j + 1 : j);
		if (x == h || y == w) continue;
		if (dis < 2 && (int)dir != z) continue;
		ans += solve(x, y, z, z == (int)dir ? dis + 1 : 1);
	}
	return (dp[i][j][dir][dis] = ans % 100000);
}
signed main() {
	while (cin >> w >> h&&w != 0 && h != 0) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int dir = 0; dir < 2; dir++) {
					for (int dis = 0; dis < 100; dis++)
						dp[i][j][dir][dis] = -1;
				}
			}
		}
		cout << (solve(0, 1, 1, 2) + solve(1, 0, 0, 2)) % 100000 << endl;
	}
}

Measured memory_bytes: 10896
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int i, j, n, k;
	int x[200] = { 0 };

	cin >> n >> k;

	for (i = 0; i < n; i++) {
		cin >> x[i];
	}

	int sum = 0;
	for (i = 0; i < n; i++) {
		//cout <<  x[i] << " ";
		sum = sum + min(x[i], k - x[i]);


	}

	cout << sum * 2 << endl;


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val s = sc.next
    val akiba = "AKIHABARA"
    var i = 0
    var j = 0
    while (i < s.length && j < akiba.length) {
      if (s(i) == akiba(j)) {
        i += 1
        j += 1
      } else if (akiba(j) == 'A') {
        j += 1
      } else {
        j = akiba.length
      }
    }
    if (i == s.length && j >= akiba.length-1) {
      println("YES")
    } else {
      println("NO")
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25528
#include<iostream>

using namespace std;

int hantei(void);

string in;

int main(){


  int sum = 0;

  while(cin >> in){
    if(in.length() == 1) sum++;
    else{
      if(hantei()) sum++;
	//cout << in<< endl;
    }
  }
  cout << sum <<endl;
  return 0;
}


int hantei(void){
  for(int i = 0; i < in.length()/2; i++){
    if(in[i] != in[in.length()-1-i]) return 0;
  }
  return 1;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define Pi 3.141592653589793238
#define M 1000000007
#define mp make_pair
#define pb push_back
#define p(k) printf("%d ",k)
#define pl(k) printf("%lld ",k)
#define pn(k) printf("%d\n",k)
#define pln(k) printf("%lld\n",k)
#define ps(str) printf("%s",str)
#define s(k) scanf("%d",&k)
#define sl(k) scanf("%lld",&k)
#define ss(str) scanf("%s",str)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define ppi pair<int,int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ft first
#define sd second
#define count(x) __builtin_popcountll(x)

using namespace std;

const int N = 100005;
vector<int>v[N];
vector<int>vp[N];
vector<int>dp(N,0);
vector<int>visited(N,0);
vector<int>arr;
void dfs(int u){
	visited[u] = 1;
	for(auto child: v[u]){
		if(visited[child]==0){
			dfs(child);
		}
	}
	arr.pb(u);
	return ;
}
int find(){
	int maxi = 0;
	int i;
	for(i=0;i<(int)sz(arr);i++){
		int mx = 0;
		for(auto pp: vp[arr[i]]){
			mx = max(mx,dp[pp]+1);
		}
		dp[arr[i]] = mx;
		maxi = max(mx,maxi);
	}
	return maxi;
}
int main(){
	int n,i,m,p,q,k,mx;
	s(n);s(m);
	for(i=0;i<m;i++){
		s(p);s(q);
		p--;q--;
		v[p].pb(q);
		vp[q].pb(p);
	}
	mx = 0;
	for(i=0;i<n;i++){
		if(visited[i]==0){
			//~ arr.clear();
			dfs(i);
		}
	}
	reverse(all(arr));
	k = find();
	cerr<<i<<" "<<k<<"\n";
	mx = max(mx,k);
	p(mx);
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> C(N-1);
    vector<ll> S(N-1);
    vector<ll> F(N-1);

    REP(i, N-1){
        cin >> C[i] >> S[i] >> F[i];
    }

    REP(i, N){
        ll ans = 0;
        if(i == N-1){
            cout << 0 << endl;
            return 0;
        }
        for(ll j=i; j<N-1; j++){
            if(i==j){
                ans = S[j] + C[j];
            }
            else{
                ll t = max(ans, S[j]);
                ll t2 = (F[j] - t % F[j]) % F[j];
                ans = t + t2 + C[j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    int count = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        count++;
      }
    }
    if (count == 8) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int mini = 1000000;

    for (int x = -100; x <= 100; x++) {
        int gross = 0;
        for (int i = 0; i < n; i++) {
            gross += (a[i] - x)*(a[i] - x);
        }
        mini = min(mini, gross);
        
    }
    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,n,x,count=0,l,num=1;
  scanf("%d%d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&l);
    if(count+l<=x){
      count+=l;num++;
    }
    else{
      break;
    }
  }
  printf("%d",num);
  return(0);
}


Measured memory_bytes: 128
def main():
    n = int(input())
    a = list(map(int, input().split()))
    c = 0
    d = 10**9+1 

    for i in range(n):
        c = max(a[i], c)
        d = min(a[i], d)

    print(c-d)

if __name__=='__main__':
    main()


Measured memory_bytes: 3060
#include <cstdio>

int main()
{
    int a, b, c, d, e, f;
    double x, y;

    while (scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) != EOF) {
        x = (double)(e * c - b * f) / (a * e - b * d);
        y = (double)(a * f - d * c) / (a * e - b * d);

        printf("%.3f %.3f\n", x == -0 ? 0 : x, y == -0 ? 0 : y);
    }

    return 0;
}

Measured memory_bytes: 1064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define INF 1000000000
using namespace std;
int N,M,R;
int r[9];
int G[200][200];
void wf(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
	G[j][k]=min(G[j][k],G[j][i]+G[i][k]);
      }
    }
  }
}
int main(){
  for(int i=0;i<200;i++){
    for(int j=0;j<200;j++){
      G[i][j]=INF;
      if(i==j)G[i][j]=0;
    }
  }
  cin >> N >> M >> R;
  for(int i=0;i<R;i++){
    cin >> r[i];
    r[i]--;
  }
  for(int i=0;i<M;i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    G[a][b]=c;
    G[b][a]=c;
  }
  wf();
  sort(r,r+R);
  int Min=INF;
  do{
    int ans=0;
    for(int i=0;i<R-1;i++){
      ans+=G[r[i]][r[i+1]];
    }
    Min=min(Min,ans);
  }while(next_permutation(r,r+R));
  cout << Min << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 200200
#define lson (now<<1)
#define rson (now<<1|1)
void WA(){puts("-1");exit(0);}
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,K,top;
ll a[MAX],b[MAX],t[MAX<<2];
ll L[MAX],R[MAX],f[MAX],s[MAX],S[MAX];
void pushdown(int now)
{
	if(!t[now])return;
	t[lson]=t[rson]=t[now];
	t[now]=0;
}
void modify(int now,int l,int r,int L,int R,int w)
{
	if(L>R)return;
	if(L<=l&&r<=R){t[now]=w;return;}
	int mid=(l+r)>>1;pushdown(now);
	if(L<=mid)modify(lson,l,mid,L,R,w);
	if(R>mid)modify(rson,mid+1,r,L,R,w);
}
int Query(int now,int l,int r,int p)
{
	if(l==r)return t[now];
	int mid=(l+r)>>1;pushdown(now);
	if(p<=mid)return Query(lson,l,mid,p);
	else return Query(rson,mid+1,r,p);
}
ll Query(int x)
{
	int d=Query(1,1,top,x);
	if(!d)return 0;
	return f[d]+(S[L[d]]%K-S[x]%K+K)%K;
}
int main()
{
	n=read();K=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read(),b[i]=read();
		s[i]=s[i-1]+a[i];
		if(b[i]==1&&a[i]+a[i]>K)WA();
	}
	for(int i=n;i;--i)
		if(b[i]==1)L[i]=(-2*s[i-1]%K+K)%K,R[i]=(-2*s[i]%K+K)%K;
		else L[i]=0,R[i]=K-1;//No limit
	for(int i=1;i<=n;++i)S[++top]=L[i],S[++top]=R[i];
	sort(&S[1],&S[top+1]);top=unique(&S[1],&S[top+1])-S-1;
	for(int i=n;i;--i)
	{
		L[i]=lower_bound(&S[1],&S[top+1],L[i])-S;
		R[i]=lower_bound(&S[1],&S[top+1],R[i])-S;
		f[i]=Query(L[i]);
		if(L[i]>R[i])modify(1,1,top,R[i]+1,L[i]-1,i);
		else modify(1,1,top,1,L[i]-1,i),modify(1,1,top,R[i]+1,top,i);
	}
	ll ans=1e18;
	for(int i=top;i;--i)ans=min(ans,Query(i));
	cout<<ans+s[n]+s[n]<<endl;
	return 0;
}


Measured memory_bytes: 14592
N = int(input())
ABC = [list(map(int,input().split())) for _ in [0]*(N-1)]
Q,K = map(int,input().split())
XY = [list(map(int,input().split())) for _ in [0]*Q]

E = [{} for _ in [0]*N]
for a,b,c in ABC:
    E[a-1][b-1] = c
    E[b-1][a-1] = c

def dist_dfs_tree(N,E,start):
    d = [-1]*N
    d[start] = 0
    q = [start]
    while q:
        i = q.pop()
        ci = d[i]
        for j,cj in E[i].items():
            if d[j] !=-1:continue
            d[j] = ci+cj
            q.append(j)
    return d

d = dist_dfs_tree(N,E,K-1)
for x,y in XY:
    print(d[x-1]+d[y-1])

Measured memory_bytes: 98636
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll X;  cin >> X;
	ll num = 1, ans = 0;;
	while(X > 0){
		ans += 1;
		X -= num;
		num += 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<deque>
using namespace std;
int ans[300005];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    //cout<<(n-i)/2<<" "<<n-(n-i)/2<<endl;
    if(i%2==0){
    if(n%2==0)
    ans[1+(n-i)/2]=x;
    else
    ans[n-(n-i)/2]=x;
    }
    else{
    if(n%2==0)
    ans[n-(n-i)/2]=x;
    else
    ans[1+(n-i)/2]=x;     
    }
    }
    for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
    //system("pause");
    return 0;
}


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

int main() {
	string s;
  	int count=0;
  
  	cin >> s;
  
  	if(s.at(0)=='1'){count++;}
  	if(s.at(1)=='1'){count++;}
  	if(s.at(2)=='1'){count++;}
      
  	cout << count << endl;
}

Measured memory_bytes: 3600