akhauriyash/Code-Regression huggingface dataset:
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}

func nextIntSplit() []int {
	splitted := strings.Fields(nextLine())
	n := len(splitted)
	res := make([]int, n)
	for i, str := range splitted {
		res[i], _ = strconv.Atoi(str)
	}
	return res
}

type edge struct {
	to   int
	cost uint
}

func dfs(graph [][]edge, costs []uint, node int, prev int, totalCost uint) {
	paths := graph[node]
	for _, p := range paths {
		if p.to != prev {
			cost := totalCost + p.cost
			costs[p.to] = cost
			dfs(graph, costs, p.to, node, cost)
		}
	}
}

func main() {
	n := nextInt()

	graph := make([][]edge, n+1)
	for i := 0; i < n-1; i++ {
		arr := nextIntSplit()
		a, b, cost := arr[0], arr[1], uint(arr[2])
		graph[a] = append(graph[a], edge{b, cost})
		graph[b] = append(graph[b], edge{a, cost})
	}

	qk := nextIntSplit()
	q, k := qk[0], qk[1]

	costs := make([]uint, n+1)
	dfs(graph, costs, k, -1, 0)

	for i := 0; i < q; i++ {
		q := nextIntSplit()
		fmt.Println(costs[q[0]] + costs[q[1]])
	}
}

Measured memory_bytes: 64128
#include <stdio.h>
#include <string.h>
int main(void){
  int A,B;
  scanf("%d",&A);
  scanf("%d",&B);
  if(A+B>=A-B&&A+B>=A*B){
    printf("%d\n",A+B);
  }
  else if(A-B>=A+B&&A-B>=A*B){
    printf("%d\n",A-B);
  }
  else{
    printf("%d",A*B);
  }
  return 0;
}

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

long long min(long long a,long long b){
  if(a < b){
    return a;
  }
  return b;
}

int compare_int(const void *b,const void *a){
  if(*(long*)a-*(long*)b > 0) return 1;
  return -1;
}

int main(void){
  int X,Y,Z,K;
  scanf("%d%d%d%d",&X,&Y,&Z,&K);

  long long A[X],B[Y],C[Z];
  for(int i = 0;i < X;i++) scanf("%lld",&A[i]);
  for(int i = 0;i < Y;i++) scanf("%lld",&B[i]);
  for(int i = 0;i < Z;i++) scanf("%lld",&C[i]);

  long long D[X*Y];
  int cnt = 0;
  for(int i = 0;i < X;i++){
    for(int j = 0;j < Y;j++){
      D[cnt++] = A[i]+B[j];
    }
  }

  qsort(D,X*Y,sizeof(long long),compare_int);
  qsort(C,Z,sizeof(long long),compare_int);

  cnt = 0;
  long long E[min(K,X*Y)*min(K,Z)];
  for(int i = 0;i < min(K,X*Y);i++){
    for(int j = 0;j < min(K,Z);j++){
      E[cnt++] = D[i]+C[j];
    }
  }

  qsort(E,min(K,X*Y)*min(K,Z),sizeof(long long),compare_int);

  for(int i = 0;i < K;i++){
    printf("%lld\n",E[i]);
  }


  return 0;
}

Measured memory_bytes: 54908
import sys
sys.setrecursionlimit(1000000)
N, Q = map(int, sys.stdin.readline().split())
a_b = [list(map(int, sys.stdin.readline().split())) for _ in range(N-1)]
p_x = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

rin = [[] for _ in range(N)]
for v in a_b:
    rin[v[0]-1].append(v[1]-1)
    rin[v[1]-1].append(v[0]-1)

score = [0 for _ in range(N)]
for ele in p_x:
    score[ele[0]-1] +=ele[1]
#print(score)

def dfs(p, bp=-1):
    for c in rin[p]:
        if c != bp:
            #print(c)
            score[c]+= score[p]
            dfs(c, p)

dfs(0)
print(*score)

Measured memory_bytes: 350252
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	int A, B, C, D, E,ans;
	ans = 0;
	vint a(5);
	cin >> A >> B >> C >> D >> E;
	a[0] = 10 - (A % 10);
	a[1] = 10-(B % 10);
	a[2] = 10-(C % 10);
	a[3] =10- (D % 10);
	a[4] = 10-(E % 10);
	for (int i = 0; i < 5; i++)if (a[i] == 10)a[i] = 0;
	sort(a.begin(), a.end());
	for (int i = 0; i<4 ; i++)ans += a[i];
	ans += A + B + C + D + E;
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>

int n;
int a[20];

int dfs(int now,int x,int d){

	if(now == x)
		return 1;
		
	if(now > x || d == n)
		return 0;
	
	if(dfs(now+a[d],x,d+1))
		return 1;
	
	if(dfs(now,x,d+1))
		return 1;
	
	return 0;
}

int main(){
	int i,q,x;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&x);
		if(dfs(0,x,0))
			printf("yes\n");
		else 
			printf("no\n");
	}
	
	return 0;
	
}


Measured memory_bytes: 2144
n, m = list(map(int, input().split()))
maxlim = int(m**0.5)+1
minj = m
for j in range(1,maxlim+1):
    rem = m%j
    if rem == 0:
        div = m//j
        if j >= n and j < minj:
            minj = j
        elif div >= n and div < minj:
            minj = div

k = m//minj
print(k)


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

#define int long long
#define F first
#define S second
#define vi vector<int>


int findTrailingZeros(int n)
{
    // Initialize result
    int count = 0;

    // Keep dividing n by powers of
    // 5 and update count
    for (int i = 5; n / i >= 1; i *= 5)
        count += n / i;

    return count;
}

void mymain(){
    int n;
    cin >> n;
    if(n&1)
        cout << 0 << endl;
    else{
        int ans = findTrailingZeros(n/2);
        cout << ans << endl;
    }
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        mymain();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>

using namespace std;

typedef pair<long long,int> P; // cost & to

struct EDGE {
    int from;
    int to;
    long long len;
    EDGE() {}
    EDGE(int a,int b,int c) {
        this->from=a; this->to=b; this->len=c;
    }
};

#define MAX(a,b) ((a)>(b)?(a):(b))
#define ABS(a) ((a)>0?(a):(-(a)))

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

    vector<P> r[N];
    vector<EDGE> e;
    for(int i=0; i<M; ++i) {
        int a,b;
        long long cost;
        cin >> a >> b >> cost;
        r[a-1].push_back(P(cost,b-1));
        r[b-1].push_back(P(cost,a-1));
        e.push_back(EDGE(a-1,b-1,cost));
    }

    unordered_map<int,long long> cst; // town & cost
    for(int i=0; i<K; ++i) {
        int town;
        cin >> town;
        cst[town-1]=0;
    }

    priority_queue<P,vector<P>,greater<P> > q;
    for(auto x : cst) { // x = shoping town
        for(auto t : r[x.first]) { // t = directry connected to town x ( type P )
            q.push(t);
        }
    }

    while(cst.size()!=N) {
        P p=q.top(); q.pop();
        if(cst.find(p.second)!=cst.end()) continue;
        cst[p.second]=p.first;
        for(auto t : r[p.second]) {
            if(cst.find(t.second)!=cst.end()) continue;
            q.push(P(p.first+t.first,t.second));
        }
    }

    long long ans=0;
    for(auto edg : e) {
        ans=MAX(ans,(cst[edg.from]+cst[edg.to]+edg.len+1)/2);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n,d;cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  rep(i,n)rep(j,d)cin>>x[i][j];
  int ans=0;
  rep(i,n)for(int j=i+1;j<n;j++){
    int cnt=0;
    rep(k,d){
      int a=abs(x[i][k]-x[j][k]);
      cnt+=a*a;
    }
    for(int k=0;k<=cnt;k++){
      if(k*k==cnt)ans++;
    }
  }
  cout<<ans<<endl;
}

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

typedef long long   ll;
typedef long double ld;

using namespace std;
const ld pi=2*acos(0.0);
ll mod = 998244353;

int main() {
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
 // ios::sync_with_stdio(0);
 // cin.tie(0);
    ll k, a , b;
    cin >> k >> a >> b;
    ll ans = k + 1ll;
    ll res = b;
    if(a >= b || a >= k)
        res = 0;
    else{
        res = b;
        k -= a;
        k --;
        ll Q = a + 2;
        res += (k / 2)*(b - a) +  k%2;
    }
    cerr << res << endl;
    cout << max(ans, res);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	unsigned n; cin >> n;
	vector<vector<pair<unsigned, unsigned>>> e(n);
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		e[a].push_back({ b, i });
		e[b].push_back({ a, i });
	}
	unsigned m = 0; rep(i, n) { m = max(m, (unsigned)e[i].size()); }
	vector<pair<unsigned, unsigned>> ncol(n);
	rep(i, n) ncol[i] = { 0, -1 };
	vector<unsigned> ecol(n - 1);
	stack<unsigned> st; st.push(0);
	while (!st.empty()) {
		unsigned p = st.top(); st.pop();
		unsigned skipc = ncol[p].first;
		unsigned skipn = ncol[p].second;
		unsigned colori = 1;
		rep(i, e[p].size()) {
			auto pe = e[p][i];
			if (skipn == pe.first) continue;
			if (colori == skipc) colori++;
			ncol[pe.first].first = colori;
			ncol[pe.first].second = p;
			ecol[pe.second] = colori;
			st.push(pe.first);
			colori++;
		}
	}

	cout << m << endl;
	rep(i, n - 1) cout << ecol[i] << endl;
}

int main() {

	solve();

	return 0;
}


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

const int maxn = 3e5+10;

int n, a[maxn], cnt[maxn], sum[maxn], tmp[maxn], len, cur, ans;

bool check(int x, int y=1) {
	if (x > n/cur) return 0;
	int tmp = (cnt+len+1)-lower_bound(cnt+1, cnt+len+1, x);
	if (tmp >= cur) return cnt[len-cur+1] >= x;
	else return sum[len-tmp]/(cur-tmp) >= x;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	sort(cnt+1, cnt+n+1);
	len = (cnt+n+1)-upper_bound(cnt+1, cnt+n+1, 0);
	rotate(cnt+1, upper_bound(cnt+1, cnt+n+1, 0), cnt+n+1);
	for (int i = 1; i <= len; ++i) sum[i] = sum[i-1] + cnt[i];
	for (int i = 1; i <= n; ++i) tmp[i] = i;
	for (cur = 1, ans = n; cur <= n; ++cur) {
		while (ans && !check(ans)) ans--;
		cout << ans << endl;
	}
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    int p,q;
    cin>>p>>q;
    int x=p-a;
    int y=q-b;
    cout<<p-y<<" "<<q+x<<" "<<a-y<<" "<<b+x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
using mp = map<int,int>;
const int MN = 1e5+2, MOD = 1e9+7;
char s[MN];
int main () {
	int n;
	scanf ("%d",&n);
	scanf ("%s",s); int len = strlen(s);
	for (int i = 0; i < len; i++) {
		s[i] = ((s[i]-'A')+n)%26+'A';
	}
	printf ("%s\n",s);
    return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    int ans=0;

    int left=x;

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

    sort(m.begin(),m.end(),greater<int>());

    for(int i=0;i<n;i++){
        left-=m[i];
        ans++;
    }
    int add=left/m[n-1];

    ans+=add;

    cout << ans << endl;

    



}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v, w;
    for(int i = 0; i < 10; i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    for(int i = 0; i < 10; i++)
    {
        int x;
        cin >> x;
        w.push_back(x);
    }
    sort(v.begin(), v.end());
    sort(w.begin(), w.end());
    int sum1 = v[9] + v[8] + v[7];
    int sum2 = w[9] + w[8] + w[7];
    cout << sum1 << " " << sum2 << endl;
    return 0;
}




Measured memory_bytes: 3128
import sys
input=sys.stdin.readline

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

m=1000

for i in range(n-1):
    if a[i+1]>a[i]:
        k=m//a[i]
        m+=a[i+1]*k-a[i]*k

print(m)

Measured memory_bytes: 61724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
int main(){
  long n;
  cin >> n;
  long nod = n*(n+1)*(n+2)/6;
  long edg = 0;
  rep(i,n-1){
    long u,v;
    cin >> u >> v;
    if(u > v) swap(u,v);
    edg += u * (n-v+1);
  }
  cout << nod - edg << endl;
}



Measured memory_bytes: 3628
#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main(int argc, char** argv) {
    int tam;
    long double dTotal=0;
    scanf("%d", &tam);
    int pos[tam][2];
    for (int i = 0; i < tam; i++) {
        scanf("%d %d",&pos[i][0],&pos[i][1]);
    }
    for (int i = 0; i < tam; i++) {
        for (int j = 0; j < tam; j++) {
            if(i==j)
                continue;
            dTotal+=sqrt((pos[i][0]-pos[j][0])*(pos[i][0]-pos[j][0])+(pos[i][1]-pos[j][1])*(pos[i][1]-pos[j][1]));
        }
    }
    cout << fixed << setprecision(10);
    cout << dTotal/tam;


    return 0;
}



Measured memory_bytes: 256
S['= r'],m[4]['= r'],W,z,d[4]={1,-1},k,i;

f(i){
	return m[k][i]=S[i]+47?0:m[k][i]?:1+f(i+d[k]);
}

main(t){
	for(d[2]-=d[3]=scanf("%*d%d ",&W)+W;S[i-~W]=~getchar();++i);
	for(;i--;z=fmax(z,t))for(t=k=0;k<4;++k)t+=f(i-~W);
	printf("%d",z-3);
}


Measured memory_bytes: 78464
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
ans = 0
MIN = 10 ** 8
for i in range(N):
    if MIN > abs(A - (T - H[i] * 0.006)):
        MIN = abs(A - (T - H[i] * 0.006))
        ans = i+1
print(ans)

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

int main() {
    // C: A のカウンティング配列
    // D[x] := C の中に x 以上が何個あるか
    // S: D の累積和
    int N; cin >> N;
    vector<long long> C(N, 0);
    vector<long long> D(N+1, 0);
    vector<long long> S(N+2, 0);
    for (int i = 0; i < N; ++i) {
        int a; cin >> a; --a;
        C[a]++;
        D[C[a]]++;
    }
    for (int i = 0; i < N+1; ++i) S[i+1] = S[i] + D[i];

    // 各 K に対して
    for (long long K = 1; K <= N; ++K) {
        // 二分探索
        long long low = 0, high = N+1;
        while (high - low > 1) {
            long long x = (low + high) / 2;
            if (S[x+1] >= K * x) low = x;
            else high = x;
        }
        cout << low << endl;
    }
}


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

int H[22];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cin >> H[i];
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        bool is_ok = true;
        for (int j = 0; j < i; j++) {
            if (H[i] < H[j]) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
ta=[]
for i in range(n):
    ta.append(list(map(int,input().split())))
#print(ta)
for i in range(n-1):
    if ta[i+1][0]<ta[i][0] or ta[i+1][1]<ta[i][1]:
        k=max(((ta[i][0]-1)//ta[i+1][0]+1), ((ta[i][1]-1)//ta[i+1][1]+1))
        ta[i+1][0]*=k
        ta[i+1][1]*=k
#print(ta)
print(ta[-1][0]+ta[-1][1])

Measured memory_bytes: 9188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,k;
ll a[510];
ll d[10000],cnt;
ll dd;
int c(const void*p,const void*q){
	if(*(int*)p%dd<*(int*)q%dd)return -1;
	return 1;
}

int main(){
	scanf("%lld%lld",&n,&k);
	rep(i,0,n)scanf("%lld",a+i);
	ll s=0;
	rep(i,0,n)s+=a[i];
	//sは5e8くらい
	for(int i=1;i*i<=s;i++)if(s%i==0){
		d[cnt++]=i;
		d[cnt++]=s/i;
	}
	sortdown(d,cnt);
	rep(i,0,cnt){
		dd=d[i];
		qsort(a,n,sizeof(ll),c);
		int r=n,pre=0;
		ll temp=k;
		rep(j,0,r){
			pre+=a[j]%dd;
			temp-=a[j]%dd;
			if(temp<0)break;
			while(a[r-1]%dd+pre>=dd){
				pre-=dd-a[r-1]%dd;
				r--;
			}
		}
		if(temp>=0){
			printf("%lld",dd);
			return 0;
		}
	}
}

Measured memory_bytes: 252
#include<iostream>

using namespace std;

bool kaibun(string n, int s, int e)
{
  bool ret = true;
  
  while(true)
  {
    if(s==e || s > e) break;
    if(n[s] != n[e])
    {
      ret = false;
      break;
    }
    s++;e--;
  }
  
  return ret;
}

int main()
{
  string s;
  
  cin >> s;
  
  int n = s.size();
  
  bool ans = kaibun(s, 0, n-1) && kaibun(s, 0, (n-1)/2 - 1) && kaibun(s, (n+3)/2 - 1, n-1);
  
  if(ans)
  { cout << "Yes";
  }else{ cout << "No";}
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
X, U = list(zip(*[map(str, sys.stdin.readline().split()) for _ in range(N)]))

ans = 0
for x, u  in zip(X, U):
    x = float(x)
    if u == 'BTC':
        x *= 380000
    ans += x
print(ans)


Measured memory_bytes: 13624
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

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; }
const long long INF = 1LL << 60;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll N,M;cin>>N>>M;
  vi k(M);
  vvi s(M);
  rep(i,M){
    cin>>k[i];
    rep(j,k[i]){
      int x;cin>>x;
      x--;
      s[i].pb(x);
    }
  }
  vi p(M);
  rep(i,M)cin>>p[i];
  int ans=0;
  for(int tmp ; tmp<(1<<N);tmp++){
    bitset<10> st(tmp);
    bool ok=true; 
    rep(i,M){
      bool pk=true;
      int cnt=0;
      rep(j,s[i].size()){
        if(st.test(s[i][j]))cnt++;
      }
      if(cnt %2!=p[i])pk=false;
      if(!pk){
        ok=false;
      }
    }
    if(ok)ans++;
  }
  cout<<ans<<endl;
}





Measured memory_bytes: 3732
#include <limits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int64_t N,K;
    cin >> N >> K;
    
    if(K == 0)
    {
        cout << N * N << '\n';
        return 0;
    }
    
    int64_t count = 0;
    
    for(int64_t b = K + 1; b <= N; ++b)
    {
        count += (N / b) * (b - K);
        count += max(0L, (N % b) - K + 1);
    }
    
    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys
import heapq
def input(): return sys.stdin.readline().rstrip()

def culc(li):
    li.sort(key=lambda x: x[1])
    h=[]
    for i in li:
        if len(h) >= i[1]:
            heapq.heappushpop(h, i[0])
        else:
            heapq.heappush(h, i[0])
    return sum(h)

def main():
    T=int(input())
    for _ in range(T):
        n=int(input())
        mae=[]
        ushiro=[]
        kijun=0
        for _ in range(n):
            k,l,r=map(int, input().split())
            if l>r:
                mae.append([l-r,k])
            else:
                ushiro.append([r-l,n-k])
            kijun+=min(l,r)
        print(culc(mae)+culc(ushiro)+kijun)
                    



if __name__ == '__main__':
    main()

Measured memory_bytes: 39276
#include <cstdio>
#include <algorithm>
using namespace std;

int dp(int, int);

int N,W;
int w[1001];
int v[101];

int main(){
    scanf("%d %d",&N,&W);

    for(int i = 0; i < N; i++){
        scanf("%d %d",&v[i],&w[i]);
    }

    int dp[N + 1][W + 1]; //N + 1 W + 1
    for(int i = 0; i < W + 1; i++){
        dp[0][i] = 0;
    }

    for(int i = 1;i <= N;i++){
        for(int j = 0;j <= W;j++){
            if(j - w[i - 1] < 0){
                dp[i][j] = dp[i - 1][j];
            }else{
                dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    }

    printf("%d\n",dp[N][W]);

    return 0;
}


Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int A, B, H;
  cin >> A;
  cin >> B;
  cin >> H;
  cout << (A + B) * H / 2 << endl;
  return 0;
}


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

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
static long[] f;
static long mod=(long)1e9+7;
//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
				assign();
				int t=1;//int_v(read()),cn=1;
				while(t--!=0){
					int n=int_v(read());
					char[] c=read().toCharArray();
					int i=0,j=c.length-1,res=0;
					while(i<j){
						while(i<n&&c[i]=='R'){i++;}
						while(j>=0&&c[j]=='W'){j--;}
						if(i<j){
							res++;
							c[i]='R';c[j]='W';
							i++;j--;
						}
					}
					out.write(res+"");
				}
			    
			    out.flush();

	}
}

	       

	       


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

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

  int t[3][3];
  int x[3], y[3];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> t[i][j];
    }
  }

  y[0] = 0;
  for (int i = 0; i < 3; i++) {
    x[i] = t[0][i] - y[0];
  }

  for (int i = 1; i < 3; i++) {
    y[i] = t[i][0] - x[0];
  }

  bool ans = true;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (y[i] + x[j] != t[i][j]) {
        ans = false;
      }
    }
  }

  cout << (ans ? "Yes" : "No");

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var nk = CRL().ArrayInts();
        var str = CRL().ToCharArray();
        str[nk[1] - 1] = str[nk[1] - 1].ToString().ToLower().ToCharArray()[0];
        CWL(str.Join());
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);  
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = new[] {0, -1, 0, 1};
    public static readonly int[] Dy = new[] {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

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

int main(){
	string str;
	cin>>str;
	int cnt=0;
	for(int i=0;i<str.size();i++){
		if(cnt==0 && str[i]=='C')cnt++;
		else if(cnt==1 && str[i]=='F')cnt++;
	}
	if(cnt==2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

int main(){
	int N,L;
  	cin >> N >> L;
  	vector<string> W(N);
  	for(int i=0;i<N;i++){
    	cin >> W.at(i);
    }
  	sort (W.begin(),W.end());
  	string ans;
  	for(int i=0 ;i < N; i++){
    	ans+=W.at(i);
    }
  cout << ans << endl;
}


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

int main() {
  
  int A, B;
  cin >> A >> B;
  
  if((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
  
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
tmp = input()
num = list(map(int,input().split()))
minCount = 100
chkCount = 0
for i in num:
  chk = i
  chkCount = 0
  while(True):
    if chk%2 == 0:
      chk = chk/2
      chkCount+=1
      if chkCount >= minCount:
        break;
    else:
      break
  if minCount > chkCount:
    minCount = chkCount
print(str(minCount))

Measured memory_bytes: 3060
#include <stdio.h>
//#define DEBUG

int main()
{
	long int a,b;
	scanf("%ld%ld",&a,&b);
#ifdef DEBUG
	printf("%ld %ld\n",a,b);
#endif
	if((a*b)%2) printf("Odd\n");
	else        printf("Even\n");
	fflush(stdout);

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>//头文件
using namespace std;
int a,b,d;
char c[52][52];//二维数组
int main(){
    cin>>a>>b;//输入行列
    for(int i=0;i<a;i++)
        for(int j=0;j<b;j++)cin>>c[i][j];//记录雷的位置
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            d=0;//要清零!!!
            if(c[i][j]=='#')cout<<"#";//如果是雷就直接输出
            else{
                if(c[i-1][j-1]=='#')d++;
                if(c[i-1][j]=='#')d++;
                if(c[i-1][j+1]=='#')d++;
                if(c[i][j-1]=='#')d++;
                if(c[i][j+1]=='#')d++;
                if(c[i+1][j-1]=='#')d++;
                if(c[i+1][j]=='#')d++;
                if(c[i+1][j+1]=='#')d++;
                cout<<d;
            }//如果是填数字的，判断周围有没有雷，有一个就加一，最后输出个数
        }
        cout<<endl;//一定要回车!!!你懂滴
    }
    /*留个return 0;给你自己打*/
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        if (new int[] { 2, 4, 5, 7, 9 }.Contains(N % 10))
            Console.WriteLine("hon");
        else if (new int[] { 0, 1, 4, 6, 8 }.Contains(N % 10))
            Console.WriteLine("pon");
        else
            Console.WriteLine("bon");
        return;
    }
}


Measured memory_bytes: 27832
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
std::map<T, int> prime_factorize(T x) {
  std::map<T, int> ans;
  for (T i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      T count = 0;
      while (x % i == 0) {
          count++;
          x /= i;
      }
      ans[i] = count;
    }
  }
  if (x != 1) ans[x] = 1;
  return ans;
}

int main() {
  LL A, B; std::cin >> A >> B;

  auto pA = prime_factorize(A);
  auto pB = prime_factorize(B);

#if 0
  for (auto p : pA) {
    std::cout << p.first << " ";
  }
  std::cout << std::endl;

  for (auto p : pB) {
    std::cout << p.first << " ";
  }
  std::cout << std::endl;
#endif

  int count = 0;
  for (auto p : pA) {
    if (pB.find(p.first) != pB.end()){
      ++count;
    }
  }
  std::cout << count + 1 << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a[210];
bool f=false;

int main(){
	cin >> n;
	REP(i,0,n) cin >> a[i],f+=a[i]%2;
	
	int c=0;
	while(!f){
		REP(i,0,n) a[i]=a[i]/2,f+=a[i]%2;
		c++;
	}
	
	cout << c << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll sum(ll l, ll r) {
  return (l+r)*(r-l+1) / 2;
}

int main() {
  int n, k; cin >> n >> k;
  mint ans;
  for(int i = k; i <= n+1; i++) {
    ll l = sum(0, i-1), r = sum(n-i+1, n);
    ans += r-l+1;
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int mn = 1000000000;
  int mnp = -1;
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    if(mn > t){
      mnp = i;
      mn = t;
    }
  }
  cout << mnp+1 << endl;
}


Measured memory_bytes: 3100
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

import           System.IO

main :: IO ()
main = do
    n <- readLn :: IO Int
    solve n

(x,y) # (z, w) = (x ++ z, y ++ w)

solve :: Int -> IO ()
solve n = do
    res0 <- queries [(s1, s2) | s1<-["#", "."], s2 <- ["#", "."]]
    case res0 of
        Nothing -> return ()
        Just cands@(cand:_) -> do
            let goL q = do
                res <- queryFirst $ map (#q) cands
                case res of
                    Nothing -> return ()
                    Just Nothing -> undefined
                    Just (Just l) -> goL l
            let goR q = do
                res <- queryFirst $ map (q#) cands
                case res of
                    Nothing -> return ()
                    Just Nothing -> goL q
                    Just (Just r) -> goR r

            goR cand

type Request = (String, String)
type Response = Maybe Bool

queryFirst :: [Request] -> IO (Maybe (Maybe Request))
queryFirst = go
  where
    go (q:qs) = do
      res <- query q
      case res of
          Just True -> return $ Just (Just q)
          Just False -> go qs
          Nothing -> return Nothing
    go [] = return $ Just Nothing

queries :: [Request] -> IO (Maybe [Request])
queries = go []
  where
    go acc (q:qs) = do
      res <- query q
      case res of
          Just True -> go (q:acc) qs
          Just False -> go acc qs
          Nothing -> return Nothing
    go acc [] = return $ Just $ reverse acc

query :: Request -> IO Response
query (s1, s2) = do
    putStrLn s1
    putStrLn s2
    hFlush stdout
    res <- getLine
    case res of
        "T" -> return $ Just True
        "F" -> return $ Just False
        "end" -> return $ Nothing


Measured memory_bytes: 1360
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<map>
#include<string>
#include<stack>
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pqueue priority_queue
#define NEW(a,b) memset(a,b,sizeof(a))
const double pi=4.0*atan(1.0);
const double e=exp(1.0);
const int maxn=1e5+8;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const ULL base=1e7+7;
using namespace std;
int a[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+1+n);
    int g=n/2;
    int ans=a[g+1]-a[g];
    cout<<ans<<endl;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		ArrayList<Integer> numList = new ArrayList<Integer>();

		while (true) {
			int num = sc.nextInt();
			if(num != 0) {
				numList.add(num);
			} else {
				break;
			}
		}
		for(int i = 0;i < numList.size();i++) {
			System.out.println("Case " + (i + 1) + ": " + numList.get(i));
		}
		sc.close();
	}
}

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

#define sz(s) (int)(s).size()
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 100000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}

ll a[222222];
int main()
{	
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i ++)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	for (int i = 1; i <= n; i ++)
	{
		if (m > 0)
		{
			a[i] = 0;
			m --;
		}
		else
		{
			break;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i ++)
	{
		ans += a[i];
	}
	cout << ans;









	getchar();
	getchar();
	return 0;
}

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

int main(){
  char a; cin >>a;
  if(a-65<=25) cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0; 
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
double r[555];
double dist[555];

int main(){
  cin>>n;
  rep(i,n)cin>>r[i];
  rep(i,n){
    double maxd=2*r[i];
    rep(j,i){
      double dist2=dist[j]-r[j];
      maxch(maxd,dist2+sqrt(pow(r[i]+r[j],2)-pow(r[i]-r[j],2))+r[i]);
    }
    dist[i]=maxd;
  }
  printf("%.10f\n", *max_element(dist,dist+n));
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll T;
    cin >> T;
    while (T--) {
        ll N;
        cin >> N;
        vec A(N);
        Rep (i, N) {
            cin >> A[i];
        }
        string S;
        cin >> S;

        vector<ll> basis;
        ll ans = 0;
        for (ll i = N-1; i >= 0; i--) {
            if (S[i] == '0') {
                for (ll b : basis) chmin(A[i], A[i]^b);
                if (A[i]) basis.push_back(A[i]);
            } else {
                for (ll b : basis) chmin(A[i], A[i]^b);
                if (A[i]) ans = 1;
            }
        }

        cout << ans << "\n";
    }
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x,k;
    cin>>x;
    k=x/100;
    if(x%100<=k*5)
    {
        cout<<1;
    }
    else{cout<<0;}

}


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

int main(void){
    int N; cin >> N;
    vector<ll> L(N+1);

    L[0]=2; L[1]=1;
    for(int i=2; i<=N; i++) L[i]=L[i-2]+L[i-1];

    cout << L[N] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>  
int a[105][105],b[10000+50];  
int main ()  
{  
    int h,w;  
    while(scanf("%d %d",&h,&w)!=EOF)  
    {  
        int i,j,t,k=0;  
        scanf("%d",&t);  
        for(i=0;i<t;i++)  
            scanf("%d",&b[i]);  
        for(i=0;i<h;i++)  
        {  
            if(i%2==0)  
                for(j=0;j<w;j++)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
            if(i%2==1)  
                for(j=w-1;j>=0;j--)  
                {  
                    a[i][j]=k+1;  
                    b[k]--;  
                    if(b[k]==0)  
                        k++;  
                }  
        }  
        for(i=0;i<h;i++)  
        {  
            for(j=0;j<w-1;j++)  
                printf("%d ",a[i][j]);  
            printf("%d\n",a[i][w-1]);  
        }  
    }  
}  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using vv = vector<V<T>>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
vvi gr;
vi dp;
int dfs(int now){
  if(dp[now]!=-1) return dp[now];
  if(gr[now].size()==0){
    return dp[now] = 0;
  }
  int mx = 0;
  REP(i,gr[now].size()){
    maxs(mx,dfs(gr[now][i])+1);
  }
  return dp[now] = mx;
}
signed main(){
  int n,m;
  cin >> n >> m;
  gr.resize(n);
  dp.assign(n,-1);
  REP(i,m){
    int s,t;
    cin >> s >> t;
    s--,t--;
    gr[s].emplace_back(t);
  }
  int mx = 0;
  REP(i,n){
    maxs(mx,dfs(i));
  }
  cout << mx << endl;
}


Measured memory_bytes: 8192