akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  int d,s,t;
  cin>>d>>s>>t;
  
  if(d<=s*t) cout<<"Yes\n";
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

int main() {
    //
    int num, m;
    cin >> num >> m;
    vector<tuple<long long, long long, long long>> tpl;
    vector<pair<long long, long long>> p(m);
    vector<long long> vec(m);
    for (int i = 0; i < m; i++) {
        long long a, b;
        cin >> a >> b;
        tpl.emplace_back(a, b, i);
    }

    sort(begin(tpl), end(tpl));

    long long tmpP = -1;
    long long cnt = 0;
    for (int i = 0; i < m; i++) {
        if (tmpP != get<0>(tpl[i])) {
            tmpP = get<0>(tpl[i]);
            cnt = 1;
        }
        p.at(get<2>(tpl[i])) = make_pair(get<0>(tpl[i]), cnt);
        cnt++;
    }

    for (int i = 0; i < m; i++) {
        cout << setfill('0') << right << setw(6) << p.at(i).first;
        cout << setfill('0') << right << setw(6) << p.at(i).second << endl;
    }

    //
}


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

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

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

int main()
{
    int n;
    unsigned long long k;
    cin>>n>>k;
    vector<ll >v(n+2);
    vector<ll >intime(n+2,-1);

    for(int i=1;i<=n;i++)
        cin>>v[i];

    intime[1]=0;
    ll current=v[1];
    ll time=0;
    ll length=0;
    ll distance=0;
    ll startPoint=0;
    while(true)
    {
        if(intime[current]!=-1)
        {
            length=time-intime[current]+1;
            distance=intime[current];
            startPoint=current;
            break;
        }
        intime[current]=++time;
        current=v[current];
    }
    //cout<<length<<" "<<distance<<" "<<startPoint<<endl;
    if(k==distance)
    {
        cout<<startPoint<<endl;
    }
    else if(k<distance)
    {
        int current=1;
        while(k--)
            current=v[current];
        cout<<current<<endl;
    }
    else
    {
        k-=distance;
        k%=length;
        int current=startPoint;
        while(k--)
            current=v[current];
        cout<<current<<endl;
    }
    return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	string s; cin >> s;
	fill(all(s), 'x');
	cout << s << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };


int main() {
	int x, y, z, k;
	cin >> x >> y >> z >> k;

	vector<ll>a(x);
	vector<ll>b(y);
	vector<ll>c(z);
	vector<ll>temp;
	vector<ll>ans;
	rep(i, 0, x)cin >> a[i];
	rep(i, 0, y)cin >> b[i];
	rep(i, 0, z)cin >> c[i];

	sort(all(a));
	sort(all(b));
	sort(all(c));
	reverse(all(a));
	reverse(all(b));
	reverse(all(c));

	int f = 0;
	int cnt = 0;
	rep(i, 0, x) {
		rep(j, 0, y) {
			temp.pb(a[i]+b[j]);
		}
	}
	sort(all(temp));
	reverse(all(temp));

	int sz = temp.size();
	rep(i, 0, min(sz,k))rep(j,0,z){
		ans.pb(temp[i]+c[j]);
	}
	sort(all(ans));
	reverse(all(ans));


	rep(i, 0, k) {
		cout << ans[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 43240
K,N=map(int,input().split())
Alist=list(map(int,input().split()))
kyori=[]
ans=0
for i in range(N-1):
    kyori.append(Alist[i+1]-Alist[i])
kyori.append(K-Alist[N-1]+Alist[0])
kyori.remove(max(kyori))
for i in range(len(kyori)):
    ans+=kyori[i]
print(ans)

Measured memory_bytes: 26436
n=int(input())
P=list(map(int,input().split()))
cnt=0
L=[0,0,0]
for i in range(1,n-1,1):
  L=sorted([P[i-1],P[i],P[i+1]])
  #print(L,P[i],L[1])
  if P[i]==L[1]:
    cnt += 1
print(cnt)

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

using namespace std;
using LLONG = long long;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A + B >= 10)
    {
        cout << "error" << endl;
    }
    else
    {
        cout << A + B << endl;
    }

    return 0;
}

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

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

signed main() {
	ll n, a, b, count = 0;
  cin >> n >> a >> b;
  FOR(i, 1, n + 1) {
    int ii = i;
    int sum = 0;
    rep(j, 5) {
      sum += ii % 10;
      ii /= 10;
    }
    if (a <= sum && sum <= b) count += i;
  }
  cout << count << endl;
}

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

void chmin(ll &a, ll b) {
    a = min(a, b);
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, M;
ll s[20], d[200];
ll sum[1 << 17];
ll dp[1 << 17];

void solve() {
    //cout.precision(10);
    for(int i = 0; i < N; i++) cin >> s[i];
    s[N] = 1e9;
    N++;
    for(int i = 0; i < M; i++) {
        cin >> d[i];
    }
    for(int bits = 0; bits < (1 << N); bits++) {
        dp[bits] = 1e18;
        sum[bits] = 0;
        for(int i = 0; i < N; i++) {
            if(bits & (1 << i)) {
                sum[bits] += s[i];
            }
        }
    }
    dp[0] = 0;
    for(int bits = 0; bits < (1 << N); bits++) {
        for(int j = 0; j < N; j++) {
            if(bits & (1 << j)) continue;
            ll val = dp[bits];
            int Next = bits | (1 << j);
            for(int k = 0; k < M; k++) {
                if(sum[bits] <= d[k] && d[k] < sum[Next]) {
                    val += min(abs(sum[bits] - d[k]), abs(sum[Next] - d[k]));
                }
            }
            chmin(dp[Next], val);
        }
    }
    cout << dp[(1 << N) - 1] << endl;
}

int main() {
    while(true) {
        cin >> N >> M;
        if(N == 0 and M == 0) break;
        solve();
    }
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    cout << fixed << setprecision(15);
    int n;
    cin >> n;
    if(n == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << 1.0-((n/2)/(double)n) << endl;
    return 0;
}

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


class Main {
    static int memo[];
    static ArrayList<Integer> edges[];
    static int n,m;

    public static int shortestPath(int node)
    {
        if(memo[node] != -1)
        {
            return memo[node];
        }

        memo[node] = 0;

        for(int i = 0 ; i < edges[node].size() ; i++)
        {
            memo[node] = Math.max(memo[node] , 1 + shortestPath(edges[node].get(i)));
        }

        return memo[node];
    }

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer st1 = new StringTokenizer(br.readLine());

        int n = Integer.parseInt(st1.nextToken());
        int m = Integer.parseInt(st1.nextToken());

        edges = new ArrayList[n];
        memo = new int [n];

        Arrays.fill(memo , -1);

        for(int i = 0 ; i < n ; i++)
            edges[i] = new ArrayList<>();

        for(int i = 0 ; i < m ; i++)
        {
            st1 = new StringTokenizer(br.readLine());

            int x = Integer.parseInt(st1.nextToken());
            int y = Integer.parseInt(st1.nextToken());

            edges[x-1].add(y-1);
        }

        int max = 0;

        for(int i = 0 ; i < n ; i++)
            max = Math.max(max , shortestPath(i));

        out.println(max);



        out.flush();
        out.close();
    }

}

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

typedef complex<ll> P;

int n;
vector< P > G[MAX_R];
ll sx,sy,tx,ty;
P sp,tp;

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<MAX_R;i++)G[i].clear();
    cin>>sx>>sy>>tx>>ty;
    sp=P(sx,sy);
    tp=P(tx,ty);
    for(int i=0;i<n;i++){
      ll x,y,r;
      cin>>x>>y>>r;
      P p=P(x,y);
      if(norm(tp-p)==r*r||norm(sp-p)==r*r){
        assert(0);
      }
      
      if(norm(tp-p)<r*r&&norm(sp-p)<r*r)continue;
      if(norm(tp-p)>r*r&&norm(sp-p)>r*r)continue;
      G[r].push_back(p);
    }
    
    vector<P> A,B;
    vector<ll> Ar,Br;
    for(ll i=0;i<MAX_R;i++){
      for(int j=0;j<(int)G[i].size();j++){
        P p=G[i][j];
        if(norm(tp-p)<i*i){
          A.push_back(p);
          Ar.push_back(i);
        }
        if(norm(sp-p)<i*i){
          B.push_back(p);
          Br.push_back(i);
        }
      }
    }

    int ans=0;
    
    vector<int> dpA(A.size(),1);
    vector<int> dpB(B.size(),1);

    for(int i=0;i<(int)A.size();i++){
      for(int j=0;j<i;j++){
        if( norm(A[i]-A[j])  < (Ar[i]-Ar[j])*(Ar[i]-Ar[j]) ){
          dpA[i]=max(dpA[i],dpA[j]+1);
        }
      }
      ans=max(ans,dpA[i]);
    }

    for(int i=0;i<(int)B.size();i++){
      for(int j=0;j<i;j++){
        if( norm(B[i]-B[j]) < (Br[i]-Br[j])*(Br[i]-Br[j]) ){
          dpB[i]=max(dpB[i],dpB[j]+1);
        }
      }
      ans=max(ans,dpB[i]);
    }

    for(int i=0;i<(int)A.size();i++){
      for(int j=0;j<(int)B.size();j++){
        if( norm(A[i]-B[j]) > (Ar[i]+Br[j])*(Ar[i]+Br[j]) ){
          ans=max(ans,dpA[i]+dpB[j]);
        }
      }
    }

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

Measured memory_bytes: 1584
import sys
input = sys.stdin.readline
def print_ans(N, K, Q, arr):
    """Test Case
    >>> print_ans(6, 3, 4, [3, 1, 3, 2])
    No
    No
    Yes
    No
    No
    No
    >>> print_ans(6, 5, 4, [3, 1, 3, 2])
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    >>> print_ans(10, 13, 15,[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9])
    No
    No
    No
    No
    Yes
    No
    No
    No
    Yes
    No
    """
    point = [K - Q] * N
    for a in arr:
        point[a - 1] += 1
    ans_arr = ["Yes" if p > 0 else "No" for p in point]
    for ans in ans_arr:
        print(ans)

if __name__ == '__main__':
    N, K, Q = map(int,input().rstrip().split())
    arr = [ int(input()) for i in range(Q)]
    print_ans(N, K, Q, arr)

Measured memory_bytes: 11272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i <= s.size(); i++) {
        if (s.find(string(i, 'R')) != string::npos) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
//============================================================================
// Name        : e
// Date        : Wed Feb 20 10:22:05 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define pvi(x, v) if(v) pvar(x); fora(a, x) cout << a << " "; cout << "\n"
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int inf = (int) 1e9 + 7;

void amin(int &a, int b) {
    a = min(a, b);
}

void solve() {
    int n, w; cin >> n >> w;
    vi ww(n, 0), vv(n, 0);
    fori (i, 0, n) {
        cin >> ww[i] >> vv[i];
    }

    int sum = accumulate(all(vv), 0);

    // dp[i] the mimimum weights with the sum of item's value is `i`
    vi dp(sum + 1, inf);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = sum - vv[i]; j >= 0; --j) {
            amin(dp[j + vv[i]], dp[j] + ww[i]);
        }
    }

    int ret = 0;
    fori (i, 0, sum + 1) {
        if (dp[i] <= w) {
            ret = max(ret, i);
        }
    }
    output(ret);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
int main(int argc, char* argv[])
{
	//ABC164 C
	int n;
	string str;
	set<string> st;
	// N
	// S1
	// S2
	// S3

	cin >> n;

	while (n > 0) {
		cin >> str;
		st.insert(str);
		n--;
	}

	cout << st.size();
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long long> A(100005);
    vector<long long> B(100005);
    for (int i = 1; i <= n + 1; i++) {
        cin >> A[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> B[i];
    }

    long long cnt = 0;
    for (int i = n; i >= 1; i--) {
        // B[i]がA[i+1]以上
        if (B[i] >= A[i + 1]) {
            cnt += A[i + 1];
            B[i] -= A[i + 1];
            A[i + 1] -= A[i + 1];
            // B[i] - A[i+1]が　A[i]以上
            if (B[i] >= A[i]) {
                cnt += A[i];
                B[i] -= A[i];
                A[i] -= A[i];
            }
            // B[i] - A[i+1]が　A[i]より小さい
            else {
                cnt += B[i];
                A[i] -= B[i];
                B[i] -= B[i];
            }
        }
        // B[i]がA[i+1]より小さい
        else {
            cnt += B[i];
            A[i + 1] -= B[i];
            B[i] -= B[i];
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1792
W, H, N = map(int, input().split())
x1 = y1 = 0
x2 = W
y2 = H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    else:
        y2 = min(y2, y)

print(max(0, (x2 - x1)) * max(0, (y2 - y1)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
int A,B;

int main(){
    cin>>A>>B;
    if(A<=8 && B<= 8) cout << "Yay!" << "\n";
    else cout << ":(" <<"\n";
    
    return 0;
}


Measured memory_bytes: 256
#093 C

a =[int(j) for j in input().split()]
a.sort()
if abs(a[0]-a[1])%2==0 and abs(a[2]-a[1])%2==0 and abs(a[2]-a[0])%2==0:
    cnt=0
    cnt+=(a[2]-a[1])//2 +(a[2]-a[0])//2
    
elif abs(a[0]-a[1])%2==0:
    cnt=1
    cnt+=(a[2]-a[1])//2 +(a[2]-a[0])//2

else:
    cnt=2
    cnt+=(a[2]-a[1])//2 +(a[2]-a[0])//2
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RAnK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 1e5+233;
vector<pair<int,int> > ans;
int d[maxn],w[maxn],a[maxn];
int del,n;
void GG(){
	puts("-1"); exit(0);
}
bool cmp(int x,int y){
	return d[x] < d[y];
}
int query(int l,int r,int need){
	int pos = -1;
	while(l<=r){
		int mid =(l+r)>>1;
		if(d[a[mid]] - del < need) l = mid + 1; else
		if(d[a[mid]] - del > need) r = mid - 1; else
		return a[mid];
	}
	return -1;
}
vector<int> edge[maxn];
int f[maxn],F[maxn],size[maxn];
void dfs(int u,int fa){
	f[u] = 0;
	size[u] = 1;
	for(auto v:edge[u]){
		if(v==fa) continue;
		dfs(v,u);
		size[u] += size[v];
		f[u] += f[v] + size[v];
	}
}
void DFS(int u,int fa){
	if(u==1) F[u]=f[u];
	for(auto v:edge[u]){
		if(v==fa) continue;
		F[v] = F[u] + (n - size[v]) - (size[v]);
		DFS(v,u);
	}
}
signed main(){
	n = rd();
	Rep(i,1,n) d[i] = rd();
	Rep(i,1,n) w[i] = 1;
	Rep(i,1,n) a[i] = i;
	sort(a+1,a+1+n,cmp);
	del = 0;
	Dep(i,n,2){
		ll need = d[a[i]] - del - (n - w[a[i]]) + w[a[i]]; 
		int pos = query(1,i-1,need);
		if(pos == -1){
			GG();
		}
		del += w[a[i]];
		w[pos] += w[a[i]];
		ans . push_back(pii(a[i],pos));
	}
	for(auto i:ans){
		int x = i.fi,y = i.se;
		edge[x]. push_back(y);
		edge[y]. push_back(x);
	}
	dfs(1,0);
	DFS(1,0);
	sort(d+1,d+1+n);
	sort(F+1,F+1+n);
	Rep(i,1,n){
		if(d[i] != F[i]){
			GG();
		}
	}
	for(auto i:ans){
		printf("%lld %lld\n",i.fi,i.se);
	}
	return 0;
}

Measured memory_bytes: 17776
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  double l;
  cin >> l;
  cout << fixed << setprecision(10);
  cout << (l/3)*(l/3)*(l/3) << endl;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===

//const ll mod = static_cast<int>(1e9 + 7);



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

	map<string, ll> str_map;
	for (int i = 0; i < N; ++i) {
		string str_tmp;
		cin >> str_tmp;

		sort(str_tmp.begin(), str_tmp.end());
		++str_map[str_tmp];
	}

	ll ans = 0;
	for (const auto& cnt : str_map) {
		ans += cnt.second * (cnt.second - 1) / 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 11136
import java.util.*;
public class Main {
    static final int MAX = Integer.MAX_VALUE;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] w = new int[n+1][n+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                int  k = sc.nextInt();
                w[i][j] = k == -1 ? MAX : k;
            }
        }
        
        int sumCost = 0;
        boolean[] used = new boolean[n+1];
        // minCostFromMST[i]: 作成中 MST(どの頂点でもよい) から,未訪問の頂点 i に移動するための最小コスト。
        int[] minCostFromTempMST = new int[n+1]; 
        
        for (int i = 1; i <= n; i++) {
            minCostFromTempMST[i] = MAX;
        }
        // 頂点1以外は何で初期化する? -> とりあえず-1 -> minCostとの比較で支障が出そうなのでMAX
        minCostFromTempMST[1] = 0;
        
        while (true) {
            // 次に訪問する頂点と, 作成中MSTとG-MSTの中で最小コストの辺のコスト
            int next = -1;
            int minCost = MAX;
            
            // 「未訪問で、作成中MSTからもっとも近い頂点」をnextにする。初回は頂点1が選ばれる
            for (int i = 1; i <= n; i++) {
                if (!used[i] && minCostFromTempMST[i] < minCost) {
                    next = i;
                    minCost = minCostFromTempMST[i];
                }
            }
            if (next == -1) break;
            
            used[next] = true;
            sumCost += minCostFromTempMST[next];
            for (int i = 1; i <= n; i++) {
                // 「未訪問で、nextと隣接する頂点」 の minCostFromTempMST を更新する。
                if (!used[i] && w[next][i] != MAX) {
                    minCostFromTempMST[i] = Math.min(minCostFromTempMST[i], w[next][i]);
                }
            }
        }
        System.out.println(sumCost);
    }
}



Measured memory_bytes: 41336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define bit(k) (1LL<<(k))

// [0,x]
ll f(ll x) {
    ll res = (x%4 == 1 || x%4 == 2);
    rep1(k,60){
        if (x&bit(k) && (x%2 == 0)) {
            res |= bit(k);
        }
    }
    return res;
}

int main(void){
    ll a,b;
    cin >> a >> b;
    cout << (f(a-1)^f(b)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main()
{
	int N;
	cin >> N;
	vector<vector<ll>> abc(3, vector<ll> (N, 0));
	rep(i, N) cin >> abc[0][i] >> abc[1][i] >> abc[2][i];
	
	vector<vector<ll>> dp(3, vector<ll>(N, 0));
	dp[0][0] = abc[0][0];
	dp[1][0] = abc[1][0];
	dp[2][0] = abc[2][0];

	for (int i = 1; i < N; ++i) {
		dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + abc[0][i];
		dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + abc[1][i];
		dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + abc[2][i];
	}

	ll ans = max(dp[0][N - 1], dp[1][N - 1]);
	ans = max(ans, dp[2][N - 1]);
	cout << ans << endl;
	return 0;
}

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

#define int long long
#define double long double

using namespace std;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e9;

signed main() {

	int n;
	cin >> n;

	int n3 = n * 3;
	vector<int> a(n3);

	rep(i, n3){
		cin >> a[i];
	}

	map<int, int> l, r, r2;
	int ls = 0, rs = 0;

	for(int i = 0; i < n; i++){
		l[a[i]]++;
		ls += a[i];
	}
	dump(ls);

	vector<int> rv;
	for(int i = n; i < n3; i++){
		rv.push_back(a[i]);
	}
	sort(all(rv));
	for(int i = 0;i < n;i++){
		r[rv[i]]++;
		rs += rv[i];
	}
	for(int i = n;i < rv.size();i++){
		r2[rv[i]]++;
	}
	dump(rs);

	int ans = ls - rs;
	for(int i = n; i < n * 2; i++){

		auto le = l.begin();
		int lev = le->first;
		if(lev < a[i]){
			l[a[i]]++;
			ls += a[i];
			l[lev]--;
			ls -= lev;
			if(l[lev] == 0){
				l.erase(lev);
			}
		}

		if(r.count(a[i])){
			r[a[i]]--;
			rs -= a[i];
			if(r[a[i]] == 0){
				r.erase(a[i]);
			}
			auto r2e = r2.begin();
			int r2ev = r2e->first;

			r[r2ev]++;
			rs += r2ev;

			r2[r2ev]--;
			if(r2[r2ev] == 0){
				r2.erase(r2ev);
			}
		}else
		if(r2.count(a[i])){
			r2[a[i]]--;
			if(r2[a[i]] == 0){
				r2.erase(a[i]);
			}
		}

		ans = max(ans, ls - rs);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
        final int N = Integer.parseInt(br.readLine());
        int[] array = Stream.of(br.readLine().split(" "))
                                   .mapToInt(Integer::parseInt)
                                   .toArray();
        Arrays.sort(array);
        int result = 0;
        for (int i = 0; i < array.length; i += 2) {
            result += Math.min(array[i], array[i + 1]);
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 27476
import java.util.Scanner;

public class Main {

	/**成績をつける
	 *
	 * @param args
	 */
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){
		for(; scan.hasNext();){
			int mid_term = scan.nextInt();
			int fin_term = scan.nextInt();

			int re_test = scan.nextInt();
			//			int mid_term = Integer.parseInt(args[k]);		//中間試験
			//			int fin_term = Integer.parseInt(args[k+1]);		//期末試験
			//
			//			int re_test = Integer.parseInt(args[k+2]);			//再試験

			if(!(mid_term == -1 && fin_term == -1 && re_test == -1)){
				score(mid_term, fin_term, re_test);
			}else{
				//		System.out.println();//おまじない
				break;
			}
		}

	}

	/**
	 * 点数に応じたスコアを出力する
	 * @param mid	中間試験の点数
	 * @param fin	期末試験の点数
	 * @param re	再テストの点数
	 */
	public  static void score(int mid,int fin,int re){

		int sum = mid + fin;
		boolean flag = true;		//受けていない場合

		//期末、中間どちらか受けていない場合は即F
		if(mid == -1 || fin == -1){
			System.out.println("F");
			flag = false;
		}
		//期末、中間を受験している場合
		if(flag){
			if(sum >= 80){

				System.out.println("A");
			}else if(65 <= sum && sum < 80){
				System.out.println("B");
			}else if(50 <= sum && sum <65){
				System.out.println("C");
			}else if(30 <= sum && sum < 50){
				if(re >= 50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else
				System.out.println("F");
		}
	}
}


Measured memory_bytes: 26268
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int gcd(int x, int y) {
  if (x%y == 0) return y;
  return gcd(y, x%y);
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll lcm = A * B / gcd(A,B);
  cout << lcm << endl;
  return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {


    int n;
    cin>>n;
    vi v(n);
    vi p(n);
    rep(i,n){
        cin>>v[i];
        p[i]=v[i]+i;
        if(p[i]>=n)p[i]=-1;
    }
    mii s;
    rep(i,n){
        s[v[i]-i]++;
    }
    ll ans=0;
    rep(i,n){
        if(p[i]>0){
            ans+=s[-p[i]];
        }
    }
    fin(ans);
}



Measured memory_bytes: 15060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var d = ria();
		var A = d[0];
		var B = d[1];
		Console.WriteLine(Math.Max(A, B) <= 8 ? "Yay!" : ":(");
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int a[205];

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	int answer = 1e9;
	for(int i = 1; i <= 100; ++i) {
		int cur = 0;
		for(int j = 1; j <= n; ++j)
			cur += (i - a[j]) * (i - a[j]);
		answer = min(answer, cur);
	}
	cout << answer;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;

int main(){
  int n,m,p,a;
  int d[11111];
  cin >> n >> m >> p;
  for(int i=0;i<m;i++){
    cin >> a;
    d[i] = (a - p + n) % n;
  }
  sort(d,d+m);
  int res = min(n-d[0],d[m-1]);
  for(int i=0;i<m;i++){
    if(i > 0){
      res = min(res,2*(n-d[i])+d[i-1]);
    }
    if(i < m-1){
      res = min(res,2*d[i]+n-d[i+1]);
    }
  }
  cout << res * 100 << endl;
}

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

N, A, B = [int(x) for x in input().split()]

AB = A + B

if AB == 0:
    print(0)
    sys.exit()

ans = A * (N // AB)
ans_mod = N % AB 

if ans_mod == 0:
    print(ans)
    sys.exit()

if ans_mod >= A:
    ans += A
elif ans_mod < A:
    ans += ans_mod

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
#define MAXNUM 5555
ll mod;
ll dp[MAXNUM][2];
void add(ll &a,ll b)
{
    a+=b;
    if(a>=mod)a-=mod;
}
int main()
{
    int n;
    scanf("%d%lld",&n,&mod);
    dp[0][0]=1;int m=(n-1)/2;
    rep(i,1,m+1)
    rep(j,0,n+1)
    {
        dp[j][1]=dp[j][0];
        if(j>=i)add(dp[j][1],dp[j-i][1]);
        dp[j][0]=dp[j][1];
        if(j>=i)add(dp[j][0],dp[j-i][0]);
    }
    ll res=0;
    if(n&1)
    {
        rep(i,1,n+1)
        for(int j=0;j*(m+1)<=n-i;j++)
            add(res,dp[n-i-j*(m+1)][0]);
    }
    else{
        rep(i,1,n+1)
            for(int j=0;j*(m+1)<=n-i;j++)
                add(res,dp[n-i-j*(m+1)][0]*(j+1)%mod);
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 384
#include <iostream>

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


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

int main() {

	ll n, k, sum = 0;
	cin >> n >> k;
	vector<ll> v(n);
	for(ll i = 0; i < n; i++)
		cin >> v[i];
	sort(v.begin(), v.end());
	for(ll i = 0; i < k; i++)
		sum += v[i];

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>
#include <queue>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	int ABCDE[5];
	int minIndex = 0;
	int minValue = 9;

	for (int i = 0; i < 5; ++i) {
		cin >> ABCDE[i];

		int val = ABCDE[i] % 10;
		if (val > 0) {
			if (minValue > val) {
				minValue = val;
				minIndex = i;
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 5; ++i) {
		if (i != minIndex) {
			if (ABCDE[i] % 10 > 0) {
				ABCDE[i] = (ABCDE[i] / 10) * 10 + 10;
			}
		}
		ans += ABCDE[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string.h>
#include<set>
using namespace std;
 
int main(){
    string s,t;
    set<string> S;
    int n1,n2,n;
    int k=0;
    cin>>s>>t;
    n1=s.length();
    n2=t.length();
    n=n1-n2;
    if(n<0){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=0;i<=n;i++){
        string ss(s);
        bool check=true;
        for(int j=0;j<n2;j++){
            if((s[i+j]!=t[j])&&(s[i+j]!='?')) check=false;
        }
        if(check){
            for(int j=0;j<n2;j++){
                ss[i+j]=t[j];
            }
            for(int j=0;j<n1;j++){
                if(ss[j]=='?')ss[j]='a';
            }  
            S.insert(ss);
        }
    }
    if(S.size()==0)cout<<"UNRESTORABLE"<<endl;
    else cout<<*S.begin()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int h[105];


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


  int ans = 0;
  for(int i = 1; i <= 100; i++) {
    int j = 0;
    while(j < n) {
    while(j < n && h[j] < i) j++;
    if(j >= n) break;
    ans++;
    while(j < n && h[j] >= i) j++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=5e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ll x,k,d;
  cin>>x>>k>>d;
  x=abs(x);
  ll val=x/d;
  if(val>k)
  {
    ll ans=(x-(k*d));
    cout<<ans<<endl;
  }
  else
  {
    ll ans=x%d;
    k-=val;
    if(k&1)
    {
      ans=d-ans;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3628
<?php

fscanf(STDIN, '%d', $N);
$line = trim(fgets(STDIN));
$arr = explode(' ', $line);

echo implode(' ', $arr), PHP_EOL;
for ($i = 1; $i < $N; $i++) {
    $tmp = $arr[$i];
    if ($arr[$i - 1] > $tmp) {
        $j = $i;
        do {
            $arr[$j] = $arr[$j - 1];
            $j--;
        } while ($j > 0 && $arr[$j - 1] > $tmp);
        $arr[$j] = $tmp;
    }
    echo implode(' ', $arr), PHP_EOL;
}

Measured memory_bytes: 6612
-- Watch
import Data.List

main = readLn >>= putStrLn . intercalate ":" . map show . solve

solve :: Int -> [Int]
solve n = [h,m,s]
  where
    h = div n 3600
    m = mod (div n 60) 60
    s = mod n 60

-- import Data.List
-- intercalate :: [a] -> [[a]] -> [a]
-- intercalate xs xss = concat $ intersperse xs xss

Measured memory_bytes: 3568
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int INF=1e9+7;
int main(){
  ll s;
  cin>>s;
  ll a=s/500;
  s-=a*500;
  ll b=s/5;
  cout<<1000*a+b*5<<endl;
}

Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define inf 1e10
#define MOD 1000000007
#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)
#define adj(N) vector<vector<int>> ADJ(N+1)
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

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

	READV(N);
	READV(M);
	READAR(A,N);
	READAR(B,M);
	ll dp[N+1][M+1];
	FORI(i,0,N+1)
	{
		FORI(j,0,M+1)
		{
			dp[i][j]=0;
		}
	}
	FORI(i,1,N+1)
	{
		FORI(j,1,M+1)
		{
			if(A[i-1]==B[j-1])
			{
				dp[i][j] =(1+dp[i][j - 1]+dp[i - 1][j])%MOD;
			}
			else
			{
				dp[i][j]=((dp[i][j-1]+dp[i - 1][j])%MOD-dp[i - 1][j - 1]+MOD)%MOD;  
			}
		}
	}
	cout<<(dp[N][M]+1)%MOD<<endl;

	return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  ll N,K; cin>>N>>K;
  ll h[N]; CINA(h,N);
  sort(h,h+N,greater<ll>());
  ll r = 0;
  for(int i=K;i<N;i++){
    r += h[i];
  }
  cout << r <<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	ll N,A,B,Ans=LLONG_MAX;
	cin>>N>>A>>B;
	vector<ll> h(N);
	for(int i=0;i<N;i++) cin>>h[i];
	ll ok=0,ng=1000000001;
	while(abs(ok-ng)>1){
		ll sum=0,mid=(ok+ng)/2;
		for(int i=0;i<N;i++){
			sum+=max(0LL,(h[i]-B*mid+A-B-1)/(A-B));
		}
		if(sum<=mid){
			ng=mid;
			Ans=min(Ans,mid);
		}else if(sum>mid){
			ok=mid;
		}
	}
	cout<<Ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
A, B, C, D = map(int, input().split())

if B <= D:
    if C <= A:
        print(B-A)
    else:
        print(B-C if B-C > 0 else 0)

else:
    if A <= C:
        print(D-C)
    else:
        print(D-A if D-A > 0 else 0)

Measured memory_bytes: 2940
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

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

a.sort(reverse=True)

ali = 0
bob = 0

for i in range(n):
    if i % 2 == 0:
        ali += a[i]
    else:
        bob += a[i]
print(ali-bob)








Measured memory_bytes: 9048
#include <bits/stdc++.h>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a = n/500;
	int b = (n%500)/5;
	ll otpt = a*1000+b*5;
	cout << otpt << endl;
}



Measured memory_bytes: 256
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	boost; IO();

	int N; cin>>N;

	int ans=0;
	for(int i=1; i<N; i++){
		ans+=N/i; if(N%i==0) ans--;
	}
	cout << ans << endl;




	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

struct Edge {
  Edge() = default;

  Edge(size_t a, size_t b) {
    if (a > b) std::swap(a, b);
    this->a = a;
    this->b = b;
  }

  bool operator<(const Edge& other) const noexcept {
    if (a < other.a) return true;
    if (a > other.a) return false;
    return b < other.b;
  }

  size_t a = 0;
  size_t b = 0;
};

// 木構造 = 親は1つ = それ以外を子との辺に割り当てる
int main() {
  size_t N;
  std::cin >> N;

  std::vector<std::vector<size_t>> graph(N + 1);
  std::vector<Edge> edges(N - 1);
  for (size_t i = 0; i < N - 1; ++i) {
    std::cin >> edges[i].a >> edges[i].b;
    graph[edges[i].a].push_back(edges[i].b);
  }

  // 幅優先で色を塗る
  const size_t INVALID_COLOR = N + 1;
  std::vector<size_t> indices;
  std::vector<size_t> parent_colors;
  indices.reserve(N);
  parent_colors.reserve(N);
  std::map<Edge, size_t> color_map;
    
  size_t num_colors = 0;

  size_t color = 1;
  for (const auto child : graph[1]) {
    const auto child_color = color++;
    color_map.emplace(Edge{1, child}, child_color);
    indices.push_back(child);
    parent_colors.push_back(child_color);
  }
  num_colors = std::max(num_colors, graph[1].size());

  while (!indices.empty()) {
    const auto parent = indices.back();
    const auto parent_color = parent_colors.back();
    indices.pop_back();
    parent_colors.pop_back();
    
    size_t color = 1;
    const auto& children = graph[parent];
    for (const auto child : children) {
      if (color == parent_color) color++;

      const auto child_color = color++;
      color_map.emplace(Edge{parent, child}, child_color);
      indices.push_back(child);
      parent_colors.push_back(child_color);
    }

    // 色の数は頂点に接続される辺の最大数に等しい
    num_colors = std::max(num_colors, children.size() + 1);
  }

  std::cout << num_colors << '\n';
  for (const auto& edge : edges) {
    std::cout << color_map[edge] << '\n';
  }

  return 0;
}


Measured memory_bytes: 12892