akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)



int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int n, k;
    cin >> n >> k;
    if (k==1) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> a(n+1);
    FOR1(i, n) {
        cin >> a[i];
//        a[i] %= k;
    }

    vector<ll> y(n+1);
    FOR1(i, n) {
        y[i] = y[i - 1] + a[i];
        y[i] %= k;
    }
    FOR1(i, n)
        y[i] -= i;

    ll sol = 0;
    unordered_map<int, int> H;
    H[0] = 1;
    FOR1(i, n){
        sol += H[y[i]] + H[y[i]+k];
        H[y[i]]++;
        if (i-k+1>=0)
            H[y[i-k+1]]--;
    }
    cout << sol << endl;

//    ll sol = 0;
//    for(int r = 1; r<min(n, k); r++){
//        for(int i=0; i+r<=n; i++){
//            if ((y[i+r] - y[i] + k)%k == r)
//                sol++;
//        }
//    }
//    cout << sol << endl;

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 19188
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;


public class Main{
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		long n = sc.nextLong();
		if (n % 2 == 1) {
			System.out.println(0);
		} else {
			long five = 0;
			n /= 2;
			for (long i = 5; i <= n; i *= 5) {
				five += n / i;
			}
			System.out.println(five);
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21332
#include "bits/stdc++.h"
using namespace std;

int c=0;
int A[100000000];

void marge(int A[], int left, int mid, int right){
  int n1=0,n2=0;
  int L[500100];
  int R[500100];
  n1=mid-left;
  n2=right-mid;
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=INT_MAX;
  R[n2]=INT_MAX;
  int j=0;
  int i=0;
  for(int k=left;k<right;k++){
    c++;
    if(L[i]<=R[j]){
      
      A[k]=L[i];
      i++;
      
    }
    else {
      A[k]=R[j];
      j++;
    }
  }
}

void margesort(int A[], int left, int right){
  int mid=0;
  if(left+1<right){
    mid=(left+right)/2;
    margesort(A,left,mid);
    margesort(A,mid,right);
    marge(A,left,mid,right);
  }
}

int main(){
  int n=0;
  int left=0,right=0;
  //int S[100000000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  left=0;
  right=n;
  margesort(A,left,right);
  for(int i=0;i<n;i++){
    if(i!=0)cout<<" ";
    cout<<A[i];
  }
  printf("\n%d\n",c);
  
  return 0;
}




Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename S, typename T>
void xmin(S&a, T const&b){if(b<a) a=b;}
template<typename S, typename T>
void xmax(S&a, T const&b){if(b>a) a=b;}

signed main()
{
    #ifdef LOCAL_RUN
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int TTT; cin >> TTT; while(TTT--){
    #else
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    #endif // LOCAL_RUN

    int n;
    cin >> n;
    vector<ll> v(n);
    ll ans = 0;
    for(auto &e:v){
        cin >> e;
        ans+=e-1;
    }
    cout << ans << "\n";


    #ifdef LOCAL_RUN
    }
    #endif // LOCAL_RUN
    return 0;
}


Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque

def comb(n, r, mod, bunsi):
    if r > n:
        return 0
    ans = bunsi[n] * pow(bunsi[r], mod - 2, mod) * pow(bunsi[n - r], mod - 2, mod)
    return ans


def main():
    num = int(input())
    data = list(map(int, input().split()))

    mod = 10 ** 9 + 7

    count_data = Counter(data)
    count_data = sorted(count_data.items(), key=lambda x: -x[1])
    two_num = count_data[0][0]

    flg = 0
    left, mid, right = 0, 0, 0

    for i in range(num + 1):
        if data[i] == two_num:
            flg += 1
        elif flg == 0:
            left += 1
        elif flg == 1:
            mid += 1
        else:
            right += 1

    bunsi = [0 for i in range(num + 10)]
    bunsi[1] = 1
    bunsi[0] = 1
    for i in range(2, num + 10):
        bunsi[i] = (bunsi[i - 1] * i) % mod


    for now_num in range(1, num + 2):
        ans = 0
        if now_num == 1:
            ans += num
        elif now_num == 2:
            ans += comb(num - 1, 2, mod, bunsi)
            ans += 1
            ans += left + right + mid * 2
        else:
            ans += comb(num - 1, now_num, mod, bunsi)
            ans += comb(num - 1, now_num - 2, mod, bunsi)
            ans += comb(num - 1, now_num - 1, mod, bunsi) * 2 - comb(left, now_num - 1, mod, bunsi) - comb(right, now_num - 1, mod, bunsi)
            kari = comb(left + right, now_num - 1, mod, bunsi) - comb(left, now_num - 1, mod, bunsi) - comb(right, now_num - 1, mod, bunsi)
            ans -= kari

        ans %= mod
        print(ans)


if __name__ == '__main__':
    main()
    # test()


Measured memory_bytes: 83236
#include <stdio.h>


int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if ( (n-1)*(n-2)/2 <k )
    {
        printf("-1\n");return 0;
    }
    if (n==2)
    {
        if (k==0){
            printf("1\n1 2");
        }
        else
            printf("-1");
        return 0;
    }

    int ans=(n-1);ans+=(n-1)*(n-2)/2-k;
    printf("%d\n",ans);
    for (int i=2;i<=n;i++) printf("%d %d\n",1,i);
    int tmp1=2,tmp2=3;
    while (ans>n-1)
    {
        printf("%d %d\n",tmp1,tmp2);
        tmp2++;if (tmp2>n) {tmp1++;tmp2=tmp1+1;}
        ans--;
    }

}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int h,m,s;
    int h_,m_,s_;
    int ah = 0,am = 0,as = 0;
    int w,v;
    for(int i = 0;i < 3; i++){

        scanf("%d%d%d",&h,&m,&s);
        scanf("%d%d%d",&h_,&m_,&s_);

        w = (h*3600) + (m*60) + s;
        v = (h_*3600) + (m_*60) + s_;
        v -= w;

        for(;;){
            if(v-3600 >= 0){++ah;v -= 3600;}
            else if(v-60 >= 0){++am;v -= 60;}
            else {++as;--v;}
            if(v == 0)break;
        }
        printf("%d %d %d\n",ah,am,as);
        ah = 0,am = 0,as = 0;
    }
    return 0;
}

Measured memory_bytes: 1188
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

int main()
{
    ll a,b,c;
    sl(a);sl(b);sl(c);
    printf("%lld\n",min(c,b/a));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    string s;
    cin>>s;
    if(s.size()%2){
        cout<<"No"<<endl;
        return 0;
    }
    for (int i = 0; i < s.size(); i += 2)
    {
        if(s[i]!='h'||s[i+1]!='i'){
            cout<<"No"<<endl;
            return 0;
            
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	vector<int>x(3);
	for (int i = 0;i < 3;++i)cin >> x[i];
	SORT(x);
	int ans = x[2] - x[1];
	x[0] = x[0] + x[2] - x[1];
	ans = ans + (x[2] - x[0] + 1) / 2;
	if ((x[2] - x[0]) % 2 == 0)cout << ans << "\n";
	else cout << ans + 1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> vec(n+1, 0);
    vec[0] = 1;
    vec[1] = 1;
    for (int i = 2; i <= n; i++) {
        vec[i] = vec[i-1] + vec[i-2];
    }
    std::cout << vec[n] << std::endl;
}



Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    int r = stdin.nextInt();
    int c = stdin.nextInt();
    int[][] sheet = new int[r + 1][c + 1];

    int sum = 0;
    for (int i = 0; i < r; i++) {
      for (int j = 0; j < c; j++) {
        int n = stdin.nextInt();
        sheet[i][j] = n;
        sheet[r][j] += n;
        sheet[i][c] += n;
        sum += n;
      }
    }

    sheet[r][c] = sum;
    for (int i = 0; i <= r; i++) {
      for (int j = 0; j <= c; j++) {
        System.out.printf(j < c ? "%d " : "%d%n", sheet[i][j]);
      }
    }
  }

}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, m, ac = 0, wa = 0;
  cin >> n >> m;
  unordered_map<ll, ll> mpac, mpwa;

  int no;
  string res;
  rep(i, m) {
    cin >> no >> res;
    if (res == "AC") mpac[no]++;
    else if (res == "WA") if(!mpac.count(no))  mpwa[no]++;
  }

  for (auto m : mpac) {
    wa += mpwa[m.first];
    ac++;
  }

  cout << ac << " " << wa << endl;
  return 0;
}


Measured memory_bytes: 8484
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, a[3000];
	int sum = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	printf("%d", sum - N);
	return 0;
}

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


/*-----------構造体定義-----------------*/
typedef struct node{
 int num;
 struct node *left;
 struct node *right;
}node;
/*--------------------------------------*/


/*-----------------要素作成-------------*/
node* makenode(int x){
node* new;

new=(node*)malloc(sizeof(node));
new->num=x;
new->right=NULL;

return new;
}
/*-------------------------------------*/


int main(){
int n,i,x;
int y=1;
char com[13];
node* root;
node* last;
node* p;
node** q;
node* r;
root=NULL;
last=NULL;
scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%s",&com);

 if(com[0]=='i'){
   scanf("%d",&x);
   p=makenode(x);
    if(root!=NULL){
        root->left=p;
        p->right=root;
        root=p;
    }else{root=p;last=p;}
 }else
 if(strcmp(com,"deleteFirst")==0){
   if(root->right==NULL){free(root);root=NULL;last=NULL;}
   else{root->right->left=NULL;
        root=root->right;}
  }else
  if(strcmp(com,"deleteLast")==0){
   if(last->left==NULL){free(root);root=NULL;last=NULL;}
   else{
    last->left->right=NULL;
    last=last->left;}
  }else
  

if(strcmp(com,"delete")==0){
   scanf("%d",&x);

/*要素1つの場合*/
if(root->right==NULL){if(root->num==x){free(root);root=NULL;last=NULL;}}

/*要素が2以上*/
else{

  if(root->num==x){/*先頭*/
       root->right->left=NULL;
       root=root->right;}

  else{p=root;
  
      while(p!=NULL){

        if(p->num==x){

          if(p->right==NULL){p->left->right=NULL;last=p->left;break;}
          else{

            p->right->left=p->left;
            p->left->right=p->right;
            p->right=NULL;}
        }

        p=p->right;


       }/*while終了*/


   }
}
}
}
p=root;
while(p!=NULL){

if(p->right==NULL){printf("%d\n",p->num);}
else{printf("%d ",p->num);}
p=p->right;

}



return 0;
}






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

typedef long long ll;

template <class T>
ostream & operator << (ostream &out, const vector<T> v) {
    for (int i = 0; i < int(v.size()); i++) {
        out << v[i] << " ";
    }
    return out;
}

ll solve() {
    int R, C, K;
    cin >> R >> C >> K;

    auto A = vector<vector<ll>>(R + 1, vector<ll>(C + 1, 0));
    for (int k = 0; k < K; k++) {
        int r, c, v; cin >> r >> c >> v; r--; c--;
        A[r][c] = v;
    }

    auto dp = vector<vector<vector<ll>>>(R + 1, vector<vector<ll>>(C + 1, vector<ll>(5, 0)));
    dp[0][0][1] = ((A[0][0] > 0) ? A[0][0] : 0);
    
    for (int r = 0; r < R; r++) {
        for (int c = 0; c < C; c++) {
            for (int p = 0; p < 4; p++) {
                // walk down and pick
                if (A[r + 1][c] > 0) {
                    dp[r + 1][c][1] = max(dp[r + 1][c][1], dp[r][c][p] + A[r + 1][c]);
                }
                // walk down and don't pick
                dp[r + 1][c][0] = max(dp[r + 1][c][0], dp[r][c][p]);
                // walk right and pick
                if (A[r][c + 1] > 0) {
                    dp[r][c + 1][p + 1] = max(dp[r][c + 1][p + 1], dp[r][c][p] + A[r][c + 1]);
                }
                // walk right and don't pick
                dp[r][c + 1][p] = max(dp[r][c + 1][p], dp[r][c][p]);
            }
        }
    }

    return *max_element(dp[R - 1][C - 1].begin(), dp[R - 1][C - 1].begin() + 4);
}

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

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 706312
#include <stdio.h>

int main(void){
  int mts[20];
  int inp;
  scanf("%d",&inp);
  int i;
  for(i=0;i<inp;i++){
    scanf("%d",&mts[i]);
  }
  int max=0;
  int count=0;
  for(i=0;i<inp;i++){
    if(mts[i]>=max){
      max=mts[i];
      count++;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    static Scanner sc = new Scanner();

    internal static void Main(string[] args) {
        var D = sc.nextInt();
        var G = sc.nextInt();
        var p = new int[D];
        var c = new int[D];
        for (int i = 0; i < D; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        var hoge = new int[D];
        for (int i = 0; i < D; i++) {
            hoge[i] = (100 * (i + 1)) * p[i] + c[i];
        }

        var ans = int.MaxValue;
        for (int i = 0; i < (1 << D); i++) {
            var sum = 0;
            var cnt = 0;
            var rest = -1;
            for (int j = 0; j < D; j++) {
                if ((1 & i >> j) == 1) {
                    sum += hoge[j];
                    cnt += p[j];
                } else {
                    rest = j;
                }
            }

            if (sum < G) {
                var score = 100 * (rest + 1);
                var need = (G - sum) / score;
                if ((G - sum) % score != 0) { need++; }
                if (need >= p[rest]) { continue; }
                cnt += need;
            }

            ans = Math.Min(ans, cnt);
            
        }

        WriteLine(ans);
    }
}




class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
from heapq import heapify, heappush, heappop
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,K = map(int, readline().split())
    A = [int(i) for i in readline().split()]

    MOD = 10**9+7
    ans = 1
    if K == N:
        for a in A:
            ans *= a
            ans %= MOD
        print(ans)
        exit()

    plus = []
    minus = []

    for a in A:
        if a < 0:
            heappush(minus, a)
        else:
            heappush(plus, -a)

    if not plus:
        if K % 2 == 1:
            for _ in range(N-K):
                heappop(minus)
            for _ in range(K):
                ans *= heappop(minus)
                ans %= MOD
        else:
            for _ in range(K):
                ans *= heappop(minus)
                ans %= MOD
        print(ans)
        exit()

    p = []
    m = []
    for _ in range(K):
        if plus and minus:
            if plus[0] <= minus[0]:
                p.append(-heappop(plus))
            else:
                m.append(heappop(minus))
        elif plus:
            p.append(-heappop(plus))
        else:
            m.append(heappop(minus))

    for i in p:
        ans *= i
        ans %= MOD
    for j in m:
        ans *= j
        ans %= MOD

    if len(m) % 2 == 0:
        print(ans)

    else:
        if plus and minus and p and m:
            if p[-1] * (-plus[0]) >= m[-1] * minus[0]:
                ans *= pow(m[-1], MOD-2, MOD)
                ans *= -plus[0]
                ans %= MOD
            else:
                ans *= pow(p[-1], MOD-2, MOD)
                ans *= minus[0]
                ans %= MOD
        elif plus:
            ans *= pow(m[-1], MOD-2, MOD)
            ans *= -plus[0]
            ans %= MOD
        else:
            ans *= pow(p[-1], MOD-2, MOD)
            ans *= minus[0]
            ans %= MOD
        
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31712
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int N;
vector<int> L;

int solve(){
    int ans = 0;
    for(int a=0;a<N;++a){
    	for(int b=a+1;b<N;++b){
    		for(int c=b+1;c<N;++c){
    			if(L[c]>=L[a]+L[b]) break;
    			else ++ans;
    		}
    	}
    }		
    return ans;
}

int main(){
    while(cin>>N && N>0){
    	L.resize(N);
    	for(auto& l: L)cin>>l;
    	sort(L.begin(), L.end());
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// class point	の練習（クラスの高度な実装）
#include <iostream>
using namespace std;



int main() {
	int S;

	cin >> S;

	cout << S / 3600 << ":" << (S % 3600) / 60 << ":" << (S % 60) << endl;
	return 0;
}



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

int main() {
	int N;
	cin >> N;
	if (N < 10)cout << N << endl;
	else if (10 <= N && N < 100)cout << 9 << endl;
	else if (100 <= N && N < 1000)cout << N - 90 << endl;
	else if (1000 <= N && N < 10000)cout << 909 << endl;
	else if (10000 <= N && N < 100000)cout << N - 9090 << endl;
	else cout << 90909 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a,i,c=0,z=0;
   int b[100];

   scanf("%d",&a);

   for(i=0;a>i;i++){
      scanf("%d",&b[i]);
         if(z<=b[i]){
            c = c+1;
            z = b[i];
         }
   }

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

   return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll S; cin >> S;
    ll dp[2005];
    dp[1] = dp[2] = 0;
    reps(i,3,S) dp[i] = 1;

    reps(i,3,S){
        reps(j,3,S){
            if(i+j>S) continue;
            dp[i+j] = (dp[i+j] + dp[i]) % MOD;
        }
    }

    cout << dp[S] << ednl;
    return 0;
}

Measured memory_bytes: 3536
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
inlist=[]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    inlist.append([xi,yi,hi])
inlist.sort(key=lambda x :-x[2])
for i in range(n):
    xi,yi,hi=inlist[i]
    if hi==0:
        xymap[xi][yi]=-2
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]<=a:
                    pass
                else:
                    xymap[x][y]=-2
    else:
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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() {
	string S; cin >> S;
	string ans = "No";
	if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]){ans = "Yes";}
	if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]){ans = "Yes";}
	if(S[0] == S[3] && S[1] == S[2] && S[0] != S[1]){ans = "Yes";}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
       fast;
       string s;
       cin>>s;
       int arr[26]={0},cnt=0;
       for(int i=0;i<s.length();i++)
       {
       		arr[s[i]-'A']++;
       }
       for(int i=0;i<26;i++)
    		if(arr[i])
    			cnt++;
    	if(cnt==2)
    		cout<<"Yes";
    	else
    		cout<<"No";
       return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >>a >>b >>c >>d;

    if(a<=c && b<=c) cout <<0;
    else if(a<=c && d<=b) cout <<d-c;
    else if(a<=c && b<=d) cout <<b-c;
    else if(c<=a && d<=a) cout <<0;
    else if(c<=a && b<=d) cout <<b-a;
    else if(c<=a && d<=b) cout <<d-a;

    return 0;
    
}

Measured memory_bytes: 256
import collections
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
L1=[]
for x in collections.Counter(L).most_common():
    L1.append(list(x))
for x in L1:
    if x[1] > 2 and x[1] % 2 == 0:
        x[1] = 2
    elif x[1] > 2 and x[1] % 2 == 1:
        x[1] = 1
flag = 0
temp = -1
for i in range(len(L1)):
    if L1[i][1] == 2 and flag == 0:
        flag = 1
        temp = i
    elif L1[i][1] == 2 and flag == 1:
        flag = 0
        L1[i][1] = 1
        L1[temp][1] = 1
        temp = -1
for x in L1:
    if x[1] == 2:
        print(len(L1)-1)
        break
else:
    print(len(L1))
#print(L1)


Measured memory_bytes: 26568
#include<bits/stdc++.h>
using namespace std;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    TEZ;
    int n;
    cin>>n;
    unsigned long long a[n];
    int zero = 0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i] == 0)
            zero = 1;
    }
    if(zero == 1)
    {
        cout<<0;
        // continue;
        return 0;
    }
    unsigned long long temp;
    int i;
    unsigned long long int ans = 1;
    for(i=0;i<n;i++)
    {
        temp = 1000000000000000000/ans;
        if(temp<a[i])
        {
            break;
        }
        ans = ans*a[i];
    }
    if(i!=n)
        cout<<-1;
    else    
        cout<<ans;
    
}

Measured memory_bytes: 4436
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    string s;cin>>s;
    string t;cin>>t;
    int n = sz(s);
    int cnt = 0;
    rep(i, n){
        if (s[i]!=t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3888
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

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

	unsigned long long out = 1;

	vector<unsigned long long> a(n);

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

	sort(a.begin(), a.end());

	if (a[0] == 0) {
		cout << 0;
		return 0;
	}

	for (int x = 0; x < n; x++) {
		
		if (out > 1000000000000000000/a[x]) {
			cout << -1;
			return 0;
		}
		out = out * a[x];
	}


	if (out > 1000000000000000000) {
		cout << -1;
	}
	else {
		cout << out;
	}

	return 0;
}


Measured memory_bytes: 3980
import sys
sys.setrecursionlimit(100000)

def load_fields():
	fields = []
	i = 0
	H, W = 0, 0
	field = []
	for line in sys.stdin:
		line = line.rstrip()
		if line[0] not in ["#", "@", "*"]:
			line = line.split(" ")
			H = int(line[0])
			W = int(line[1])
			if (len(field) != 0):
				fields.append(field)
				field = []
			if (H == 0 and W == 0):
				break

		else:
			field.append(list(line))
		i += 1
	return fields

def dfs(x, y, fruit):
	field[x][y] = "0"
	for dx in [-1, 0, 1]:
		if dx == -1: width = [0]
		if dx == 0: width = [-1, 0, 1]
		if dx == 1: width = [0]
		for dy in width:
			nx = x+dx
			ny = y+dy
			inField = (0 <= nx) and (0 <= ny) and (nx < H) and (ny < W)
			if inField and field[nx][ny] == fruit:
				dfs(nx, ny, fruit)
				
fields = load_fields()
count = 0
for field in fields:
	H = len(field)
	W = len(field[0])
	for x in range(H):
		for y in range(W):
			if (field[x][y] != "0"):
				dfs(x, y, field[x][y])
				count += 1
	print(count)
	count = 0

Measured memory_bytes: 18992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    for (int i=0; i<100; i++) {
        if (a%2 || b%2 || c%2) {
            return cout << i << '\n', 0;
        }
        tie(a, b, c) = make_tuple((b+c)/2, (a+c)/2, (a+b)/2);
    }
    cout << "-1\n";
}


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

int main() {
  int N;
  string ans;
  cin >> N;
  ans = "Three";
  for(int i=0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      ans = "Four";
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    tezi;
    int a, b;
    cin >> a >> b;
    cout << a * b << "\n";
    return 0;
}


Measured memory_bytes: 3648
import math 

def prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return 0
    return 1

#エラトステネスのふるい
MAX =100000
is_prime = [1]*(MAX+1)
is_prime[0] = 0 
is_prime[1] = 0
for i in range(2,MAX+1):
    if prime(i) == 1:
        j = i*2
        while j <= MAX:
            is_prime[j] = 0
            j += i

#２０１７のような数かどうか
a = [0]*(MAX+1)
for i in range(0,MAX):
    if i % 2 == 1:
        if is_prime[i]==1 and is_prime[int((i+1)/2)]==1:
            a[i] = 1

#累積和
s = [0] * (MAX+1)
for i in range(0,MAX):
    s[i+1] = s[i] + a[i]

#クエリ処理
Q = int(input())
for q in range(Q):
    l,r = map(int,input().split())
    r += 1

    print(s[r]-s[l])

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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> H(N);
  for(int i = 0; i < N; i++)cin >> H.at(i);
  
  sort(H.begin(), H.end());
  
  for(int i = 0; i < K; i++) H.pop_back();

  int zan;
  zan = N-K;
    
  long sum=0;
  for(int i = 0; i < zan; i++)sum +=H.at(i); 
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define INF 1000000000000000000
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define x first 
#define y second
const int maxx = 1000006;
const int maxlog = 20;
const ll mod = 1000000007;

int main() {
    IOS
    int N;
    cin >> N;
    string s;
    cin >> s;
    int ans = 1;
    char last  = s[0];
    for (char to : s) {
        if (to != last) {
            ans++;
            last = to;
        }
    }
    cout << ans;
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
typedef long long ll;

struct Item{
    int value;
    int weight;
};
int N,W;
Item items[102];
int C[102][10003];
//C[i][j]:=items[0]~[i]までを使って重さjまでのうちの価値の最大値
int main(){
    cin>>N>>W;
    REP(i,1,N+1){
        cin>>items[i].value>>items[i].weight;
    }
    REP(i,1,N+1){
        REP(j,0,W+1){
            int w=items[i].weight;
            int v=items[i].value;
            if(w<=j){
                C[i][j]=max({C[i-1][j],C[i-1][j-w]+v,C[i][j-w]+v});
            }
            else C[i][j]=C[i-1][j];
        }
    }
    cout<<C[N][W]<<endl;

    return 0;
}



Measured memory_bytes: 7012
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n,k;cin>>n>>k;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a));

  auto check = [&](int x) -> bool{
    int cnt = 0;
    rep(i,n)cnt += (a[i]/x) - 1 + !!(a[i]%x);
    return cnt <= k;
  };

  auto binary_search = [&]() -> int{
    int ok = a[n-1];
    int ng = 0;
    while(abs(ok - ng) > 1){
      int mid = (ok + ng)/2;
      if(check(mid))ok = mid;
      else ng = mid;
    }
    return ok;
  };
  print(binary_search());
  return 0;
}

Measured memory_bytes: 4000
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <queue>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <ctime>

using namespace std;

typedef int INT;
#define int long long


int dp[100001];

int d(int n)
{
	if (n < 6)
		return n;
	if (dp[n])
		return dp[n];
	int k = 6, v = -1;
	while (k <= n)
	{
		if (v == -1 || d(n - k) + 1 < v)
			v = d(n - k) + 1;
		k *= 6;
	}
	k = 9;
	while (k <= n)
	{
		if (v == -1 || d(n - k) + 1 < v)
			v = d(n - k) + 1;
		k *= 9;
	}
	dp[n] = v;
	return v;
}





INT main()
{
	int n;
	cin >> n;
	int m = n;

	
	cout << d(n);
	
	//system("pause");
	return 0;
}




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

int main()
{
    long long N, ans = 0;
    string ans1;
    cin >> N;
    long long t, t1, t2, t3;
    t = N / 1.08;
    t = (int)t;
    t1 = (int)(t * 1.08);
    t2 = (int)((t + 1) * 1.08);
    t3 = (int)((t - 1) * 1.08);

    if (N == t1)
    {
        ans = t;
    }
    else if (N == t2)
    {
        ans = t + 1;
    }
    else if (N == t3)
    {
        ans = t - 1;
    }
    else
    {
        ans1 = ":(";
    }

    if (ans == 0)
    {
        cout << ans1 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
import Data.Array
alp = array ('a','z') (zip ['a'..'z'] (0:[25,24..1]))
main=do
 s<-getLine;k<-readLn
 putStrLn(f s k)
  where f [c] k = [([c..'z']++['a'..'z'])!!(mod k 26)]
        f (c:s) k = if (alp!c)<=k then ('a':(f s (k-(alp!c)))) else (c:(f s k))

Measured memory_bytes: 5116
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
const int MAXN=10005;
typedef long long LL;
int main()
{
    LL n, m;
    LL sum=0;
    scanf("%lld %lld", &n, &m);
    if(n*2<=m)
    {
        sum+=n;
        sum+=(m-2*n)/4;
    }
    else
    {
        sum+=m/2;
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

struct Combination{

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
  }

  int inv(int n){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1, p = MOD-2;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}c;

signed main(){

  int n; cin >> n;
  vector<vector<int>> G(n);
  for(int i = 0; i < n-1; i++){
    int a, b; cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  c.init(2e6);
  vector<int> num(n, 0), dp(n, 1);
  auto dfs1 = [&](auto&& dfs1, int u, int p)->void{
    for(int v : G[u]){
      if(v == p) continue;
      dfs1(dfs1, v, u);
      num[u] += num[v];
      dp[u] = dp[u] * dp[v]%MOD * c.nCr(num[u], num[v]) % MOD;
    }
    num[u]++;
  };
  dfs1(dfs1, 0, -1);

  vector<int> ans(n);
  auto dfs2 = [&](auto&& dfs2, int u, int p, int res)->void{
    ans[u] = dp[u] * res%MOD * c.nCr(n-1, n-num[u]) % MOD;
    for(int v : G[u]){
      if(v == p) continue;
      res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      dfs2(dfs2, v, u, res);
    }
  };
  dfs2(dfs2, 0, -1, 1);

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}


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

const int mod = 1000000007;

char s[200010];

int main() {
	int n; scanf("%d", &n), n += n;
	scanf("%s", s);
	if (s[0] == 'W' || s[n - 1] == 'W') {
		printf("0\n");
		return 0;
	}
	long long ans = 1;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int x = s[i] == 'W' ? 0 : 1;
		if ((x ^ 1 ^ (cnt & 1))) {
			ans = ans * cnt % mod, cnt--;
			if (cnt < 0) {
				printf("0\n");
				return 0;
			}
		}
		else cnt++;
	}
	for (int i = 1; i <= n / 2; i++) {
		ans = ans * i % mod;
	}
	if (cnt != 0) printf("0\n");
	else printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
main = do
  li <- getLine
  let n = read li
  let ans = compute n
  print ans

{-
nまでの数の和はs=n(n+1)/2
3の倍数は数えない、a=n/3個、和はt=a(a+1)/2*3
5の倍数も数えない、b=n/5個、和はu=b(b+1)/2*5
s-t-uだと15の倍数を引きすぎる
15の倍数がc=n/15個、総和はv=c(c+1)/2*15
戻すとs-t-u+v
-}

compute :: Int -> Int
compute n = f n - 3 * f (div n 3) - 5 * f (div n 5) + 15 * f (div n 15)
  where
    f k = div (k * (k + 1)) 2


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

int main(){
 int a,b;
cin>>a>>b;
  if(a==1){
    a+=13;
  }
  if(b==1){
    b+=13;
  }
   if(a<b){
     cout<<"Bob"<<endl;
   }
  else if(a>b){
    cout<<"Alice"<<endl;
  }
  else{
    cout<<"Draw"<<endl;
}
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))

using namespace std;

/*
N W
v1 w1
...
vN wN

N 100
W 10000
 */

int N,W;
int dp[101][10001];

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

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

  cout << dp[N-1][W] << endl;

  return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

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

int main()
{
  fastio;
  int n; cin >> n;
  long res = 0;
  for (int i = 1; i <= n; i++){
    if (i % 3 != 0 && i % 5 != 0) res += i;
  }
  cout << res;
  return 0;
}

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

int count_div2(int n) {
    int ans = 0;

    while (n % 2 == 0) {
        n /= 2;
        ++ans;
    }

    return ans;
}

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

    int n, ans = 1, mx = 0;
    cin >> n;
    for (int i = n; i >= 1; --i) {
        int x = count_div2(i);
        if (x > mx) {
            ans = i;
            mx = x;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3564
from itertools import combinations, permutations
def inpl(): return list(map(int, input().split()))

N, M = inpl()
G = [[0]*(N+1) for _ in range(N+1)]

for _ in range(M):
    a, b = inpl()
    G[a][b] = 1
    G[b][a] = 1

ans = 0
for X in permutations(range(2, N+1)):
    a = 1
    for i in range(N-1):
        b = X[i]
        if G[a][b] == 0:
            break
        a = b
    else:
        ans += 1

print(ans)


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

string yoko[5];
string tate[4];
int x = 0;
int y = 0;
char d;

void left()
{
	x--;
	d = 'L';
	cout << 'L';
}
void right()
{
	x++;
	d = 'R';
	cout << 'R';
}
void up()
{
	y--;
	d = 'U';
	cout << 'U';
}
void down()
{
	y++;
	d = 'D';
	cout << 'D';
}

int main()
{
	for (int i = 0; i < 9; i++)
	{
		if (i % 2 == 0) cin >> yoko[i / 2];
		else cin >> tate[i / 2];
	}

	right();

	while (true)
	{
		if (d == 'R')
		{
			if (y != 0 && tate[y - 1][x] == '1')  up();
			else if (x != 4 && yoko[y][x] == '1') right();
			else if (y != 4 && tate[y][x] == '1') down();
			else								  left();
		}
		else if (d == 'L')
		{
			if (y != 4 && tate[y][x] == '1')		  down();
			else if (x != 0 && yoko[y][x - 1] == '1') left();
			else if (y != 0 && tate[y - 1][x] == '1') up();
			else									  right();
		}
		else if (d == 'U')
		{
			if (x != 0 && yoko[y][x - 1] == '1')	  left();
			else if (y != 0 && tate[y - 1][x] == '1') up();
			else if (x != 4 && yoko[y][x] == '1')	  right();
			else									  down();
		}
		else if (d == 'D')
		{
			if (x != 4 && yoko[y][x] == '1')		  right();
			else if (y != 4 && tate[y][x] == '1')	  down();
			else if (x != 0 && yoko[y][x - 1] == '1') left();
			else									  up();
		}

		if (x == 0 && y == 0) break;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 1184