akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
const ll inf = 1e18;
const int nax = 2e6 + 7;
ll mod;
int n , q;
using namespace std;
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}
ll tree[nax];
ll arr[nax];
void update(int ind , int val , int tl , int tr , int pos){
	if(tl == tr){
		tree[pos] += val;
		return ;
	}
	int mid = tl + (tr - tl)/2;
	if(ind <= mid)
		update(ind , val , tl , mid , 2 * pos );
	else
		update(ind , val , mid + 1 , tr , 2 * pos + 1);
	tree[pos] = tree[2*pos] + tree[ 2* pos + 1 ];
}
ll query(int l , int r , int tl , int tr , int pos){
	if(l > r)
		return 0;
	if(l == tl && r == tr)
		return tree[pos];
	int mid = tl + (tr - tl)/2;
	return query(l , min(r , mid) , tl , mid , 2*pos) + query(max(mid + 1 , l) , r , mid + 1 , tr ,2 * pos + 1);	
}
int main(int argc,char ** argv){
	dhoom;

	cin >> n >> q;
	for(int i = 0 ; i < q ; i++){
		int a , b , c;
		cin >> a >> b >> c;
		if(a == 0){
				update(b , c , 1 , n , 1);
		}
		else 
			cout << query(b , c , 1 , n , 1) << endl;
	}
	return 0;
	
}



Measured memory_bytes: 5204
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
#define ABS(x) (x) < 0 ? (-x) : (x)
#define RG register
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 200000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e8 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int INF = 0x3f3f3f3f;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int m, int n) {
    /*
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    */
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

ll n, sum, a[N], df[N], t, b;
bool flag = true;

int main() {
    std::ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i], t += i;
    if (sum % t != 0) return puts("NO"), 0;
    b = sum / t;
    a[n + 1] = a[1] - a[n];
    for (int i = 1; i <= n; i++) a[i] = a[i + 1] - a[i];
    a[n] = a[n + 1];
    for (int i = 1; i <= n; i++) {
        a[i] -= b;
        if (a[i] % n != 0 || a[i] > 0) flag = false;
    }
    if (flag) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
using namespace std;
#define RENT 100000
int main(){
    int n;
    while(cin>>n){
        int ans=0;
        for(int a=0;a<10;a++){
            for(int b=0;b<10;b++){
                for(int c=0;c<10;c++){
                    for(int d=0;d<10;d++){
                        if(a+b+c+d==n)ans++;
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
}

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

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

int main() {
	long long N;
	cin >> N;
	long long res = 0;
	for (long long  i = 0; i < N - 1; i++) {
		res = res + i + 1;
	}

	cout << res << endl;
}

Measured memory_bytes: 256
import collections
a = int(input())
l = []
for i in range(a):
    l.append(input())
counted = collections.Counter(l)
 
m = max(counted.values())
 
chars = [key for key, value in counted.items()
             if value == m]
chars.sort()
 
for i in chars:
    print(i)

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

enum flugs{
  NONE=0,
  SPARE=1,
  STRIKE=2
};

struct data{
  int stud;
  int point;
};

int comp(const void *p1, const void *p2);
struct data inputmake(void);
void output(struct data datas);

int main(void){
  int i,j,k;
  int student;
  struct data *cases;

  while(scanf("%d",&student) && student){
    cases=(struct data *)calloc(student,sizeof(struct data));
    for(i=0;i<student;i++) cases[i]=inputmake();
    qsort(cases,student,sizeof(struct data),comp);
    for(i=0;i<student;i++) output(cases[i]);
    free(cases);
  }
  return 0;
}

int comp(const void *p1, const void *p2) {
  struct data *n1, *n2;
  n1 = (struct data *)p1;
  n2 = (struct data *)p2;
  if (n1->point == n2->point) {
    return n1->stud - n2->stud;
  }else{
    return n2->point - n1->point;
  }
}

struct data inputmake(void){
  enum flugs flg[3]={NONE,NONE,NONE};
  int frame=1,through=0,nums[3];
  struct data ret;
  scanf("%d",&ret.stud);
  ret.point=0;
  while(frame<11){
    scanf("%d",&nums[0]);
    through++;
    if(frame!=10){
      if(through==1 && nums[0]==10) flg[0]=STRIKE;
      else if(through==2 && nums[0]+nums[1]==10) flg[0]=SPARE;
      else flg[0]=NONE;
      ret.point+=nums[0];
      if(flg[1]==SPARE || flg[1]==STRIKE) ret.point+=nums[0];
      if(flg[2]==STRIKE) ret.point+=nums[0];
    }else{
      if(through==1){
	flg[0]=NONE;
	ret.point+=nums[0];
	if(flg[1]==SPARE || flg[1]==STRIKE) ret.point+=nums[0];
	if(flg[2]==STRIKE) ret.point+=nums[0];
      }else{
	ret.point+=nums[0];
	if(flg[2]==STRIKE) ret.point+=nums[0];
	if(nums[0]+nums[1]>=10){
	  scanf("%d",&nums[2]);
	  ret.point+=nums[2];
	}
	break;
      }
    }
    nums[2]=nums[1];
    nums[1]=nums[0];
    flg[2]=flg[1];
    flg[1]=flg[0];
    if(through==2 || (through==1 && flg[0]==STRIKE)){
      frame++;
      through=0;
    }
  }
  return ret;
}

void output(struct data datas){
  printf("%d %d\n",datas.stud,datas.point);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t x;
  cin >> x;
  if(x %11 > 6){
    cout << (x/11)*2 + 2 << endl;
  }
  else if(x %11 > 0){
    cout << (x/11)*2 + 1 << endl;
  }
  else{
    cout << (x/11)*2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String s = scan.nextLine();
	String p = scan.nextLine();
	if (match(s, p)) {
	    System.out.println("Yes");
	} else {
	    System.out.println("No");
	}
    }
    public static boolean match (String s, String p) {
	int pLength = p.length();
	String doubleS = s + s;
	for (int i = 0; i < s.length(); i++) {
	    String word = doubleS.substring(i, i+pLength);
	    if (word.equals(p)) {
		return true;
	    }
	}
	return false;
    }
}

Measured memory_bytes: 26320
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#include<unordered_set>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 1000000009;
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first	
#define sc  second


int main() {
	int n;
	cin >> n;
	int ret = INF;

	repft(i, 1, n) {
		int a = i;
		int b = n - i;
		int r = 0;
		while (a > 0) {
			r += a % 10; a /= 10;
		}
		while (b > 0) {
			r += b % 10; b /= 10;
		}
		ret = min(r, ret);
	}
	cout << ret << endl;


}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun knapsack2(V: IntArray, W: IntArray, WLim: Int): Long {
    val N = V.size
    val dp = Array(N+1) {
        LongArray(WLim + W.last() + 4) { 0L }
    }
    for (i in 0 until N) {
        dp[i][0] = 0
    }
    for (j in 0 .. WLim+W.last()) {
        dp[0][j] = 0
    }
    for (i in 0 until N) {
        //for (j in 0 .. WLim) {
            //if (j + W[i] <= WLim) {
        for (j in 0 .. WLim + W.last()) {
            if (j + W[i] < WLim + W[i]) {
                dp[i+1][j+W[i]] = max(dp[i+1][j+W[i]], dp[i][j] + V[i])
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        }
    }

    //return dp[N][WLim]
    var res = 0L
    for (v in dp[N]) res = max(res, v)
    return res
}


fun solve() {
    val (N, T) = rd.readIntArray()
    val A = IntArray(N); val B = IntArray(N)
    val P = Array(N){IntPair(0,0)}
    for (i in 0 until N) {
        val (a, b) = rd.readIntArray()
        P[i] = IntPair(a, b)
    }
    P.sortWith(compareBy({it.first}, {it.second}))
    for (i in 0 until N) {
        A[i] = P[i].first
        B[i] = P[i].second
    }

    val ans = knapsack2(B, A, T)

    print(ans)
}


//val rd = debug.Reader("abc", "145", "e", "sample-4")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 216200
n=int(input())
a_list=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(n+1):
    cost.append(abs(a_list[i+1]-a_list[i]))
Sum=sum(cost)
for i in range(1,n+1):
    print(Sum-cost[i-1]-cost[i]+abs(a_list[i+1]-a_list[i-1]))


Measured memory_bytes: 58604
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i<int(s.size()); i++) {
        int curr = s[i] - '0';
        ans = (ans + curr)%9;
    }
    if(ans == 0) cout << "Yes\n";
    else cout << "No\n";
}

int main() {_
    int t = 1;
//    cin >> t;
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


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

typedef long long LL;

const int N = 5005;
const int MOD = 1000000007;

int n, po[N], f[N], g[N], h[N], dp[N][N], a[N], m;

int find(int x)
{
	return f[x] == x ? x : f[x] = find(f[x]);
}

int main()
{
	scanf("%d", &n);
	po[0] = 1;
	for (int i = 1; i <= n; i++) f[i] = i, g[i] = 1, po[i] = (LL)po[i - 1] * (n - 1) % MOD;
	int tot = 0;
	for (int i = 1; i <= n; i++)
	{
		int x; scanf("%d", &x);
		if (x == -1) {tot++; continue;}
		if (find(x) == find(i)) h[find(x)] = 1;
		else h[find(x)] ^= h[find(i)], g[find(x)] += g[find(i)], f[find(i)] = find(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) if (f[i] == i)
	{
		if (h[i]) (ans += po[tot]) %= MOD;
		else a[++m] = g[i], (ans += (LL)(g[i] - 1) * po[tot - 1] % MOD) %= MOD;
	}
	for (int i = 1; i <= m; i++)
	{
		dp[i][1] = (dp[i - 1][1] + a[i]) % MOD;
		for (int j = 2; j <= i; j++)
			dp[i][j] = (dp[i - 1][j] + (LL)dp[i - 1][j - 1] * (j - 1) % MOD * a[i] % MOD) % MOD;
	}
	for (int i = 2; i <= m; i++) (ans += (LL)dp[m][i] * po[tot - i] % MOD) %= MOD;
	printf("%d\n", ((LL)n * po[tot] % MOD + MOD - ans) % MOD);
	return 0;
}

Measured memory_bytes: 70644
H, W = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

grid = H.times.map { gets.chomp.chars }

dp = Array.new(H) { Array.new(W, 0) }
dp[0][0] = 1

H.times do |y|
  W.times do |x|
    next if grid[y][x] == '#'

    if y + 1 < H && dp[y + 1][x] != '#'
      dp[y + 1][x] = (dp[y + 1][x] + dp[y][x]) % MOD
    end

    if x + 1 < W && dp[y][x + 1] != '#'
      dp[y][x + 1] = (dp[y][x + 1] + dp[y][x]) % MOD
    end
  end
end

puts dp[H - 1][W - 1]


Measured memory_bytes: 90780
# -*- coding:utf-8 -*-

def calc(S, T):
    # 差を計算する
    ans = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ans += 1
    return ans


def solve():
    s = input()
    S = [moji for moji in s]
    T = input()

    # 文字の置き換えをして、差が減ってなかったら無理？
    
    diff = calc(S, T)
    if diff == 0:
        print("Yes")
        return
    pre_diff = diff

    while True:
        # c1, c2を決める
        for i in range(len(S)):
            if S[i] != T[i]:
                c1 = S[i]
                c2 = T[i]
                break
        
        # 文字を置き換える
        for i in range(len(S)):
            if S[i] == c1:
                S[i] = c2
            elif S[i] == c2:
                S[i] = c1
        
        # 差を計算する
        diff = calc(S, T)
        if diff == 0:
            break
        elif diff < pre_diff:
            pre_diff = diff
            continue
        else:
            print("No")
            return
    print("Yes")





if __name__ == "__main__":
    solve()

Measured memory_bytes: 5192
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def factorization(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


def main():
    N = I()
    n = 5
    ans = 0

    if N % 2 == 0:
        while n <= N:
            ans += N // n // 2
            n *= 5
        print(ans)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63980
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main(){
	ll X;
	cin >> X;

	ll A, B;
	bool done = false;
	for (ll i=0;; i++) {
		//cout << i << endl; // **** debug ****
		ll A5 = pow(i, 5);
		if (A5 < X) {
			for (ll j=0;;j--) {
				//cout << "  " << j << endl; // **** debug ****
				ll B5 = pow(j, 5);
				if (A5 - B5 > X) break;

				if (A5 - B5 == X) {
					done = true;
					B = j;
					break;
				}
			}
		} else {
			for (ll j=0;;j++) {
				//cout << "  " << j << endl; // **** debug ****
				ll B5 = pow(j, 5);
				if (A5 - B5 < X) break;

				if (A5 - B5 == X) {
					done = true;
					B = j;
					break;
				}
			}
		}

		if (done) {
			A = i;
			break;
		}

	}

	cout << A << " " << B << endl;

	return 0;
}

Measured memory_bytes: 4104
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	int A, B, C, D, E;
	cin >> A >> B >> C >> D >> E;
	int num1 = A + (10 - A % 10) % 10 + B + (10 - B % 10) % 10 + C + (10 - C % 10) % 10 + D + (10 - D % 10) % 10 + E + (10 - E % 10) % 10;
	int num2 = max({ (10 - A % 10) % 10,(10 - B % 10) % 10,(10 - C % 10) % 10 ,(10 - D % 10) % 10 ,(10 - E % 10) % 10 });
	cout << num1 - num2;
}

Measured memory_bytes: 256
line = input()
rain_day = 0
k = 0
for wether in line:
  #当日雨
  if wether == "R":
    rain_day += 1
  #当日晴れ、前日は雨
  elif rain_day != 0:
    k = rain_day
    rain_day = 0
  #当日晴れ、前日も晴れ
  else:
    pass
if k > rain_day:
  print(k)
else:
  print(rain_day)

Measured memory_bytes: 9056
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
const int N = 1005;
const int Inf = 2e9+7;
//const int alpha = 29;
const int MOD = 998244353;

int n, m, k, a[11][N], t[11];
//int pf[N];
//int dp[N][N], ans[N][N];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
	cin >> n >> m >> k;
	char cc;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			cin >> cc;
			a[i][j] = cc == '1';
		}
	}
	int ans = Inf;
	for (int mask = 0; mask < (1 << n); ++mask)
	{
		memset(t, 0, sizeof t);
		int cur_ans = 0;
		bool ok = 1;
		for (int i = 0; i < m; ++i)
		{
			int ceil = 0;
			bool reset = false;
			for (int j = 0; j < n; ++j)
			{
				if (a[j][i])
				{
					++t[ceil];
				}
				if (t[ceil] == k + 1)
				{
					reset = true;
				}
				if (mask & (1 << j))
				{
					++ceil;
				}
			}
			if (reset)
			{
//				cerr << i << endl;
				++cur_ans;
				ceil = 0;
				int sm = 0;
				memset(t, 0, sizeof t);
				for (int j = 0; j < n; ++j)
				{
					if (a[j][i])
					{
						++t[ceil];
						++sm;
					}
					if (sm > k)
						ok = false;
					if (mask & (1 << j))
					{
						++ceil;
						sm = 0;
					}
				}
			}/*
			for (int j = 0; j < n; ++j)
			{
				cerr << t[j];
			}cerr << endl;*/
		}
		if (ok)
		{
	//		cerr << ans << ' ' << mask << ' ' << cur_ans << endl;
			ans = min(ans, cur_ans + __builtin_popcount(mask));
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

const int maxn = 2016;

int times[maxn][maxn];
int wys[2][maxn * 2];

int perm[maxn * 4];
int invperm[maxn * 4];

int inv(int x) {
    return x < 2 ? x : MOD - (MOD / x) * 1ll * inv(MOD % x) % MOD;
}

int comb(int a, int b) {
    return perm[a + b] * 1ll * invperm[a] % MOD * invperm[b] % MOD;
}

int main()
{
    perm[1] = invperm[1] = 1;
    for (int i = 2; i < maxn * 4; i++) {
        perm[i] = perm[i - 1] * 1ll * i % MOD;
        invperm[i] = inv(perm[i]);
    }
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int ai, bi;
        scanf("%d%d", &ai, &bi);
        times[ai][bi] ++;
        ans = (ans + MOD - comb(ai * 2, bi * 2)) % MOD;
    }
    int now = 0;
    memset(wys, 0, sizeof(wys));
    for (int sum = (maxn - 1) * 2, len = 0; sum > 0; sum --, len ++) {
        for (int i = 0; i <= len; i++) {
            int x = maxn - 1 - len + i, y = maxn - 1 - i;
            if (x > 0 && y > 0) {
                (wys[now][i] += times[x][y]) %= MOD;
            }
        }
        int next = now ^ 1;
        memcpy(wys[next], wys[now], sizeof(wys[now][0]) * (len + 1));
        wys[next][len + 1] = 0;
        for (int i = 0; i <= len; i++)
            (wys[next][i + 1] += wys[now][i]) %= MOD;
        now = next;
    }
    int len = (maxn - 1) * 2;
    for (int i = 0; i <= len; i++) {
        (ans += wys[now][i] * 1ll * wys[now][len - i] % MOD) %= MOD;
    }
    ans = ans * 1ll * inv(2) % MOD;
    printf("%d\n", ans);
}



Measured memory_bytes: 16128
#include<stdio.h>
int buble(int a, int b[200]){
   int j,i,tmp;
  for(i=0;i<a;i++){
 	 for(j=0;j<a;j++){
   		 if(b[i]>b[j]){
  	   	   tmp=b[i];
   		   b[i]=b[j];
   		   b[j]=tmp;    
		  }
 	 }
  }
   return b;
  }
int main(){
  int N=0,L[200]={},p=0,d=0,e=0,f=0,count=0;
  scanf("%d",&N);
  for(p=0;p<=N;p++){
  scanf("%d",&L[p]);
  }
  L[200]=buble(N,L);
  p=(N*N*N-3*N*N+2*N)/6;
  for(d=0;d<N;d++){
    for(e=d+1;e<N;e++){
      for(f=e+1;f<N;f++){
  if(L[d]>=L[e]+L[f]||L[d]==L[e]||L[e]==L[f]){
    count++;
  }
      }
    }
  }
  count=p-count;
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

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

        Integer[] a = new Integer[n*3];
        for(int i=0; i<n*3; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(a, Collections.reverseOrder());

        int cnt = 1;
        long sum = 0;
        for(int i=1; i<=n*3; i+=2) {
            if(cnt > n) {
                break;
            } else {
                sum += a[i];
            }
            cnt++;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 101060
// import chie template :) {{{
import std;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  int n;
  string s;
  cin.scan(n, s);

  int[][dchar] imos;
  imos['R'] = new int[n + 1];
  imos['G'] = new int[n + 1];
  imos['B'] = new int[n + 1];

  foreach (i, c; s) {
    imos[c][i] = 1;
  }

  imos['R'] = imos['R'].cumulativeFold!"a + b".array;
  imos['G'] = imos['G'].cumulativeFold!"a + b".array;
  imos['B'] = imos['B'].cumulativeFold!"a + b".array;

  alias T = Tuple!(uint, "fst", uint, "snd", dchar, "rem");
  T[] can;

  auto per = permutations("RGB".to!(dchar[]));
  foreach (p; per) {
    foreach (i; 0 .. n) {
      foreach (j; i + 1 .. n) {
        if (p[0] == s[i] && p[1] == s[j]) {
          can ~= T(i, j, p[2]);
        }
      }
    }
  }

  long res;
  foreach (e; can) {
    uint mid = min(2 * e.snd - e.fst, n);
    auto sum = imos[e.rem];

    res += sum[mid - 1] - sum[e.snd] + sum[n] - sum[mid];
  }

  writeln(res);
}


Measured memory_bytes: 108432
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>


using namespace std;
#define MAX 100000

int main(){
    int N;
    vector<int> a;

    scanf("%d", &N);
    for (int i = 0; i < N; i++){
        int temp;
        scanf("%d", &temp);
        a.push_back(temp);
    }
    int sum = accumulate(a.begin(), a.end(), 0);
    int ans = sum - N;

    printf("%d", ans);

    return 0;
}

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

using namespace std;
typedef long long ll;

typedef pair<int, int> p;

vector<p> factors[101] = {
    {}, {}, {p(2,1)}, {p(3,1)}, {p(2,2)}, {p(5,1)}, {p(2,1), p(3,1)}, {p(7,1)}, {p(2,3)}, {p(3,2)}, {p(2,1), p(5,1)}, {p(11,1)}, {p(2,2), p(3,1)}, {p(13,1)}, {p(2,1), p(7,1)}, {p(3,1), p(5,1)}, {p(2,4)}, {p(17,1)}, {p(2,1), p(3,2)}, {p(19,1)}, {p(2,2), p(5,1)}, {p(3,1), p(7,1)}, {p(2,1), p(11,1)}, {p(23,1)}, {p(2,3), p(3,1)}, {p(5,2)}, {p(2,1), p(13,1)}, {p(3,3)}, {p(2,2), p(7,1)}, {p(29,1)}, {p(2,1), p(3,1), p(5,1)}, {p(31,1)}, {p(2,5)}, {p(3,1), p(11,1)}, {p(2,1), p(17,1)}, {p(5,1), p(7,1)}, {p(2,2), p(3,2)}, {p(37,1)}, {p(2,1), p(19,1)}, {p(3,1), p(13,1)}, {p(2,3), p(5,1)}, {p(41,1)}, {p(2,1), p(3,1), p(7,1)}, {p(43,1)}, {p(2,2), p(11,1)}, {p(3,2), p(5,1)}, {p(2,1), p(23,1)}, {p(47,1)}, {p(2,4), p(3,1)}, {p(7,2)}, {p(2,1), p(5,2)}, {p(3,1), p(17,1)}, {p(2,2), p(13,1)}, {p(53,1)}, {p(2,1), p(3,3)}, {p(5,1), p(11,1)}, {p(2,3), p(7,1)}, {p(3,1), p(19,1)}, {p(2,1), p(29,1)}, {p(59,1)}, {p(2,2), p(3,1), p(5,1)}, {p(61,1)}, {p(2,1), p(31,1)}, {p(3,2), p(7,1)}, {p(2,6)}, {p(5,1), p(13,1)}, {p(2,1), p(3,1), p(11,1)}, {p(67,1)}, {p(2,2), p(17,1)}, {p(3,1), p(23,1)}, {p(2,1), p(5,1), p(7,1)}, {p(71,1)}, {p(2,3), p(3,2)}, {p(73,1)}, {p(2,1), p(37,1)}, {p(3,1), p(5,2)}, {p(2,2), p(19,1)}, {p(7,1), p(11,1)}, {p(2,1), p(3,1), p(13,1)}, {p(79,1)}, {p(2,4), p(5,1)}, {p(3,4)}, {p(2,1), p(41,1)}, {p(83,1)}, {p(2,2), p(3,1), p(7,1)}, {p(5,1), p(17,1)}, {p(2,1), p(43,1)}, {p(3,1), p(29,1)}, {p(2,3), p(11,1)}, {p(89,1)}, {p(2,1), p(3,2), p(5,1)}, {p(7,1), p(13,1)}, {p(2,2), p(23,1)}, {p(3,1), p(31,1)}, {p(2,1), p(47,1)}, {p(5,1), p(19,1)}, {p(2,5), p(3,1)}, {p(97,1)}, {p(2,1), p(7,2)}, {p(3,2), p(11,1)}, {p(2,2), p(5,2)}
};

int count(vector<int> es) {
    int cnt = 0;
    int l = es.size();
    // 75
    for (int i = 0; i < l; i ++) {
        if (es[i] >= 75) cnt ++;
    }
    // 25 * 3
    for (int i = 0; i < l; i ++) {
        if (es[i] >= 25) {
            for (int j = 0; j < l; j ++) {
                if (i != j && es[j] >= 3) cnt ++;
            }
        }
    }
    // 15 * 5
    for (int i = 0; i < l; i ++) {
        if (es[i] >= 15) {
            for (int j = 0; j < l; j ++) {
                if (i != j && es[j] >= 5) cnt ++;
            }
        }
    }
    // 5 * 5 * 3
    for (int i = 0; i < l; i ++) {
        if (es[i] >= 5) {
            for (int j = i + 1; j < l; j ++) {
                if (es[j] >= 5) {
                    for (int k = 0; k < l; k ++) {
                        if (k != i && k != j && es[k] >= 3) cnt ++;
                    }
                }
            }
        }
    }
    return cnt;
}

int main() {
    int N;
    cin >> N;
    int exp[97 + 1] = {0};
    for (int i = 1; i <= N; i ++) {
        for (auto pair : factors[i]) {
            exp[pair.first] += pair.second;
        }
    }
    vector<int> squashed_exp = {};
    for (int i = 1; i <= 97; i ++) {
        if (exp[i]) squashed_exp.push_back(exp[i] + 1);
    }
    cout << count(squashed_exp) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();

		int i = 1;
		int c = x;
		ArrayList<Integer> yakusu = new ArrayList<Integer>();
		while(c >= i) {

//			System.out.println("pass");
			if(x % i == 0) {

				c = x / i;

				if(c < i) break;

				if(i == c) yakusu.add(c);
				else {
					yakusu.add(i);
					yakusu.add(c);
				}
			}
			i++;

		}

		int count = 0;
		for(int j = 0; j < yakusu.size(); j++) {
			if(yakusu.get(j) >= a && yakusu.get(j) <= b) {
				count++;
			}
		}

		System.out.println(count);

	}

}



Measured memory_bytes: 26408
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("myfile.in","r",stdin);freopen ("myfile.out","w",stdout);
using namespace std;

ll n,a,b,c;
ii p[N];


 
int main()
{
	int sum=0;
	fast;
	cin>>a>>b>>c;
	sum+=b;
	sum+=min(c,a+b+1);
	cout<<sum;
}


Measured memory_bytes: 256
tr' ([]:_) = []
tr' x =
  let c = map head x
      x'= map (drop 1) x
  in
    c:tr' x'

ans'' :: Int -> String -> Int
ans'' _ [] = 0
ans'' n m =
  let l = length $ takeWhile (== '.') m
      a = if l >= n
          then 1
          else 0
  in
    a + (ans'' n $ drop 1 m)

ans' _ [] = 0
ans' n (m:ms) = (ans'' n m) + ans' n ms

ans n m =
  let yoko = ans' n m
      tate = ans' n $ tr' m
  in
    yoko + tate

main = do
  l <- getLine
  c <- getContents
  let [n,m,d] = map read $ words l
      c' = lines c
      o = ans d c'
  print o

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

vector<int> g[100001];
int dp[100001];

int dfs(int nd){
    if(dp[nd] != -1)
        return dp[nd];

    int res = 0;
    for(auto nbr : g[nd]){
        res = max(res, 1 + dfs(nbr));
    }

    return dp[nd] = res;

}


void solve(){
    int n, m;
    cin >> n >> m;

    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }

    int ans = 0;
    memset(dp, -1, sizeof(dp));
    for(int i = 1; i <= n; i++){
        ans = max(ans, dfs(i));
    }

    cout << ans;

}


int main(){
    solve();
}


Measured memory_bytes: 11436
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;


long long gcd(long long A, long long B){
    if(A > B){
        std::swap(A, B);
    }

    while(A != 0){
        long long q = B % A;
        B = A;
        A = q;
    }

    return B;
}


int main(){ 
    long long A, B;
    cin >> A >> B;


    cout << A * B / gcd(A, B);
}



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

typedef long long ll;
string str;
priority_queue<int> q;

int main() {
    string str;
    while(cin >> str) {
        if(str == "insert" || str == "end")
            continue;
        else if(str == "extract") {
            int val = q.top();
            q.pop();
            cout << val << endl;
        } else {
            q.push(stoi(str));
        }
    }
}


Measured memory_bytes: 6984
n,k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

if k >= sum(a):
    print(0)
    exit()

def solve(time):
    cnt=0
    for i in range(n):
        tmp = time // f[i]
        if a[i] - tmp > 0:
            cnt += (a[i]-tmp)
    if cnt <= k:
        return True
    else:
        return False

r=0
l=0
for i in range(n):
    r=max(r,a[i]*f[i])

while r-l>1:
    mid=(l+r)//2

    if solve(mid):
        r=mid
    else:
        l=mid
print(r)

Measured memory_bytes: 119628
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
template<class T> void read(T & x) {
  register int c = getchar(), f = 1; x = 0;
  while(!isdigit(c)) {if (c == '-') f = -f; c = getchar();}
  while(isdigit(c)) x = x * 10 + (c & 15), c = getchar();
  x *= f;
}
const int MAXN = 1e5+7;
int a[MAXN], n; int cost;
int main(void) {
  read(n); //1..n+2
  for(int i = 2; i <= n+1; ++i) read(a[i]); n+=2;
  for(int i = 2; i <= n; ++i) cost += abs(a[i] - a[i-1]);
  for(int i = 2; i < n; ++i) {
    int tmp = cost;
    tmp -= (abs(a[i]-a[i-1])+abs(a[i+1]-a[i])); tmp += abs(a[i-1] - a[i+1]);
    printf("%d\n", tmp);
  }
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
// typedef pair<int,int> P;
using Graph = vector<vector<int>>;

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

  int N, R;
  cin >> N >> R;
  if(N >= 10){
    cout << R << endl;
  }
  else{
    int W = R + 100 * (10-N);
    cout << W << endl;
  }
}

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

int main()
{
  int a = 0, b = 0, c = 0;
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) == 'a')
    {
      a++;
    }
    else if (S.at(i) == 'b')
    {
      b++;
    }
    else
    {
      c++;
    }
  }
  if (abs(a - b) > 1 || abs(b - c) > 1 || abs(c - a) > 1)
  {
    cout << "NO" << endl;
  }
  else
  {
    cout << "YES" << endl;
  }
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "NO";
  if (a == 5 && b == 5 && c == 7) ans = "YES";
  if (a == 5 && b == 7 && c == 5) ans = "YES";
  if (a == 7 && b == 5 && c == 5) ans = "YES";
  cout << ans << endl;
}

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

int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long x, y ,ans;
  x = n/(a+b);

  if(n-x*(a+b)>=a){
    ans = (x+1)*a;
  }
  else{
    ans = x*a+ (n-x*(a+b));
  }

  cout << ans<< endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
A, B, C, D, E, F = map(int, input().split())
s = set()
for i in range(31):
  for j in range(31):
    if (i * A + j * B) * 100 <= F:
      s.add((i * A + j * B) * 100)
    else: break
s.discard(0)
#print(s)
ss = set()
for i in range(3001):
  for j in range(3001):
    if i * C + (j * D) <= F:
      ss.add(i * C + j * D)
    else: break
resw = 100 * A
ress = 0
for water in s:
  for suger in ss:
    if water // 100 * E >= suger and (water + suger <= F):
      if suger * (resw + ress) > (ress * (water + suger)):
        resw = water
        ress = suger
print(resw + ress, ress)

Measured memory_bytes: 40304
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
  int key;
  struct node *p;       //親
  struct node *left;    //左の子
  struct node *right;   //右の子
} tree;
void insert(tree *);
void Inorder(tree *);
void Preorder(tree *);
void find(tree *,int);
tree *t = NULL;

int main(){
  int n,i,k;
  char function[10];
  tree *new;
  
  scanf("%d",&n);
   for(i=0;i<n;i++){
    scanf("%s",function);
     if(function[0] == 'f'){
      scanf("%d",&k);
      find(t,k);
      }
    if(function[0] == 'p'){
      Inorder(t);
      printf("\n");
      Preorder(t);
      printf("\n");
    }
    else if(function[0] == 'i'){
      scanf("%d",&k);
      new=malloc(sizeof(struct node));
      new->key=k;
      insert(new);
    }
    //  printf("%d\n",i);
  }
  return 0;
}

void Preorder(tree *x){
  if(x == NULL) return;
  else  printf(" %d",x->key);
  if(x->left != NULL) Preorder(x->left);
  if(x->right != NULL) Preorder(x->right);
}
void Inorder(tree *x){
  if(x == NULL) return;
  if(x->left != NULL) Inorder(x->left);
  if(x != NULL) printf(" %d",x->key);
  if(x->right != NULL) Inorder(x->right);
}

void insert(tree *new){
  tree *x;
  tree *y;
  
  y=NULL;
  x=t;
  
  while(x != NULL){
    y=x;
    if(x->key > new->key) x=x->left;
    else x=x->right;
  }
  new->p = y;
  
  if(y == NULL){
    t=new;
    new->left = NULL;
    new->right = NULL;
  }
  else if(y->key > new->key){
    y->left = new;
    new->left = NULL;
    new->right = NULL;
  }
  else{
    y->right = new;
    new->left = NULL;
    new->right = NULL;
  }
}

void find(tree *t,int key){
  if(t == NULL){
    printf("no\n");
    return;
  }
  if(t->key == key){
    printf("yes\n");
    return;
  }
  if(t->key > key){
    find(t->left,key);
    return;
  }
  else{
    find(t->right,key);
    return;
  }
}

Measured memory_bytes: 19364
#include<bits/stdc++.h>
const int N=1000009;

int n,ans,h[N];
int tr[N<<2],sz[N<<2];
char s[N],t[N];

inline void chkmax(int &a,int b){if(a<b)a=b;}

inline void upd(int x)
{
	sz[x]=sz[x<<1]+sz[x<<1|1];
}

inline void push(int x)
{
	if(tr[x])
	{
		tr[x<<1]+=tr[x];
		tr[x<<1|1]+=tr[x];
		tr[x]=0;
	}
}

inline void build(int x,int l,int r)
{
	if(l==r){sz[x]=1;tr[x]=0;return;}
	int mid=l+r>>1;
	build(x<<1,l,mid);
	build(x<<1|1,mid+1,r);
	upd(x);
}

inline void del(int x,int l,int r,int p)
{
	if(l==r){sz[x]=0;return;}
	push(x);int mid=sz[x<<1];
	if(p<=mid)del(x<<1,l,(l+r)>>1,p);
	else del(x<<1|1,((l+r)>>1)+1,r,p-mid);
	upd(x);
}

inline void add(int x,int l,int r)
{
	if(l==1 && r==sz[x]){tr[x]+=1;return;}
	push(x);int mid=sz[x<<1];
	if(r<=mid)add(x<<1,l,r);
	else if(mid<l)add(x<<1|1,l-mid,r-mid);
	else add(x<<1,l,mid),add(x<<1|1,1,r-mid);
	upd(x);
}

inline int query(int x,int l,int r,int p)
{
	if(l==r)return tr[x];
	push(x);int mid=sz[x<<1];
	if(p<=mid)return query(x<<1,l,(l+r)>>1,p);
	else return query(x<<1|1,((l+r)>>1)+1,r,p-mid);
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%d%s%s",&n,s+1,t+1);
	if(!strcmp(s+1,t+1))return puts("0"),0;
	build(1,1,n);
	for(int i=n,p=n;i;i--)
		if(i==1 || t[i-1]!=t[i])
		{
			if(p>i)p=i;
			while(p && (query(1,1,n,p) || s[p]!=t[i]))
				p--;
			if(!p)return puts("-1"),0;
			if(p==i)continue;
			del(1,1,n,p);add(1,p,i-1);
			chkmax(ans,query(1,1,n,i-1));
		}
		else chkmax(ans,query(1,1,n,i));
	printf("%d\n",ans+1);
	return 0;
}


Measured memory_bytes: 20864
n,k = map(int,input().split())
a = list(map(int,input().split()))
import collections
c = collections.Counter(a)
L = set(a)
b = list(L)
d = [0]*len(b)
for i in range(len(b)):
    d[i] = c[b[i]]
d = sorted(d)
if len(b) <= k:
    print(0)
else:
    print(sum(d[:len(b)-k]))

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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = "";
            while ((line = Console.ReadLine()) != null)
            {
                String[] num = line.Split(' ');
                Console.WriteLine((int.Parse(num[0]) + int.Parse(num[1])).ToString().Length);
            }
        }
    }
}

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

def main():
    mod=998244353
    n,k=map(int,input().split())
    LR=[list(map(int,input().split())) for _ in range(k)]
    DP=[0]*n
    Acc=[0]*(n+1)
    DP[0]=1
    Acc[1]=1
    for i in range(1,n):
        for l,r in LR:
            if l>i:
                continue
            left=max(0,i-r)
            right=i-l
            DP[i]+=Acc[right+1]-Acc[left]
        DP[i]%=mod
        Acc[i+1]=Acc[i]+DP[i]
    print(DP[-1])
    #print(DP)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 71136
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,a,b,c,d;

int main(){
	cin>>n>>a>>b>>c>>d;
	b-=a;
	ll e=(n-1)*d;
	if(abs(b)<=e&&(b+e)%(c+d)<=(n-1)*(d-c)) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1001001001001001001;


//N^P(modM)




int main() {
  ll h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  ll a1=60*h1+m1;
  ll a2=60*h2+m2;
  ll a3=a2-a1;
  ll ans=a3-k;
  cout<<ans;

}


Measured memory_bytes: 3624
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll maxn=2e5+10;
const ll mod=1e9+7;

int main(){
	fast;
	int n;
	cin>>n;
	unordered_set<string> sr;
	while(n--){
		string s;
		cin>>s;
		sr.insert(s);
	}
	cout<<sr.size();
}

Measured memory_bytes: 17704
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, K; string S;
	cin >> N >> K >> S;
	vector<int> l;
	if(S[0] == '1') l.push_back(0);
	char pre = S[0];
	for (int i = 0; i < N; i++)
	{
		int cnt = 1;
		while (i + 1 < N)
		{
			if(S[i+1] == pre) {
				i++;
				cnt++;
			}
			else break;
		}
		l.push_back(cnt);
		pre = (pre == '0') ? '1' : '0';
	}
	
	int sum[l.size()+1];
	sum[0] = 0;
	for (int i = 0; i < l.size(); i++)
	{
		sum[i+1] = sum[i] + l[i];
	}
	

	int ans = sum[min((int)l.size(), 2*K)];
	for (int i = 2; i < l.size(); i+=2)
	{
		ans = max(ans, sum[min((int)l.size(), i+2*K)] - sum[i-1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1272
list1=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(list1[a-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionset(int x, int y){
        x = root(x); y = root(y);
        if(x!=y){
            if(data[y]< data[x]) swap(x,y);
            data[x] += data[y]; data[y] = x;
        }
        return x!=y;
    }
    bool find(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x] = root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,l; cin >> n >> k >> l;
  UnionFind UF(n);
  REP(i,k){
      int p,q; 
      cin >> p >> q;p--; q--;
      UF.unionset(p,q);
  }
  UnionFind UF2(n);
  REP(i,l){
      int r,s;
      cin >> r >> s; r--; s--;
      UF2.unionset(r,s);
  }
  REP(i,n){
      UF2.root(i);
  }
  map<P, int> m;
  REP(i,n){
      int a = UF.root(i);
      int b = UF2.root(i);
      m[mp(a,b)]++;
  }
  REP(i,n){
      int a = UF.root(i);
      int b = UF2.root(i);
      cout << m[mp(a,b)] << " ";
  }

}


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

using namespace std;

char a[105];

int main()
{
    cin >> a;

    bool C = 0;

    for(short i = 0 ; i < strlen(a) ; i++)
    {
        if(a[i] == 'C')
            C = 1;

        if(a[i] == 'F' && C == 1)
        {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";

    return 0;
}


Measured memory_bytes: 256