akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ss string
#define ll long long int
#define Endl endl
#define forn for(long long int i=0;i<n;i++)
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1e9 + 7;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
ll         tests=          1;

using namespace std;
int binarySearch(int arr[], int l, int r, int x)
{
	if (r >= l) {
		int mid = l + (r - l) / 2;
		if (arr[mid] == x)
			return mid;
		if (arr[mid] > x)
			return binarySearch(arr, l, mid - 1, x);
		return binarySearch(arr, mid + 1, r, x);
	}
	return l;
}
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
// ll ctr=1;
// ll vis[10001];
// ll color[10001];
// vector<ll>v[10001];
// void dfs(ll node,ll colr)
// {
// 	vis[node]=1;
// 	for(ll i=0;i<v[node].size();i++)
// 	{
//        if(!vis[v[node][i]])
//        {
//        	  if(color[v[node][i]]!=colr)
//        	  	ctr++;
//        	dfs(v[node][i],color[v[node][i]]);
//        }
// 	}
// }
 // for(ll i=2;i<=n;i++)
    // {
    //       ll x;
    //      cin>>x;
    //    v[i].push_back(x);
    //    v[x].push_back(i);
    // }
    // fr(i,1,n)
    // {
    // 	cin>>color[i];
    // }
    // ll result=0;
    // dfs(1,color[1]);
    // result+=ctr;
    // cout<<result;
   // for(ll i=1;i<=n;i++)
   // {
   // 	   cout<<i;
   // 	for(ll j=0;j<v[i].size();j++)
   // 	{
   // 		cout<<"-"<<v[i][j];
   // 	}
   // 	cout<<endl;
   // }
int main()
{
    #ifndef ONLINE_JUDGE
	{
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
   #endif
    map<string,ll>mp;
    ll n;
    cin>>n;
    while(n--)
    {
    	ss s;
    	cin>>s;
    	mp[s]++;
    }
    cout<<mp.size();
  
   }



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

using namespace std;

#define MAX_N 200005
#define MAX_M 200005

int N, M;
int A[MAX_N];
int X[MAX_M], Y[MAX_M];

int main()
{
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < M; i++) {
    cin >> X[i] >> Y[i]; X[i]--;
  }

  int List[MAX_N];
  int NumCnt[MAX_N];

  memset(List, 0, sizeof(List));
  memset(NumCnt, 0, sizeof(NumCnt));

  for (int i = 0; i < N; i++) {
    List[max(1, A[i] - NumCnt[A[i]])]++;
    NumCnt[A[i]]++;
  }

  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if(List[i] == 0){
      ans++;
    }
  }

  for (int i = 0; i < M; i++) {
    int before = A[X[i]], after = Y[i];

    //減らした際に，そこをカバーするものがなくなった
    if(List[max(1, before + 1 - NumCnt[before])] == 1){
      ans++;
    }

    //更新
    List[max(1, before + 1 - NumCnt[before])]--;
    NumCnt[before]--;

    //増やした際に，カバーできるものが増えた
    if(List[max(1, after - NumCnt[after])] == 0){
      ans--;
    }

    //更新
    List[max(1, after - NumCnt[after])]++;
    NumCnt[after]++;

    A[X[i]] = Y[i];

    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 5376
#include<stdio.h>
int main(void){
  int n, m,l;
  scanf("%d",&n);
  if(n / 100 == 1){
    m += 900;
    n -= 100;
  }
  else{
    m += 100;
    n -= 900;
  }
  if(n / 10 == 1){
    l += 90;
    n -= 10;
  }
  else{
    l += 10;
    n -= 90;
  }
  if(n == 1){
    printf("%d\n",m+l+9);
  }
  else{
    printf("%d\n",m+l+1);
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    double  s,t1,v,t2;
    scanf("%lf %lf %lf",&s,&t1,&v);
    t2=s/v;
    if(t2<=t1)
    {
    printf("Yes\n");
    }
    else
    {
    printf("No\n");
    }
    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[111];

int main() {
    li n;
    cin >> n;
    li now = 1;
    while (now * 2 <= n) {
        now *= 2;
    }
    cout << now << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
typedef struct{
	long long int prev;//?????¨????????????????????????????????????????´?
	long long int next;//?????¨??????????????????????¬?????????????????´?
	long long int data;
} list;

list L[2000000];

long long int ff = -1,bb = -1;//ff:???????????????????????´??? bb:????????????????°??????´???
long long int num = 0,usecnt = -1; //num:????????????????´???° usecnt:????????????????????§?????¨?????????

int main(){
	int i,j,k;
	long long int n;
	scanf("%lld",&n);
	for(i=0; i<n; i++){
		char op[20];
		scanf("%s",op);
		if(strcmp(op,"insert")==0){
			long long int p;
			scanf("%lld",&p);

			if(num==0){
				// L[usecnt+1]??????????????¨??§??°????????´???????????????????????????
				L[usecnt+1].data = p; 
				/*?????????????°????usecnt+1*/
				ff = usecnt+1;
				bb = usecnt+1;
				usecnt++;
				num++;
			}else{
				L[usecnt+1].data = p;
				L[usecnt+1].next = ff; /*??°??????????´?????¬????????´????????????§???????????£?????´???*/
				L[ff].prev = usecnt+1; /*????????§???????????£?????¨?????????????????°??????????????£???????´?*/
				ff = usecnt+1; /*???????????°?????????????????´??°*/
				usecnt++;
				num++;
			}
		}else if(strcmp(op,"delete")==0){
			long long int p;
			scanf("%lld",&p);
			long long int nowcnt = 0; /*??????????´????????????????*/
			long long int nowpos = ff; /*?????¨?????????*/
			long long int tg = L[nowpos].data; /*????±?*/
			while(nowcnt<num){
				if(tg==p){ /*???????????£??????*/
					if(nowcnt==0){
						ff = L[ff].next; /*?????????????????§?????????????¬????????´??????????*/
						num--;
					}else if(nowcnt==num-1){ 
						bb = L[bb].prev; /*?????????????°????????´?????????????????´??????????*/
						num--;
					}else{
						/*A -> B -> C?????? A -> C????????????*/
						L[L[nowpos].prev].next = L[nowpos].next;
						L[L[nowpos].next].prev = L[nowpos].prev;
						num--;
					}
					//L[nowpos]?????????????????§????????????????????§?????????????????????????????¢????????¨???????????????????????¢????§£???
					break;
				}
				nowcnt++;
				/*?????????????±???¨????????????????????´??°*/
				tg = L[L[nowpos].next].data;
				nowpos = L[nowpos].next;
			}
		}else if(strcmp(op,"deleteFirst")==0){ /*??????delete???nowcnt==0?????¨?????¨??????*/
			ff = L[ff].next;
			num--;
		}else if(strcmp(op,"deleteLast")==0){ /*??????delete???nowcnt==num-1?????¨?????¨??????*/
			bb = L[bb].prev;
			num--;
		}
		/*long long  int pos = ff;
		while(pos!=bb){
			printf("%lld ",L[pos].data);
			pos = L[pos].next;
		}
		printf("%lld\n",L[pos].data);
		printf("\n");*/
	}

	//?????????????????????????????£????????£?????????*/
	long long  int pos = ff;
	while(pos!=bb){
		printf("%lld ",L[pos].data);
		pos = L[pos].next;
	}
	printf("%lld\n",L[pos].data);
	
	return 0;
}

Measured memory_bytes: 28392
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b,c;
    string ans="";
    cin >>a>>b>>c;
    if(a+b>=c)ans="Yes";
    else ans="No";
    cout<<ans<<endl;
}


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    int a[n];

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

    for (int i = 0; i < n; i++) {
        if (i == 0) {
            cout << a[n-1-i];
        } else {
            cout << ' ' << a[n-1-i];
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3072
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')


def solve(N: int):
    return (N//2 + N % 2) / N


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(f'{solve(N)}')


if __name__ == '__main__':
    main()


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

int main() {
	ll n;
	cin >> n;
	ll t = n;
	ll m = 26;
	int cnt(0);
	while (t>0) {
		t = t - m;
		m *= 26;
		++cnt;
	}
	m /= 26;
	ll k = t + m;
	
	cnt--;
	k--;
	while (cnt>=0){
		ll aa = pow(26, cnt);
		int a = k / aa;
		cout <<char(a+97);
		k %= aa;
		cnt--;

	}
	return 0;
}

Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    cin >> x;
    ld P = 100;
    int i = 0;
    while (P < x)
    {
        i++;
        P = P * (1.01);
        P = (ll)P;
    }
    cout << i << '\n';
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N+1], k;
  for (int i = 0; i < N; i++) {
    cin >> k;
    A[k] = i + 1;
  }
  for (int i = 1; i <= N; i++) {
    cout << A[i] << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 1152
import math
K=int(input())+1
goke=0
for i in range(1,K):
    for j in range(i,K):
        for k in range(j,K):
            if i==j and i==k:
                goke=goke+i
            elif (i==j and i<k) or (i<j and j==k):
                goke=goke+3*math.gcd(i,k)
            else:
                goke=goke+6*math.gcd(math.gcd(i,j),k)
print(goke)

Measured memory_bytes: 9208
import java.util.*;
import java.math.*;
import java.text.*;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			int a=in.nextInt(),b=in.nextInt(),c=in.nextInt(),d=in.nextInt(),e=in.nextInt(),f=in.nextInt();
			double x=0,y=0;
			x=((double)c*(double)e-(double)b*(double)f)/((double)a*(double)e-(double)b*(double)d);
			y=((double)c*(double)d-(double)a*(double)f)/((double)b*(double)d-(double)a*(double)e);
			BigDecimal bx = new BigDecimal(x);
			BigDecimal by = new BigDecimal(y);
			System.out.println(bx.setScale(3,BigDecimal.ROUND_HALF_UP)+" "+by.setScale(3,BigDecimal.ROUND_HALF_UP));
		}
	}
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
 
using namespace std;
 
int INF = 1e9 + 5;
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n;
    cin >> n;
    vector<int> prev_day(3);
    for (int i = 0; i < n; i++) {
        vector<int> activity(3);
        for (int j = 0; j < 3; j++) 
            cin >> activity[j];
        
        vector<int> next_day(3);
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k != j) {
                    next_day[k] = max(next_day[k], prev_day[j]);
                }
            }
        }
        for (int j = 0; j < 3; j++) 
            next_day[j] += activity[j];
        prev_day = next_day;
    }
    cout << max({prev_day[0], prev_day[1], prev_day[2]});
}

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

int main() {
  int n;
  cin >> n;
  list<ll> B;
  for (ll i = 0; i < n; ++i) {
    ll ai;
    cin >> ai;
    if ((n % 2 == 0 && i % 2 == 0) || (n % 2 == 1 && i % 2 == 1)) {
      B.push_back(ai);
    } else {
      B.push_front(ai);
    }
  }
  for (auto itr = B.begin(); itr != B.end(); itr++) {
        std::cout << *itr << std::endl;
    }
}


Measured memory_bytes: 10496
//import for Scanner and other utility classes
import java.util.*;
import java.io.*;
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    public static void main(String args[] ) {
        Scanner s = new Scanner(System.in);
       int n=s.nextInt();
      int num=0;
      if(n%2==1)
        num=n/2+1;
      else
        num=n/2;
      
      double ans=(double)num/(double)n;
      
      System.out.format("%.10f",ans);
      
        // Write your code here
 
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        n = ni();
        int m = ni();
        graph= new ArrayList<>();
        for (int i = 0; i < n; i++){
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = ni()-1;
            int b = ni()-1;
            graph.get(a).add(b);
            graph.get(b).add(a);
        }
        dfs(0,0);
        
        out.println(ans);
    }
    
    int n;
    ArrayList<ArrayList<Integer>> graph;
    int ans=0;

    void dfs(int next, int state){
        state = state | 1<<next;
        if(state == (1<<n)-1){
            ans++;
            return;
        }
        for (Integer n : graph.get(next)) {
            if((1<<n & state) ==0){
                dfs(n,state);
            }
        }
    }
 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    double a, b, x; cin >> a >> b >> x;
    double ans;
    if (x <= a * a * b / 2) {
        ans = atan(a * b * b / (2 * x));
    } else {
        ans = abs(atan(2 / pow(a, 3) * (x - a * a * b)));
    }
    printf("%.12f\n", ans * 180 / M_PI);
    return 0;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <vector>
using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

#define PI 3.141592653589793L
int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double ath = (long double)PI / 6.0 * (h + m / 60.0);
    long double bth = (long double)PI / 30.0 * m;
    // long double theta = abs(ath - bth);
    long double theta = ath - bth;
    // if (theta > PI) {
    //     theta -= PI;
    // }
    long double aa  = a * a;
    long double bb  = b * b;
    long double ab  = aa + bb;
    long double c   = 2 * a * b;
    long double d   = c * cosl(theta);
    long double len = sqrtl(ab - d);
    cout << fixed << setprecision(16) << len << endl;

    return 0;
}


Measured memory_bytes: 4160
import math

hp, attack = map(int, input().split())

print(math.ceil(hp / attack))

# x, y = divmod(hp, attack)
#
# if y == 0:
#     print(x)
# else:
#     print(x + 1)

# count = 0
# 
# while True:
#     hp -= attack
#     count += 1
# 
#     if hp <= 0:
#         print(count)
#         break
# 


Measured memory_bytes: 2940
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

const p = 1000000007

func Pow(n, k int) int {
  m := 1
  for 1 << uint(m) <= k { m++ }
  P := make([]int, m)
  P[0] = n % p
  for i := range P[1:] { P[i + 1] = P[i] * P[i] % p }
  a := 1
  for i := 0; 0 < k; i++ {
    if k % 2 == 1 { a = a * P[i] % p }
    k /= 2
  }
  return a
}

func GCD(a, b int) int {
  if a < b { a, b = b, a }
  if b == 0 { return a }
  return GCD(b, a % b)
}

func Solve() {
  var N int
  NextInt(&N)
  MA := make(map[int]map[int]int)
  MB := make(map[int]map[int]int)
  var a, b, gcd int
  var ok bool
  Add := func(M *map[int]map[int]int, a, b int) {
    a, b = AbsInt(a), AbsInt(b)
    gcd = GCD(a, b)
    a, b = a / gcd, b / gcd
    if _, ok = (*M)[a]; !ok { (*M)[a] = make(map[int]int) }
    if _, ok = (*M)[a][b]; !ok { (*M)[a][b] = 0 }
    (*M)[a][b]++
  }
  z := 0
  for i := 0; i < N; i++ {
    NextInt(&a, &b)
    if a == 0 && b == 0 {
      z++
    } else {
      if (a > 0 && b > 0) || (a < 0 && b < 0) || a == 0 {
        Add(&MA, a, b)
      } else {
        Add(&MB, a, b)
      }
    }
  }
  cnt := 1
  var v int
  var M map[int]int
  for a, M = range MA {
    for b, v = range M {
      if _, ok = MB[b][a]; ok {
        cnt = cnt * ((Pow(2, v) + Pow(2, MB[b][a]) + p - 1) % p) % p
      } else {
        cnt = cnt * Pow(2, v) % p
      }
    }
  }
  for a, M = range MB {
    for b, v = range M {
      if _, ok = MA[b][a]; !ok {
        cnt = cnt * Pow(2, v) % p
      }
    }
  }
  ans := (z + cnt + p - 1) % p
  Write(ans)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 68996
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 20:12:13 2019

@author: yuta
"""

def judge(n,a):
    rest500 = int(n / 500)
    rest1 = n - (500 * rest500)
    if rest1 <= a:
        print("Yes")
    else:
        print("No")

x = input()
y = input()
judge(int(x),int(y))

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

int main(void)
{
  int buf;
  bool students[30];
  for (int i = 0; i < 30; i++)
  {
    students[i] = true;
  }

  for (int i = 0; i < 28; i++)
  {
    cin >> buf;
    students[buf - 1] = false;
  }

  for (int i = 0; i < 30; i++)
  {
    if ( students[i] ) cout << i + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}
// cf IO: I64d
// atcoder IO: ｌｌｄ
const int Maxn=100005;
int a[Maxn];
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	int x=0,mx=0;
	for (int i=0;i<n;i++){
		scanf("%d",&a[i]);
		x=__gcd(x,a[i]);
		mx=max(mx,a[i]);
	}
	if (k>mx || k%x!=0){
		printf("IMPOSSIBLE\n");
	}
	else{
		printf("POSSIBLE\n");
	}
	return 0;
} 

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
# template: v1.3.1

# 丸太の分割分割問題。
# 速度の観点から、「答えの二分探索」が必要。典型らしい。
# f(x) の処理、すぬけさんのをチェック


import io
import sys
import math

### DEBUG ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
2 1
1 3
"""

# Worst
# _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }"
# _INPUT = f"{str(2*(10**5))} {str(10**9)}\n{(str(10**9)+' ')*(2*(10**5)) }"


_EXPECTED = """\
ABC
"""
if _DEB:
    sys.stdin = io.StringIO(_INPUT)
    print("!! Debug Mode !!")


def logd(str):
    if _DEB: print(f"[deb] {str}")

# is_m_OK?
def f(m):
    cut=0
    for aa in a:
        #ここを変えた
        c=(aa-1)//m 
        cut+=c
        if cut > k:
            return False
    return True
#m=7,a=[7,9]


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

### Solve ####
def solve():
    # Process

    ans=0
    l,r=0,10**9
    while abs(r-l)!=1:
        m=(l+r)//2
        if f(m): # m is ok: Go left
            r=m
        else: # m is ng : Go right
            l=m
    
    ans=r
    # ans=min(r,max(a))

    # OUPUT
    ans = str(ans)
    print(ans)
    return ans

### MAIN ###
if __name__ == "__main__":
    ans = solve()

    # Checker
    if _DEB:
        if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!")
        else: print(f"\n!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 31116
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,A,B; cin>>N>>A>>B;
  int a=0,b=0;
  a=min(A,B);
  b=A+B-N;
  if(b<0) b=0;
  cout<<a<<" "<<b<<endl;
}

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

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007LL;

int main(void) {
    int N, M;
    vector<int> k(11), p(11);
    vector<vector<int>> s(11,vector<int>(11));
    cin >> N >> M;
    for (int i=0;i<M;i++) {
        cin >> k[i];
        for (int j=0;j<k[i];j++) cin >> s[i][j];
    }
    for (int i=0;i<M;i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int b=0;b<(1<<N);b++) {
        int cnt = 0;
        for (int i=0;i<M;i++) {
            int sw = 0;
            for (int j=0;j<k[i];j++) {
                if (b & (1<<(s[i][j]-1))) sw++;
            }
            if (sw % 2 == p[i]) cnt++;
        }
        if (cnt == M) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
ll MOD = 1e9+7;

ll dp[104][100009];
ll a[104],pre[104][100009];
inline int add(int a, int b){
    a += b;
    if(a >= MOD)a -= MOD;
    return a;
}
 
inline int sub(int a, int b){
    a -= b;
    if(a < 0)a += MOD;
    return a;
}
int main(){
    fast;
    ll n,k;cin>>n>>k;

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

    for(ll i=0;i<n;++i)
        pre[i][0] = dp[i][0] = 1;
    
    
    for(ll i=0;i<=k;++i){
        dp[0][i] = 1*(i<=a[0]);
        if(i>0)
            pre[0][i] = pre[0][i-1] + dp[0][i];
        else
            pre[0][0] = 1;
        
    }
    for(ll i=1;i<n;++i){
        for(ll j=1;j<=k;++j){//sum to make
            if(j-a[i]-1<0){
                dp[i][j] = pre[i-1][j]%MOD;
            }
            else{
                dp[i][j] = (pre[i-1][j]%MOD - pre[i-1][j-a[i]-1]%MOD+MOD)%MOD;
            }
            pre[i][j] = (pre[i][j-1]%MOD + dp[i][j]%MOD)%MOD;

            
            /*int first = (j - a[i] - 1 >= 0)? pre[i - 1][j - a[i] - 1] : 0;
            int last = pre[i - 1][j];
            dp[i][j] = add(dp[i][j], sub(last, first));
            pre[i][j] = add(pre[i][j - 1], dp[i][j]);
            */
            /*  precalculate the sum from dp[i-1][max(0,j-a[i])] to dp[i-1][j].
                which is equal to dp[i-1][j] - dp[i-1][max(0,j-a[i])-1]
            */
            /*for(ll l=max(0ll,j-a[i]);l<=j;++l){//
                dp[i][j] = (dp[i][j]%mod + dp[i-1][l]%mod)%mod;
                
            }*/
        }
    }
    cout<<dp[n-1][k];
    /*cout<<endl<<"prefix\n";
    for(ll x=0;x<n;++x){ 
        cout<<"\n->"<<x+1<<endl; 
        for(ll i=0;i<=k;++i){
            cout<<"\t"<<pre[x][i]<<" ";
        }
    }
    cout<<"\ndp\n";
    for(ll x=0;x<n;++x){
        cout<<"\n->"<<x+1<<endl;
        for(ll i=0;i<=k;++i){
            cout<<"\t"<<dp[x][i]<<" ";
        }
    }*/
    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
using namespace std;
enum POSITION{CLOCKWISE, COUNTER_CLOCKWISE, ONLINE_BACK,
              ONLINE_FRONT, ON_SEGMENT};
struct Point{
    double x;
    double y;
    Point(double x, double y) : x(x), y(y){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double get_cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double get_dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}
struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2){}
};
POSITION get_position(Point p, Segment s){
    Vector base = s.p2 - s.p1;
    Vector obj  = p    - s.p1;
    double cross = get_cross(base, obj);
    if (cross >  1e-10) return CLOCKWISE;
    if (cross < -1e-10) return COUNTER_CLOCKWISE;
    if (get_dot(base, obj) < 0) return ONLINE_BACK;
    if (get_dot(base, base) < get_dot(obj, obj)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool is_intersection(Segment s1, Segment s2){
    POSITION s2p1_s1 = get_position(s2.p1, s1);
    POSITION s2p2_s1 = get_position(s2.p2, s1);
    POSITION s1p1_s2 = get_position(s1.p1, s2);
    POSITION s1p2_s2 = get_position(s1.p2, s2);
    if (s2p1_s1 == ON_SEGMENT || s2p2_s1 == ON_SEGMENT) return true;
    if (s1p1_s2 == ON_SEGMENT || s1p2_s2 == ON_SEGMENT) return true;
    if (s2p1_s1 == ONLINE_FRONT) {
        if (s2p2_s1 == ONLINE_BACK) return true;
        return false;
    }
    if (s2p1_s1 == ONLINE_BACK) {
        if (s2p2_s1 == ONLINE_FRONT) return true;
        return false;
    }
    if (s2p1_s1 == s2p2_s1) return false;
    if (s1p1_s2 == s1p2_s2) return false;
    return true;
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3;
        cin >> x_p0 >> y_p0 >> x_p1 >> y_p1;
        cin >> x_p2 >> y_p2 >> x_p3 >> y_p3;
        Point p0(x_p0, y_p0);
        Point p1(x_p1, y_p1);
        Point p2(x_p2, y_p2);
        Point p3(x_p3, y_p3);
        Segment s1(p0, p1);
        Segment s2(p2, p3);
        int ans = 0;
        if (is_intersection(s1, s2)) ans = 1;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int n;
vvi cost;
vi mincos;
vector<bool> used;

int prim() {
	rep(i, n) {
		mincos[i] = INF;
		used[i] = false;
	}
	mincos[0] = 0;
	int res = 0;
	while (1) {
		int v = -1;
		rep(u, n) {
			if(!used[u]&&(v==-1||mincos[u]<mincos[v])){
				v = u;
			}
		}
		if (v == -1) break;
		used[v] = true;
		res += mincos[v];

		rep(u, n) {
			mincos[u] = min(mincos[u], cost[v][u]);
		}
	}
	return res;
}

int main() {
	int a,b;
	cin >> n ;
	cost.resize(n);
	mincos.resize(n);
	used.resize(n);
	for (auto &i : cost) {
		i.resize(n);
	}
	rep(i, n) {
		rep(j, n) {
			cin >> cost[i][j];
			if (cost[i][j] == -1) cost[i][j] = INF;
		}
	}
	cout << prim() << endl;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N;cin >> N;
  ll ans=0;
  ll K = 10;
  while(K <= 2e17){
    ans += N/K;
    K *= 5;
  }
  ans += (N/K);
  if(N&1) ans=0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
from collections import Counter

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    counter = Counter(a_list)

    max_cnt = 0
    for i in set(a_list):
        cnt = 0
        cnt += counter[i]
        cnt += counter[i - 1]
        cnt += counter[i + 1]
        if cnt > max_cnt:
            max_cnt = cnt
    print(max_cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		int sum = n*l + n*(n+1)/2 - n;
		if(l>0) sum -= l;
		else if(l+n-1<0) sum -= l+n-1;
		System.out.println(sum);
		in.close();

	}

}


Measured memory_bytes: 23124
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
int main(){
  int n, ans=0;
  cin >> n;
  vector <int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  FOR(i,1,n-1){
      if(v[i]>v[i-1]&&v[i]<v[i+1]) ans++;
      else if(v[i]<v[i-1]&&v[i]>v[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d %d",$a,$b,$c);

  if($a < $c){
    $d = $a + $b;
    if($d < $c){
      echo "0"." "."0";
    }else{
      $e = $d - $c;
      echo "0"." ".$e;
    }    
  }else{
    $f = $a - $c;
    echo $f." ".$b;
  }

  
?>


Measured memory_bytes: 3700
def main():
    def z_algo(S):
        n, i, j = len(S), 1, 0
        a = [0]*n
        a[0] = n
        while i < n:
            while i+j < n and S[i+j] == S[j]:
                j += 1
            if not j:
                i += 1
                continue
            a[i], k = j, 1
            while a[k] < j-k and i+k < n:
                a[i+k] = a[k]
                k += 1
            i += k
            j -= k
        return a

    n = int(input())
    a, b = list(map(int, input().split())), list(map(int, input().split()))
    a1 = [a[i-1] ^ a[i] for i in range(n)]
    z = z_algo([b[i-1] ^ b[i] for i in range(n)]+a1+a1)
    memo = []
    for i in range(n):
        if z[n+i] >= n:
            memo.append(i)
    b0 = b[0]
    for i in memo:
        print(i, b0 ^ a[i])


main()

Measured memory_bytes: 55820
import java.util.*;

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

                int n = Integer.parseInt(s.next());
                int[] cards = new int[n];

                for (int i=0; i<n; i++) {
                        cards[i] = Integer.parseInt(s.next());
                }

                Arrays.sort(cards);

                int[] total = {0, 0};
                for (int i=n-1; i>=0; i--) {
                        int idx = n-1-i;
                        total[idx%2] += cards[i];
                }

                System.out.println(total[0]-total[1]);
        }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define mkp make_pair
#define sz(x) (int)x.size()
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e18+1;

ll n, m, t, d[301][301], a, b, c, q, ans[301][301];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n >> m >> t;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            d[i][j] = INF;
        }
    }
    for(int i=0; i<m; i++){
        cin >> a >> b >> c;
        if(c<=t) d[a][b] = d[b][a] = c;
    }
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(d[i][k]+d[k][j] < d[i][j]){
                    d[i][j] = d[j][i] = d[i][k] + d[k][j];
                }
            }
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(i==j) ans[i][j] = 0;
            else if(d[i][j]<=t) ans[i][j] = 1;
            else ans[i][j] = INF;
        }
    }
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(ans[i][k]+ans[k][j] < ans[i][j]){
                    ans[i][j] = ans[j][i] = ans[i][k] + ans[k][j];
                }
            }
        }
    }
    cin >> q;
    while(q--){
        int s, t;
        cin >> s >> t;
        if(ans[s][t]==INF) cout << -1 << endl;
        else cout << ans[s][t]-1 << endl;
    }
}


Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

int N, L;
string s;
map <string, int> S;
long long ans = 0;

long long factorial(int k){
    long long sum_ = 0;
    for (int i=1; i<=k; ++i){
        sum_ += i;
    }
    return sum_;
}

int main(){
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> s;
        L = s.length();
        sort(s.begin(),s.end());
        S[s] += 1;
    }
    for (auto itr = S.begin(); itr != S.end(); ++itr){
        if (itr->second > 1){
            ans += factorial(itr->second - 1);
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int cnt=0;
	int n;
	cin>>n;
	int nn=n;
	while(nn)
	{
		nn/=10;
		cnt++;
	}
	int ans=0,j=9,k=1;
	for(int i=1;i<cnt;i+=2,j*=100,k*=100)
		ans+=j;
	if(cnt&1)
		ans+=n-k+1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
using ll = long long;

const int INF = (int) 1e9 + 9;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == "Sunny") puts("Cloudy");
    if (s == "Rainy") puts("Sunny");
    if (s == "Cloudy") puts("Rainy");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

int main(){
	int a,b;
	cin>>a;
	rep(i,2){
		int t;
		cin>>t;
		a=min(a,t);
	}
	cin>>b;
	int t;
	cin>>t;
	b=min(b,t);
	cout<<a+b-50<<endl;
}

Measured memory_bytes: 1160
/* ***********************************************
Author        :ACagain
Created Time  :2018/4/21 11:50:24
File Name     :dong.cpp
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define pii pair<int,int>
#define mp make_pair
#define ll long long
#define INF 0x3f3f3f3f
const int maxn=1e4+5;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	ll n,k;
	ll ans=0;
	cin>>n>>k;
	if(k==0)
	{
		ans=n*n;
	}
	else
	for(int i=k+1;i<=n;i++)
	{
		ll b=i;
		ans+=n/b*(b-k);
		if(n%b>=k)
		  ans+=n%b-k+1;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(0);

	int n,m,x;
	cin >> n >> m;
	multiset<int>s;
	long long ans=0;
	for(int i=0;i<n;i++){
		cin >> x;
		s.insert(x);
	}

	while(m){
		x=*(--s.end());
		s.erase(s.find(x));
		s.insert(x/2);
		m--;
	}

	for(auto x : s)
		ans+=x;
	cout << ans << endl;

	return 0;
}

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


struct Seq
{
	int delta , mini;
	bool operator < (const Seq & autre) const
	{
		return mini > autre.mini;
	}
};

struct S2
{
	int delta , mini;
	bool operator < (const S2 & autre) const
	{
		return (delta - mini) < (autre.delta - autre.mini);
	}
};

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N;
	cin >> N;
	Seq s[N];
	int dTot = 0;
	for (int i = 0 ; i < N ; i++)
	{
		string m;
		cin >> m;
		s[i] = {0  , 0};
		for (int j = 0 ; j < m.size() ; j++)
		{
			if (m[j] == '(') s[i].delta++;
			else
			{
				s[i].delta--;
				s[i].mini = min(s[i].delta , s[i].mini);
			}
		}
		dTot += s[i].delta;
	}
	if (dTot != 0)
	{
		cout<<"No"<<endl;
		exit(0);
	}
	vector <Seq> positif;
	vector <S2> neg;
	for (int i = 0 ; i < N ; i++)
	{
		if (s[i].delta >= 0)
		{
			positif.push_back(s[i]);
		}
		else
		{
			neg.push_back({s[i].delta , s[i].mini});
		}
	}
	sort(positif.begin() , positif.end());
	int dActu = 0;
	for (auto actu : positif)
	{
		if (dActu + actu.mini < 0)
		{
			cout<<"No"<<endl;
			exit(0);
		}
		dActu += actu.delta;
	}
	sort(neg.begin() , neg.end());
	for (int i = neg.size() - 1 ; i >= 0 ; i--)
	{
		if (dActu + neg[i].mini < 0)
		{
			cout<<"No"<<endl;
			exit(0);
		}
		dActu += neg[i].delta;
	}
	cout<<"Yes"<<endl;

}

Measured memory_bytes: 34636
#include<stdio.h>

int main(){

  int N, T;
  scanf("%d %d", &N, &T);

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

  int dmax = 0;
  int count = 0;
  int amin = price[0];

  for(int i=1; i<N; i++){
    if(price[i]<amin){
      amin = price[i];
    }else if(dmax==price[i]-amin){
      count ++;
    }else if(dmax<price[i]-amin){
      dmax = price[i]-amin;
      count = 1;
    }
  }

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

  return 0;
}


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

struct Card{char pic;int num;};
//partitionでは末尾も含む。
int partition(int p,int r,Card A[]){
    int x=A[r].num;//基準
    int i=p-1;
    for(int j=p;j<r+1;j++){
        if(A[j].num<=x){//A[j]の方が大きいならそのまま
        Card tmp=A[j];
        A[j]=A[++i];
        A[i]=tmp;
        if(j==r)return i;
        }
    }
    return r;//[]で括るために取り出さないと。
}
void quickSort(int p,int r,Card A[]){//分ける部分は先の問題のi。
    if(p<r){
    int q=partition(p,r,A);
    quickSort(p,q-1,A);
    quickSort(q,r,A);
    }
}
void merge(int left,int mid,int right,Card B[]){
    //2つの配列をmerge,つまりソートする
    int n1=mid-left;//本来の要素数より1つ多いのは、最後に
    int n2=right-mid;//番兵をいれたいから。
    Card L[n1+1],R[n2+1];
    for(int i=0;i<n1;i++){
        L[i]=B[left+i];
    }L[n1].num=pow(10,9)+1;
    for(int j=0;j<n2;j++){
        R[j]=B[mid+j];
    }R[n2].num=pow(10,9)+1;
    int i=0,j=0;//インデックスを比較していく
    while(i<n1 || j<n2){
        //どっちも番兵に来たらオワリ
        if(L[i].num<=R[j].num){
            B[left+i+j]=L[i];
            i++;
        }
        else{
            B[left+i+j]=R[j];
            j++;
        }
    }
}

void mergeSort(int left,int right,Card B[]){
    if(right>left+1){
        int mid = (right+left)/2;
        mergeSort(left,mid,B);
        mergeSort(mid,right,B);
        merge(left,mid,right,B);
    }
}

int main(){//安定か否かは、安定なソートと比べるのが一番良い。先ほどやったmergeSortは安定だよね。
    int n;cin>>n;Card A[n];for(int i=0;i<n;i++)cin>>A[i].pic>>A[i].num;
    Card B[n];for(int j=0;j<n;j++)B[j]=A[j];//比較用。BはmergeSortする。
    quickSort(0,n-1,A);
    mergeSort(0,n,B);//mergeSortは右端を入れないスタイル。
    bool flg=0;
    for(int k=0;k<n;k++){
        if(A[k].pic!=B[k].pic || A[k].num!=B[k].num){
            flg=1;
            break;
        }
    }
    if(flg==1)cout<<"Not stable"<<endl;
    else{cout<<"Stable"<<endl;}
    for(int i=0;i<n;i++){
        cout<<A[i].pic<<' '<<A[i].num<<endl;
    }
    return 0;
}


Measured memory_bytes: 5432
#include<stdio.h>

int main()
{
    int a,b;

    scanf("%d %d",&a,&b);

    if (a<b){
        printf("a < b\n");
    }
    else if (a>b){
        printf("a > b\n");
    }
    else {
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580