akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

class Edge{
	int source, sink, id;
	public Edge(int sc, int sk, int id) {
		source = sc; sink = sk; this.id = id;
	}
}
class Main{
	static Edge[] edges;
	static int[][] adj_mat;
	static int N, M;
	static boolean check(int idx) {
		// edge[idx] を削除して連結になるかを判定する
		Stack<Integer> st = new Stack<Integer>();
		st.add(0);
		boolean[] isVisited = new boolean[N];
		Arrays.fill(isVisited, false);
		while(!st.isEmpty()) {
			int now = st.pop();
			isVisited[now] = true;
			for(Edge e : edges) {
				if((e.source != now && e.sink != now) || e.id == idx) continue;
				if(e.source == now) {
					if(isVisited[e.sink]) continue;
					st.add(e.sink);
				}else {
					if(isVisited[e.source]) continue;
					st.add(e.source);
				}
			}
		}
		boolean res = true;
		for(int i = 0; i < N; i++) res &= isVisited[i];
		return res;
	}
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		N = sc.nextInt(); M = sc.nextInt();
		edges = new Edge[M];
		for(int i = 0; i < M; i++) {
			edges[i] = new Edge(sc.nextInt() - 1, sc.nextInt() - 1, i);
		}
		int cnt = 0;
		for(int i = 0; i < M; i++) {
			if(!check(i)) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 23252
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] D = new int[N];
        long sumA = 0;
        long sumB = 0;
        long diff = 0;
        int count = 0;
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
            sumA += A[i];
        }
        for(int i = 0; i < N; i++){
            B[i] = sc.nextInt();
            sumB += B[i];
            D[i] = B[i] - A[i];
            if(A[i] < B[i]){
                diff += B[i] - A[i];
                count++;
            }
        }
        sc.close();
        Arrays.sort(D);

        if(sumA < sumB){
            System.out.println(-1);
        } else {
            int idx = 0;
            while(diff > 0){
                diff += D[idx];
                count++;
                idx++;
            }
            System.out.println(count);
        }

    }
}

Measured memory_bytes: 84664
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int dp[101][10004];

signed main(){
  int n,W;
  cin>>n>>W;
  vector<int> v(n),w(n);
  rep(i,n)cin>>v[i]>>w[i];

  loop(i,1,n+1){
    rep(j,W+1){
      if(j-w[i-1]>=0){
      dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]);
      }else{
      dp[i][j]=dp[i-1][j];
      }
    }
  }

  cout<<dp[n][W]<<endl;

  return 0;
}

Measured memory_bytes: 10896
#!/usr/bin/env python3

n = int(input())
h = list(map(int, input().split()))

ans = 0
count = 0
for i in range(1, n):
    # print(h)
    # print(h[i-1], h[i])
    if h[i-1] >= h[i]:
        count += 1
    else:
        ans = max(count, ans)
        count = 0
    # print(count)
ans = max(count, ans)
print(ans)


Measured memory_bytes: 14252
#include <cstdio>
#include <cmath>
#include <algorithm>

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int k;
    scanf("%d", &k);
    if (a >= b && b >= c) { printf("%d\n", a * (int)pow(2, k) + b + c); }
    else if (b >= a && b >= c) { printf("%d\n", a + b * (int)pow(2, k) + c); }
    else { printf("%d\n", a + b + c * (int)pow(2, k)); }
    return 0;
}

Measured memory_bytes: 128
from collections import deque, defaultdict

def main():
  n=int(input())
  edges=[tuple(map(int,input().split())) for _ in range(n-1)]
  d=defaultdict(list)
  for e in edges:
    d[e[0]].append(e[1])
    d[e[1]].append(e[0])
  def dist(m):
    c=-1
    dl=[-1]*(n+1)
    cv=deque([m])
    nv=deque([1])
    while nv:
      c+=1
      cv.extend(nv)
      nv.clear()
      for e in cv:
        dl[e]=c
        for x in d[e]:
          if dl[x]<0:
            nv.append(x)
      cv.clear()
    return dl[1:]
  fnc=dist(1)
  snk=dist(n)
  j=sum([(fnc[i]<=snk[i])-(fnc[i]>snk[i]) for i in range(n)])
  if j>0:
    print('Fennec')
  else:
    print('Snuke')

if __name__=='__main__':
    main()


Measured memory_bytes: 44952
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
// 素因数分解
vector<pair<ll,ll>> prime_factor(ll num){
	vector<pair<ll,ll>> vpl;
	ll cnt;
	for(ll i=2;i*i<num;i++){
		if(num%i!=0){
			continue;
		}
		cnt=0;
		while(num%i==0){
			num/=i;
			cnt++;
		}
		vpl.push_back(mp(i,cnt));
	}
	if(num>1){
		vpl.push_back(mp(num,1));
	}
	return vpl;
}

// i*(i+1)/2 <= num となる最大の整数を探す
int hoge(int num){
  ll i = sqrt(2*num)+1;
  while(i*(i+1)/2 > num){
    i--;
  }
  return i;
}

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  ll n; cin>>n;
  auto pf = prime_factor(n);
  int cnt = 0;
  for(auto kv : pf){
    int num = kv.second;
    // i*(i+1)/2 <= num となる最大の整数を探す
    cnt += hoge(num);

    // === TLE ===
    // int e = 1;
    // while(e<=num){
    //   num -= e; cnt++; e++;
    // }


  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>

using namespace std;

bool search(string& s, int idx, int accum, string rep) {
  if (idx == 4) {
    if (accum == 7) {
      cout << rep << "=7\n";
      return true;
    }
    return false;
  }

  int digit = s[idx] - '0';

  if (rep.size() != 0) {
    if (search(s, idx + 1, accum + digit, rep + "+" + s[idx]))
      return true;
    if (search(s, idx + 1, accum - digit, rep + "-" + s[idx]))
      return true;
  } else {
    if (search(s, idx + 1, accum + digit, string(1, s[idx])))
      return true;
    if (search(s, idx + 1, accum - digit, string(1, s[idx])))
      return true;
  }
  return false;
}

int main() {
  string s;
  cin >> s;
  search(s, 0, 0, "");
}



Measured memory_bytes: 256
n = gets.to_i
nums = gets.split.map(&:to_i)
nums << 0
costs = []
deleted_costs = []


nums.each_with_index do |i, idx|
  prev_num = idx == 0 ? 0 : nums[idx - 1]
  next_num = nums[idx + 1]
  cost = (i - prev_num).abs
  costs << cost
  break if idx == nums.size - 1
  deleted_cost = ( next_num - prev_num ).abs - (cost + (next_num - i).abs)
  deleted_costs << deleted_cost
end
# p costs
base = costs.inject(:+)
# p deleted_costs
deleted_costs.each { |i| puts base + i }

Measured memory_bytes: 13208
#include <iostream>
#include <string>
using namespace std;
using ll=long long;

int main(){
    int A, B, C;
    ll X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll easy = A * X + B * Y;
    ll maxnum = max(X, Y) * 2;
    for(ll i = maxnum; i > 1; i -= 2){
        ll tmp;
        if (i == maxnum) tmp = C * i;
        else if (X - (i / 2) > 0 && Y - (i / 2) > 0) tmp = A * (X - (i / 2)) + B * (Y - (i / 2)) + C * i;
        else if (X - (i / 2) > 0) tmp = A * (X - (i / 2)) + C * i;
        else if (Y - (i / 2) > 0) tmp = B * (Y - (i / 2)) + C * i;
        if (tmp < easy) easy = tmp;
    }
    cout << easy << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[110];
int main()
{
    int i;
    while(~scanf("%s",s))
    {
        int len=strlen(s);
        int flag=0,ans=0;
        for(i=0;i<len;i++)
        {
            if(s[i]=='C') flag=1;
            if((s[i]=='F') && flag)
            {
                printf("Yes\n");
                ans=1;
                break;
            }

        }
        if(!ans) printf("No\n");
    }

    return 0;
}


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

const int64_t MOD = 1e+9 + 7;

using Graph = vector<vector<int64_t>> ;
Graph G;

int64_t N,K,num;

int64_t P(int64_t x, int64_t y){
    int64_t ans = 1;
    for ( int64_t i = 0; i < y; ++i){
        ans = ( ans * (x-i) ) % MOD;
    }
    return ans;
}

// 現在地v 親p
void dfs( int64_t v, int64_t p ) {
    if ( G[v].size() == 1 ){
        return;
    } else {
        num = ( num * P(K-2,(G[v].size()-1)) ) % MOD;
    }
    for ( int64_t nv: G[v] ){
        if ( nv == p ) continue;
        dfs(nv,v);
    }
    return;
}



int main() {
    cin >> N >> K;
    G.assign(N,vector<int64_t>());
    for ( int i = 0; i < N-1; ++i){
        int64_t a,b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    //cout << "A" << endl;
    num = ( K * P(K-1,G[0].size()) ) % MOD;
    //cout << "A" << endl;
    for ( int64_t v: G[0]) {
        //cout << num << endl;
        dfs(v,0);
    }
    
    cout << num << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 9216
S = input()
flag = 1
if S[0] != "A":
	flag = 0
elif S[2:-1].count("C") != 1:
	flag = 0
else:
	idx = S[2:-1].find("C")
	S2 = S[1:idx+2]+ S[idx + 3:]
	if not S2.islower():
		flag = 0

if flag == 1:
	print("AC")
else:
	print("WA")



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

int main()
{
    long A,B;
    cin >> A >> B;

    if (A > B)
    {
        long tmp = A;
        A = B;
        B = tmp;
    }
    long x = A * B;
long r = A % B;
  while(r!=0){
    A = B;
    B = r;
    r = A % B;
  }
  long ans = x/B;
cout << ans << endl;

}

Measured memory_bytes: 256
count = -1
a = []
while True:
    count += 1
    n = input()
    if n == "0 0":
        break
    a.append(n.split())
    if int(a[count][0]) <= int(a[count][1]):
        print(a[count][0]+" "+a[count][1])
    else:
        print(a[count][1]+" "+a[count][0])

Measured memory_bytes: 8100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N;
	int K;
	int x[100];
	scanf("%d", &N);
	scanf("%d", &K);
	for(int i=0;i<N;i++){
		scanf("%d",&x[i]);
	}

	int ans = 0;
	for(int i=0;i<N;i++){
		ans += 2*min(x[i],K-x[i]);
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
using ll = long long;
/*
    g++ -std=c++11 test.cpp -o test.out && ./test.out
*/

const int MOD = 1e9 + 7;
const int N = 2000001;

int modpow(int a, int b) {
	int ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = 1LL * ans * a % MOD;
		a = 1LL * a * a % MOD;
		b >>= 1;
	}
	return ans;
}

ll F[N],R[N];

void make(){
    F[0] = 1;
    for(int i=1;i<N;i++) F[i] = F[i-1]*i%MOD;
    for(int i=0;i<N;i++) R[i] = modpow(F[i],MOD-2);
}

ll sum(ll a, ll b){
	a += b;
	if(a >= MOD) a -= MOD;
 	if(a < 0) a += MOD;
	return a;
} 

ll mult(ll a, ll b){
	return a * 1ll * b % MOD;
}

ll sub(ll a, ll b){
    a -= b;
    if(a < 0) a += MOD;
    return a;
}

void solve(){
    ll k; cin >> k;

    string str; cin >> str;
    int n = str.size();

    ll ans = 0;
    for(int i = 0; i <= k; i++){
        ans = sum(ans, mult(mult(modpow(26, k - i),modpow(25, i)), (mult(mult(F[n - 1 + i],R[n - 1]),R[i]))));
    }
    cout << ans << endl;

}   

int main()
{    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    make();
    solve();
    
    return 0;
}

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


int main() {
  string s;
  cin >> s;
  if(s=="ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}


Measured memory_bytes: 3596
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)    sort(all(v)); (v).erase(unique(all(v)),(v).end())
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
#define int long long
/*/-----------------------------Code begins----------------------------------/*/

int32_t main(){
fio;
int n,k;
cin>>n>>k;
int a[n];
For(i,0,n)
cin>>a[i];
sort(a,a+n);
int sum=0;
for(int i=0;i<n-k;i++)
    sum+=a[i];
cout<<sum;
return 0;}


Measured memory_bytes: 1792
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; }

int main()
{
    int k, t; cin >> k >> t;
    priority_queue<int> que;
    rep(i, t) {
        int a; cin >> a;
        que.push(a);
    }

    while(!que.empty()){
        int a, b;
        a = que.top(); que.pop();
        if(que.empty()){
            que.push(a);
            break;
        }
        b = que.top(); que.pop();

        int c = min(a, b);
        a -= c;
        b -= c;
        if(a>0) que.push(a);
        if(b>0) que.push(b);
    }

    if(que.empty()){
        pr(0);
    }else{
        int a = que.top();
        pr(a-1);
    }
    return 0;}

Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(10 ** 7)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    # input part
    N = int(input())
    L = LI()
    L.sort()
    m = L[0]
    M = L[N-1]
    ANS = []
    for i in range(1, N-1):
        if L[i] > 0:
            ANS.append((m, L[i]))
            m -= L[i]
            continue
        ANS.append((M, L[i]))
        M -= L[i]
    ANS.append((M, m))
    print(M-m)
    for (x, y) in ANS:
        print(x, y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19176
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;
  if (a <= 5)
    cout << 0 << endl;
  else if (a <= 12)
    cout << b / 2 << endl;
  else
    cout << b << endl;
  return 0;
}


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

int main() {
    int ans = 0;
    int m = 10;
    int m_i = 5;
    int A[5];
    for (int i = 0; i < 5; ++i){
        cin >> A[i];
    }

     for (int i = 0; i < 5; ++i){
        int d = A[i] % 10;
        if (m > d && d > 0){
            m = d;
            m_i = i;
        }
     }

    for (int i = 0; i < 5; ++i){
        if (i == m_i) ans += A[i];
        else ans += (int)((A[i] + 9)/10) * 10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
f;main(a,b,q){for(;q=0,scanf("%d%d",&a,&b),a;q?:puts("NA"))for(f?puts(""):0;a<=b;a++,f=1)if(a%4==0&&a%100||a%400==0)printf("%d\n",a),q++;exit(0);}







////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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


int main() {
	
	int N, t, a;
	cin >> N >> t >> a;
	vector<pair<double,int>> s(N);
	for(int i=0; i<N; i++){
		int h;
		cin >> h;
		s.at(i) = make_pair(abs(t-h*0.006-a), i);
	}
	sort(s.begin(),s.end());
	cout << s.front().second+1 << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    string S;
    cin>>N>>S;
    vector<int> dplw(N),dpre(N);
    int allE=0,allW=0;//全体の東向きの人の数と西向きの人の数
    //dplw[i]:=i番目の人の左側にいる,西を向いている人の総数
    //dpre[i]:=i番目の人の右側にいる,東を向いている人の総数
    dplw[0]=0;
    dpre[N-1]=0;//初期値
    rep(i,N){
        if(S.at(i)=='E'){
            allE++;
        }
    }
    allW=N-allE;
    rep2(i,1,N){
        if(S.at(i-1)=='W'){
            dplw[i]=dplw[i-1]+1;
        }else{
            dplw[i]=dplw[i-1];
        }
    }
    for(int i=N-1;i>0;i--){
        if(S.at(i)=='E'){
            dpre[i-1]=dpre[i]+1;
        }else{
            dpre[i-1]=dpre[i];
        }
    }
    int ans=1000000;
    //i番目の人がリーダーになった時の転換回数は、dplw[i]+dpre[i]
    rep(i,N){
    //   cout << dplw[i] << " " << dpre[i]<<endl;
        ans=min(ans,dplw[i]+dpre[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2964
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b ] <- readInts
	print $ maximum $ [ (+), (-), (*) ] <*> pure a <*> pure b

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k,i,l,r,ans = 0;scanf("%lld%lld",&n,&k);
  for(i=k+1;i<=n;i++){
    if(i!=1) ans += n/i*(i-k);
    l = n/i*i+k;r = n/i*i+i;
    if(n>=l) ans += min(n-l+1,r-l);
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().rstrip().split())

BL = (300001-1).bit_length()
WIDTH = pow(2, BL)
BUFSIZE = pow(2, BL+1) - 1
BASE = BUFSIZE - WIDTH
DEFAULT = 0

buf = [DEFAULT] * BUFSIZE

def update(i, x):
    i += BASE
    buf[i] = x
    i = (i-1) // 2
    while i >= 0:
        buf[i] = compare(buf[2*i+1], buf[2*i+2])
        i = (i-1) // 2

# [q_left, q_right]
def search(left, right):
    ansl = ansr = DEFAULT
    left += BASE
    right += BASE
    while left < right:
        if not (left & 1):
            ansl = compare(ansl, buf[left])
            left += 1
        if right & 1:
            ansr = compare(ansr, buf[right])
            right -= 1
        left = (left-1) // 2
        right = (right-1) // 2
    if left == right:
        ansl = compare(ansl, buf[left])
    return compare(ansl, ansr)

def compare(v1, v2):
    return v1 if v1 > v2 else v2

for _ in range(N):
    a = int(input().rstrip())
    maxlen = search(max(0, a-K), min(a+K, 300000))
    update(a, maxlen+1)
print(search(0, 300000))


Measured memory_bytes: 108812
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int s,cnt=1; cin>>s;
    vector<int> a(1000010);
    while(1){
        a[s]++;
        if(a[s]>=2) break;
        if(s%2==0) s=s/2;
        else s=3*s+1;
        cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 7212
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
// driver code 
int main() 
{ 
    int n,q;
    cin>>n>>q;
    int a[n]; 
    for(int b=0;b<n;b++)
        cin>>a[b];
    Query queries[q]; 
    for(int b=0;b<q;b++)
    {
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        queries[b].l = u; 
        queries[b].r = v; 
        queries[b].idx = b; 
    }
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 

Measured memory_bytes: 19308
#include<iostream>

using namespace std;

int main(void){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int num=0;
    int max=0;
    for(int i=0;i<n;i++){
        if(max<=h[i]){
            max=h[i];
            num++;
        }
    }
    cout<<num<<endl;
    return 0;
}

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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;

ll k;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> k;
	if (k <= 50) {
		cout << 50 << '\n';
		for (int i = 0; i < k; ++i) cout << "50 ";
		for (int i = 0; i < 50 - k; ++i) cout << "0 ";
	} else {
		cout << 50 << '\n';
		ll universal = k / 50;
		ll extra = k % 50;
		k %= 50;
		// start + extra - universal = 49
		// cout << universal << ' ' << extra << endl;
		for (int i = 0; i < 50; ++i) {
			if (k > 0) {
				cout << 50 + universal << ' ';
			} else {
				cout << 49 + universal - extra << ' ';
			}
			--k;
		}
	}
}


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

template<class Type_k,class Type_p>
Type_p mod_pow(long long n,Type_k k,Type_p p){//n^k(mod p).
	if(k==0) return 1;
	long long res=mod_pow(n*n%p,k/2,p);
	if(k&1) res=res*n%p;
	return res;
}

/*拡張ユークリッドの互除法(ax+by=GCD(a,b)の(x,y)を求める.)*/
int extgcd(int a,int b,int &x,int &y){
	int d=a;
	if(b!=0){
		d=extgcd(b,a%b,y,x);
		y=y-(a/b)*x;
	}else{
		x=1, y=0;
	}
	return d;//返り値はGCD(a,b).
}

int mod_inverse(int a,int m){//aの逆元を求める.
	int x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	
	llong ans=mod_pow(2LL,n,MOD)-1;
	
	llong tmp=1;
	REP(i,a) tmp=tmp*(n-i)%MOD;
	llong hoge=1;
	REP(i,a) hoge=hoge*(i+1)%MOD;
	tmp=tmp*mod_inverse(hoge,MOD)%MOD;
	
	llong tmpp=1;
	REP(i,b) tmpp=tmpp*(n-i)%MOD;
	llong hogee=1;
	REP(i,b) hogee=hogee*(i+1)%MOD;
	tmpp=tmpp*mod_inverse(hogee,MOD)%MOD;
	
	ans-=tmp+tmpp;
	while(ans<0) ans+=MOD;
	
	cout<<ans%MOD<<endl;
}

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

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

  int64_t sum=1e10;
  for(int x=-100;x<=100;++x){
    int64_t subsum=0;
    for(int i=0;i<N;++i) subsum += (x-a[i])*(x-a[i]);
    sum = min(sum,subsum);
  }

  cout<<sum<<endl;
}

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

using namespace std;

bool is_sq(vector<int> a, vector<int> b) {
    int d2 = 0;
    for (int i = 0; i < a.size(); ++i) {
        d2 += pow(a[i] - b[i], 2.0);
    }
    int m = static_cast<int>(sqrt(d2));
    return abs(m*m - d2) < 1e-6;
}
int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < n-1; ++i) {
        for (int j = i+1; j < n; ++j) {
            if (is_sq(x[i], x[j])) {
                ++ans;
            }
        }
    }

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

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

int main() {
	int N;
	cin >> N;
	vector<vector<int>> edge(N);
	for(int i=0;i<N-1;i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	// 0からN-1までの最短距離を求める
	// 0とN-1の真ん中
	vector<int> before(N, 0);
	queue<pair<int,int>> q;
	q.push({-1, 0});
	while(!q.empty()) {
		auto tmp = q.front(); q.pop();
		int bef = tmp.first;
		int now = tmp.second;
		if(bef != -1) {
			before[now] = bef;
		}
		for(int i=0;i<edge[now].size();i++) {
			int next = edge[now][i];
			if(next == bef) continue;
			q.push({now, next});
		}
	}
	vector<int> route;
	int now = N - 1;
	route.push_back(now);
	while(now != 0) {
		int bef = before[now];
		route.push_back(bef);
		now = bef;
	}
	reverse(route.begin(), route.end());
	int fcnt = 0;
	int forbidden = route[(route.size()+1)/2];

	queue<pair<int,int>> qq;
	qq.push({-1,0});
	while(!qq.empty()) {
		auto tmp = qq.front(); qq.pop();
		int bef = tmp.first;
		int now = tmp.second;
		fcnt++;
		for(int i=0;i<edge[now].size();i++) {
			int next = edge[now][i];
			if(bef == next or next == forbidden) continue;
			qq.push({now,next});
		}
	}
	int scnt = N - fcnt;
	cout << ((fcnt>scnt) ? "Fennec" : "Snuke") << endl;
}

Measured memory_bytes: 6780
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000001

using namespace std;
#define ll long long
#define dbg if(0)



int main(){
    int n,t;
    ll ans=-1;
    cin>>n>>t;
    vector<ll> data(t,0);
    
    for(int i=0;i<n;i++){
        int in,out;
        cin>> in>>out;
        data[in]+=1;
        data[out]-=1;
    }
    ll rui[t+1];
    rui[0]=0;
    for(int i=1;i<=t;i++){
        rui[i]=rui[i-1]+data[i-1];
        dbg cout<<rui[i]<<" ";
        ans=max(rui[i],ans);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4420
#include<iostream>
#include<algorithm>
using namespace std;
int main (){
    int n;
    int mid1,mid2;
    cin >> n;
    int m[n],b[n];
    for(int i=0;i<n;i++){
        cin >> m[i];
        b[i] = m[i];
    }
    sort(m, m+n);
    for(int i=0;i<n; i++){
        cout << (b[i]<=m[n/2 - 1]?m[n/2]:m[n/2 -1]) << endl;
    }
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    char s;
    cin >> s;
    cout << (char)(s+1) << endl;
}


Measured memory_bytes: 256
# Aizu Problem 0080: Third Root
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def third_root(q):
    x = q / 2
    while abs(x**3 - q) >= 1e-5 * q:
        x = x - (x**3 - q) / (3 * x**2)
    return x


for line in sys.stdin:
    n = int(line)
    if n == -1:
        break
    print("%f" % third_root(n))

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

int main () {
  string h;
  cin >> h;
  int max;
  max = 0;
  char a[4] = {'A', 'T', 'G', 'C'};
  for (int i = 0; i < h.size(); i++) {
    for (int j = i; j < h.size(); j++) {
      // i ~ jまで取る
      string sub = h.substr(i, j - i + 1);
      bool ok = true;
      for (int l = 0; l < sub.size(); l++) {
        for (int q = 0; q < 4; q++) {
          if (sub[l] == a[q]) {
            break;  
          }  
          if (q == 3) {
            ok = false;  
          }
        }    
      }
      if (ok == true) {
        if ((int) sub.size() >= max) {
          max = sub.size();  
        }  
      }
    }  
  }
  cout << max << endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

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

	if (n % 2 == 0) {
		cout << n / 2 - 1;;
	} else {
		cout << (n - 1) / 2;
	}

	return 0;
}

Measured memory_bytes: 256
//A,Elebereth,Gilthoniel mantae!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring> 
#include<map>
using namespace std;
int dis[205][205];int rr[10];
int main()
{
	int n,m,r;cin>>n>>m>>r;for(int i=0;i<n;i++) for(int j=0;j<n;j++) dis[i+1][j+1]=1e9;
	for(int i=0;i<r;i++) cin>>rr[i];
	for(int i=0;i<m;i++)
	{
		int a,b,c;cin>>a>>b>>c;dis[a][b]=dis[b][a]=c;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
			{
				dis[k][j]=dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k]);
			}
		}
	}
	sort(rr,rr+r);int ans=1e9;
	do
	{
		int uo=0;
		for(int i=0;i<r-1;i++)
		{
			uo+=dis[rr[i]][rr[i+1]];
		}	
		ans=min(ans,uo);
	}while(next_permutation(rr,rr+r));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
def mpow(x, n):
    result = 1
    while n != 0:
        if n & 1 == 1:
            result *= x
            result %= 1000000007
        x *= x
        x %= 1000000007
        n >>= 1
    return result


def mcomb(n, k):
    a = 1
    b = 1
    for i in range(k):
        a *= n - i
        a %= 1000000007
        b *= i + 1
        b %= 1000000007
    return a * mpow(b, 1000000005) % 1000000007


n, a, b = map(int, input().split())

result = mpow(2, n) - 1
result -= mcomb(n, a)
result + 1000000007
result %= 1000000007
result -= mcomb(n, b)
result + 1000000007
result %= 1000000007
print(result)


Measured memory_bytes: 3064
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

SA = [0]
SB = [0]

tmp_A, tmp_B = 0 ,0

for i in range(N):
    tmp_A += A[i]
    if tmp_A <= K:
        SA.append(tmp_A)
    else:
        break

for i in range(M):
    tmp_B += B[i]
    if tmp_B <= K:
        SB.append(tmp_B)
    else:
        break

ans = 0
cursol_B = len(SB) - 1

for i in range(len(SA)):
    while SA[i] + SB[cursol_B] > K:
        cursol_B -= 1
        
    ans = max(ans, i + cursol_B)

print(ans)

Measured memory_bytes: 42516
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int alfabets[26];
int main() {
    string s;
    cin >> s;
    rep(i, s.size()){
        alfabets[(int)s[i] - 97] += 1;
    }
    rep(i, 26){
        if (alfabets[i] == 0){
            cout << (char)(i+97) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

int main(){
  string n;
  cin >> n;
  int ans = 0;
  rep(i,n.size()){
    if(n[i] == '9') ans ++;
  }

  if(ans == 0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include<iomanip>
using namespace std;
int A, B, H, M;

long double kakudo(long double a, long double b)
{
	if (a - b >= -180 && a - b <= 180) return a - b;
	else if (a - b > 180) return b + 360 - a;
	else if (a - b < -180) return a + 360 - b;
}

int main()
{	
	cin >> A >> B >> H >> M;
	long double jisin, funsin;
	jisin = (60 *(long double) H +(long double) M) / 2;
	funsin = 6 * M;
	long double c = kakudo(jisin,funsin);
	long double ans = (long double)(A * A + B *B) - (long double)(2*A * B) * cosl(M_PI*c/180);
	
	cout << setprecision(12)<<pow(ans,0.5) << endl;
}


Measured memory_bytes: 4164
# abc116_a.py
# https://atcoder.jp/contests/abc116/tasks/abc116_a

# A - Right Triangle /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 直角三角形 ABCがあります。∠ABC=90°です。
# 三角形 ABCの三辺の長さである |AB|,|BC|,|CA| が与えられるので、直角三角形 ABCの面積を求めて下さい。
# ただし、三角形 ABCの面積は整数となることが保証されています。

# 制約
#     1≦|AB|,|BC|,|CA|≦100
#     入力はすべて整数である。
#     三角形 ABCの面積は整数である。

# 入力
# 入力は以下の形式で標準入力から与えられます。
# |AB| |BC| |CA|

# 出力
# 三角形 ABCの面積を出力してください。

# 入力例 1
# 3 4 5

# 出力例 1
# 6

# tri

# この三角形の面積は 6です。

# 入力例 2
# 5 12 13

# 出力例 2
# 30

# この三角形の面積は 30です。

# 入力例 3
# 45 28 53

# 出力例 3
# 630

# この三角形の面積は 630です。


def calculation(lines):
    # X = lines[0]
    # N = int(lines[0])
    ab, bc, ca = list(map(int, lines[0].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))
    
    result = int(ab*bc/2)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 4 5']
        lines_export = [6]
    if pattern == 2:
        lines_input = ['5 12 13']
        lines_export = [30]
    if pattern == 3:
        lines_input = ['45 28 53']
        lines_export = [630]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
// AOJ GRL_5_B Height of a Tree
// 2019.3.9 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

int n;
typedef struct { int to, w; } T;
T *tbl[10005]; int hi[10005];
int ans[10005];

typedef struct { int id, w; } Q;
Q q[10005]; int end;
char visited[10005];
int max_id, max_w;

void bfs(int id)
{
	int i, s, t, w, ww;

	memset(visited, 0, n*sizeof(visited[0]));
	q[0].id = id, q[0].w = 0, end = 1, visited[id] = 1, max_w = 0;
	while (end) {
		s = q[--end].id, w = q[end].w;
		for (i = 0; i < hi[s]; i++) {
			t = tbl[s][i].to;
			if (visited[t]) continue;
			visited[t] = 1, ww = w + tbl[s][i].w;
			if (ww > ans[t]) ans[t] = ww;
			q[end].id = t, q[end++].w = ww;
			if (ww > max_w) max_w = ww, max_id = t;
		}
	}
}

int main()
{
	int i, k, s, t, w;
	int *memo, sz;

	n = in();
	memo = malloc(n * 3 * sizeof(int));
	sz = 0; for (i = 0; i < n-1; i++) {
		memo[sz++] = s = in();
		memo[sz++] = t = in();
		memo[sz++] = in();
		hi[s]++, hi[t]++;
	}
	for (i = 0; i < n; i++) tbl[i] = malloc(hi[i] * sizeof(T));
	memset(hi, 0, n*sizeof(hi[0]));
	i = 0; while (i < sz) {
		s = memo[i++], t = memo[i++], w = memo[i++];
		k = hi[s]++, tbl[s][k].to = t, tbl[s][k].w = w;
		k = hi[t]++, tbl[t][k].to = s, tbl[t][k].w = w;
	}
	free(memo);

	bfs(0);
	bfs(max_id);
	bfs(max_id);
	for (i = 0; i < n; i++) out(ans[i]);
	return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    map<int,int> cnt;
    vi a(N);
    Rep(i,N){
        Scd(a[i]);
        a[i] -= (i+1);
    }

    ll ans = 0;
    RRep(i,N){
        ans += cnt[-2*i-2-a[i]];
        cnt[a[i]]+=1;
    }

    printf ("%lld\n", ans );

    return 0;
}



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

int main(){
    int A,B,C,D,ans=0;
    cin >> A >> B >> C >> D;
    vector<int> vec(101);
    for(int i=A;i<B+1;i++){
        vec[i]++;
    }
    for(int i=C;i<D+1;i++){
        vec[i]++;
    }
    for(int i=0;i<101;i++){
        if(vec[i]==2)
        ans++;
    }
    if(ans){
        cout << ans-1 << endl;
    }
    else
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n, k;
  cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
a *= 100
b *= 100

W = []
for i in range(f+1):
    for j in range(f+1):
        w = a*i + b*j
        if w <= f and w > 0:
            W.append(w)
S = []
for i in range(f+1):
    for j in range(f+1):
        s = c*i + d*j
        if s <= f:
            S.append(s)

cmax = -1
solubility = e/(e+100)
argmax = 0, 0

for w in W:
    for s in S:
        if w+s > f:
            continue

        concentration = s/(w+s)

        if cmax < concentration <= solubility:
            cmax = s/(w+s)
            argmax = w+s, s

print(*argmax)


Measured memory_bytes: 52316
import statistics
n = int(input())
a = list(map(int, input().split()))
a = [a[i]-(i+1) for i in range(n)]
# print(a)
med = statistics.median_low(a)
ans = 0
for i in range(len(a)):
    ans += abs(a[i] - med)
print(ans)


Measured memory_bytes: 27236
#include <iostream>
using namespace std;
int main(){
	int a,b,c,buf;
	cin >> a >> b >> c;
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	if(b>c){
		buf=b;
		b=c;
		c=buf;
	}
	if(a>b){
		buf=a;
		a=b;
		b=buf;
	}
	cout << a << " "<< b << " " << c << endl;
	
	return 0;
}



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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359;
#define inf (1 << 21);
#define mod 1000000007;

int main() {
    int N, K; cin >> N >> K;
    int R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    vector<vector<char>> t(K);
    for (int i = 0; i < N; i++) {
        int m = i % K;
        t.at(m).push_back(T.at(i));
    }
    int ans = 0;
    for (int i = 0; i < K; i++) {
        char prev = 'n';
        for (int j = 0; j < t.at(i).size(); j++) {
            if (t.at(i).at(j) != prev) {
                if (t.at(i).at(j) == 'r') {
                    ans += P;
                    prev = 'r';
                }
                else if (t.at(i).at(j) == 's') {
                    ans += R;
                    prev = 's';
                }
                else {
                    ans += S;
                    prev = 'p';
                }
            }
            else {
                if (j < t.at(i).size() - 1) {
                    if (t.at(i).at(j + 1) == 'r') {
                        prev = 's';
                    }
                    else if (t.at(i).at(j + 1) == 's') {
                        prev = 'p';
                    }
                    else {
                        prev = 'r';
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>

int main()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif

int n,i,j;

scanf("%d",&n);

int x[n-1],y[n];

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


for(i=0;i<n-1;i++)
     y[x[i]-1]++;

for(i=0;i<n;i++)
	printf("%d\n",y[i]);

}
 

Measured memory_bytes: 3284
N = int(input())
A = [int(input()) for i in range(N)]

a = max(A)
A_max = []
A_ = A[:]

for i in range(N):
  if A[i] == a:
    A_[i] = 0
    break
    
a_ = max(A_)    
    
for i in range(N):
  if A[i] != a:
    A_max.append(a)
  else:
    A_max.append(a_)
    
for i in A_max:
  print(i)

Measured memory_bytes: 15700