akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
 
#define N 100000
 
 
 
main(){
 
int n, q;
int S[N], T;
int i, j;
int k=0, count=0;
int left, right, mid;
 
 
scanf("%d",&n);
 
for(i = 0; i < n; i++){
scanf("%d",&S[i]);
}
 
scanf("%d",&q);
 
for(j = 0; j < q; j++){
scanf("%d",&T);
 left = 0;
 right = n;
 
while(left < right){
mid = (left+right)/2;
 
 if(T==S[mid]){
   count++;
   break;
 }
 
 if(T > S[mid]){
   left = mid +1;
 }
 
 else if(T < S[mid]){
    right = mid;
 }
}
 }
printf("%d\n",count);
return 0;
}

Measured memory_bytes: 988
package main

import "fmt"

func countDigits(n int) int {
	digits := 0

	for n > 0 {
		n /= 10
		digits++
	}

	return digits
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var N int
	fmt.Scan(&N)

	ans := countDigits(N)

	for a := 1; a * a <= N; a++ {
		if N % a != 0 {
			continue
		}

		b := N / a

		cur := max(countDigits(a), countDigits(b))

		if ans > cur {
			ans = cur
		}
	}

	fmt.Println(ans)
}



Measured memory_bytes: 512
{-# LANGUAGE TypeApplications #-}

getIntList = map (read @Double) . words <$> getLine

main :: IO ()
main = do
  [a, b, c, d] <- getIntList
  let n1 = ceiling (c / b)
  let n2 = ceiling (a / d)
  putStrLn $ if n1 > n2 then "No" else "Yes"


Measured memory_bytes: 3916
#include <bits/stdc++.h>
 
typedef long long ll;

using namespace std;
using Graph = vector<vector<int>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

const double PI=3.14159265358979323846; // or M_PI


void Main() {
    ll x, n, m=1000, s=1000, flag=0;
    cin >> x >> n;
    vector<ll> p(n);
    vector<ll> kouho(n);

    REP(i, n) {
        cin >> p[i];
    }

    FOR(i, -300, 300) {
        REP(j, n) {
            if (i == p[j]) {
                flag = 1;
                break;
            }
        }
        if (flag == 1) {
            flag = 0;
            continue;
        }

        if (abs(x - i) < m) {
            s = i;
            m = abs(x - i);
            // COUT(s);
        }
        else if (abs(x - i) == m) {
            if (i< s) {
                s = i;
            }
        } 
    }

    COUT(s);

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int MAXN = 2e5 + 2;
const ll INF = 1e9 + 1;
const ld pi = acos(-1);
const int dx[4] = {-1, -1, 1, 1};
const int dy[4] = {-1, 1, -1, 1};

ll n, a[MAXN], l[MAXN], r[MAXN], ans;
stack<ll> s;

int main(){
 
    faster();

    cin >> n;

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

    a[0] = a[n + 1] = -INF;

    s.push(0);
    for(int i = 1; i <= n; ++i){
        while(a[s.top()] > a[i])
            s.pop();
        l[i] = s.top() + 1;
        s.push(i);
    }
    while(!s.empty())
        s.pop();

    s.push(n + 1);
    for(int i = n; i >= 1; --i){
        while(a[s.top()] > a[i])
            s.pop();
        r[i] = s.top() - 1;
        s.push(i);
    }
    while(!s.empty())
        s.pop();

    for(int i = 1; i <= n; ++i){
        ans += (i - l[i] + 1) * (r[i] - i + 1) * a[i];
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
	int a, b;
	cin >> a;
	cin >> b;
	int d = a / b;
	int r = a % b;
	double f = 1.0L * a / b;
	cout << d << " " << r << " ";
	printf("%.5lf\n", f);
	return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>

using namespace std;

int S[100000], n;

int binarySearch(int key) {
    /*
    if(left <= right) {
        int mid = (right+left+1) / 2;
        if(key == A[mid]) return key;
        if(key < A[mid]) return binarySearch(left, mid-1, key, A);
        if(key > A[mid]) return binarySearch(mid+1, right, key, A);
    }
    else

        return -1;
    */

    int mid;
    int left = 0, right = n-1;
    while(left <= right) {
       mid = (right+left+1) / 2;
       if(key == S[mid]) return 1;
       if(key > S[mid]) left = mid + 1;
       else if(key < S[mid]) right = mid-1;
    }
    return 0;


}

int main()
{
    int result = 0, q, key;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }

    scanf("%d",&q);
    for(int i = 0; i < q; i++) {
        scanf("%d", &key);
        if(binarySearch(key)) result++;
    }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= String.valueOf(N).length(); i++) {
            ans += N % (int) Math.pow(10, i) / (int) Math.pow(10, i - 1);
        }
        if (N % ans == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21332
from collections import Counter
N = input()
def rec(list1,initial,time):
    empty = []
    for e in list1:
        for b in [0,1,2]:
            if b == 0:
                e_copy = e + "3"
                empty.append(e_copy)
            elif b == 1:
                e_copy = e + "5"
                empty.append(e_copy)
            elif b == 2:
                e_copy = e + "7"
                empty.append(e_copy)
    list1 = empty[:]
    # initial + 1 がn回目のループ
    if initial + 1 >= time :
        return list1
    else:
        return rec(list1,initial + 1, time)
l1 = [""]
result = [""]
for i in range(1,len(N)+1):
    result += rec(l1,0,i)
result = [int(e) for e in result if e.count("3")*e.count("5")*e.count("7") >= 1]
#result = list(set(result))
count = 0
for e in result:
    if int(N) < e:
        break
    count += 1
print(count)

Measured memory_bytes: 6508
#[allow(non_snake_case)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
 
fn main() {
    input!(
        a: usize,
        b: usize,
    );
    println!("{}", 6/a/b);
}

Measured memory_bytes: 4352
N, M = map(int, input().split())
a = [0] * M
b = [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())

check = [[] for _ in range(N+1)]

for i in range(M):
    check[a[i]].append(b[i])
    check[b[i]].append(a[i])


a = 0

for i in range(N+1):
    if 1 in check[i] and N in check[i]:
        print('POSSIBLE')
        a = 1
        break

if a == 0:
    print('IMPOSSIBLE')




Measured memory_bytes: 41520
N = int(input())
ABC = [list(map(int,input().split())) for _ in range(N)]
dp = [[0] * 3 for _ in range(N+1)]
#print(dp)
for i in range(1,N+1):
  for j in range(3):
    dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) + ABC[i-1][j]
print(max(dp[-1]))

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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 1e(18)
#define MOD 1000000007
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int main()
{

    _fastIO;

    ll n, x, mn=LONG_LONG_MAX,cnt=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>x;
        mn=min(x,mn);
        if(x<=mn)cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN
    
    ll n,m,c;cin>>n>>m>>c;
    c *= -1;
    vll b(m); REP(i,m) cin>>b[i];
    vll a(m);
    ll ans=0;
    REP(i,n){
        REP(j,m) cin>>a[j];
        ll sm=0;
        REP(j,m) sm+=a[j]*b[j];
        if (sm>c) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 

int main(void) {
  int n;cin>>n;
  vector<pair<string, int>> st(n);
  int sum = 0;
  fr(i,n) {
    cin>>st[i].first>>st[i].second;
    sum += st[i].second;
  }
  string x;cin>>x;
  int temp = 0;
  fr(i,n) {
    temp += st[i].second;
    if(x == st[i].first) break;
  }
 
  
 cout << sum - temp << endl;
  return 0;
}

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

int main() {
  
  int h[5];
  int ans = 0, m = 10;
  REP(i,5) {
    cin >> h[i];
    int c = h[i] % 10;
    if (c != 0) m = min(m,c);
    ans += (h[i] + 9) / 10 * 10;
  }
  
  if (m != 10) ans = ans + m - 10;  
  
  cout << ans << endl;
  
}

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

int main(void){
    int n; cin >> n;
    set<string> s;
    for(int i = 0; i < n; i++){
        string input; cin >> input;
        s.insert(input);
    }

    int m; cin >> m;
    int t = 0;
    for(int i = 0; i < m; i++){
        string input; cin >> input;
        if(s.find(input) != s.end()){
            if(t % 2 == 0) cout << "Opened by " << input << endl;
            else cout << "Closed by " << input << endl;
            t++;
        }else{
            cout << "Unknown " << input << endl;
        }
    }

    return 0;
}

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

int main() {
	char c[2][3];
	for (int i = 0; i < 2; ++i)
		for (int j = 0; j < 3; ++j)
			cin >> c[i][j];
	if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0])
		cout << "YES";
	else
		cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    string s;
    cin>>s;
    ll r1[n]{0},g1[n]{0},b1[n]{0};
    ll r2[n]{0},g2[n]{0},b2[n]{0};
    for(ll i=1;i<n;i++)
    {
      r1[i]=r1[i-1];
      g1[i]=g1[i-1];
      b1[i]=b1[i-1];
        if(s[i-1]=='R')
            r1[i]++;
        else if(s[i-1]=='G')
            g1[i]++;
        else
            b1[i]++;
    }
    for(ll i=n-2;i>=0;i--)
    {
      r2[i]=r2[i+1];
      g2[i]=g2[i+1];
      b2[i]=b2[i+1];
        if(s[i+1]=='R')
            r2[i]++;
        else if(s[i+1]=='G')
            g2[i]++;
        else
            b2[i]++;
    }
    /*for(ll i=0;i<n;i++)
    {
      cout<<r1[i]<<" "<<g1[i]<<" "<<b1[i]<<endl;
      cout<<r2[i]<<" "<<g2[i]<<" "<<b2[i]<<endl;
    }*/
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            sum += g1[i]*b2[i];
            sum += g2[i]*b1[i];
        }
        else if(s[i]=='G')
        {
            sum += r1[i]*b2[i];
            sum += r2[i]*b1[i];
        }
        else
        {
            sum += r1[i]*g2[i];
            sum += r2[i]*g1[i];
        }
        ll j = i-1,k=i+1;
        while(1)
        {
            if(j<0||k>=n)
                break;
            else if(s[j]!=s[i]&&s[k]!=s[i]&&s[j]!=s[k])
                sum--;
            j--;
            k++;
        }
    }
    cout<<sum;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int n,m,R;
long long land[300][300],water[300][300],dp[1005][300];
int a[1005];
long long min(long long a, long long b)
{
    if (a < b) return a;
    else return b;
}
void pre(){
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++){
          land[i][j]=land[j][i]=inf;
          water[i][j]=water[j][i]=inf;
        }
    for(int i=1;i<=n;i++)
         land[i][i]=0,water[i][i]=0;
}

void floyd(){
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++){
                if(k==i||k==j||i==j) continue;
                water[i][j]=min(water[i][j],water[i][k]+water[k][j]);
                land[i][j]=min(land[i][j],land[i][k]+land[k][j]);
            }
}

int main(){
    while(1){
     scanf("%d%d",&n,&m);
     if(n==0&&m==0) break;
     pre();
     for(int i=1;i<=m;i++){
         int l,r; string str;
         long long w;
         scanf("%d%d%lld",&l,&r,&w);
         cin>>str;
         if(str=="L") land[l][r]=land[r][l]=min(land[r][l],w);
         else water[l][r]=water[r][l]=min(water[r][l],w);
    }
    floyd();
    scanf("%d",&R);
    for(int i=1;i<=R;i++)
        for(int j=1;j<=n;j++)
          dp[i][j]=inf;
    for(int i=1;i<=R;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
      dp[1][i]=water[a[1]][i]+land[i][a[1]];//第一次出发可以将船停到任意处再坐船回到当前目标点
    for(int i=2;i<=R;i++)//目的地
     for(int j=1;j<=n;j++)//上一次的下船点
     {
         dp[i][j]=min(dp[i][j],land[a[i-1]][a[i]]+dp[i-1][j]);//走陆地
         for(int k=1;k<=n;k++)//新的下船点
         dp[i][k]=min(dp[i][k],dp[i-1][j]+land[a[i-1]][j]+water[j][k]+land[k][a[i]]);//走水路
     }
         
     long long minn=inf;
     for(int i=1;i<=n;i++)
        minn=min(minn,dp[R][i]);
     printf("%lld\n",minn);
    }
    return 0;
}


Measured memory_bytes: 6508
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define ll long long

int main() {
	string s;
	int ans = 0;
	cin >> s;

	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'o') {
			ans++;
		}
	}
	
	if ((15 - s.size()) + ans >= 8) {
		cout << "YES" << endl;
	}
	else {

		cout << "NO" << endl;
	}


}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6)

def DFS(v, parent):
  for u in adj[v]:
    if u != parent:
      v_count[u] += v_count[v]
      DFS(u,v)

N, Q = map(int, input().split())

adj = [[] for _ in range(N)]
v_count = [0] * N

for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  adj[a].append(b)
  adj[b].append(a)# aがbの親とは限らないため

for j in range(Q):
  p, x = map(int, input().split())
  v_count[p-1] += x

# 0起点に親ノードの数字を子ノードに足していく
DFS(0, -1)# 現在のノード, 親ノード
print(*v_count)


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

bool comp_2nd(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int n, i;
    int a, b;
    cin >> n;
    vector<pair<int, int>> v;
    for(i = 0; i < n; i++){
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end(), comp_2nd);
    int a_sum = 0;
    int flg = 0;
    for(i = 0; i < n; i++){
        a = v[i].first;
        b = v[i].second;
        a_sum += a;
        if(a_sum > b) flg = 1;
    }
    if(flg){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll n, m;
	cin >> n >> m;
	ll x, y, z;
	vvll sum(8, vll(n));
	REP(i, n){
		cin >> x >> y >> z;
		REP(c0, 2){
			REP(c1, 2){
				REP(c2, 2){
					ll t = c0 + 2 * c1 + 4 * c2, xx, yy, zz;
					xx = (c0) ? x : -x;
					yy = (c1) ? y : -y;
					zz = (c2) ? z : -z;
					sum[t][i] = xx + yy + zz;
				}
			}
		}
	}
	ll res = 0;
	REP(i, 8){
		VSORTR(sum[i]);
		ll tmp = 0;
		REP(j, m) tmp += sum[i][j];
		res = max(res, tmp);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
s = list(input())
n = len(s)

st = []
res = 0
for i in range(n):
    if len(st)>0:
        top = st[-1]
        if s[i]!=top:
            res += 2
            st.pop()
        else:
            st.append(s[i])
    else:
        st.append(s[i])
print(res)


Measured memory_bytes: 4648
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
if n == 1:
    print(1)
    sys.exit()
tmp = make_divisors(n)
leng = len(tmp)
ans = 0
if leng%2 == 0:
    ans = max(len(str(tmp[leng//2-1])), len(str(tmp[leng//2])))
else:
    ans = len(str(tmp[leng//2]))
print(ans)

Measured memory_bytes: 77836
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
 int x;
  cin>>x;
  /////
  int ans=0;
  while(ans==0){
    bool ok=true;
    for(int i=2;i<=sqrt(x);i++){
     if( x%i==0) ok=false;
      
    }
    if(ok) ans=x;
    x++;
  }
  cout<<ans<<endl;
}



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

map<int, int> C;

int main() {
 	ios_base::sync_with_stdio(0), cin.tie(0);
 	int N; cin >> N;
 	vector<int> A(N);
 	for (int i = 0; i < N; ++i) cin >> A[i];
	sort(A.begin(), A.end());
	for (auto i : A) ++C[i];
	A.erase(unique(A.begin(), A.end()), A.end());
	if (A.size() > 3) printf("No");
	else if (A.size() == 3) {
		if ((A[0] ^ A[1]) == A[2] && C[A[0]] == C[A[1]] && C[A[1]] == C[A[2]]) printf("Yes");
		else printf("No");
	}
	else {
		if (A[0]) printf("No");
		else {
			if (A.size() == 2 && C[A[0]] * 2 != C[A[1]]) printf("No");
			else printf("Yes");
		}
	}
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int count,count2;
	while(cin>>s){
        count=0;
		count2=0;
		int len=s.size();
		for(int i=0; i<len; i++){
			if(s[i]=='J'&&s[i+1]=='O'&&s[i+2]=='I'){count++;}
		}
		cout << count << endl;
		for(int j=0; j<len; j++){
			if(s[j]=='I'&&s[j+1]=='O'&&s[j+2]=='I'){count2++;}
		}
		cout << count2 << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
# include <iostream>
# include <set>
#include <algorithm>
#include <math.h>
# include<map>
typedef long long ll;
using namespace std;
int main() {
    int n;
    scanf("%d", &n);
    int arr[n];
    for (int i=0; i<n; i++) {
        cin >> arr[i];
    }
    multiset<int> m;
    for (int i=0; i<n; i++) {
        multiset<int> :: iterator it = m.lower_bound(arr[i]);
        if (it == m.begin()) {
            m.insert(arr[i]);
        } else {
            it--;
            m.erase(it);
            m.insert(arr[i]);
        }
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 5376
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}
#line 2 "main.cpp"
int n,a[200010];
int main(){
	std::cin>>n;
	int max=0;
	lint ans=0;
	rep(i,n){
		std::cin>>a[i];
		if(!chmax(max,a[i]))ans+=max-a[i];
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 4400
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,d;
  string s,ss,sss;
  cin>>n>>d;
  vvi X(2222);
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      ll x;cin>>x;
      X[i].pb(x);
    }
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ll sum=0;
      for(int k=0;k<d;k++){
	sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      ll rt=sqrt(sum);
      if(rt*rt==sum)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main() {
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int N,M;

	scanf("%d %d", &N,&M);

	printf("%d", N*M - N - M + 1);
	
}

Measured memory_bytes: 128
N=int(input())
t=[0]*N
x=[0]*N
y=[0]*N
for i in range(N):
  t[i],x[i],y[i]=map(int,input().split())
  
def traveling(t,x,y):
  time_i=0
  x_i=0
  y_i=0
  for i,time in enumerate(t):
    time_i=time-time_i
    x_i=x[i]-x_i
    y_i=y[i]-y_i
    z=x_i+y_i
    if (time_i-z)%2!=0 or z>time_i:
      return "No"
    time_i=time
    x_i=x[i]
    y_i=y[i]
  return "Yes"
    
print("{}".format(traveling(t,x,y)))

Measured memory_bytes: 11732
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	int n;
	cin>>n;
	int odd[n/2],even[n/2];
	rep(i,n/2)cin>>odd[i]>>even[i];
	sort(odd,odd+n/2);
	sort(even,even+n/2);
	int cnt1=1,cnt2=1;
	int work[4][2]={{1,odd[0]},{0,0},{1,even[0]},{0,0}};

	rep(i,n/2-1){
		if(odd[i]!=odd[i+1])cnt1=1;
		else cnt1++;
		if(even[i]!=even[i+1])cnt2=1;
		else cnt2++;
		if(work[0][0] < cnt1){
			if(work[0][1]==odd[i+1])work[0][0]++;
			else{
				work[1][0]=work[0][0];
				work[1][1]=work[0][1];
				work[0][0]=cnt1;
				work[0][1]=odd[i+1];
			} 
		}
		else if(work[1][0] < cnt1){
			work[1][0]=cnt1;
			work[1][1]=odd[i+1];
		}
		if(work[2][0] < cnt2){
			if(work[2][1]==even[i+1])work[2][0]++;
			else{
				work[3][0]=work[2][0];
				work[3][1]=work[2][1];
				work[2][0]=cnt2;
				work[2][1]=even[i+1];
			}
		}
		else if(work[3][0] < cnt2){
			work[3][0]=cnt2;
			work[3][1]=even[i+1];
		}
	}

	//rep(i,4)cout<<work[i][0]<<","<<work[i][1]<<endl;

	if(work[0][1] != work[2][1])cout<<n-work[0][0]-work[2][0]<<endl;
	else if(work[1][1]==0 && work[3][1]==0)cout<<n/2<<endl;
	else if(work[0][0]+work[3][0] > work[1][0]+work[2][0])cout<<n-work[0][0]-work[3][0]<<endl;
	else cout<<n-work[1][0]-work[2][0]<<endl;
	return 0;

}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class UnionFindTree
{
private:
    int n;
    int groupNum;       // グループの数
    vector<int> parent; // 親ノード
    vector<int> rank;   // 木の高さの上限
    vector<int> num;    // グループの要素数
    int find(int i){
        if(parent[i] == i)
            return i;
        else
            return parent[i] = find(parent[i]);
    }
public:
    UnionFindTree(int n){ // コンストラクタ
        this->n = n;
        groupNum = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // aとbのグループを併合
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                num[b] += num[a];
            }
            else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                num[a] += num[b];
            }
            -- groupNum;
        }
    }
    bool same(int a, int b){ // aとbのグループが同じかを調べる
        return find(a) == find(b);
    }
};

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

    vector<pair<int, int> > p(m);
    for(int i=0; i<m; ++i){
        cin >> p[i].first >> p[i].second;
        -- p[i].first;
        -- p[i].second;
    }
    sort(p.begin(), p.end());

    int k = 0;
    int x = INT_MAX;
    int ans = 0;
    for(int a=0; a<n; ++a){
        if(a == x){
            x = INT_MAX;
            ++ ans;
        }
        while(k < m && p[k].first == a){
            x = min(x, p[k].second);
            ++ k;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




int main() {
    ll n;
    cin>>n;
    queue<ll>que;
    for(ll i=1;i<=9;i++){
        que.push(i);
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans=que.front();
        que.pop();
        ll tmp=ans%10;
        if(tmp!=0){
            que.push(10*ans+tmp-1);
        }
        que.push(10*ans+tmp);
        if(tmp!=9){
            que.push(10*ans+tmp+1);
        }
    }
    cout<<ans<<endl;



    return 0;
}


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

#define rep(i,n)  for (int i = 0; i < (int)(n); i++)
#define INF 999999999

using namespace std;
int main()
{
	int i,j,k,n,m,x,ans=INF;
	bool f;
	cin >> n >> m >> x;
	int c[n],a[n][m],skill[m],cost;
	rep(i,n){
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}
	rep(i,pow(2,n)){
		rep(j,m) skill[j]=0;
		cost=0;
		rep(k,n){
			if (i>>k & 1) {
				rep(j,m) skill[j]+=a[k][j];
				cost+=c[k];
			}
		}
		f=true;
		rep(j,m) if (skill[j]<x) f=false;
		if (f) ans=min(ans,cost);
	}

	if (ans==INF) ans=-1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3160
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
dp=[[a[0][0],a[0][1],a[0][2]]]+[[0]*3 for i in range(n-1)]
for i in range(1,n):
  for j in range(3):
    if j==0:
      dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i][0]
    elif j==1:
      dp[i][j]=max(dp[i-1][0],dp[i-1][2])+a[i][1]
    else:
      dp[i][j]=max(dp[i-1][1],dp[i-1][0])+a[i][2]
print(max(dp[n-1]))

Measured memory_bytes: 106196
// https://atcoder.jp/contests/abc148/tasks/abc148_e

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e18;

ll N;

void solve() {
  if (N % 2) {
    puts("0");
    return;
  }
  N /= 2;
  ll ans = 0;
  while (N > 0) {
    N /= 5;
    ans += N;
  }
  printf("%lld\n", ans);
}

void input() {
  scanf("%lld", &N);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
n = gets().to_i
k = gets().to_i
x_str = gets().split( )

sum = 0

for i in 0..n-1
	x = x_str[i].to_i
	d_a = x
	d_b = 0
	if(x <= k)
		d_b = k - x
	elsif(x > k)
		d_b = x - k
	end
	if(d_a >= d_b)
		sum = sum + d_b*2
	elsif(d_a < d_b)
		sum = sum + d_a*2
	end
end

puts(sum)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, k;
ll a[100000], b[100000];
 
int main(int argc, char **argv) {
	cin >> n >> k;
	REP(i, n) cin >> a[i] >> b[i];
	ll m = 1, m1 = -1, m2 = 0;
	while (k & m1) {
		m <<= 1;
		m1 <<= 1;
		m2 = (m2 << 1) | 1;
	}
	ll res = 0;
	for (m >>= 1, m2 >>= 1; ; m >>= 1, m1 >>= 1, m2 >>= 1) {
		ll s = 0;
		REP(i, n) if (((k & m1) | a[i] | m2) <= k) s += b[i];
		res = max(res, s);
		if (m == 0) break;
	}
	cout << res << endl;
	return 0;
}
 

Measured memory_bytes: 1792
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define INF 1000000000000000001

int n;
long k;

static int cmp_ascl(const void *a, const void *b) {
  return *(long *)a - *(long *)b;
}

static bool higher(long *a, long x) {
  long sum = 0;
  for (int i = 0; i < n; i++) {
    int l = -1;
    int h = n;
    if (a[i] < 0) {
      while (1 < h - l) {
        int m = (l + h) / 2;
        if (a[i] * a[m] < x) {
          h = m;
        } else {
          l = m;
        }
      }
      sum += n - h;
    } else {
      while (1 < h - l) {
        int m = (l + h) / 2;
        if (a[i] * a[m] < x) {
          l = m;
        } else {
          h = m;
        }
      }
      sum += h;
    }
    if (a[i] * a[i] < x) sum--;
  }
  return sum / 2 < k;
}

int main(int argc, char **argv) {
  scanf("%d %ld", &n, &k);
  long a[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", a + i);
  }
  qsort(a, n, sizeof(long), cmp_ascl);
  long l = -INF;
  long h = INF;
  while (1 < h - l) {
    long x = (l + h) / 2;
    if (higher(a, x)) {
      l = x;
    } else {
      h = x;
    }
  }
  printf("%ld\n", l);
  return EXIT_SUCCESS;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<llong> H(n);
    rep(i, n) {
      cin >> H[i];
    }
    if (n == 1) {
      cout << 0 << endl;
      return 0;
    }

    int ans = 0, max_ans = -1;
    for (int i = 0; i < n - 1; ++i) {
      if (H[i + 1] <= H[i]) ++ans;
      else max_ans = max(ans, max_ans), ans = 0;
    }

    cout << max(ans, max_ans) << endl;
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool approve = true;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 2 == 0 && a % 3 != 0 && a % 5 != 0)
      approve = false;
  }
  if (approve)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << 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 r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int ans = r*100 + g*10 + b;
    if(ans%4 == 0){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 20948
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Zero Division Checker
// 2012/09/20
public class Main{
	Scanner sc=new Scanner(System.in);

	int m;
	HashMap<String, Integer> lbMap, ubMap;
	int n;
	String[] es;

	void run(){
		m=sc.nextInt();
		lbMap=new HashMap<String, Integer>();
		ubMap=new HashMap<String, Integer>();
		for(int i=0; i<m; i++){
			String name=sc.next();
			int lb=sc.nextInt();
			int ub=sc.nextInt();
			lbMap.put(name, lb);
			ubMap.put(name, ub);
		}
		n=sc.nextInt();
		es=new String[n];
		for(int i=0; i<n; i++){
			es[i]=sc.next();
		}
		solve();
	}

	void solve(){
		int M=256;
		LinkedList<int[]> stack=new LinkedList<int[]>();
		boolean correct=true;
		for(int k=0; k<n; k++){
			char c=es[k].charAt(0);
			if(Character.isDigit(c)){
				int[] a=new int[M];
				a[Integer.parseInt(es[k])]=1;
				stack.push(a);
			}else if(Character.isLetter(c)){
				int[] a=new int[M];
				int lb=lbMap.get(es[k]);
				int ub=ubMap.get(es[k]);
				for(int i=lb; i<=ub; i++){
					a[i]=1;
				}
				stack.push(a);
			}else{
				int[] b=stack.pop();
				int[] a=stack.pop();
				int[] r=new int[M];
				for(int j=0; j<M; j++){
					for(int i=0; i<M; i++){
						if(a[i]==0||b[j]==0){
							continue;
						}
						int res;
						if(c=='+'){
							res=(i+j)%256;
						}else if(c=='-'){
							res=(i-j+256)%256;
						}else if(c=='*'){
							res=(i*j)%256;
						}else{
							if(j==0){
								correct=false;
								res=0;
							}else{
								res=(i/j)%256;
							}
						}
						r[res]=1;
					}
				}
				stack.push(r);
			}
		}
		println(correct?"correct":"error");
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << x << '\n';
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = n-1;
  for (ll i = 2; i*i <= n; ++i) {
    if (n % i == 0) {
      ans = min(ans, i + n/i - 2);
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#define INF 123456789

int main()
{

	int A, B;
	scanf("%d%d", &A, &B);
	if (A + B >= 10) printf("error\n");
	else
	{
		printf("%d", A + B);
	}
	return 0;
}

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

int main() {
  
  int S, h, m, s; cin >> S;
  
  h = S / 3600;
  
  m = S % 3600 / 60;
  
  s = S % 3600 % 60;
  
  cout << h << ":" << m << ":" << s << endl;
  
}


Measured memory_bytes: 3096
#include <stdio.h>

#define SIZE 200005

int a[SIZE],
//record[SIZE],//町の履歴
loop[SIZE],//町1から一周ループするまでを入れておく配列
dp[SIZE] = { 0 };//各町が登場したかの判定配列。0(false)で来てない。

int main() {
	long long k;
	int n,
		town = 1,//一番最初は1の町にいる
		start = 0,//ループ開始のループ部の中身のインデックス
		length = 0,//配列loopの長さ
		loop_length = 0;//実際のループの長さ
		//z = 0;//ループで数列を割ったときのあまり

	//入力
	scanf("%d%lld", &n, &k);
	for (int i = 0; i < n; i++)scanf("%d", &a[i]);

	//ここからの処理で配列loopを作る
	//もし一度でも来たことがある町に来たら
	//配列dpが1(true)になるはずなので
	//(!dp[town-1])はfalseになる
	for (int i = 0; !dp[town - 1]; i++) {
		//配列dpの今いる町を1(true)にする
		dp[town - 1] = 1;
		//配列loopに今の町を記録する
		loop[i] = town;
		//テレポートする
		town = a[town - 1];
		//配列loopの使う長さが変わるので記録
		length++;
	}

	//配列loopのどこからループが始まっているのかを調べ、実際のループの大きさを調べる
	for (int i = 0; i < length; i++) {
		//もしtown(ループの始まりであると保証できる)と配列loopが同じだったら
		if (town == loop[i]) {
			//実際のループの大きさを記録して
			loop_length = length - i;
			//ループに入る前の場所のインデックスを記録
			start = i;
			//ループをやめる
			break;
		}
	}
	//もし配列loopの大きさよりもkが小さければ
	//無条件でloop[k]を出力すればいい
	if (k < length) {
		printf("%d", loop[k]);
	}
	else {

		//そうでなければkから実際のループに入る前を引いて
		//それから何回きっちりループしてそのあとどのくらい移動するかを出す
		//その、「そのあとどのくらい移動するか」というのは
		//ループに入る前の分を抜かした上での配列loopの添え字なので、
		//ちゃんとループに入る前を足してあげる
		printf("%d\n", loop[(k - start) % loop_length + start]);
	}
}

Measured memory_bytes: 4016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int x = 800 * N;
		int y = 0;
		if(N>=15){
			int num = N/15;
			y = 200 * num;
		}
		int cost = x - y;
		System.out.println(cost);
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

int main()
{
    int q;

    cin >> q;

    int inum = 0;
    int64_t c = 0;

    multiset<int64_t> higher;
    multiset<int64_t> lower;
    int64_t hsum = 0;
    int64_t lsum = 0;

    for (int i = 0; i < q; i++)
    {
        int query;
        cin >> query;

        if (query == 1)
        {
            int64_t a, b;
            cin >> a >> b;
            c += b;

            if (higher.size() == 0)
            {
                higher.insert(a);
                lower.insert(a);
                hsum = lsum = a;
            }
            else
            {
                auto h = *(higher.begin());
                auto l = *(lower.rbegin());

                if (h < a)
                {
                    higher.insert(a);
                    higher.insert(a);

                    auto med = higher.begin();
                    lower.insert(*med);

                    hsum += 2 * a;
                    hsum -= *med;
                    lsum += *med;

                    higher.erase(med);
                }
                else if (l > a)
                {
                    lower.insert(a);
                    lower.insert(a);

                    auto med = lower.rbegin();
                    higher.insert(*med);

                    lsum += 2 * a;
                    lsum -= *med;
                    hsum += *med;

                    lower.erase(--(med.base()));
                }
                else
                {
                    higher.insert(a);
                    lower.insert(a);

                    hsum += a;
                    lsum += a;
                }
            }
        }
        else
        {
            int64_t x = *(lower.rbegin());
            int64_t result = (hsum - lsum) / 2LL + c;
            cout << x << " " << result << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <cassert>
#include <deque>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int H,W,N;
int area[1000][1000];
int subGoal = 1;
deque<int> posX;
deque<int> posY;
deque<int> step;
void init();
void reset(int st);
int main() {
  cin >> H >> W >> N;
  init();
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  int x,y,st;
  while(true){
    x = posX.front();
    posX.pop_front();
    y = posY.front();
    posY.pop_front();
    st = step.front();
    step.pop_front();
    rep(i,4){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(nx<0||nx>=W||ny<0||ny>=H) continue;
      if(area[nx][ny]==subGoal){
        if(subGoal==N){
          cout << st+1 << endl;
          return 0;
        }
        reset(st+1);
        break;
      }
      if(area[nx][ny]>0){
        area[nx][ny] -= 10;
        posX.push_back(nx);
        posY.push_back(ny);
        step.push_back(st+1);
      }
    }
  }
  return 0;
}

void init(){
  char input;
  rep(i,H){
    rep(j,W){
      cin >> input;
      if(input == '.'){
        area[j][i] = 10;
      }else if(input == 'X'){
        area[j][i] = -10;
      }else if(input == 'S'){
        posX.push_back(j);
        posY.push_back(i);
        step.push_back(0);
        area[j][i] = 0;
      }else{
        area[j][i] = (int)(input-'0');
      }
    }
  }
}

void reset(int st){
  posX.clear();
  posY.clear();
  step.clear();
  rep(i,H){
    rep(j,W){
      if(area[j][i] == subGoal){
        posX.push_back(j);
        posY.push_back(i);
        step.push_back(st);
      }else if(area[j][i] > -10&&area[j][i]<=0) area[j][i] += 10;
    }
  }
  subGoal++;
}

Measured memory_bytes: 5120
let rec gcd m n =
  if n = 0 then m else gcd n (m mod n);;

let () =
  let rec read z =
    try let (m,n) = Scanf.scanf "%d %d\n" (fun x y -> (x,y)) in
        let g = gcd m n in
        Printf.printf "%d %d\n" g (m*n/g);
        read z
    with End_of_file -> ()
  in read ();;

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if ((a+b)>=10)cout<<"error";
    else cout<<a+b;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
	int a[4][3][10]={0},n,i,j,k,b,f,r,v;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		a[b-1][f-1][r-1]+=v;
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf("%2d",a[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3) printf("####################\n");
	}
	
	return 0;
}


Measured memory_bytes: 2136