akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        String S = sc.next();
                        int g = 0, c = 0, p = 0;
                        int ans = 0;
                        for (int i = 0; i < S.length(); i++) {
                                switch (S.charAt(i)) {
                                        case 'g':{
                                                                 if (p<g) {
                                                                         p++;
                                                                         ans++;
                                                                 }else {
                                                                         g++;
                                                                 }
                                                                 break;
                                        }
                                        case 'p':
                                                         {
                                                                 if (p<g) {
                                                                         p++;
                                                                 }else{
                                                                         g++;
                                                                         ans--;
                                                                 }
                                                                 break;
                                                         }
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 13824
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n;
ll con(vi v){
    string s;
    ll th=0,fi=0,se=0;
    for(int i = v.size()-1;i>=0;i--){
        switch (v[i]){
            case 0:
                s+='3';th++;
                break;
            case 1:
                s+='5';fi++;
                break;
            case 2:
                s+='7';se++;
                break;
            default:
                break;
        }
    }
    if(th==0||fi==0||se==0)return -1;
    return stoll(s);
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    vi vv;
    ll ans = 0;
    vv.pb(-1);
    bool flg;
    while(1){
        flg = false;
        rep(i,vv.size()){
            if(vv[i]>=2){
                vv[i]=0;
                flg = true;
            }else{
                flg = false;
                vv[i]++; break;
            }
        }
        if(flg)vv.pb(0);
        if(con(vv)>n)break;
        if(con(vv)!=-1)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int m = saori.saori_hayami();
		int d = saori.saori_hayami();
		int ans = 0;
		for(int i = 1;i <= m;i++){
			for(int j = 1;j <= d;j++){
				int d1 = j/10;
				int d2 = j%10;
				if(d1*d2 == i && d1 >= 2 && d2 >= 2){
					ans++;
				}
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <iostream>
#include <set>

using namespace std;

int main(){
  int n;
  set<int> st;

  cin >> n;
  for(int i = 0; i < n; i++){
    int t;
    cin >> t;
    auto itr = st.find(t);
    if(itr != st.end()){
      st.erase(itr);
    }else{
      st.insert(t);
    }
  }

  cout << st.size() << "\n";

  return 0;

}


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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 9999999999
 
using namespace std;

int32_t main(){
    string str;
    cin >> str;

    if(str=="zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }

    int n=str.length();
    vector<int> v(26, INF);
    REP(i, n){
        v[str[i]-'a']=i;
    }

    if(n!=26){
        REP(i, 26){
            if(v[i]==INF){
                str+=(char)('a'+i);
                break;
            }
        }

        cout << str << endl;
        return 0;
    }

    int cnt=1;
    for(int i=n-1; i>0; i--){
        if(str[i]<str[i-1]){
            cnt++;
        }
        else{
            break;
        }
    }

    for(int i=str[n-1-cnt]+1; i<='z'; i++){
        if(v[str[n-1-cnt]-'a']<v[i-'a']){
            REP(i, n-cnt-1){
                cout << str[i];
            }
            cout << (char)(i) << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n, a) for(int i = a; i < n; ++i)
 
int main(void) {
  int n, i, j, st = 0;
  scanf("%d", &n);
  char a[n][5], b[n][5], s[n][5];
  rep(i, n) {
    scanf("%s", a[i]);
    rep(j, 5) b[i][j] = a[i][j], s[i][j] = a[i][j];
  }
  int flag = 1;
  rep(i, n) {
    flag = 0;
    for(j = n - 1; j > i; --j) {
      if(b[j][1] < b[j - 1][1]) {
        char t;
        t = b[j][0], b[j][0] = b[j - 1][0], b[j - 1][0] = t;
        t = b[j][1], b[j][1] = b[j - 1][1], b[j - 1][1] = t;
       }
    }
  }
  rep(i, n) {
    int minj = i;
    char t;
    repi(j, n, i) if(s[j][1] < s[minj][1]) minj = j;
    t = s[i][0], s[i][0] = s[minj][0], s[minj][0] = t;
    t = s[i][1], s[i][1] = s[minj][1], s[minj][1] = t;
  }
  rep(i, n) {
    if(i) printf(" %s", b[i]);
    else printf("%s", b[i]);
  }
  printf("\nStable\n");
  rep(i, n) {
    if(s[i][0] != b[i][0]) st = 1;
    if(i) printf(" %s", s[i]);
    else printf("%s", s[i]);
  }
  if(st) printf("\nNot stable\n");
  else printf("\nStable\n");
  return 0;
}



Measured memory_bytes: 2680
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_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>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N;
    cin >> N;

    vector<int> a(N);
    for (int i = 0; i < N; i++)cin >> a[i];

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

    int maxV = a.back();

    sort(a.begin(), a.end(), [maxV](const int &a, const int &b) {
        int c = min(a, maxV - a);
        int d = min(b, maxV - b);
        return c < d;
    });

    int backV;
    for (int i = N - 1; i >= 0; i--)
        if (maxV != a[i]) {
            backV = a[i];
            break;
        }

    cout << maxV << " " << backV << endl;
}






















































Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int MOD = int(pow(10,9))+7;



int main(void){
    ll n,m; cin >> n >> m;
    if(n < m){
        ll tmp = n;n = m;m = tmp;
    }

    if(1 < n-m){
        cout << 0 << endl;
        return 0;
    }else{
        ll tmp=1;
        for(int i=1;i<=n;i++){
            tmp = (tmp*i)%MOD;
        }
        for(int i=1;i<=m;i++){
            tmp = (tmp*i)%MOD;
        }
        if(n-m == 0){
            tmp = (tmp*2)%MOD;
        }
        cout << tmp << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int min (int n, int m) {
    if (n < m) {
        return n;
    }
    return m;
}

int max (int n, int m) {
    if (n > m) {
        return n;
    }
    return m;
}

int main(int argc, char **argv)
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);

    int s;
    if (b < c || d < a) {
        s = 0;
    } else {
        s = min(b, d) - max(a, c);
    }
    printf("%d\n", s);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;*/
//#define int long long
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; i++)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define mp make_pair
double jk=0.4;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
#define mod 1000000007
#define N 1000000000
int in(){
int n;cin>>n;
return n;}
void _do_(){
		int n,k;
		cin>>n>>k;
		int a[n];
		rep(i,0,n)a[i]=0;
		rep(i,0,k){
			int z;cin>>z;
			while(z--){
				int x;cin>>x;
				a[x-1]++;
			}
		}
		int count=0;
		rep(i,0,n){
			if(a[i]==0)count++;
		}
		//rep(i,0,n)cout<<a[i]<<" ";
		cout<<count<<endl;

}signed main(){fastr
//int tc=in();
int tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
return 0;}

Measured memory_bytes: 3656
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

struct UFTree(T)
{
    struct Node
    {
        T parent;
        T rank = 1;
    }

    ///
    this(T n)
    {
        nodes.length = n;
        sizes.length = n;
        foreach (i, ref node; nodes) {
            node = Node(i.to!T);
            sizes[i] = 1;
        }
    }

    ///
    bool unite(T a, T b)
    {
        a = root(a);
        b = root(b);

        if (a == b) return false;

        if (nodes[a].rank < nodes[b].rank) {
            sizes[nodes[a].parent] += sizes[nodes[b].parent];
            nodes[b].parent = nodes[a].parent;
        } else {
            sizes[nodes[b].parent] += sizes[nodes[a].parent];
            nodes[a].parent = nodes[b].parent;
            if (nodes[a].rank == nodes[b].rank) nodes[a].rank += 1;
        }

        return true;
    }

    ///
    bool is_same(T a, T b)
    {
        return root(a) == root(b);
    }

    ///
    T size(T i)
    {
        return sizes[root(i)];
    }

    T size()
    {
        bool[T] rs;
        foreach (i; 0..this.nodes.length) {
            rs[root(i.to!T)] = true;
        }

        T cnt;
        foreach (_r; rs) ++cnt;

        return cnt;
    }

private:
    Node[] nodes;
    T[] sizes;

    T root(T i)
    {
        if (nodes[i].parent == i) return i;

        return nodes[i].parent = root(nodes[i].parent);
    }
}

///
UFTree!T uftree(T)(T n)
{
    return UFTree!T(n);
}

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    auto uft = uftree(N);

    foreach (_; 0..M) {
        auto xyz = readln.split.to!(int[]);
        auto X = xyz[0]-1;
        auto Y = xyz[1]-1;
        uft.unite(X, Y);
    }

    writeln(uft.size());
}

Measured memory_bytes: 7932
import heapq
from collections import deque
n,m=map(int,input().split())
A=list(map(int,input().split()))

for i in range(n):
    A[i]*=-1
heapq.heapify(A)

for i in range(m):
    x=heapq.heappop(A)
    if x%2==0:
        x//=2
    else:
        x=x//2 +1
    heapq.heappush(A,x)

ans=-1*sum(A)
print(ans)

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

int n;
vector<int> a;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

int l(int i) { // a[1]...a[i-1]のgcd
    if (i == 1) return  a[i];
    return gcd(l(i-1), a[i-1]);
}

int r(int i) { // a[i+1]...a[n]のgcd
    if (i == n-1) return  a[i+1];
    return gcd(a[i+1], r(i+1));
}

int m(int i) { // a[1]...a[n]のうちa[i]を除いた部分のgcd
    if (i == 1) return r(i);
    if (i == n) return l(i);
    return gcd(l(i), r(i));
}

int main() {
    cin >> n;
    a.resize(n+1);
    rep(i, n) {
        // if (i == 0) continue;
        cin >> a[i];
    }
    int max_v = 0;

    vector<int> l(n+1), r(n+1), m(n+1);
    for (int i = 2; i <= n; i++) {
        l[i] = gcd(l[i-1], a[i-1]);
    }
    for (int i = n-1; i >= 1; i--) {
        r[i] = gcd(a[i+1], r[i+1]);
    }
    // スッキリと書けるけど逆にわかりづらいかも
    // rep(i, n) {
    //     int j = n-i+1;
    //     if (i == 1) {
    //         l[i] = 0;
    //         r[j] = 0;
    //     } else {
    //         l[i] = gcd(l[i-1], a[i-1]);
    //         r[j] = gcd(a[j+1], r[j+1]);
    //     }
    // }
    rep(i, n) {
        // if (i == 1) m[i] = r[i];
        // else if (i == n) m[i] = l[i];
        // else m[i] = gcd(l[i], r[i]);
        m[i] = gcd(l[i], r[i]);
        max_v = max(m[i], max_v);
    }
    // for (int i = 1; i <= n; i++) {
    //     // max_v = max(m(i+1), max_v);
    //     // max_v = max(m[i], max_v);
    // }
    printf("%d\n", max_v);
}

Measured memory_bytes: 4800
#include <stdio.h>
int main(int argc, char **argv) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);

  int t1 = a + b;
  int t2 = b + c;
  int t3 = c + a;
  int t0;
  if (t1 <= t2 && t1 <= t3)
    t0 = t1;
  else if (t2 <= t3 && t2 <= t1)
    t0 = t2;
  else
    t0 = t3;
  printf("%d\n", t0);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int howX = tx - sx, howY = ty - sy;
	REP(i, howX){
		cout << "R";
	}
	REP(i, howY){
		cout << "U";
	}
	REP(i, howX){
		cout << "L";
	}
	REP(i, howY){
		cout << "D";
	}
	cout << "D";
	REP(i, howX + 1){
		cout << "R";
	}
	REP(i, howY + 1){
		cout << "U";
	}
	cout << "L";

	cout << "U";
	REP(i, howX + 1){
		cout << "L";
	}
	REP(i, howY + 1){
		cout << "D";
	}
	cout << "R";
	cout << endl;
	return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  
  if(n % 2){
    for(int i = 1; i <= m; i++) cout << i << ' ' << n-i << endl;
  }
  else{
    for(int i = 1; i <= m; i++){
      if(i < (double)n/4) cout << i << ' ' << n-i << endl;
      else cout << i << ' ' << n-i-1 << endl;
    }
  }
}

Measured memory_bytes: 3604
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    t = list(map(int, input().strip().split()))
    
    m = int(input().strip())

    for i in range(m):
        p, x = map(int,input().strip().split())
        print(sum(t) + x - t[p-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 60396
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 1,000,000,000,000,001
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		List<String> list = Arrays.asList("abcdefghijklmnopqrstuvwxyz".split(""));
		List<Integer> q = new ArrayList<>();
		while (n > 0) {
			q.add((int) ((n-1) % 26));
			n = (n-1) / 26;
		}
		Collections.reverse(q);
		StringBuilder sb = new StringBuilder();
		for (Integer i : q) {
			sb.append(list.get(i));
		}
		System.out.println(sb.toString());

	}
}


Measured memory_bytes: 27040
# 青の点をX座標が小さい順に見ていく
# それよりX座標が小さい赤の点で、最もY座標が大きいものとペアにする
# N = 100なので3重ループ回す

import sys
readline = sys.stdin.readline

N = int(readline())

R = [None] * N
B = [None] * N
for i in range(N):
  x,y = map(int,readline().split())
  R[i] = (x,y)
  
for i in range(N):
  x,y = map(int,readline().split())
  B[i] = (x,y)
  
R = sorted(R, key = lambda x:x[0])
B = sorted(B, key = lambda x:x[0])

ans = 0
used = set()
for b in B:
  bx,by = b
  max_ry = -1
  max_ind = -1
  for i in range(len(R)):
    rx,ry = R[i]
    if (rx,ry) in used:
      continue
    if ry >= by:
      continue
    if rx >= bx:
      break
    if ry > max_ry:
      max_ry = ry
      max_ind = i
  if max_ind != -1:
    ans += 1
    used.add(R[max_ind])
      
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>

using namespace std;

long long N, M;
vector<long long> X;
vector<long long> diff;

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

    X.resize(M);

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

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

    for (int i = 1; i < M; i++)
    {
        diff.push_back(X[i] - X[i-1]);
    }

    if(M == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    sort(diff.begin(), diff.end(), greater<long long>());

    long long ans = *max_element(X.begin(), X.end()) - X[0] - accumulate(diff.begin(), diff.begin() + min(N-1, M), 0LL);

    cout << ans << endl;

    return 0;
}

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

int sumnum(int n) {
  int x, sum = 0;
  while(n >= 1) {
    x = n % 10;
    sum += x;
    n = (n - x) / 10;
  }
  return sum;
}

int main() {
  int n, a, b, s, r = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; ++i) {
    s = sumnum(i);
    if (a <= s && s <= b) {
      r += i;
    }
  }
  cout << r << endl;
  return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    int a[2000], b[2000], c[2000];
    for(int i=0; i<M; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
        c[i] *= -1;
    }

    long long dist[1000];
    dist[0] = 0;
    for(int i=1; i<N; ++i) dist[i] = INF;

    bool neg = false;
    for(int i=0; i<2*N; ++i) {
        for(int j=0; j<M; ++j) {
            if(dist[a[j]] + c[j] < dist[b[j]]) {
                dist[b[j]] = dist[a[j]] + c[j];
                if(i >= N && b[j] == N-1) {
                    neg = true;
                    break;
                }
            }
        }
    }
    if(neg) cout << "inf" << endl;
    else cout << (-1) * dist[N-1] << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, K = map(int, input().split())
MOD = 998244353

# 階乗、Combinationコンビネーション(numpyを使う)


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L ** 0.5 + 1)
    arr = np.resize(arr, Lsq ** 2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


U = (10 ** 5) * 2 + 100
fact, fact_inv = make_fact(U, MOD)


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod


ans = 0
t = M

if K == (N - 1):
    ans += M

for i in range(1, N):
    kumi = N - i - 1
    t *= M - 1
    t %= MOD
    if K < kumi:
        continue

    c = mod_comb_k(N - 1, i, MOD)
    ans += c * t
    ans %= MOD

print(ans)


Measured memory_bytes: 34600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int length = Integer.parseInt(br.readLine());
		String in = br.readLine();
		String[] inArray = in.split(" ");

		for(int i=length-1; i>=0; i--){
			if(i == 0 ){
				System.out.println(inArray[0]);;
			}else{
			System.out.print(inArray[i]+" ");
			}
		}

	}

}

Measured memory_bytes: 24276
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
 
struct FastIO {
  FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;
 
struct UnionFind {
  vector<int> u;
  UnionFind(int n): u(n+5, -1) {}
  int  size(int i)        { return (-u[root(i)]); }
  int  root(int x)        { return (u[x] < 0)? x : u[x] = root(u[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y){ return (x=root(x)) == (y=root(y))? false : (u[x]+=u[y], u[y]=x, true); }
};
 
 
signed main()
{
  int pos[100010];
  int N, M;
 
  cin >> N >> M;
  rep(i, 1, N+1) {
    int p; cin >> p;
    pos[p] = i;
  }
 
  UnionFind uf(N);
  rep(i, 0, M) {
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }
 
  int ans = 0;
  rep(i, 1, N+1) {
    if (uf.same(i, pos[i])) ++ans;
  }
 
  cout << (ans) << '\n';
 
 
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	vint v(3);
	while(cin >> v[0] >> v[1] >> v[2] && (v[0] || v[1] || v[2]))
	{
		sort(ALL(v));

		int n;
		cin >> n;
		rep(i, n)
		{
			int r;
			cin >> r;

			cout << (4 * r * r <= v[0] * v[0] + v[1] * v[1] ? "NA" : "OK" ) << endl;
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> b.at(i);
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> c.at(i);
  }

  int ans = accumulate(b.begin(), b.end(), 0);
  for (int i = 0; i < n - 1; i++) {
    if (a.at(i) + 1 == a.at(i + 1)) {
      ans += c.at(a.at(i) - 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    char num[4];
    char c;

    cin >> num;

    for(int i=0; i<3; ++i)
    {
        if(num[i]=='1')
            num[i] = '9';
        else
            num[i] = '1';
    }

    cout<<num<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if (i)
            a[i] += a[i - 1];
    }
    for (int i = 0; i < n; ++i)
        if (a[i] > x)
            return cout << i + 1, 0;
    cout << n + 1;
}


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

void solve() {
  string s;
  cin >> s;
  string ans;
  int b = 0;
  for (int i = (int) s.size() - 1; i >= 0; i--) {
    if(s[i] == 'B') {
      b++;
    }
    else {
      if(b == 0) {
        ans = s[i] + ans;
      }
      if(b > 0) {
        b--;
      }
    }
  }
  cout << ans;
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
#define P ((ll)1e9+7)
using namespace std;

ll qpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n&1) res = res*a%P;
        a = a*a%P, n >>= 1;
    }
    return res;
}
ll inv(ll x){
    return qpow(x, P-2);
}

int n, cnt;
int head[MAX], vet[MAX], Next[MAX];
ll f[MAX], sz[MAX], fac[MAX], g[MAX];

void init(){
    fac[0] = 1;
    for(int i = 1; i < MAX; i++){
        fac[i] = fac[i-1]*i%P;
    }
}

void add(int x, int y){
    cnt++;
    Next[cnt] = head[x];
    head[x] = cnt;
    vet[cnt] = y;
}

void dfs(int x, int fa){
    sz[x] = 1;
    for(int i = head[x]; i; i = Next[i]){
        int v = vet[i];
        if(v == fa) continue;
        dfs(v, x);
        sz[x] += sz[v];
    }
    f[x] = fac[sz[x]-1];
    for(int i = head[x]; i; i = Next[i]){
        int v = vet[i];
        if(v == fa) continue;
        f[x] = f[x]*inv(fac[sz[v]])%P*f[v]%P;
    }
    g[x] = f[x];
}

void dfs2(int x, int fa){
    for(int i = head[x]; i; i = Next[i]){
        int v = vet[i];
        if(v == fa) continue;
        ll t = fac[n-1]*inv(fac[n-1-sz[v]])%P, d = fac[n-1]*inv(fac[sz[v]-1])%P;
        ll F = g[x]*inv(t)%P*fac[sz[v]]%P*inv(f[v])%P;
        g[v] = g[v]*F%P*d%P*inv(fac[n-sz[v]])%P;
        dfs2(v, x);
    }
}

int main()
{
    init();
    cin >> n;
    int x, y;
    for(int i = 1; i < n; i++){
        scanf("%d%d", &x, &y);
        add(x, y), add(y, x);
    }
    dfs(1, 0);
    g[1] = f[1];
    dfs2(1, 0);
    for(int i = 1; i <= n; i++){
        printf("%lld\n", g[i]);
    }

    return 0;
}

Measured memory_bytes: 22272
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Hashtable;
//https://vjudge.net/contest/159423#problem/B
public class Main {
	public static void main(String [] argv) throws Exception{
		// lucky: only contain digits 4, 7.
		Scanner in = new Scanner(System.in);
		String a = in.next();
		
		int firstA = 0;
		while(a.charAt(firstA) != 'A') {
			firstA++;
		}
		
		int lastZ = a.length() - 1;
		while(a.charAt(lastZ) != 'Z') {
			lastZ--;
		}
		
		System.out.println(lastZ - firstA + 1);
		// R G B
	} 
	


}


Measured memory_bytes: 26576
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A = vector<int>(N);

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

    vector<int> B = vector<int>(N);
    copy(A.begin(), A.end(), B.begin());
    sort(B.begin(), B.end(), greater<int>());
    for (int i = 0; i < N; i++) {
        cout << ((A[i] == B[0]) ? B[1] : B[0]) << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#pragma warning(disable:4996)

int main()
{
	
	int num, cnt;
	unsigned int i, j, k, data_num;
	int data[30];
	unsigned int sq_num;
	unsigned int *prime;

	for (data_num = 0; data_num <30; data_num++)
	{
		data[data_num] = -1;
		scanf("%d", &data[data_num]);
		if (data[data_num] < 0)
			break;
	}

	for (k = 0; k < data_num; k++)
	{
		sq_num = (int)sqrt((double)data[k]);
		prime = (unsigned int*)malloc(sizeof(unsigned int) * data[k]);

		prime[0] = 0;
		for (i = 1; i < data[k]; i++)
		{
			prime[i] = 1;
		}

		for (i = 1; i < sq_num; i++)
		{

			if (prime[i] == 1)
			{
				for (j = (i + 1); (i + 1)* j <= data[k]; j++)
				{
					prime[(i + 1) * j - 1] = 0;
				}
			}
		}

		cnt = 0; 
		for (i = 0; i < data[k]; i++)
		{
			if (prime[i] == 1)
			{
				cnt++;
			}
		}
		printf("%d\n", cnt);
		free(prime);
	}
	return 0;
}

Measured memory_bytes: 5184
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    for(int i = 1;; i++){
        int len = K * i;
        if(len >= A && len <= B){
            cout << "OK" << endl;
            break;
        }else if(len > B){
            cout << "NG" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  string s;
  cin>>s;
  bool f=false,c=false;
  rep(i,0,s.size()){
    if(s[i]=='F' && c) f=true;
    if(s[i]=='C') c=true;
  }
  if(f && c) cout<<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 256
// in the name of Allah

#include <bits/stdc++.h>

#define endl '\n'
#define ll long long
#define pb push_back
#define ld double
#define sz(x) ((int) (x.size()))

#define max_n 5123456
#define mod 1000000007
// #define mod 998244353
#define myPrime 97654321

#define fr first
#define se second

using namespace std;

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll x, ll y) {
	if(y == 0) return 1;
	ll foo = power(x, y/2);
	foo = mul(foo, foo);
	if(y&1) return mul(x, foo);
	return foo;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int x, y;
	cin >> x >> y;
	cout << x + y/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

vector<int> edg[5];
bool vis[5];

bool func(int pos) {
	bool ret = true;
	for (int i = 0; i < 4; i++) {
		ret &= pos == i || vis[i];
	}
	if (ret) return true;
	vis[pos] = true;
	for (int to : edg[pos]) {
		if (vis[to]) continue;
		if (func(to)) {
			vis[pos] = false;
			return true;
		}
	}
	vis[pos] = false;
	return false;
}

int main() {
	for (int i = 0; i < 3; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		edg[a].push_back(b);
		edg[b].push_back(a);
	}
	for (int i = 0; i < 4; i++) {
		if (func(i)) {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<random>
using namespace std;

class Dice{
  public:
    vector<int> n;
    int top;
    Dice(){
      n.resize(6);
      top = 0;
    }
    void roll(char c){
      int tmp = n[0];
      if( c == 'E' ){
        n[0] = n[3];
        n[3] = n[5];
        n[5] = n[2];
        n[2] = tmp;
      }else if( c == 'W' ){
        n[0] = n[2];
        n[2] = n[5];
        n[5] = n[3];
        n[3] = tmp;
      }else if( c == 'N' ){
        n[0] = n[1];
        n[1] = n[5];
        n[5] = n[4];
        n[4] = tmp;
      }else if( c == 'S' ){
        n[0] = n[4];
        n[4] = n[5];
        n[5] = n[1];
        n[1] = tmp;
      }else if( c == 'R' ){
        tmp = n[4];
        n[4] = n[3];
        n[3] = n[1];
        n[1] = n[2];
        n[2] = tmp;
      }else if( c == 'L' ){
        tmp = n[4];
        n[4] = n[2];
        n[2] = n[1];
        n[1] = n[3];
        n[3] = tmp;
      }

      // cerr << " " << n[0] << endl;
    }
    void input(){
      for(int i=0; i<6; i++) cin >> n[i];
    }
    // void input_top_and_before(){
    //   int a, b;
    //   cin >> a >> b;
    //   q2(a, b);
    // }
    //
    // void q2(int a, int b){
    //   vector<int> tmp = n;
    //   for(int i=0; i<tmp.size(); i++){
    //     if( tmp[i] == a ){
    //
    //     }
    //   }
    // }

    void output_top(){
      cout << n[top] << endl;
    }
};

bool diff_check(Dice d, Dice d2){
  random_device rnd;
  string con = "NSEW";

  int cnt = 0;
  while(true){
    if( cnt >= 1000 ) break;
    d2.roll( con[rnd()%4] );
    if( d.n[0] == d2.n[0] ){
      if( d.n[5] != d2.n[5] ) break;

      for(int i=0; i<4; i++){
        d2.roll('R');
        bool f = true;
        for(int i=1; i<5; i++){
          if( d.n[i] != d2.n[i] ) f = false;
        }
        if( f ){
          return true;;
        }
      }

      break;
    }
    cnt++;
  }
  return false;
}

int main(){

  int n;
  cin >> n;

  // Dice d;
  // d.input();

  vector<Dice> d(n);
  for(int i=0; i<n; i++) d[i].input();

  bool ans = true;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if( diff_check(d[i], d[j]) ){
        ans = false;
        break;
      }
    }
  }

  if( ans ) cout << "Yes" << endl;
  else cout << "No" << endl;
  // d.output_top();

  return 0;
}





// EOF

Measured memory_bytes: 3232
t1,t2=map(int, input().split())
a1,a2=map(int, input().split())
b1,b2=map(int, input().split())
a1*=t1
a2*=t2
b1*=t1
b2*=t2
if a1<b1:
    a1,a2,b1,b2=b1,b2,a1,a2
#a1>b2
if a1+a2==b1+b2:
    print('infinity')
    exit()

a1-=b1;b2-=a2

b2-=a1
if b2<0:
    print(0)
    exit()

ans=1+(a1//b2)*2
if a1%b2==0:
    ans-=1####

print(ans)

Measured memory_bytes: 61844
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if ((a[a.size()-1] == b[0]) && (b[b.size()-1] == c[0])) {
		cout << "YES" << endl;
	}
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	
	auto dp = make_v<i64>(n + 1, 2);
	for(int i = 0; i <= n; i++) for(int j = 0; j < 2; j++) dp[i][j] = -(1LL << 60); dp[0][0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 2; j++) {
			if(i == 0 and j == 1) continue;
			if(j) {
				dp[i + 1][0] = std::max(dp[i + 1][0], dp[i][j] - a[i]);
				if(i + 1 != n) dp[i + 1][1] = std::max(dp[i + 1][1], dp[i][j] + a[i]);
			} else {
				dp[i + 1][0] = std::max(dp[i + 1][0], dp[i][j] + a[i]);
				if(i + 1 != n) dp[i + 1][1] = std::max(dp[i + 1][1], dp[i][j] - a[i]);
			}
		}
	}
	
	printf("%lld\n", dp[n][0]);
	return 0;
}


Measured memory_bytes: 6528
import std.stdio;
import std.string;
import std.conv;

void main()
{
    string line = chomp(readln());
    auto S = to!int(line);
    // auto S = to!int(chomp(readln()));
    auto h = S/60/60;
    auto m = (S-h*60*60)/60;
    auto s = (S-m*60-h*60*60);
    writefln("%d:%d:%d", h, m, s);
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b; cin >> n >> a >> b;
    ll k = n / (a+b);
    ll ret = k * a;
    ll diff = min(a,n-k*(a+b));
    cout << ret+diff << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

map<ll, ll> prime_decomposition(ll n) {
  map<ll, ll> mp;
  FOR(i, 2, n + 1) {
    ll t = i;
    for (ll p = 2; p * p <= t; p++) {
      if (t % p != 0) continue;
      ll cnt = 0;
      while (t % p == 0) {
        cnt++;
        t /= p;
      }
      mp[p] += cnt;
    }
    if (t != 1) mp[t] += 1;
  }

  return mp;
}

int main() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  map<ll, ll> mp = prime_decomposition(n);
  // for (auto& x : mp) {
  //   cout << x.first << " " << x.second << endl;
  // }
  ll m = SZ(mp);
  vector<vector<ll>> dp(m + 1, vector<ll>(76, 0));
  dp[0][1] = 1;
  ll i = 0;
  for (auto& x : mp) {
    FOR(j, 1, 76) {
      REP(k, x.second + 1) {
        ll nj = (k + 1) * j;
        if (nj > 75) {
          continue;
        }
        dp[i + 1][nj] += dp[i][j];
      }
    }
    i++;
  }
  // REP(i, m + 1) {
  //   REP(j, 76) {
  //     if (dp[i][j]) {
  //       DUMP(i);
  //       DUMP(j);
  //       DUMP(dp[i][j]);
  //     }
  //   }
  // }
  cout << dp[m][75] << endl;
}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n-1);
    int sum = 0;
    for(int i = 0; i < n-1; i++){
        cin >> a[i];
        if( i == 0){
            sum += a[i];
        }else{
            sum += min(a[i], a[i-1]);
        }
    }
    cout << sum + a[n-2] << endl;
    return 0;
}

Measured memory_bytes: 256
n = str(input())

last = n[len(n)-1]

if last == '2' or last == '4' or last == '5' or last == '7' or last == '9':
    print('hon')
elif last == '0' or last == '1' or last == '6' or last == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9112
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<cmath>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define REPll(i,m,n) for(ll i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<ll>v;

ll cal(vector<ll>a, int b) {
	ll hoge = 0;
	REP(i, 0, a.size()) {
		hoge += abs(v[i] - b);
	}
	return hoge;
}

int main() {
	int n;
	cin >> n;
	REPll(i, 0, n) {
		ll tmp;
		cin >> tmp;
		v.push_back(tmp - i - 1);
	}
	sort(all(v));
	int bottom = 0, top = n - 1;
	while (top - bottom >= 2) {
		if (cal(v, v[bottom]) > cal(v, v[top])) {
			bottom = (bottom + top) / 2;
		}
		else {
			top = (bottom + top) / 2;
		}
	}
	ll ans = min(cal(v, v[bottom]), cal(v, v[top]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, ans = 1e9;
vector< int > dp( 110, 0 );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> dp[ i ];
		dp[ i ] += dp[ i - 1 ];		
	}
	for( int i = 1; i <= n - 1; ++i )
	{
		ans = min( ans, abs( 2 * dp[ i ] - dp[ n ] ) );
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int L = sc.nextInt();
        int jump_time_L = D / L;
        // System.out.println(jump_time_L);
        int jump_time = jump_time_L + (D - (L * jump_time_L));
        System.out.println(jump_time);
    }
}


Measured memory_bytes: 26268
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
#include<unordered_map>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=998244353;
#define ll long long

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>x(m+1),y(m+1),num(n+1,1);
    vector<bool>red(n+1,false);
    int ans=0;
    red[1]=true;
    re(i,1,m+1){
        cin>>x[i]>>y[i];
        if(red[x[i]]){
            red[y[i]]=true;
        }
        num[x[i]]--;
        num[y[i]]++;
        if(num[x[i]]==0){
            red[x[i]]=false;
        }
    }
    re(i,1,n+1){
        if(red[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
n=int(input())
a=[str(input()) for i in range(n)]
b={}
for i in a:
  if i in b:
    b[i]+=1
  else:
    b[i]=0
maxb=max(b.values())
b=sorted(b.items(),key=lambda x:x[0])
for i,j in b:
  if maxb==j:
    print(i)

Measured memory_bytes: 46352