akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define f(i,a,b) for (int i=a; i<=b; i++)
#define fd(i,a,b) for (int i=a; i>=b; i--)
#define name "Limited Insertion"
#define maxn 105
#define ll long long

using namespace std;

ll n,b[maxn],d[maxn],c[maxn];
bool xd;

int main()
{
    ios_base::sync_with_stdio();
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(name".inp","r",stdin);
    //freopen(name".out","w",stdout);

    cin>>n;
    f(i,1,n)
    {
        cin>>b[i];
    }
    f(i,1,n)
    {
        xd=1;
        fd(j,n,1)
        {
            if(c[j]==0 && b[j]<=i)
            {
                ll z=0;
                f(t,j+1,n)
                {
                    if(c[t]==0 && b[t]>=b[j])
                    {
                        z=0;
                    }
                    else if(c[t]>=b[j])
                    {
                        z=0;
                    }
                    else
                    {
                        z=1;
                        break;
                    }
                }
                if(z==0)
                {
                    d[i]=j;
                    f(t,1,n)
                    {
                        if(c[t]!=0 && c[t]>=b[j])
                        {
                            c[t]++;
                        }
                    }
                    c[j]=b[j];
                    xd=0;
                    break;
                }
            }
        }
        if(xd==1)
        {
            break;
        }
    }
    if(xd==1)
    {
        cout<<-1;
    }
    else
    {
        f(i,1,n)
        {
            cout<<b[d[i]]<<'\n';
        }
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}
ll dp[N][2];
vector<int> adj[N];

void dfs(int i,int p)
{
    dp[i][0]=1;
    dp[i][1]=1;
    for(auto ve:adj[i])
    {
        if(p-ve){
            dfs(ve,i);
            dp[i][1] = (dp[i][1]*dp[ve][0])%mod;
            dp[i][0]= (dp[i][0]*((dp[ve][0]+dp[ve][1])%mod))%mod;
        }

     }
}
         

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
   ios_base::sync_with_stdio(false);cin.tie(NULL);

    int t=1,n,i,j,m;
    cin>>n;
    int u,v;
    rep(i,1,n-1)
    {
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(1,-1);
    cout<<(dp[1][0]+dp[1][1])%mod<<"\n";
    
    return 0;
}


Measured memory_bytes: 12800
import java.util.*;

public class Main {


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

        String s = sc.nextLine();

        int before = Integer.parseInt(s.substring(0,2));
        int after = Integer.parseInt(s.substring(2));

        boolean yymm, mmyy;
        yymm = mmyy = false;
        if(0 <= before && before < 100 && 0 < after && after < 13) yymm = true;
        if(0 <= after && after < 100 && 0 < before && before < 13) mmyy = true;

        if(yymm && mmyy) System.out.println("AMBIGUOUS");
        else if(yymm) System.out.println("YYMM");
        else if(mmyy) System.out.println("MMYY");
        else System.out.println("NA");

        return;
    }
}


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

int main(){
  int N;
  cin>>N;
  int j=0;
  for(int i=N;i>0;i/=10){
    j+=i%10;
  }
  if(N%j==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  int a,b;
  cin >> a >> b;
  if(a <= 5) cout << 0 << endl;
  else if(a <= 12) cout << b/2 << endl;
  else cout << b << endl;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <cctype>
//小文字を大文字 c-0x20;


#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define vvll(z,a,b) vector<vector<ll>>z(a,vector<ll>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define fix(k) fixed<<setprecision(k)
#define PI 3.141592653589793
using namespace std;


int main(){
  while(1){
  int n;cin>>n;
  if(n==0)break;
  vi sum(n);
  db m=0;
  rep(i,n){
    cin>>sum.at(i);
    m+=sum.at(i);
  }
  m/=n;
  db bun=0;
  rep(j,n){
    bun+=(sum.at(j)-m)*(sum.at(j)-m);
  }
  bun/=n;
  bun=sqrt(bun);
  bun=abs(bun);
  cout<<fix(6)<<bun<<endl;
  }




}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define MAXN 10000

using namespace std;
typedef long long ll;

int main()
{
	//freopen("t.txt","r",stdin);
	int n,l; cin>>n>>l;
	int a[100],sum=0,kq;
	
	for (int i=1;i<=n;i++){
		a[i]=l+i-1; sum+=a[i];
	}
	long long MIN = 10000000000;
	
	for (int i=1;i<=n;i++){
		int t= sum-a[i];
		if (abs (sum-t) <MIN  ){
			MIN= abs (sum-t);
			kq= t;
		}
	}
	cout<<kq;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=200000+10;
const LL MOD=1e9+7;

int n,c[N];
int a[N],tot;
LL dp[N],s[N];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&c[i]);
    }
    for(int i=1;i<=n;i++){
        if(c[i]!=c[i-1]){
            a[++tot]=c[i];
        }
    }

    n=tot; s[a[1]]=1; 
    for(int i=1;i<=n;i++){
        dp[i]=s[a[i]];
        (s[a[i+1]]+=dp[i])%=MOD;
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
from sys import setrecursionlimit
setrecursionlimit(100000)

def inpl(): return tuple(map(int, input().split()))

V, E = inpl()
graph = [[] for k in range(V)]

for _ in range(E):
    s, t = inpl()
    graph[s].append(t)
    graph[t].append(s)

prenum = [-1] * V
lowest = [float("inf")] * V
found = [False] * V
parent = [-1] * V

result = set()
root = 0

def DFS(i, c, prev):
    global root
    prenum[i] = c
    lowest[i] = c
    found[i] = True
    
    for p in graph[i]:
        if found[p]:
            if p != prev:
                lowest[i] = min(lowest[i], prenum[p])
        else:
            c = DFS(p, c+1, i)
            lowest[i] = min(lowest[i], lowest[p])
    
    if prenum[prev] <= lowest[i]:
        result.add(prev)
    parent[i] = prev
    
    return c
DFS(0, 1, 0)

if parent.count(0) <= 2:
    result = result.difference([0])

for r in sorted(result):
    print(r)
    
    

Measured memory_bytes: 20332
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> as(n), bs(n), cs(m), ds(m);
    for(int i=0;i<n;i++){
        cin >> as[i] >> bs[i];
    }
    for(int i=0;i<m;i++){
        cin >> cs[i] >> ds[i];
    }
    for(int i=0;i<n;i++){
        int ans = 0, len = M;
        for(int j=0;j<m;j++){
            if(abs(as[i] - cs[j]) + abs(bs[i] - ds[j]) < len){
                len = abs(as[i] - cs[j]) + abs(bs[i] - ds[j]);
                ans = j;
            }
        }
        cout << ans + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 888
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr size_t SIZE=1e5;
vector<int> graph[SIZE];
array<array<ll, 2>, SIZE> dp;

void dfs(int s, int p = -1) {
  dp[s][0] = 1;
  dp[s][1] = 1;
  for (auto t : graph[s]) {
    if (t == p) continue;
    dfs(t, s);
    (dp[s][0] *= (dp[t][0]+dp[t][1])%MOD)%=MOD;
    (dp[s][1] *= dp[t][0])%=MOD;
  }
}

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

  int n; cin>>n;
  for (int i = 0; i < n-1; i++) {
    int x,y; cin>>x>>y; x--; y--;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }

  dfs(0);
  cout << (dp[0][0]+dp[0][1])%MOD << endl;

  return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int ans = max({a + b, 2 * a - 1, 2 * b - 1});
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int calc(int x) {
  int r = 0;
  while (x) {
    r += x % 10;
    x /= 10;
  }
  return r;
}

int main() {  
  int n;
  scanf("%d", &n);
  int ans = 1e9;
  for (int a = 1; n-a >= 1; ++a) {
    int b = n-a;
    ans = min(calc(a) + calc(b), ans);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
const int N=100000;
int n;
char s[N+3];
int pw[N+1];
int dp[N+2][13];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	pw[0]=1;
	for(int i=1;i<=n;i++)pw[i]=pw[i-1]*10%13;
	dp[n+1][0]=1;
	for(int i=n;i;i--)for(int j=0;j<13;j++)
		if(s[i]=='?')for(int k=0;k<=9;k++)(dp[i][j]+=dp[i+1][(j-k*pw[n-i]+1300000)%13])%=mod;
		else dp[i][j]=dp[i+1][(j-(s[i]^48)*pw[n-i]+1300000)%13];
	printf("%d",dp[1][5]);
	return 0;
}
/*1
??2??5
*/
/*2
?44
*/
/*3
7?4
*/
/*4
?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???
*/

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+n;
		if(a[i]>90){
			a[i]=a[i]-26;
		}
		printf("%c",a[i]);
	}
	return 0;
}

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

int main() {
    
    int n; cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 0; i < n - 1; i++) {
        int time = 0;
        time += s[i];
        time += c[i];
        for (int j = i + 1; j < n - 1; j++) {
            if (s[j] < time) {
                if (time % f[j] != 0) {
                    int diff = time % f[j];
                    time += f[j] - diff;
                }
            }
            else { // time <= s[j]
                time = s[j];
            }        
            time += c[j];
        }
        cout << time << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3520
import java.util.Scanner;

public class Main {
  static final long M = 998244353L;

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

    int N = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    long K = scanner.nextLong();

    System.out.println(solve(N, A, B, K));
  }

  private static long solve(int N, long A, long B, long K) {
    if (A > B) return solve(N, B, A, K);

    long[] C = chooseForN(N, M);

    long res = 0;
    for (int i = 0; i <= Math.min(N, K / B); i++) {
      if ((K - B * i) % A == 0) {
        long j = (K - B * i) / A;
        if (j > N) continue;
        res += C[i] * C[(int) j] % M;
        res %= M;
      }
    }
    return res;
  }

  private static long[] chooseForN(int n, long mod) {
    long[] C = new long[n + 1];
    long[] fact = new long[n + 1];
    long[] factinv = new long[n + 1];

    fact[0] = 1;
    for (int i = 0; i < n; i++) fact[i + 1] = fact[i] * (n - i) % mod;
    factinv[0] = 1;
    for (int i = 1; i <= n; i++) factinv[i] = factinv[i - 1] * inverse(i, mod) % mod;

    for (int i = 0; i <= n; i++) C[i] = fact[i] * factinv[i] % mod;

    return C;
  }

  private static long inverse(long a, long mod) {
    return modpow(a, mod - 2, mod);
  }

  private static long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
      if (n % 2 == 1) res = (res * a) % mod;
      a = (a * a) % mod;
      n >>= 1;
    }
    return res % mod;
  }
}


Measured memory_bytes: 30932
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  string s;
  cin>>s;
  
 int n = s.length();
  bool qwq = true;
  if(n%2==0)
    qwq = false;
  int i =0;int j=n-1;
  while(i<=j)
  {
    if(s[i]!=s[j])
    {
      qwq = false;
      break;
    }
    i++;
    j--;
  }
  
   i =0;j = (n-1)/2-1;
  
  while(i<=j)
  {
    if(s[i]!=s[j])
    {
      qwq = false;
      break;
    }
    i++;
    j--;
  }
  i =(n+1)/2; j =n-1;
   while(i<=j)
  {
    if(s[i]!=s[j])
    {
      qwq = false;
      break;
    }
    i++;
    j--;
  }
  if(qwq)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include <cstring>
using namespace std;
 
int main()
{
	char num[1001];

	while(1){
		scanf("%s",num);//%s??????????????¨????????\??????????????¨?????¨???
		if(num[0] == '0') break;
		int s=0;

		for(int i=0;i<strlen(num);i++){//strlen??????????????????????????????????????´??????
			s += num[i] - '0';//??¢????????????????????§num?????????????????°??????????????????s????¶????
		}
		printf("%d\n",s);
	}

    return 0;
}

Measured memory_bytes: 1132
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
from itertools import accumulate #list(accumulate(A))

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            j = 2 * i
            while j <= n:
                is_prime[j] = False
                j += i
    return is_prime 
    #table = [ i for i in range(1, n+1) if is_prime[i-1]]
    #return is_prime, table

Q = ii()
lr = li2(Q)

prime = sieve(10**5)
flag = [0]*(10**5+1)

for i in range(3, 10**5+1, 2):
    if prime[i] and prime[(i+1)//2]:
        flag[i] = 1

flag = list(accumulate(flag))

for i in range(Q):
    print(flag[lr[i][1]] - flag[lr[i][0]-1])

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

#define MAX 2000001
#define VMAX 10000

int main(void)
{
  unsigned short *A, *B;
  
  int C[VMAX+1];
  int n, i, j;
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;i++) C[i] = 0;
  
  for(i=0;i<n;i++) {
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
  
  for(j=1;j<=n;j++) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++) {
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 9644
<?php
  
$nab = explode(' ',trim(fgets(STDIN)));
$n = $nab[0];
$a = $nab[1];
$b = $nab[2];

$sum = 0;
for($i=1; $i<=$n; $i++){
  $s = 0;
  $c = $i;
  $c = strval($c);
  for($j=0; $j<strlen($c); $j++){
    $s += $c[$j];
  }
  if ($a <= $s && $s <= $b){
    $sum += $i;
  }
}

echo $sum;
  
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    rep(i,s.size()){
        if(s[i]=='1'){
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main() {
  
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A+B>C+D) {
    cout << "Left" << endl;
  }
  
  else if (A+B<C+D) {
    cout << "Right" <<endl;
  }
  
  else {
    cout << "Balanced" << endl;
  }
  
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int k = 0;

  if((a - b) % 2 ==  0){
    k = (a + b ) / 2;
    cout << k << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	a := ReadInts(N)
	mean := float64(Sum(a...)) / float64(N)
	b := make([]float64, N)
	for i := 0; i < N; i++ {
		b[i] = Abs(float64(a[i]) - mean)
	}
	best := Min(b...)
	for i := 0; i < N; i++ {
		if Abs(float64(a[i])-mean) == best {
			fmt.Println(i)
			return
		}
	}
}

func Min(xs ...float64) float64 {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

func Abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const x = Number(inputs[0]);
  let deposit = 100;
  let year = 0;

  while (deposit < x) {
    deposit += Math.floor(deposit / 100);
    year++;
  }

  console.log(year);
}


Measured memory_bytes: 30032
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 * 026?????? 30??????OK???3/20
 * @author kentaro.maeda
 *
 */
public class Main {	

	// ??§?¨?
	private static class Point{
		public final int x;
		public final int y;
		public Point(int x, int y) {
			this.x=x;
			this.y=y;
		}
	}
	// ??§?¨?????????????????????£????????£
	private static Point p(int x, int y){
		return new Point(x, y);
	}
	
	// ???????????\??????????????????????????????
	private static final Map<Integer, List<Point>> INC = new HashMap<Integer, List<Point>>();
	static{
		List<Point> small = Arrays.asList(p(0,0),p(-1, 0), p(1, 0), p(0, -1), p(0 ,1));//?°????????????????????????????
		List<Point> middle = new ArrayList<Point>(small); // ??\???????????????????????????????????¨???????????????
		middle.addAll(Arrays.asList(p(-1,-1), p(-1, 1), p(1, -1), p(1,1))); //????????????
		List<Point> big = new ArrayList<Point>(middle);
		big.addAll(Arrays.asList(p(2,0), p(-2,0), p(0,2), p(0,-2))); //??§?????????
		
		INC.put(1, small); 
		INC.put(2, middle); 
		INC.put(3, big);
	};
	
	public static void main(String[] args) throws Exception{
		
		int[][] paper = new int[10][10];
		
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNext()) {
			
			String line = scan.nextLine();
			String[] in = line.split(",");
			paint(paper, Integer.parseInt(in[0]), Integer.parseInt(in[1]), Integer.parseInt(in[2]));
		}
		scan.close();
		
		// ????¨????????§?
		int whiteCells = 0; //?????????????????°
		int max = 0; // ???????????????
		
		for (int[] row : paper) {
			for(int cell : row) {
				//?±????????????????????¨?
				if (cell == 0) {
					whiteCells++;
				}
				// ?????§????????´??°
				if (max < cell) {
					max = cell;
				}
			}
		}
		System.out.println(whiteCells);
		System.out.println(max);
	}
	// ?????????????´????????????????
	private static void paint(int[][] paper, int x, int y, int size) {
		int xLen = paper[0].length;
		int yLen = paper.length;
		// INC????????????????????¨??????????????????????????????????????????????????????????????§????§????????????????????????????????????°OK???
		for (Point p : INC.get(size)) {
			if (inPaper(p.x + x, xLen) && inPaper(p.y + y, yLen)){
				paper[p.x + x][p.y + y]++;
			}
		}
		
	}
	// ?´???????????????????
	private static boolean inPaper(int n, int len) {
		return 0 <= n && n < len;
	}
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N;
    cin >> N;
    vector<int> A(40, 0);
    for (int i = 0; i < 40; i++) {
        if(N == 0){
            break;
        }
        A[i] = abs(N) % 2;
        if(i % 2 == 0){
            N -= A[i];
        }
        else{
            N += A[i];
        }
        N = N / 2;
    }
    int m = 0;
    for (int i = 0; i < 40; i++) {
        if(A[i] != 0){
            m = i;
        }
    }
    for (int i = m; i >= 0; i--) {
        printf("%d", A[i]);
    }
    printf("\n");
}

Measured memory_bytes: 3688
import sys
from functools import cmp_to_key

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

mod = 1000000007
n = ni()
co = []
z = 0
for i in range(n):
    x = na()
    if x[0] == 0 and x[1] == 0:
        z += 1
    else:
        co.append(x)
n = len(co)

for c in co:
    if c[1] < 0 or c[1] == 0 and c[0] < 0:
        c[1] = -c[1]
        c[0] = -c[0]

mod = 1000000007
ans = 1

co.sort(key=cmp_to_key(lambda x,y: -(x[0]*y[1]-y[0]*x[1])))

p = 0
while p < n and co[p][0] > 0:
    p += 1

col = []
i = 0
rem = n
while i < n:
    if co[i][0] <= 0:
        break
    while p < n and co[i][0]*co[p][0]+co[i][1]*co[p][1] > 0:
        p += 1

    op = p
    while p < n and co[i][0]*co[p][0]+co[i][1]*co[p][1] == 0:
        p += 1

    oi = i
    while i < n and co[i][0]*co[oi][1]-co[i][1]*co[oi][0] == 0:
        i += 1

    if p-op > 0:
        ans = ans * (pow(2, i-oi, mod) + pow(2, p-op, mod) - 1) % mod
        rem -= (p-op) + (i-oi)

ans = ans * pow(2, rem, mod) % mod
print((ans+z+mod-1)%mod)


Measured memory_bytes: 122488
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
string s;
int f,q,t,ltr;
string c;
string ff,bb;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	cin>>q;
	ltr=1;
	while(q--){
		cin>>t;
		if(t==1){
			ltr=1-ltr;
		}
		else{
			cin>>f>>c;
			if(f==1&&ltr==1)
				ff+=c;
			if(f==1&&ltr==0)
				bb+=c;
			if(f==2&&ltr==1)
				bb+=c;
			if(f==2&&ltr==0)
				ff+=c;
		}
	}
	reverse(ff.begin(),ff.end());
	s=ff+s+bb;
	if(ltr==0)
		reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include<iomanip>
#include <vector>
#include <math.h>
using namespace std;

typedef long long ll;

int main(void){
    cout<<fixed<<setprecision(15);
    long double a,b,x;
    cin >> a >> b >> x;
    long double preans = 2*(b*a*a - x)/(a*a*a);
    if(x/a<a*b/2)preans = 0.5*b*b*a/x;
    long double ans = atan(preans) / M_PI * 180;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n, Q;
    cin >> n >> Q;
    int block_len = sqrt(n);
    vector<int> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    vector<pair<pair<int,int>, int>> query(Q);
    for(int i = 0; i < Q; ++i){
        int x, y;
        cin >> x >> y;
        x--; y--;
        query[i] = {{x, y}, i};
    }
    sort(query.begin(), query.end(), [&block_len](const pair<pair<int,int>, int> lhs, const pair<pair<int,int>, int> rhs)->bool{
            if(lhs.first.first / block_len != rhs.first.first / block_len){
                return lhs.first.first < rhs.first.first;
            }
            return lhs.first.second < rhs.first.second;
            });


    const int N = 5e5 + 10;
    vector<int> cnt(N, 0);
    int current = 0;
    auto remove = [&cnt, &arr, &current](int pos){
        cnt[arr[pos]]--;
        if(cnt[arr[pos]] == 0){
            current--;
        }
    };
    auto add = [&cnt, &arr, &current](int pos){
        cnt[arr[pos]]++;
        if(cnt[arr[pos]] == 1){
            current++;
        }
    };
    int l = 0;
    int r = -1;
    vector<int> ans(Q);
    for(int i = 0; i < Q; ++i){
        int x = query[i].first.first;
        int y = query[i].first.second;
        while(l < x){
            remove(l);
            l++;
        }
        while(l > x){
            l--;
            add(l);
        }
        while(r < y){
            r++;
            add(r);
        }
        while(r > y){
            remove(r);
            r--;
        }
        ans[query[i].second] = current;
    }
    for(auto i : ans){
        cout << i << endl;
    }
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 15488
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> istream& operator>>(istream& is, vector<T>& v);
template<class T> ostream& operator<<(ostream& os, vector<T> const& v);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream&, const tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream& os, const tuple<T...>& t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream& operator<<(ostream& os, const tuple<T...>& t){ _ot<0>(os, t); return os; }
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream&, tuple<T...>&){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream& is, tuple<T...>& t){ is >> get<n>(t); _it<n+1>(is, t); }
template<class...T> istream& operator>>(istream& is, tuple<T...>& t){ _it<0>(is, t); return is; }
template<class T> istream& operator>>(istream& is, vector<T>& v){ rep(i,v.size()) is >> v[i]; return is; }
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif


string ans[1<<20];
char s[32];
char t[32];

int main(){
#ifdef LOCAL
    freopen("in","r",stdin);
#endif
    while(cin >> s && s[0]!='#'){
        int sz = 0;
        int n = strlen(s);
        rep(i,n) t[i] = s[i];
        t[n] = 0;
        int change[32];
        rep(mask,1<<n){
            bool ok = true;
            rep(i,n){
                ok &= s[i]!='z' || ~mask>>i&1;
            }
            if(!ok) continue;
            rep(i,n){
                t[i] = s[i] + (mask>>i & 1);
            }
            rep(i,26){
                change[i] = 30;
            }
            rep(i,n){
                change[t[n-i-1]-'a'] = n-i-1;
            }
            change[0] = 30;
            rep(i,26){
                t[change[i]]--;
            }
            if(strcmp(t,s)==0){
                rep(i,n){
                    t[i] = s[i] + (mask>>i&1);
                }
                ans[sz++] = t;
            }
        }
        sort(ans, ans + sz);
        printf("%d\n",sz);
        if(sz > 10){
            rep(i,5) printf("%s\n", ans[i].c_str());
            rep(i,5) printf("%s\n", ans[sz-5+i].c_str());
        } else {
            rep(i,sz){
                printf("%s\n",ans[i].c_str());
            }
        }
    }
}

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

using namespace std;

int main() {
    int n, ans;

    scanf("%d", &n);

    if(n < 105) ans = 0;    // 3 * 5 * 7
    else if(n < 135) ans = 1;   // 3^3 * 5
    else if(n < 165) ans = 2;   // 3 * 5 * 11
    else if(n < 189) ans = 3;   // 3^3 * 7
    else if(n < 195) ans = 4;   // 3 * 5 * 13
    else ans = 5;

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

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var aa = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var a=aa[0]
    var b=aa[1]

    if(a<b)
    {
        for(i in 1..b)
            print(a)
    }
    else
    {
        for(i in 1..a)
            print(b)
    }
}

Measured memory_bytes: 36088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pa = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl P(N), Q(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];

    ll a, b, now = 0;
    vl v(N);
    rep(i, N) v[i] = i + 1;
    do {
        if (P == v)
            a = now;
        if (Q == v)
            b = now;
        now++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int minheight = -1;
        long out = 0;
        
        
        for(int i =0; i<n; i++) {
          int height = sc.nextInt();
          if(minheight == -1) {
            minheight = height;
          }
          else {
            if(height < minheight) {
              out += (minheight-height);
            }
            if(height > minheight) {
              minheight = height;
            }
          }
        }
        
        System.out.println(out);
        
    }
}

Measured memory_bytes: 58148
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define MAX (1000*1000)

int memo[2][200];

int main(){
  int n,m;
  while(scanf("%d%d",&n,&m), n+m){
    int sea[n][n], land[n][n];
    REP(i,n) REP(j,n) sea[i][j] = land[i][j] = (i==j ? 0 : MAX);
    
    REP(i,m){
      int a,b,t;
      char c;
      scanf("%d%d%d %c",&a,&b,&t,&c); a--; b--;
      if(c == 'L') land[a][b] = land[b][a] = t;
      else         sea[a][b]  = sea[b][a]  = t;
    }

    REP(k,n) REP(i,n) REP(j,n)
      if(land[i][k] + land[k][j] < land[i][j])
	land[i][j] = land[i][k] + land[k][j];
    REP(k,n) REP(i,n) REP(j,n)
      if(sea[i][k] + sea[k][j] < sea[i][j])
	sea[i][j] = sea[i][k] + sea[k][j];

    /*
    puts("land:");
    REP(i,n){REP(j,n)printf("%9d",land[i][j]);puts("");}
    puts("sea:");
    REP(i,n){REP(j,n)printf("%9d",sea[i][j]);puts("");}
    */

    int r; scanf("%d",&r);
    int z[r];
    REP(i,r){scanf("%d",&z[i]); z[i]--;}
    if(r == 1){
      printf("0\n");
      continue;
    }

    REP(i,n) memo[0][i] = min(MAX, sea[z[0]][i] + land[i][z[1]]);

    for(int i=1; i<r-1; i++){
      int *dist = memo[i%2];
      int *src  = memo[(i+1)%2];
      //printf("dist = %d, src = %d z[i]=%d, z[i+1]=%d\n",i%2,(i+1)%2,z[i],z[i+1]);
      //REP(j,n) printf("%9d",src[j]); 
      REP(j,n) dist[j] = min(MAX, src[j] + land[z[i]][z[i+1]]);
      REP(j,n) REP(k,n) dist[j] = min(dist[j], src[k] + land[z[i]][k] + sea[k][j] + land[j][z[i+1]]);
      //printf(" => ");
      //REP(j,n) printf("%9d",dist[j]); puts("");
    }
    int ans = INT_MAX;
    REP(i,n) ans = min(ans, memo[(r-2)%2][i]);
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if((a==5&&b==7&&c==5)|(a==7&&b==5&&c==5)|(a==5&&b==5&&c==7))cout<<"YES";
    else cout <<"NO";
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, raw_input().split())
from math import log, ceil
possibility = 0
ook = 1.0 / n
for d in range(1, n+1):
    if d >= k:
        exponent = 0
    else:
        exponent = int(ceil(log(float(k)/d, 2)))
    #print ook, exponent
    possibility += ook * (0.5)**exponent
print possibility

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

n, k = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
l = 32
bk = format(k, "b").zfill(l)
B = [k]
nk = 0
for i in range(l):
    if bk[i] == "1":
        nk += 2**(l-1-i)
        B.append(nk - 1)

# for i in range(len(B)):
#     print(format(B[i], "b").zfill(l))

ans0 = 0
for i in range(len(B)):
    ans = 0
    for j in range(n):
        if B[i] | A[j][0] == B[i]:
            ans += A[j][1]
    ans0 = max(ans0, ans)
print(ans0)

Measured memory_bytes: 56668
//?????????????????????????????????????????????????????????

#include<iostream>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;

int main(){
	int E;
	int Y;
	
	cin >> E >> Y;
	//??´???????\????
	if (E == 1)//??????
	{
		cout << 1868 + Y - 1 << endl;
	}
	else if (E == 2 )//??§??£
	{
		cout << 1912 + Y - 1 << endl;
	}
	else if (E == 3 )//??????
	{
		cout << 1926 + Y - 1 << endl;
	}
	else if (E == 4)//??????
	{
		cout << 1989 + Y - 1 << endl;
	}
	
	//?\?????????´???

	if (E==0){
		if (1867 < Y && Y < 1912)//??????
		{
			cout << "M" << Y - 1867 << endl;
		}
		else if (1911 < Y && Y < 1926)//??§??£
		{
			cout << "T" << Y - 1911 << endl;
		}
		else if (1925 < Y && Y < 1989)//??????
		{
			cout << "S" << Y - 1925 << endl;
		}
		else if (1988 < Y && Y < 2017)//??????
		{
			cout << "H" << Y - 1988 << endl;
		}
	}
		return 0;
}

Measured memory_bytes: 3100
N = int(input())
W = list(map(int,input().split()))

S=0

for i in range(N):
	S = S + W[i]

Sa = 0
Sb = 0
r = S
for i in range(N):
	Sa = Sa + W[i]
	Sb = S-Sa
	r = min(abs(Sa-Sb),r)

print(r)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
int isprime(ll a,vector<ll> &vec){
    if(a==2){
        vec.push_back(a);
        return 1;
    }
    else if(a%2==0)return 0;
    else{
        rep(i,vec.size()){
            if(a%vec.at(i)==0)return 0;
        }
    }
    vec.push_back(a);
    return 1;
}

int main(){
    ll a, b, ans=1;
    cin >> a >> b;
    if(a>b)swap(a,b);
    vector<ll> vec(0),codiv(0);
    rep(i,sqrt(a)-1){
        if(a%(i+1)==0){
            vec.push_back(i+1);
            if((i+1)*(i+1)!=a)vec.push_back(a/(i+1));
        }
    }
    sort(vec.begin(),vec.end());
    rep(i,vec.size()){
        if(((b%vec.at(i))==0)&&(vec.at(i)>1))codiv.push_back(vec.at(i));
    }
    ll n=codiv.size();
    vector<ll> num(0);
    rep(i,n){
        if(isprime(codiv.at(i),num))ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))

using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n);
vector<int> split(int n,int a);
string xal_number(int n,int x);
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
class Factorial{
private:
	vector<int> fac;
public:
	Factorial(int N){
		fac.push_back(1);
		rep(i,N) fac.push_back(fac[i]*(i+1)%mod);
	}
	int fact(int a){return fac[a];}
	int ifac(int a){return m_inv(fac[a]);}
	int cmb(int n,int r);
};
struct UnionFind {
    vector<int> par; // 親ノード
    UnionFind(int n = 1) { init(n);}
    void init(int n = 1) {
        par.resize(n);
        rep(i,n) par[i] = -1;
    }
    int root(int x) {
        if (par[x] <0) return x;
        else return par[x] = root(par[x]);      
    }
    int size(int x){ return -par[root(x)];}
    bool issame(int x, int y) {return root(x)==root(y);}
    bool connect(int x, int y);
};

signed main(){
	int n;
	cin>>n;
	set<int> st;
	int ans=0;
	rep(i,n){ 
		int s;
		cin>>s;
		if(s%10!=0) st.insert(s);
		ans+=s;
	}
	while(ans%10==0&&!st.empty()){
		ans-=*st.begin();
	}
	cout<<((ans%10)?ans:0)<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>
#define MAX 1000000007

using namespace std;
using namespace __gnu_pbds;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n,k,x;
  cin>>k>>x;
  long long int lo = x - k + 1;
  long long int hi = x + k - 1;
  for(long long int i = lo;i<=hi;i++){
    cout<<i<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll n,m,d;
int main()
{
    scanf("%lld%lld%lld",&n,&m,&d);
    double ans=0,len;
    len=1.0*(n-d)/n/n;
    if(d!=0)
        len*=2;
    ans+=len*(m-1);
    printf("%.10lf\n",ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>

using namespace std;
long long int kaizyou[200005] = { 1 };
long long int kai(long long int a, long long int b, long long int mod) {
	long long int tmp = 1;
	for (long long int i = a; i <= b; i++) {
		tmp *= i;
		tmp %= mod;

		kaizyou[i] = tmp;
	}
	return tmp;
}

int main() {
	int n, s[200] = {}, num[200] = {}, result = 0, lamp = 1, in, ax, h, w, m, a, b, c, d, r, tmp;
	string str ,str2;
	cin >>a;
	kai(1, 100005, 1000000007);
	cout << kaizyou[a];
	
	

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll n,arr[10005];


int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    int cnt=0;
    sort(arr,arr+n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                ll a=arr[i],b=arr[j],c=arr[k];
                if(a!=b&&b!=c&&c!=a){

                    if ((a+b)>c){
                            cnt++;
                        }
                    }
                }
            }
        }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3568
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)

max_num = 0
result = "Yes"
n.times do |index|
  if index == 0
    max_num = h[index]
    next
  end

  if max_num - 1 <= h[index]
    max_num = [max_num, h[index]].max
  else
    result = "No"
    break
  end
end

puts result

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

int main()
{
    int N, ans;
    long K;
    vector<pair<int, long>> a(100005);
    cin >> N >> K;
    REP(i, N)
        cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.begin() + N);
    REP(i, N){
        if(K <= a[i].second){
            ans = a[i].first;
            break;
        }else
            K -= a[i].second;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1792
import java.util.*;
import java.util.Arrays;

public class Main {
    class Node {
        int id, parent = -1, depth = -1, height = -1, bro = -1;
        int left = -1, right = -1, deg = 0;
        String nodeType = null;
        Node(int id, int left, int right) {
            this.id = id;
            this.left = left;
            this.right = right;
            if (left != -1) deg++;
            if (right != -1) deg++;
        }
    }

    int findRoot(boolean[] rs) {
        for (int i = 0; i < rs.length; i++) {
            if (!rs[i]) return i;
        }
        System.out.println("could not find root.");
        return -1;
    }

    void preorder(Node[] nodes, int x) {
        System.out.print(" " + x);
        if (nodes[x].left != -1)
            preorder(nodes, nodes[x].left);
        if (nodes[x].right != -1)
            preorder(nodes, nodes[x].right);
    }
    void inorder(Node[] nodes, int x) {
        if (nodes[x].left != -1)
            inorder(nodes, nodes[x].left);
        System.out.print(" " + x);
        if (nodes[x].right != -1)
            inorder(nodes, nodes[x].right);
    }
void postorder(Node[] nodes, int x) {
        if (nodes[x].left != -1)
            postorder(nodes, nodes[x].left);
        if (nodes[x].right != -1)
            postorder(nodes, nodes[x].right);
        System.out.print(" " + x);
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node[] nodes = new Node[n];
        boolean[] couldNotRoot = new boolean[n];
        for (int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int left = sc.nextInt();
            int right = sc.nextInt();
            nodes[id] = new Node(id, left, right);
            if (left != -1) couldNotRoot[left] = true;
            if (right != -1) couldNotRoot[right] = true;
        }
        int root = findRoot(couldNotRoot);
        System.out.println("Preorder");
        preorder(nodes, root);
        System.out.println("\nInorder");
        inorder(nodes, root);
        System.out.println("\nPostorder");
        postorder(nodes, root);
        System.out.println();
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 26336
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn absolute(x: i32) -> i32 {
    if x >= 0 {
        x
    } else {
        -x
    }
}

use std::cmp;

#[allow(dead_code)]
fn find_min(x: &Vec<i32>) -> i32 {
    let mut min: i32 = x[0];
    let mut x_iter = x.iter();
    while let Some(i) = x_iter.next() {
        min = cmp::min(*i, min);
    }
    return min;
}

fn main() {
    let init: Vec<i32> = read_vec();
    let mut l: Vec<i32> = Vec::new();

    for _i in 0..init[0] {
        let tmp: i32 = read();
        l.push(tmp);
    }

    fn mp(n: i32, a: i32, b: i32, c: i32, params: &Vec<i32>, length: &Vec<i32>) -> i32 {
        if n == params[0] {
            if a * b * c > 0 {
                absolute(a - params[1]) + absolute(b - params[2]) + absolute(c - params[3]) - 30
            } else {
                std::i32::MAX - 10
            }
        } else {
            let mut cost: Vec<i32> = vec![0, 0, 0, 0];
            cost[0] = mp(n + 1, a, b, c, params, length);
            cost[1] = mp(n + 1, a + length[n as usize], b, c, params, length) + 10;
            cost[2] = mp(n + 1, a, b + length[n as usize], c, params, length) + 10;
            cost[3] = mp(n + 1, a, b, c + length[n as usize], params, length) + 10;
            let ans = cmp::min(cost[3], cmp::min(cost[2], cmp::min(cost[0], cost[1])));
            ans
        }
    }

    println!("{}", mp(0, 0, 0, 0, &init, &l));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin>>a>>b>>c;
    if((a==b || b==c || c==a) && (!(a==b && b==c && c==a))) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256