akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100

int M[N][N];
int color[N],d[N],f[N],tt,n;
int u,v;
void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  f[u]=++tt;
  color[u]=BLACK;
}

void dfs(){
  int i;
  for(i=0;i<n;i++) color[i] = WHITE;
  tt = 0;
  for(i=0;i<n;i++){
    if(color[i] == WHITE) dfs_visit(i);
  }
}

int main(){
  int u,v,k;
  int i,j;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
  return 0;
}



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

#define ll long long

ll N, M;

void solve(){
	set<ll> divisor;
	for(ll i=1;i<100000;i++){
		if(M%i == 0){
			divisor.insert(i); divisor.insert(M/i);
		}
	}

	for(auto e:divisor){
		if(N <= e){
			cout << M/e << endl;
			break;
		} 
	}

}


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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define f first
 #define s second
 #define endl '\n'
 #define LL long long
 #define pb push_back
 #define sz(a) (int)a.size()
 #define all(a) a.begin(),a.end()
 #define rall(a) a.rbegin(),a.rend()
 #define debug(x) cerr << #x << " is " << x << endl;
 using namespace std;
 int const MAXN = 2e6 + 9;
 int main(){
    ios_base::sync_with_stdio (0),cin.tie(0);
    LL n,a,b;
    cin >> n >> a >> b;
    LL d = abs(a-b);
    if (d % 2 ==0){
        cout << d /2;
        return 0;
    }
    LL p1 = a  ;
    LL p2 = n - b + 1;
    cout << min(p1,p2) + (b - a - 1 )/ 2;
 }


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,a[10],i;

        scanf("%d",&n);

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

                a[i]=n%10;

                n=n/10;

                if (a[i]==1)
                        a[i]=9;
                else
                        a[i]=1;
        }

        for (i=2;i>=0;i--)
                printf("%d",a[i]);

        printf("\n");

        return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define H 500000

void maxheapi(int *a,int i,int h){
    int l,r,max;

    if(i>1){
      l=2*i;
      r=2*i+1;
    }else{
      l=i+1;
      r=l+1;
    }
    if(l<=h && a[l]>a[i])max=l;
    else max=i;

    if(r<=h && a[r]>a[max])max=r;

    if(max!=i){
        swap(a[i],a[max]);
        maxheapi(a,max,h);
    }
}
int main(){
  int h,a[H],i;
  cin>>h;
  for(i=1;i<=h;i++){
    cin>>a[i];
  }

for(i=h/2;i>0;i--){
    maxheapi(a,i,h);
}
for(i=1;i<=h;i++){
    cout<<" "<<a[i];
}
cout<<endl;

  return 0;
}



Measured memory_bytes: 5036
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();
            char[] cs = S.toCharArray();

            int[] cb = new int[N + 1];
            int[] cw = new int[N + 1];

            for (int i = 1; i < N; i++) {
                cb[i] += cb[i - 1] + (cs[i - 1] == '#' ? 1 : 0);
            }
            for (int i = N - 1; i >= 0; i--) {
                cw[i] += cw[i + 1] + (cs[i] == '.' ? 1 : 0);
            }
            int ans = Integer.MAX_VALUE;
            for (int i = 0; i < N; i++) {
                ans = Math.min(ans, cb[i] + cw[i + 1]);
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 28644
#include<bits/stdc++.h>
using namespace std;
int N,M;
vector<int> V[100000];
int ck[100000];
int d[100000];
int c[100000];
int p[100000];
int t[100000];
vector<int> A;
vector<int> W;
void dfs(int a){
    if(p[a])return;
    if(t[a]){
        cout<<"Not DAG";
        return;
    }
    t[a]=1;
    for(int i:V[a]){
        dfs(i);
    }
    W.push_back(a);
    p[a]=1;
    t[a]=0;
}
void TO(){
    for(int i=0 ; i<N ; i++){
        if(p[i])continue;
        dfs(i);
    }
    for(int i=0 ; i<N/2 ; i++){
        swap(W[i],W[N-i-1]);
    }
}
int main(){
    cin>>N>>M;
    for(int i=0,a,b ; i<M ; i++){
        cin>>a>>b;
        V[a-1].push_back(b-1);
    }
    TO();
    for(int i=N-1 ; i>=0 ; i--){
        for(int j:V[W[i]]){
            d[W[i]] = max(d[W[i]],d[j]+1);
        }
    }

    int ans =0;
    for(int i=0 ; i<N ; i++){
        ans = max(d[i],ans);
    }
    cout<<ans;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for(int i=0;i<n;i++){
        cin  >> a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int mid=n/2;
    int minv=b[mid-1];
    int maxv=b[mid];
    for(int i=0;i<n;i++){
        if(a[i]<maxv){
            cout << maxv << endl;
        }
        else{
            cout << minv << endl;
        }
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

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

	long long money = 1000;
	long long stock = 0;

	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			money += stock * a[i];
			stock = 0;
		} else if (a[i] < a[i+1]) {
			stock += money / a[i];
			money %= a[i];
		} else {
			money += stock * a[i];
			stock = 0;
		}
	}

	cout << money << endl;
	return 0;
}


Measured memory_bytes: 3192
def count(A,left, right):
    if left >= right:
        return 0
    mid = (left + right) // 2
    cl = count(A, left, mid)
    cr = count(A, mid+1, right)
    L = A[left:mid + 1]
    R = A[mid+1:right+1]
    c, m, n, k= 0, 0, 0, left
    while m < len(L) and n < len(R):
        if L[m] > R[n]:
            A[k] = R[n]
            k += 1
            c += (len(L) - m)
            n += 1
        else:
            A[k] = L[m]
            m += 1
            k += 1
    while m < len(L):
        A[k] = L[m]
        m += 1
        k += 1
    while n < len(R):
        A[k] = R[n]
        k += 1
        n += 1 
    return cl + cr + c
N = int(input())
A = list(map(int, input().split()))
print(count(A, 0, N-1))

Measured memory_bytes: 30380
// https://atcoder.jp/contests/abc066/tasks/arc077_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define FORR(i,b,e) for(int i=(b); i>=(int)(e); i--)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
int extgcd(int a, int b, int &x, int &y) {
  int ret = a;
  if (b == 0) {
    x = 1;
    y = 0;
  } else {
    ret = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
  return ret;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

//------------------------------------------------------------------------------
const int F_MAX = 1e5;

ll fact[F_MAX + 1];
ll fact_inv[F_MAX + 1];

void init_fact(int m) {
  fact[0] = 1;
  FOR(i, 1, F_MAX) fact[i] = fact[i - 1] * i % m;
  fact_inv[F_MAX] = mod_inverse(fact[F_MAX], m);
  FORR(i, F_MAX - 1, 0) fact_inv[i] = fact_inv[i + 1] * (i + 1) % m;
}

ll mod_comb_fast(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  ll a = fact[n];
  ll b = fact_inv[k] * fact_inv[n - k] % mod;
  ll ret = a * b % mod;
  // printf("%lld_C_%lld = %lld\n", n, k, ret);
  return ret;
}

//------------------------------------------------------------------------------

const int N_MAX = 1e5;
const int MOD = 1e9+7;

int n;
int a[N_MAX+1];

int m;
int ra[N_MAX + 1];

int find_m() {
  fill(ra, ra + n + 1, -1);
  REP(i, n + 1) {
    if (ra[a[i]] >= 0) {
      return i - ra[a[i]] - 1;
    }
    ra[a[i]] = i;
  }
  return -1;
}

void solve() {
  init_fact(MOD);
  m = find_m();
  // printf("m: %d\n", m);
  // k = 1
  // printf(" k=1\n");
  printf("%d\n", n);
  FOR(k, 2, n + 1) {
    // printf(" k=%d\n", k);
    ll ans = 0;
    if (k <= n - 1) ans = (ans + mod_comb_fast(n - 1, k, MOD)) % MOD;
    if (k <= n) ans = (ans + 2 * mod_comb_fast(n - 1, k - 1, MOD) % MOD) % MOD;
    ans = (ans + mod_comb_fast(n - 1, k - 2, MOD)) % MOD;
    if (k <= n - m) ans = (ans + MOD - mod_comb_fast(n - m - 1, k - 1, MOD)) % MOD;
    printf("%lld\n", ans);
  }
}

void input() {
  scanf("%d", &n);
  REP(i, n+1) scanf("%d", a + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

pair<int, int> cnt1[100010];
pair<int, int> cnt2[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int v[100010];
    rep(i, n) cin >> v[i];
    rep(i, n) {
        if (i % 2 == 0) {
            cnt1[v[i]].first++; cnt1[v[i]].second = v[i];
        } else {
            cnt2[v[i]].first++; cnt2[v[i]].second = v[i];
        }
    }
    sort(cnt1, cnt1 + 100010, greater<pair<int, int>>());
    sort(cnt2, cnt2 + 100010, greater<pair<int, int>>());
    /*
    rep(i, n/2) {
        cout << cnt1[i].first << " " << cnt1[i].second << " " << cnt2[i].first << " " << cnt2[i].second << endl;
    }
    */
    if (cnt1[0].second != cnt2[0].second) {
        cout << n - cnt1[0].first - cnt2[0].first << endl;
    } else {
        int ans1 = cnt1[0].first + cnt2[1].first;
        int ans2 = cnt1[1].first + cnt2[0].first;
        cout << n - max(ans1, ans2) << endl;
    }


    return 0;
}


Measured memory_bytes: 2176
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll n, k; cin >> n >> k;
	if (n%k == 0)cout << 0 << endl;
	else
	{
		cout << min(n%k, k - (n % k)) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}


int N;
long long T[110];

int main() {
	while (cin >> N) {
		long long res = 1;
		for (int i = 0; i < N; ++i) {
			long long a;
			cin >> a;
			res = LCM(res, a);
		}
		cout << res << endl;
	}
}

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

using namespace std;

vector<int> vc;

void dfs(vector<vector<int> >&G, int p, vector<int>&visited)
{
  visited[p] = 1;
  for(int i=0; i < G[p].size();i++){
    if(visited[G[p][i]] == 0){
      vc.push_back(G[p][i]);
      dfs(G,G[p][i],visited);
      break;
    }
  }
  return;
}


int main()
{
  int N,M;
  cin >> N >> M;
  vector<vector<int> >G(N);
  for(int i=0; i < M; i++){
    int a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }

  vector<int>visited(N,0);
  vector<int>ans;
  dfs(G,0,visited);
  reverse(vc.begin(),vc.end());
  for(int i=0; i < vc.size(); i++)
    ans.push_back(vc[i]);
  vc.clear();
  dfs(G,0,visited);
  ans.push_back(0);
  for(int i=0; i < vc.size(); i++)
    ans.push_back(vc[i]);
  cout << ans.size() << endl;
  for(int i=0; i < ans.size(); i++)
    cout << ans[i]+1 << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 7544
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = 0;
    int B = 0;
    int min = Integer.MAX_VALUE;
    
    for(int i = 1; i<N; i++){
      A=i;
      B=N-i;
      
      int sum = 0;
      while(A>0){
        sum += A%10;
        A /= 10;
      }
      while(B>0){
        sum += B%10;
        B /= 10;
      }
      min = Math.min(min, sum);
    }
    
    System.out.println(min);
  }
}
        
    
    
    

Measured memory_bytes: 35716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

const int MAX_V = 100010;
struct edge {
    int to,cost;
};
int V;
vector<edge> G[MAX_V];  //重み付き有効グラフの隣接リスト表現
int d[MAX_V];

void dijkstra(int s){
    //greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>,greater<P> > que;
    fill(d,d+V,inf);
    d[s] = 0;
    que.push(P(0,s));

     while(!que.empty()){
         P p = que.top(); que.pop();     // firstは最短距離、secondは頂点の番号
         int v = p.second;
         if(d[v] < p.first) continue;  
         for(int i = 0; i < G[v].size(); i++){
             edge e = G[v][i];
             if(d[e.to] > d[v] + e.cost){
                 d[e.to] = d[v] + e.cost;
                 que.push(P(d[e.to],e.to));
             }
         }
    }
}

int main()
{
    int h,w;
    cin >> h >> w;
    V = 10;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            int c;  cin >> c;
            if(i == j) continue;
            struct edge e;
            e.to = j; e.cost = c;
            G[i].push_back(e);
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int a; cin >> a;
            if(a == 1 || a == -1) continue;
            dijkstra(a);
            ans += d[1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2688
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	          int N;
	          cin >> N;
	          vector<ll> v(3*N);
	          for(i=0;i<3*N;i++) cin >> v[i];

	          sort(v.begin(),v.end());
	          reverse(v.begin(),v.end());

	          ll ans=0;
	          for(i=1;i<=2*N-1;i+=2) ans+=v[i];

	          cout << ans << endl;

	          return 0;
}


Measured memory_bytes: 2560
s = input()
q = int(input())
t = ""
for i in range(q):
    que = input().split()
    if que[0] == "1":
        s, t = t, s
    else:
        if que[1] == "1":
            t += que[2]
        else:
            s += que[2]
print(t[::-1] + s)

Measured memory_bytes: 4480
#include <cstdio>
#include <cstring>

#include <queue>
#include <algorithm>

using namespace std;

#define NMAX 100000

typedef long long i64;

int main() {
    priority_queue<i64> q;
    int n, K;
    scanf("%d%d", &n, &K);
    while (n--) {
        i64 v;
        scanf("%lld", &v);
        q.push(v);
    }
    while (K--) {
        i64 v = q.top();
        q.pop();
        q.push(v / 2);
    }
    i64 ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1400
/*
 *
 */
#include <cstdio>
#include <iostream>

using namespace std;

char a[8][9];

int main(){
    //freopen("a3.in", "r", stdin);
    int h, w;
    scanf("%d %d", &h, &w);
    for (int i = 0; i < h; ++i) {
        scanf("%s", &a[i]);
    }

    int curH = 0, curW = 0;

    while (curH != h-1 || curW != w-1) {
        a[curH][curW] = '.';
        if (curH+1 < h && a[curH+1][curW] == '#') {curH++;}
        else if (curW+1 < w && a[curH][curW+1] == '#') {curW++;}
        else break;
    }
    a[curH][curW] = '.';
    bool ans = true;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (a[i][j] == '#') ans = false;
        }
    }
    printf(ans ? "Possible\n" : "Impossible\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}


int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,k) {
      int b;
      cin >> b;
      rep(j,b) {
          int c;
          cin >> c;
        //pt(c-1);
          a[c-1]++;
      }
  }
  int ans=0;
  rep(i,n) {
      if(a[i]==0) ans++;
    //pt(a[i]);
  }
  pt(ans);
  return 0;
}

Measured memory_bytes: 3600
a = []
low = 10
ans = 0
for i in range(5):
    a.append(int(input()))
    if a[i] % 10 != 0:
        low = min(low, a[i]%10)
    while (a[i] % 10 != 0):
        a[i] += 1
    ans += a[i]

if low != 10:
    print(ans - 10 + low)
else:
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string N;
	cin >> N;
	if (N[0] == N[1] && N[1] == N[2])
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	bool flg=false;
	rep(i,n){
		int a;cin >> a;
		if(a%2==1) flg=true;
	}
	if(flg) cout << "first" << endl;
	else cout << "second" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[100001];
int main() {
	scanf("%s", s);
	int sl = strlen(s);
	if (s[sl - 1] == s[0] && sl % 2 == 0 || s[sl - 1] != s[0] && sl % 2 == 1) {
		printf("First");
	}
	else {
		printf("Second");
	}
	return 0;
}

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

int H, W, K;
vector<vector<char>> s;
int strayberry_number = 1;
vector<vector<int>> ans;


int numStrayberry(int h_start, int h_end, int w_start, int w_end) {

    int strayberry = 0;
    for (int i = h_start; i <= h_end; ++i)
    {
        for (int j = w_start; j <= w_end; ++j)
        {
            if(s[i][j] == '#') {
                strayberry++;
            }
        }
    }

    return strayberry;
}

void print() {
    for (int i = 0; i < ans.size(); ++i)
    {
        for (int j = 0; j < ans[i].size(); ++j)
        {
            printf("%d ", ans[i][j]);
        }
        cout << endl;
    }
    cout << endl;
}


void paint(int h_start, int h_end, int w_start, int w_end) {
    for (int i = h_start; i <= h_end; ++i)
    {
        for (int j = w_start; j <= w_end; ++j)
        {
            ans[i][j] = strayberry_number;
        }
    }
    // printf("---- print ----\n");
    // print();

    strayberry_number++;
}

void rec(int h_start, int h_end, int w_start, int w_end) {
    // printf("--- rec start ---\n");
    // printf("w_start : %d\n", w_start);
    // printf("w_end   : %d\n", w_end);
    // printf("h_start : %d\n", h_start);
    // printf("h_end   : %d\n", h_end);

    //いちごの個数と同じになるまでケーキを分割したら終了
    if(numStrayberry(h_start, h_end, w_start, w_end) == 1) { 
        paint(h_start, h_end, w_start, w_end);
        return;
    }

    //最初に見つかるいちごの位置
    int strayberry_h = 0;
    int strayberry_w = 0;
    for (int i = h_start; i <= h_end; ++i) {
        for (int j = w_start; j <= w_end; ++j) {
            if(s[i][j] == '#') {
                strayberry_h = i;
                strayberry_w = j;
                goto LABEL_EXIT;
            }
        }
    }

    LABEL_EXIT:
    //切る範囲をできるだけ下の方へ伸ばす
    int cut_h = strayberry_h;
    int cut_w = strayberry_w;
    for (int i = strayberry_h + 1; i <= h_end; ++i)
    {
        for (int j = 0; j <= strayberry_w; ++j) //幅は最初にいちごが見つかったところまで
        {
            if(s[i][j] == '#') {
                cut_h = max(cut_h, i-1);
                goto LABEL_EXIT2;
            }
        }

        //最後まで到達したら、縦に切ることになる
        if(i == h_end) {
            cut_h = h_end;
        }
    }


    LABEL_EXIT2:
    //分割して再帰
    // printf(" ==> cut : %d, %d\n", cut_h, cut_w);
    if(cut_h < h_end) { //横に切る
        rec(h_start  , cut_h, w_start, w_end);
        rec(cut_h + 1, h_end, w_start, w_end);
    } else if(cut_w < w_end){ //縦に切る
        rec(h_start, h_end, w_start  , cut_w);
        rec(h_start, h_end, cut_w + 1, w_end);
    }

    return;
}




int main() {
    cin >> H >> W >> K;

    for (int h = 0; h < H; ++h){
        vector<char> tmp;
        vector<int> ans_tmp;

        for (int w = 0; w < W; ++w)
        {
            char c;
            cin >> c;
            tmp.push_back(c);

            ans_tmp.push_back(0);

        }
        s.push_back(tmp);

        ans.push_back(ans_tmp);
    }

    // printf("---- paint ----\n");
    // paint(0, W-1, 0, H-1);

    rec(0, H-1, 0, W-1);
    // printf("---- print ----\n");
    print();

    

	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n,a,b,c,d;
  cin>>n;
  vector<pair<int,int> > points(n, make_pair(0,0));
  vector<int> rank(n, -1);
  for (int i=0; i<n; ~++i) points[i].second = i;
  for (int i=0; i<n*(n-1)/2; ++i) {
    cin>>a>>b>>c>>d; a--, b--;
    if (c>d) points[a].first += 3;
    else if (c<d) points[b].first += 3;
    else {
      points[a].first++, points[b].first++;
    }
  }

  sort(points.begin(), points.end(), greater<pair<int,int> >());
  int prev = -1, prank = 0;
  for (int i=0; i<n; ++i) {
    if (prev != points[i].first) prank = i+1;
    prev = points[i].first;
    rank[points[i].second] = prank;
  }
  for (int i=0; i<n; ++i) cout<<rank[i]<<endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int x,y,z;
    cin >> x >> y >> z;
    int s=x-z;
    int ans=0;
    
    while(s>=0){
        ans++;
        s-=(y+z);
    }
    
    cout << ans-1;;
    
	return 0;
}

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

#define NREP for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9+7;

int main(int argc, char *argv[]) {
   ll p, q, r;
   cin >> p >> q >> r;

   MSG(min(min(p + q, p + r), q + r))
}


Measured memory_bytes: 256
n = int(input())

alphabet = 'abcdefghij'
s = [-1 for i in range(n)]

def dfs(ind, r):
    if ind == n:
        ans = [alphabet[i] for i in s]
        print(''.join(ans))
        return
    for i in range(r):
        s[ind] = i
        dfs(ind+1, max(s)+2)
        s[ind] = -1

dfs(0, 1)

Measured memory_bytes: 4412
#include<iostream>
#include<cassert>
#include<vector>
#include<map>
#include<string>

using namespace std;

typedef long long ll;

ll binary_to_ll(string s, int n){
    ll a = 0LL;
    for(int j=0;j<n;j++) a |= (ll(s[j] == '1') << (n-1-j));
    return a;
}

int get_lsb(ll a, int n){
    int lsb = 0;
    while(lsb < n && ((a >> lsb) & 1LL) == 0LL) lsb++;
    return lsb;
}

void up_lsb(ll *a, int *lsb){
    if((*a >> (*lsb+1)) & 1LL){
        // 11→10
        *a ^= (1LL << (*lsb));
    }else{
        // 01→10
        *a ^= (3LL << (*lsb));
    }
    
    (*lsb)++;
}

int solve(string s, string t){
    int n = int(s.length());
    ll a = binary_to_ll(s, n), b = binary_to_ll(t, n);
    int lsba = get_lsb(a, n), lsbb = get_lsb(b, n);
    int d = 0;
    while(a != b){
        if(lsba < lsbb){
            up_lsb(&a, &lsba);
        }else{
            up_lsb(&b, &lsbb);
        }
        d++;
    }
    return d;
}

int main(){
    int n;
    cin >> n;
    string s,t;
    for(int i=0;i<n;i++){
        cin >> s >> t;
        cout << solve(s,t) << endl;
    }
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

int main(void){
    int N;
    std::vector<std::tuple<std::string, int, int>> book;
    std::cin >> N;

    for (int i=0; i<N; ++i){
        std::string s;
        int a;
        std::cin >> s >> a;
        book.emplace_back(s, a, i + 1);
    }

    std::sort(book.begin(), book.end(), [](const auto &x, const auto &y){
        return std::get<0>(x) == std::get<0>(y) ? std::get<1>(x) > std::get<1>(y) : std::get<0>(x) < std::get<0>(y);
    });

    for (auto x: book){
        std::cout << std::get<2>(x) << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL);
	
	long double a, b, c, x;
	cin>>a>>b>>c;
	x=a/c;
	if(x<=b)
		cout<<"Yes";
	else
		cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3732
#include <stdio.h>


int main(int argc, char *argv[]) {
	
	char yes[4] = "Yes\0";
	char no[3] = "No\0";
	char *flag = NULL;
	int w = 0, h = 0;
	int x = 0, y = 0, r = 0;
	
	fscanf(stdin, "%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if(x < r || y < r || (w-x) < r || (h-y) < r)  { 
		flag = no;
	}else {
		flag = yes;
	}
	fprintf(stdout, "%s\n", flag);
	
	return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const int MAX_DIGIT = 50;
ll dp[100][2];

int main()
{
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    rep(d, MAX_DIGIT)
    {
        ll mask = 1LL << (MAX_DIGIT - d - 1);

        int num = 0;
        rep(i, n) if (a[i] & mask) num++;

        ll cost0 = mask * num;
        ll cost1 = mask * (n - num);

        if (dp[d][1] != -1) chmax(dp[d + 1][1], dp[d][1] + max(cost0, cost1));

        if (dp[d][0] != -1)
        {
            if (k & mask) chmax(dp[d + 1][1], dp[d][0] + cost0);
        }

        if (dp[d][0] != -1)
        {
            if (k & mask) chmax(dp[d + 1][0], dp[d][0] + cost1);
            else chmax(dp[d + 1][0], dp[d][0] + cost0);
        }
    }
    cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
}

Measured memory_bytes: 1152
def cultimes(x):
  base=0
  start=0
  if x==0:
    return 0
  if x==1:
    return 1
  while  start <x+1:
    base+=1
    start=(base+1)*(base+2)//2
  return base
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr
n=int(input())
m=factorization(n)
t=0
for x in m:
  t+=cultimes(x[1])
t=int(t)
if n==1:
  t=0
print(t)

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

int main(){
    ll n, sum=0, ans=0, anss=0;
    cin>>n;

    vector<ll> x(n);
    for(ll i=0; i<n; i++){
        cin>>x.at(i);
        sum+=x.at(i);
    }

    ll cnt = sum/n;

    for(ll i=0; i<n; i++){
        ans+=pow(abs(x.at(i)-cnt), 2);
    }
    for(ll i=0; i<n; i++){
        anss+=pow(abs(x.at(i)-cnt-1), 2);
    }

    cout<<min(anss,ans)<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner sc =new Scanner(System.in);
	public static void main(String[] args) {
		
		int N=sc.nextInt();
		//int k=sc.nextInt();
		int a[][]=new int[100000][3];
		for(int i=0;i<N;i++)
			for(int j=0;j<3;j++)a[i][j]=sc.nextInt();

		
		int dp[]=new int[3];
		dp[0]=a[0][0];
		dp[1]=a[0][1];
		dp[2]=a[0][2];
	//	int key=0;
	
		
		
		//int f=0;
		if(N==1)	{int max=Math.max(dp[0], dp[1]);
		max=Math.max(max, dp[2]);
		System.out.println(max);}
		else {
		
			int m[]=new int[3];
		for(int i=1;i<N;i++) {

			
			
			
			//for(int j=1;j<;j++) {if(f==a[i-1][j]) {key=j;break;}}
			m[0]=a[i][0]+Math.max(dp[2],dp[1]);
			m[1]=a[i][1]+Math.max(dp[2],dp[0]);
			m[2]=a[i][2]+Math.max(dp[1],dp[0]);
		//	System.out.println(m[2]);
	//		System.out.println(m[1]);
			
			for(int j=0;j<3;j++) {
				dp[j]=m[j];
			}
			
		}
		int max=Math.max(dp[0], dp[1]);
		max=Math.max(max, dp[2]);
		System.out.println(max);
	}
		
}
	}


Measured memory_bytes: 95400
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<char> c(4);
  REP(i,4) cin >> c[i];
  sort(c.begin(), c.end());
  bool f = false;
  if(c[0] == c[1] && c[2] == c[3] && c[0] != c[2]) f = true;
  YesorNo(f);
  return 0;
}
//templete by private_yusuke

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

int n,b[505],sum;

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


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, r int
	fmt.Scan(&N)
	d := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&d[i])
	}
	for i := 0; i < len(d)-1; i++ {
		for j := i + 1; j < len(d); j++ {
			r += d[i] * d[j]
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();
//int→string
//string→int   int num = atoi(numStr.c_str());

int main() {
    int v[5],ans;
    rep0(i,5){
        cin>>v[i];
        if(v[i]==0){
            ans=i+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3572
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
//typedef long long ll;
#define int long long
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

signed main() {
    fastIO;
    string s; cin>>s;
    int ans=0;

    for(char i: s) {
        ans+= i-'0';
    }

    if(ans%9) cout<<"No\n";
    else cout<<"Yes\n";

    return 0;
}

Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i=0;i<n;i++)
#define llint long long int

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	int ans = 0;
	if (x == 1 & y == 1) {
		ans += 400000;
	}
	if (x == 1) {
		ans += 300000;
	}
	if (x == 2) {
		ans += 200000;
	}
	if (x == 3) {
		ans += 100000;
	}
	x = y;
	if (x == 1) {
		ans += 300000;
	}
	if (x == 2) {
		ans += 200000;
	}
	if (x == 3) {
		ans += 100000;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

const vector<int> FindStrawberryPositions(const int W, const vector<char> &row)
{
    vector<int> positions;
    for (int i = 0; i < W; ++i)
    {
        if (row[i] == '#')
        {
            positions.push_back(i);
        }
    }
    return positions;
}

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> sij(H, vector<char>(W));
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            cin >> sij[i][j];
        }
    }
    bool prevRowHasNoStrawberry = false;
    int noStrawberryRowNum = 0;
    vector<int> latestPositions;
    int strawberryID = 1;
    vector<vector<int>> ans(H, vector<int>(W));
    for (int i = 0; i < H; ++i)
    {
        const auto positions = FindStrawberryPositions(W, sij[i]);
        if (positions.empty())
        {
            prevRowHasNoStrawberry = true;
            ++noStrawberryRowNum;
        }
        else
        {
            // いちごがなかった行を分担する
            int col = 0;
            for (const int position : positions)
            {
                for (; col <= position; ++col)
                {
                    for (int row = i - noStrawberryRowNum; row <= i; ++row)
                    {
                        ans[row][col] = strawberryID;
                    }
                }
                // 行内最後のいちごについては，後ろも担当する
                for (int col = positions.back(); col < W; ++col)
                {
                    for (int row = i - noStrawberryRowNum; row <= i; ++row)
                    {
                        ans[row][col] = strawberryID;
                    }
                }
                ++strawberryID;
            }
            prevRowHasNoStrawberry = false;
            latestPositions = positions;
            noStrawberryRowNum = 0;
        }
    }
    if (prevRowHasNoStrawberry)
    {
        // 遡って担当する
        int col = 0;
        strawberryID -= latestPositions.size();
        for (const int position : latestPositions)
        {
            for (; col <= position; ++col)
            {
                for (int row = H - noStrawberryRowNum; row < H; ++row)
                {
                    ans[row][col] = strawberryID;
                }
            }
            // 行内最後のいちごについては，後ろも担当する
            for (int col = latestPositions.back(); col < W; ++col)
            {
                for (int row = H - noStrawberryRowNum; row < H; ++row)
                {
                    ans[row][col] = strawberryID;
                }
            }
            ++strawberryID;
        }
    }
    for (int row = 0; row < H; ++row)
    {
        for (int col = 0; col < W; ++col)
        {
            cout << ans[row][col];
            if (col < W - 1)
            {
                cout << ' ';
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
import java.util.*;
public class Main {
    public static void main(String[] args) {
 
        Scanner s = new Scanner(System.in);
    	String str = s.next();
    	String[] day = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
    	int[] l = {6,5,4,3,2,1,7};
    	for (int i = 0; i < 7; i++){
			if (str.equals(day[i])) System.out.println(l[i]);

		}

}
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>


int main(void) {
    int N;
    scanf("%d", &N);
    int *W = (int*)malloc(N * sizeof(int));
    int *S = (int*)malloc(N * sizeof(int));
    int sum = 0;
    int d = INT_MAX;
    int i, j;
    for(i=0; i<N; i++) {
        S[i] = 0;
    }

    for(i=0; i<N; i++) {
        scanf("%d", &W[i]);
        sum += W[i];
        for(j=0; j<=i; j++) {
            S[i] += W[j];
        }
    }
    for(i=0; i<N-1; i++) {
        if(abs(2*S[i] - sum) < d) {
            d = abs(2*S[i] - sum);
        }
    }
    printf("%d\n", d);

    free(W);
    free(S);
    return 0;
}


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

namespace ABC96_D
{
    class Program
    {
        static IEnumerable<int> Primes(int maxnum)
        {
            yield return 2;
            yield return 3;
            var sieve = new BitArray(maxnum + 1);
            int squareroot = (int)Math.Sqrt(maxnum);
            for (int i = 2; i <= squareroot; i++)
            {
                if (sieve[i] == false)
                {
                    for (int n = i * 2; n <= maxnum; n += i)
                        sieve[n] = true;
                }
                for (int n = i * i + 1; n <= maxnum && n < (i + 1) * (i + 1); n++)
                {
                    if (!sieve[n])
                        yield return n;
                }
            }
        }


        static void Main(string[] args)
        {

            var n = int.Parse(Console.ReadLine());

            var a = new int[n];

            int i = 0;
            foreach (var j in Primes(55555))
            {
                if (j % 5 == 1)
                {
                    a[i] = j;
                    i++;
                }
                if (i == n) break;
            }

            Console.WriteLine(String.Join(" ", a.Select(x => x.ToString()).ToArray()));
        }

    }
}


Measured memory_bytes: 13396
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;

int main()
{
	int n,t;
	int answer = int(1e9);
	int remember = int(1e9);
	cin >> n >> t;
	vector<int> c(n);
	vector<int> l(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> l[i];
		if (l[i] <= t && remember > c[i]) {
			answer = i;
			remember = c[i];
		}
	}

	if (answer == int(1e9)) {
		cout << "TLE" << endl;
		return 0;
	}
	
		cout << remember << endl;
	
}

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

ll N, K;

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

    ll ans = 0;        
    for (int i = 1; i <= N-K; i++) {
        ans += i;
    }

    for (ll i = 1; i <= N; i++) {
        if (i > K) {
            ans += ((N - i)/i) * (i - K);
            if ((N - i) % i <= i && (N - i) % i != 0) {
                if (K == 0) {
                    ans += max(0LL, ((N - i) % i) - K);
                }
                else {
                    ans += max(0LL, ((N - i) % i) - (K-1));   
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from itertools import accumulate, product

N = int(input())
A = list(map(int, input().split()))
S = list(accumulate(A))
T = sum(A)
ans = 10**16

for j in range(1, N-1):
    PQ = S[j]
    RS = T - S[j]
    #print("PQ RS", PQ, RS)
    
    i1 = bisect(S, PQ/2) - 1
    i2 = bisect_left(S, PQ/2)
    
    k1 = bisect(S, RS/2 + PQ) - 1
    k2 = bisect_left(S, RS/2 + PQ)
    
    for i, k in product([i1, i2], [k1, k2]):
        #print(i, j, k)
        if i < 0 or i==j or j == k or k == N-1:
            continue
        PQRS = [S[i], S[j] - S[i], S[k] - S[j], T - S[k]]
        #print(PQRS)
        ans = min(ans, abs(max(PQRS) - min(PQRS)))

print(ans)

Measured memory_bytes: 90872
class UnionFind
  def initialize(n); @data = Array.new(n,-1); end
  def find(a); @data[a] < 0 ? a : @data[a] = find(@data[a]); end
  def same?(a,b); find(a) == find(b); end
  def size(a); -@data[find(a)]; end
  def unite(a,b)
    a = find(a); b = find(b)
    return if a == b
    a,b = b,a if @data[a] > @data[b]
    @data[a] += @data[b]; @data[b] = a
  end
end

# UnionFind.new(N) := 要素数Nで初期化
# Ai := i番目の要素
# find(i) := Aiが属するグループ
# same?(i,j) := Ai,Ajが同じグループに属する
# size(i) := Aiが属するグループの要素の数
# unite(i,j) := Ai,Ajを同じグループに統合する

n = gets.to_i
uf = UnionFind.new(n+1)

1.upto(n/2) do |i|
  j = n - i
  j += 1 if n.even?
  uf.unite(i,j)
end

g = []
1.upto(n-1) do |i|
  (i+1).upto(n) do |j|
    next if uf.same?(i,j)
    g << [i,j].join(" ")
  end
end

puts g.size
g.each do |v|
  puts v
end


Measured memory_bytes: 2812
N = int(input())
lowid= 0
highid = N-1
print(0)
lowsex = input()
if lowsex=='Vacant':
    exit()
print(N-1)
highsex = input()
if highsex=='Vacant':
    exit()
while highid-lowid>1:
    midid = (lowid+highid)//2
    print(midid)
    midsex = input()
    if midsex=='Vacant':
        exit()
    if (midid-lowid)%2==1 and midsex==lowsex:
        highid = midid
        highsex = midsex
    elif (midid-lowid)%2==0 and midsex!=lowsex:
        highid = midid
        highsex = midsex
    else:
        lowid = midid
        lowsex = midsex

Measured memory_bytes: 38852
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++)cin>>A[i];
  for(int i = 0; n > i; i++){
    for(int j = i; n > j; j++){
      swap(A[i],A[j]);
      int z = A[0];
      bool a = true;
      for(int k = 1; n > k; k++){
        if(z > A[k]){
          a = false;
          break;
        }
        z = A[k];
      }
      if(a){
        cout << "YES" << endl;
        return 0;
      }
      swap(A[i],A[j]);
    }
  }
  cout << "NO" << endl;
}


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

int main() {
 string N;
  cin >> N;
  if (N[0]==N[1]||N[0]==N[2]||N[1]==N[2]) {
    cout << "No"<< endl;
  }
  else {
  cout << "Yes" <<endl;
  }
}


Measured memory_bytes: 256