akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()



def main():
	n=II()

	ans=10**10


	for i in range(1,n):
		a=str(i)
		b=str(n-i)
		cnt=0
		for aa in a:
			cnt+=int(aa)
		for bb in b:
			cnt+=int(bb)
		ans=min(ans,cnt)
	print(ans)









if __name__ == "__main__":
	main()


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

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
ll modpow(ll x, ll y) {
  ll cur = x;
  ll ans = 1;
  while (y > 0) {
    if (y % 2 == 1) ans = (ans * cur) % mod;
    cur = (cur * cur) % mod;
    y /= 2;
  }
  return ans;
}
ll inv[maxn];

int main() {
#ifdef LOCAL_EXEC
//    freopen("sample.in", "r", stdin);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#endif

  int n, k;
  cin >> n >> k;
  int a[maxn];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);

  for (int i = 1; i <= n; i++) {
    inv[i] = modpow(i, mod - 2);
  }
  ll cur = 1;
  ll ans = 0;
  ll num = k - 1;
  for (int i = k; i <= n; i++) {
    ans += (cur*a[i]) % mod;
    ans += mod;
    ans %= mod;
    num++;
    cur *= (num * inv[num - k + 1]) % mod;
    cur %= mod;
  }
  cur = 1;
  num = k - 1;
  for (int i = n - k + 1; i >= 1; i--) {
    ans -= (cur*a[i]) % mod;
    ans += mod;
    ans %= mod;
    num++;
    cur *= (num * inv[num - k + 1]) % mod;
    cur %= mod;
  }
  cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1408
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    h,w,a,b = mi()

    ans = []
    k = 0
    k2 = 1
    for i in range(h):
        tmp = [k for j in range(a)]
        tmp += [k2 for j in range(w-a)]
        ans.append(tmp)
        if i == b-1:
            k = 1
            k2 = 0

    for i in range(h):
        p = ''.join(list(map(str,ans[i])))
        print(p)



main()


Measured memory_bytes: 23060
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim A As Integer = NextInt()
        Dim B As Integer = NextInt()
        Dim ans As Integer

        For i As Integer = A To B
            ans += B2I(Judge(i))
        Next

        WriteLine(ans)
    End Sub

    Function Judge(a As Integer) As Boolean
        Dim s As String = CStr(a)
        Dim n As Integer = s.Length

        For i As Integer = 0 To n \ 2
            If s(i) <> s(n - i - 1) Then Return False
        Next
        Return True
    End Function

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  string s;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s;
      if(s=="snuke"){
        char c='A'+j;
        cout<<c<<i+1<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp;

fn main() {
  input! {
    n: usize,
    mut a: [i64; n],
  }

  let INF_LL: i64 = 1_000_000_000_000_000_000;
  let mut dp: [[i64; 2]; 5] = [[-INF_LL; 2]; 5];
  dp[2][0] = 0;
  // dp[i][j] := select - not is i and (selected i-1 if j == 1))

  for x in a {
    let mut dp2: [[i64; 2]; 5] = [[-INF_LL; 2]; 5];
    for j in 0..5 as usize {
      for k in 0..2 as usize {
        if j > 0 {
          dp2[j - 1][0] = std::cmp::max(dp2[j - 1][0], dp[j][k]);
        }
        if j < 4 && k == 0 {
          dp2[j + 1][1] = std::cmp::max(dp2[j + 1][1], dp[j][k] + x);
        }
      }
    }
    dp = dp2;
  }
  let sa: i32 = n as i32 /2 - (n as i32  - n as i32/2);
  println!("{}", std::cmp::max(dp[(sa+2) as usize][0], dp[(sa+2) as usize][1]));
}


Measured memory_bytes: 5668
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long sum = 0;
    ArrayList<Integer> listA = new ArrayList<>();
    ArrayList<Integer> listB = new ArrayList<>();
    ArrayList<Integer> listC = new ArrayList<>();
    Set<Integer> set = new HashSet<Integer>();
    Map<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < n; i++) {
      listA.add(sc.nextInt());
    }
    int q = sc.nextInt();
    for (int i = 0; i < q; i ++) {
      listB.add(sc.nextInt());
      listC.add(sc.nextInt());
    }
    for (int e: listB) {
      set.add(e);
    }
    for (int e: set) {
      map.put(e,0);
    }
    for (int e: listA) {
      if (map.containsKey(e)) {
        map.put(e, map.get(e)+1);
      }
      sum += e;
    }
    for (int i = 0; i < q; i++) {
      int prevKey = listB.get(i);
      int nextKey = listC.get(i);
      sum += (nextKey - prevKey)*map.get(prevKey);
      if (map.containsKey(nextKey)) {
        map.put(nextKey, map.get(nextKey) + map.get(prevKey));
      }
      map.put(prevKey, 0);
      System.out.println(sum);
    }
    sc.close();
  }
}

Measured memory_bytes: 75708
n = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(n):
    minj = i
    for j in range(i,n):
        if A[j] < A[minj]:
            minj = j
    else:
        if minj != i:
            A[i],A[minj] = A[minj],A[i]
            cnt += 1
print(" ".join(map(str,A)))
print(cnt)


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=100010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
ll n,m;
ll memo[100010]={};
vector<vector<ll> >e(100005);
ll dfs(ll now){
  if(memo[now]>0)return memo[now];
  for(int i=0;i<e[now].size();i++){
    memo[now]=max(memo[now],dfs(e[now][i])+1);
  }
  return max(memo[now],0LL);
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    a--;b--;
    e[a].pb(b);
  }
  ll ans=0;
  for(int i=0;i<n+10;i++)memo[i]=-1;
  for(int i=0;i<n;i++){
      dfs(i);
  }
  for(int i=0;i<n+1;i++){
    ans=max(ans,memo[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7808
#include<iostream>
#include<cstdio>
#define Lens 105
using namespace std;
int N;
int A[Lens][Lens];
int S[Lens], E[Lens];
int sum = 0;
char c[Lens];

void dns(int i)
{
	sum++;
	S[i] = sum;
	c[i] = 'g';
	for (int j = 1; j <= N; j++)
	{
		if (A[i][j] == 1 && c[j] == 'w')
			dns(j);
	}
	sum++;
	E[i] = sum;
	c[i] = 'b';
}

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int k, n;
		cin >> k >> n;
		c[i] = 'w';
		for (int i = 0; i < n; i++)
		{
			int j;
			cin >> j;
			A[k][j] = 1;
		}
	}
	/*
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			if (j > 1)
				cout << ' ';
			cout << A[i][j];
		}
		cout << endl;
	}
	*/
	for (int i = 1; i <= N; i++)
	{
		if (c[i] == 'w')
			dns(i);
	}
	for (int i = 1; i <= N; i++)
	{
		cout << i << ' ' << S[i] << ' ' << E[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
import math

def bangou(array, n):
    nl = []
    for i in range(n):
        nl.append(i+1)

    num = 0
    while array:
        k = array.pop(0) #先頭の要素抜き出し
        a = nl.index(k)      #index検索=大きさ順
        num += a * math.factorial(len(array))
        nl.remove(k)

    return num
        

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

v = bangou(p,n)
w = bangou(q,n)

print(abs(v-w))

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    ll start = 0;
    ll lim = 0;
    int cnt = 1;
    while (1) {
        ll x = 1;
        rep (i, cnt) x *= 26;
        if (start <= n && start + x >= n) {
            lim = start + x;
            break;
        }
        start += x;
        cnt++;
    }
    string res = "";
    rep (i, cnt) res += 'a';
    start++;
    ll diff = n - start;
    int pos = 0;
    while (diff > 0) {
        res[pos] = (char)('a' + diff % 26);
        diff /= 26;
        pos++;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

const int N = 5;
const int INF = 100000;

int times[N];
bool done[N];

int solve(int d, int t)
{
    if (d == N) { return t; }

    int ans = -1;

    rep(i, N)
    {
        if (done[i]) { continue; }

        done[i] = true;

        const int tt = (t % 10) == 0 ? t : ((t / 10) + 1) * 10;
        const int res = solve(d + 1, tt + times[i]);

        if (ans < 0 || res < ans) { ans = res; }

        done[i] = false;
    }

    return ans == -1 ? INF : ans;
}

int main()
{
    rep(i, N) { cin >> times[i]; }

    cout << solve(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int N, K, X, Y;
	int result;
	std::cin >> N >> K >> X >> Y;
	result = (N >= K) ? K * X + (N - K)*Y : N * X;
	std::cout << result << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

vector<vector<int>> g;
void bfs(int s,vector<int> &d) {
    int n=sz(g);
    d.resize(n);
    rep(i,n) d[i]=INF;
    queue<int> q;
    q.push(s);
    d[s]=0;
    while(sz(q)) {
        int now=q.front(); q.pop();
        for(int nxt:g[now]) {
            if(d[nxt]==INF) {
                q.push(nxt);
                d[nxt]=d[now]+1;
            }
        }
    }
}

int main() {
    int n,sa,st;
    cin>>n>>st>>sa;
    sa--;st--;
    g.resize(n);
    rep(i,n-1) {
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> aoki(n),takahashi(n);
    bfs(sa,aoki);
    bfs(st,takahashi);
    int MAX=0,MAX_i;
    rep(i,n) {
        if(aoki[i]>takahashi[i]) {
            if(chmax(MAX,aoki[i])) {
                MAX_i=i;
            }
        }
    }
    
    cout<<MAX-1<<endl;
}

Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    int a[20][20], m, n, z=0, k;
    double p, pa=0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            pa=0;
            for(int o=0;o<m;o++)
            {
                pa=pa+(a[i][o]-a[j][o])*(a[i][o]-a[j][o]);
            }
            p=sqrt(pa);
            k=(int)p;
            if(k==p)
                z++;
        }
    }
    printf("%d\n",z);
    return 0;
}


Measured memory_bytes: 256
S=input()
if S=='SUN':
  print(7)
elif S=='MON':
  print(6)
elif S=='TUE':
  print(5)
elif S=='WED':
  print(4)
elif S=='THU':
  print(3)
elif S=='FRI':
  print(2)
else:
  print(1)

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

int main(void)
{
        char x[20], y[20];
        unsigned long long int xi, yi;
        int count = 0;

        scanf("%s %s", x, y);

        xi = (unsigned long long int)atol(x);
        yi = (unsigned long long int)atol(y);

        do{
                ++count;
                xi <<= 1;
        }while(xi <= yi);

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

        return 0;
}


Measured memory_bytes: 128
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

vector<int> prime;
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    int x;
    int i,j;
    cin>>x;
    prime.pb(2);
    for(i=3;i<=2*x;i++){
        int flag=0;
        for(auto j:prime){
            if(i%j==0){
                flag=1;
                break;
            }
        }
        if(flag==0){
            prime.pb(i);
            //cout<<i<<endl;
        }
    }
    for(auto i:prime){
        if(i>=x){
            cout<<i;
            break;
        }
    }
    return 0;
             
    
}

Measured memory_bytes: 384
/* Dsingh_24 */
 
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
 
#define N  100005

int main()
{
	ios
	ll n,d;
	cin>>n>>d;
	cout<<(n/(2*d+1))+((n%(2*d+1))!=0?1:0);
	return 0;
}

Measured memory_bytes: 256
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	string p;
    int a,b,h,m;
    cin>>a>>b>>h>>m;

    int x = h*60 + m;
    ld j = .5*x;
    ld g = m*6;
    ld val = max(j,g)-min(j,g);
    ld ft = min(360-val,val);
    ld rad = PI;
    rad=rad/180.0;
    ld f = a*a+b*b-2*a*b*cos(rad*ft);
    coud(sqrt(f),18);
    
return 0;
}

Measured memory_bytes: 4184
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_TEST_MAX		100000									// 最大テスト数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1Now[D_TEST_MAX];									// 現在値
static int si1Need[D_TEST_MAX];									// 必要値
static int si1DF[D_TEST_MAX];									// 差
static int siTCnt;												// テスト数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// ソート関数 - int昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// int昇順
	if (*lipVal1 > *lipVal2) {
		return 1;
	}
	else if (*lipVal1 < *lipVal2) {
		return -1;
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// テスト数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siTCnt);

	// 現在値 - 取得
	for (i = 0; i < siTCnt; i++) {
		fscanf(szpFpI, "%d", &si1Now[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 必要値 - 取得
	for (i = 0; i < siTCnt; i++) {
		fscanf(szpFpI, "%d", &si1Need[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 差 - セット
	for (i = 0; i < siTCnt; i++) {
		si1DF[i] = si1Now[i] - si1Need[i];
	}

	// 差 - ソート
	qsort(si1DF, siTCnt, sizeof(int), fSortFnc);

	// 負の合計
	int liCnt = 0;
	long long llSum = 0;
	for (i = 0; i < siTCnt; i++) {
		if (si1DF[i] < 0) {
			llSum += si1DF[i];
			liCnt++;
		}
		else {
			break;
		}
	}

	// 正を加算
	for (i = siTCnt - 1; i >= 0; i--) {
		if (llSum >= 0) {
			break;
		}
		if (si1DF[i] < 0) {
			liCnt = -1;
			break;
		}
		llSum += si1DF[i];
		liCnt++;
	}

	// 結果 - セット
	sprintf(lc1Out, "%d\n", liCnt);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int n;
    vector<int> vi;
    while (cin >> n, n) {
        vi.clear();
        for (int i = 0; i < n; i++) {
            int s;
            cin >> s;
            vi.push_back(s);
        }
        sort(vi.begin(), vi.end());
        cout << accumulate(vi.begin()+1, vi.end()-1, 0) / (n-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
dif = []
for i in range(N + 1):
	dif.append((abs(A[i+1] - A[i])))

temp_sum = sum(dif)
for i in range(N):
	print(temp_sum - dif[i] - dif[i+1] + abs(A[i+2] - A[i]))

Measured memory_bytes: 14048
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long tempt = Long.parseLong(sc.next());
        long tempa = Long.parseLong(sc.next());
        for (int i = 0; i < n - 1; i++) {
            long t = Long.parseLong(sc.next());
            long a = Long.parseLong(sc.next());
            if (t >= tempt && a >= tempa) {
                tempt = t;
                tempa = a;
            } else {
                long ratiot = tempt / t;
                if (tempt % t != 0) {
                    ratiot++;
                }
                long ratioa = tempa / a;
                if (tempa % a != 0) {
                    ratioa++;
                }
                tempt = Math.max(ratiot, ratioa) * t;
                tempa = Math.max(ratiot, ratioa) * a;
            }
        }
        System.out.println(tempt + tempa);
    }
}

Measured memory_bytes: 23508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int n, *A;
void maxHeapify(int i)
{
  int l, r, max, cp;
  l = 2*i;
  r = 2*i+1;
  if(l <= n && A[l] > A[i])
    max = l;
  else max = i;
  if(r <= n && A[r] > A[max])
    max = r;
  if(max != i)
    {
      cp = A[i];
      A[i] = A[max];
      A[max] = cp;
      maxHeapify(max);
    }
  return;
}
void buildMaxHeap()
{
  int i;
  for(i = n/2; i > 0; i--)
    maxHeapify(i);
}
int main()
{
  int i;
  scanf("%d",&n);
  A = malloc(sizeof(int)*(n+1));
  for(i = 1; i <= n; i++) scanf("%d",&A[i]);
  buildMaxHeap();
  for(i = 1; i <= n; i++)
    printf(" %d",A[i]);
  printf("\n");
  free(A);
  return 0;
}

Measured memory_bytes: 2472
function main() {
  var
  n, m,
  i = 0, j, ans, dp, dp_, x, k, line, xs;
  for(;;) {
    line = input[i++].split(' ').map(parseFloat);
    n = line[0]; m = line[1];
    if (n === 0 && m === 0) break;
    
    xs = [];
    for (j = 0; j < n; j++) {
      xs.push(parseInt(input[i++], 10));
    }
    
    dp = {};
    ans = 0;
    dp[0] = true;
    for (j = 0; j < n; j++) {
      for (k = xs[j]; k <= m; k++) {
        if (dp[k - xs[j]]) {
          dp[k] = true;
          if (ps[k]) ans = Math.max(ans, k);
        }
      }
    }

    console.log(ans || 'NA');
  }
}

function prims(n) {
  var
  i, j,
  prims = [false, false];
  for (i = 2; i <= n; i++) prims[i] = true;
  for (i = 2; i <= n; i++) if (prims[i]) {
    for (j = i + i; j <= n; j += i) prims[j] = false;
  }
  return prims;
}

var
ps = prims(1000000);

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  int n;
  while(cin >> n) {
    int a[5010] = {0};
    REP(i, 1001) REP(j, 1001) {
      a[i+j]++;
    }
    int ret = 0;
    REP(i, 1001) REP(j, 1001) {
      if(i+j <= n) {
        ret += a[n-i-j];
      }
    }
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 3112
import itertools

N,M,Q=map(int, input().split())
abcd=[list(map(int, input().split())) for _ in range(Q)]
ans=0
for c in itertools.combinations_with_replacement(range(M),N):
	tmp=0
	for i in range(Q):
		if c[abcd[i][1]-1]-c[abcd[i][0]-1]==abcd[i][2]:
			tmp+=abcd[i][3]
	ans=max(ans, tmp)
print(ans)


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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == T.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

#define MOD 1000000007
#define pb push_back
#define mp make_pair

template<typename T>
void print(vector<T> &v)
{
    for_each(v.begin(), v.end(), [](auto i){cout << i << ' ';});
    cout << '\n';
}

void f(int testCase)
{
    int x;
    cin >> x;
    cout << 1 - x << '\n';   
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;

    for(int i = 1; i<=t; i++)
        f(i);
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
int isprime(int);
int main(){
  int n;
  int i;
  int a;
  int sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&a);
    if(isprime(a)) sum++;
  }
  printf("%d\n",sum);
  return 0;
}
int isprime(int n){
  int i;
  if(n==2) return 1;
  if(n%2==0) return 0;
  for(i=3;i<=sqrt(n);i+=2){
    if(n%i==0) return 0;
  }
  return 1;
}



Measured memory_bytes: 2724
N = int(input())
A = list(map(int,input().split()))

li,ri = 0,0
ans = 0
xor = A[li]
add = A[li]
while ri < N and li <= ri:
    if xor == add: # 問題条件の判定
        ans += ri - li +1   # 先頭を固定したときの組み合わせの数(e.g. 1234,123,12,1)
        ri += 1
        if ri < N:  # 境界値の判定・・・別にすると読みやすい
            xor ^= A[ri]
            add += A[ri]
    else:
        if li < N:
            xor ^= A[li]
            add -= A[li]
        li += 1

print(ans)

Measured memory_bytes: 77772
import sys
input = sys.stdin.readline
import heapq

n, m = map(int, input().split())
jobs = [[] for i in range(m)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m:
        pass
    else:
        jobs[m - a].append(b)

if len(jobs) == 0:
    print(0)
    exit(0)

q = []
heapq.heapify(q)
ans = 0
for i in reversed(range(m)):
    for b in jobs[i]:
        heapq.heappush(q, -b)
    if len(q) != 0:
        ans += heapq.heappop(q) * -1

print(ans)


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

int main() {
  int a,b; cin>>a>>b;
  if(a>0) cout<<"Positive"<<endl;
  if(a<=0 && 0<=b) cout<<"Zero"<<endl;
  if(b<0){
    if((b-a)%2==0)cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
  }
}
   

  

Measured memory_bytes: 256
import collections
n = int(input())
arr = list(map(int, input().split()))
cnt = collections.Counter(arr)
total = 0
for i in cnt.keys():
  patern = cnt[i]*(cnt[i]-1)//2
  total += patern
for j in range(n):
  tmp = total
  total -= cnt[arr[j]]*(cnt[arr[j]]-1)//2
  total += (cnt[arr[j]]-1)*(cnt[arr[j]]-2)//2
  print(total)
  total = tmp

Measured memory_bytes: 25900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    double a;
    cin >> a;
    cout << fixed << setprecision(6)<< a*2*3.141592653589 << endl;
}

Measured memory_bytes: 3780
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node {
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};

typedef struct node* Nodepointer;
Nodepointer nil, root;

void insert(int k){
  Nodepointer x, y, z;
  y = nil;
  x = root;

  z = (Nodepointer)malloc(sizeof(struct node));
  z->key = k;
  z->left = nil;
  z->right = nil;
  
  while( x != nil ){
    y = x;
    if( z->key < x->key ) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if( y == nil ) root = z;
  else if( z->key < y->key ) y->left = z;
  else y->right = z;
}

void inorder(Nodepointer u){
  if( u == nil ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Nodepointer u){
  if( u == nil ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i ,x;
  char com[7];

  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ ){
    scanf("%s",com);
    if( strcmp("insert",com) == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if( strcmp("print",com) == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25180
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<functional>

#define LLI long long int

using namespace std;

int main(){
	string S;cin>>S;
	int N=S.size();
	int ans=0;
	string s0="",s1="";
	for(int i=0;i<N;i++){
		s1.push_back(S[i]);
		if(s0!=s1){
				ans++;
				s0=s1;
				s1="";
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 640
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        for(int i = 0; i < n; i++) {
            double x1 = stdIn.nextDouble();
            double y1 = stdIn.nextDouble();
            double x2 = stdIn.nextDouble();
            double y2 = stdIn.nextDouble();
            double x3 = stdIn.nextDouble();
            double y3 = stdIn.nextDouble();
            double x4 = stdIn.nextDouble();
            double y4 = stdIn.nextDouble();
            double cross = Math.abs((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1));
             
             
            if(cross < 1e-10) {
                System.out.println("YES");
            }
            else {
                System.out.println("NO");
            }
             
        }
    }
}


Measured memory_bytes: 29980
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
  VE a(n);rep(i,n)cin>>a[i];
  int ans = 0;
  rep(i,n){
  	while(true){
    	if(a[i]%2==0){
        ans++;a[i]/=2;
        }else break;
    }
  }
  cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)
ll fast_exp(ll base, ll exp1) {
    base%=mod;
    ll res=1;
    while(exp1>0) {
       if(exp1&1) res=(res*base)%mod;
       base=(base*base)%mod;
       exp1/=2;
    }
    return res%mod;
} 
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n,k;
    cin>>n>>k;
    ll x[n];
    rep(a,0,n)
		cin>>x[a];
	ll fact[n],revfact[n];
	fact[0]=1;revfact[0]=1;
	rep(a,1,n)
	{
		fact[a]=(fact[a-1]*a)%mod;
		revfact[a]=(revfact[a-1]*fast_exp(a,mod-2))%mod;
	}
	sort(x,x+n);
	ll ans=0;
	rep(a,0,n)
	{
		if(a>=k-1)
		{
			ll p=fact[a];
			p=(p*revfact[k-1])%mod;
			p=(p*revfact[a-k+1])%mod;
			ans=(ans+(p*x[a])%mod)%mod;
		}
		if(n-1-a>=k-1)
		{
			ll left=n-1-a;
			ll p=fact[left];
			p=(p*revfact[k-1])%mod;
			p=(p*revfact[left-k+1])%mod;
			ans=(ans+mod-(p*x[a])%mod)%mod;
		}
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}


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

public class Main {

    public static void main(String[] $) throws IOException{
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        if(N%10 == 2 || 
        N%10 == 4 ||
        N%10 == 5 ||
        N%10 == 7 ||
        N%10 == 9){
            System.out.println("hon");
        }else if(N%10 == 3){
            System.out.println("bon");
        }else{
            System.out.println("pon");
        }
           

    }
}

Measured memory_bytes: 35712
#include <iostream>
#include <map>
#include <array>
#include <limits>
#include <functional>
using namespace std;

int main() {
  int t;
  cin >> t;
  for (int64_t n, a, b, c, d; cin >> n >> a >> b >> c >> d; ) {
    map<int64_t, int64_t> dp;
    array<int64_t, 3> multiple {2, 3, 5}, cost {a, b, c};
    function<int64_t(int64_t)> solve = [&] (int64_t n)->int64_t {
      if (n == 0) {
        return 0;
      }
      if (n == 1) {
        return d;
      }
      if (dp.count(n) != 0) {
        return dp[n];
      }
      int64_t result = numeric_limits<int64_t>::max();
      if (n <= result / d) {
        result = n * d;
      }
      for (auto i = 0; i < 3; ++i) {
        if (n % multiple[i] == 0) {
          result = min(result, solve(n / multiple[i]) + cost[i]);
        } else {
          auto down = n / multiple[i] * multiple[i], up = down + multiple[i];
          result = min(result, solve(down / multiple[i]) + (n - down) * d + cost[i]);
          result = min(result, solve(up / multiple[i]) + (up - n) * d + cost[i]);
        }
      }
      return dp[n] = result;
    };
    cout << solve(n) << '\n';
  }
  return 0;
}


Measured memory_bytes: 4028
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
c=[[] for i in range(N)]
for i,j in AB:
    c[i-1].append(j-1)
    c[j-1].append(i-1)
from collections import deque
def bfs(c,N,s):
    v=[0]*N
    v[s]=1
    pre=[-1]*N
    q=deque([s])
    while q:
        i=q.popleft()
        for j in c[i]:
            if v[j]==0:
                v[j]=1
                pre[j]=i
                q.append(j)
    return pre
p=bfs(c,N,0)
print('Yes',*[x+1 for x in p[1:]],sep='\n')

Measured memory_bytes: 75616
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int r = scanner.nextInt();
		int g = scanner.nextInt();
		int b = scanner.nextInt();

		if ((r * 100 + g * 10 + b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<pair<int, int>> food(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        food[i] = make_pair(a, b);
    }
    sort(food.begin(), food.end());  // かかる時間について昇順ソートするとfood[k]を最後に食べるときfood[k+1]以降は食べない

    vector<vector<int>> dp(n+1, vector<int>(t));  // dp[i+1][j] : i番目(iは0-index)までの料理をかかる時間がj以下となるように食べたときの美味しさの合計の最大値
    rep(i, n) {
        rep(j, t) {
            if(j >= food[i].first) {
                dp[i+1][j] = max(dp[i][j], dp[i][j-food[i].first] + food[i].second);
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    int ans = 0;
    rep(k, n) {  // 最後に食べる料理をfood[k]とする
        ans = max(ans, dp[k][t-1] + food[k].second);
    }

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

Measured memory_bytes: 35584
use std::io::stdin;
use std::str::FromStr;
use std::cmp::max;

fn main(){
    let _: usize = get_one();
    let xs: Vec<i64> = get_vec();
    let mut cnts = vec![0; 100004];

    for x in xs {
        for i in x..x+3 {
            cnts[i as usize] += 1;
        }
    }

    println!("{}", cnts.iter().fold(&0, max));
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


Measured memory_bytes: 6396
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = 0; i < n ; i++)
#define rrep(i,n) for(int i = 1; i <= n; i++)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;

int main(){
	int a,b=0;
	scanf("%d",&a);
	b+=a;
	scanf("%d",&a);
	b+=a*5;
	scanf("%d",&a);
	b+=a*10;
	scanf("%d",&a);
	b+=a*50;
scanf("%d",&a);
	b+=a*100;
scanf("%d",&a);
	b+=a*500;

	printf("%d\n",b>=1000?1:0);
	return 0;
}

Measured memory_bytes: 1032
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int main(){
	int n,d;scanf("%d%d",&n,&d);
	printf("%d\n",n/(2*d+1)+(n%(2*d+1)!=0));

	return 0;
}


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

int main() {
  int N, K, x, sum=0;
  cin >> N >> K;

  for (int i = 0; i < N; i++){
    cin >> x;
    if(x<(K-x)){
      sum += 2 * x;
    }else{
      sum += 2 * (K-x);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3588
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll t;
    cin>>t;
    rep(index,t){
        ll n;
        cin>>n;
        ll sum=0;
        VV vec1(n);
        VV vec2(n+1);
        rep(i,n){
            ll k,l,r;
            cin>>k>>l>>r;
            k--;
            sum+=min(l,r);
            if(l>r){
                vec1[k].push_back(l-r);
            }else{
                vec2[k+1].push_back(r-l);
            }
            
        }
        V forward;
        V backward;
        priority_queue<ll,V,greater<ll>> q;
       // cout<<sum<<endl;
        rep(i,n){
           // cout<<i<<" "<<q.size()<<endl;
            for(auto j:vec1[i]){
             //   cout<<i<<" "<<j<<"加算"<<endl;
                sum+=j;
                q.push(j);
            }
            while(q.size()>i+1){
             //   cout<<i<<" "<<q.top()<<"減"<<endl;
                sum-=q.top();
                q.pop();
            }
        }
       // cout<<sum<<endl;
        priority_queue<ll,V,greater<ll>> q2;
        for(int i=n-1;i>=0;i--){
            for(auto j:vec2[i]){
              //  cout<<i<<" "<<j<<"加算"<<endl;
                sum+=j;
                q2.push(j);
            }
            while(q2.size()>n-i){
            //    cout<<i<<" "<<q.top()<<"減"<<endl;
                sum-=q2.top();
                q2.pop();
            }
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 19604
import java.util.*

fun main(args:Array<String>){
    val (n,k) = readLine()!!.split(" ").map{it.toInt()}
    val a = readLine()!!.split(" ").map{it.toLong()}.sorted()
    var ans = 0L
    for(i in 0 until n - k){
        ans += a[i]
    }
    println(ans)
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a > 12) cout << b << endl;
    else if(a > 5) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    string S;
    cin>>S;
    if(S[0]==S[1]&&S[1]==S[2])cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;


int main() {


	int N; cin >> N;
	vvint a(N, vint(3));
	vvint dp(N + 1, vint(3));
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;

	rep(i, N) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	rep(i, N) {
		rep(j, 3)rep(k, 3) {
			if (j == k)continue;
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + a[i][j]);
		}
	}

	cout << max(dp[N][0], max(dp[N][1], dp[N][2]));


	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define YES cout << "War" << endl;
#define NO cout << "No War" << endl;
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, m, X, Y, z;
    cin >> n >> m >> X >> Y;
    
    vector<int> x(n);
    REP(i, n) cin >> x[i];
    
    vector<int> y(m);
    REP(i, m) cin >> y[i];

    sort(ALL(x));
    sort(ALL(y));

    z = y[0];

    if(y[0] - x[x.size()-1] < 1){
        cout << "War" << endl;
        return 0;
    }

    if(z <= X || z > Y) {
        cout << "War" << endl;
        return 0;
    }

    cout << "No War" << endl;
    
    return 0;    
        




}

Measured memory_bytes: 256
class unionFind():
	def __init__(self,n):
		self.tree=[-1]*n
	def find(self,x):
		if self.tree[x]<0:
			return x
		else:
			return self.find(self.tree[x])
	def union(self,x,y):
		xr=self.find(x)
		yr=self.find(y)
		if xr!=yr:
			if self.tree[xr]<self.tree[yr]:
				self.tree[yr]=xr
			elif self.tree[xr]>self.tree[yr]:
				self.tree[xr]=yr
			else:
				self.tree[xr]-=1
				self.tree[yr]=xr
			return True
		
		return False
def main():
	ans=0
	n,m=map(int,input().split())
	a=unionFind(n)
	li=[x-1 for x in list(map(int,input().split()))]
	for _ in range(m):
		x,y=map(int,input().split())
		a.union(x-1,y-1)
	for x in range(n):
		if a.find(x)==a.find(li[x]):
			ans+=1
	return ans
print(main())


Measured memory_bytes: 14708