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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
        cout<<"hon"<<endl;
    if(n==0 || n==1 || n==6 || n==8)
        cout<<"pon"<<endl;
    if(n==3)
        cout<<"bon"<<endl;
    return 0;
}

Measured memory_bytes: 3580
H, W = map(int, input().split())
maze = []
for _ in range(H):
    maze.append(input())
nodes = []
nodedict = {}
for r in range(H):
    for c in range(W):
        if maze[r][c] == '.':
            node_id = len(nodes)
            nodedict[(r,c)] = node_id
            nodes.append((r,c))
N = len(nodes)
INF = H*W+100
dist = [[INF] * N for _ in range(N)]
for i in range(N):
    dist[i][i] = 0

def connect(r1, c1, r2, c2):
    n1 = nodedict[(r1, c1)]
    n2 = nodedict[(r2, c2)]
    dist[n1][n2] = 1
    dist[n2][n1] = 1

def solve():
    for i in range(N):
        r, c = nodes[i]
        if r > 0 and maze[r-1][c] == '.':
            connect(r, c, r-1, c)
        if r < H-1 and maze[r+1][c] == '.':
            connect(r, c, r+1, c)
        if c > 0 and maze[r][c-1] == '.':
            connect(r, c, r, c-1)
        if c < W-1 and maze[r][c+1] == '.':
            connect(r, c, r, c+1)

    # Warshall Floyd
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    maxd = 0
    di, dj = None, None
    for i in range(N):
        for j in range(N):
            d = dist[i][j]
            if d < INF and maxd < d:
                maxd = d
                di = nodes[i]
                dj = nodes[j]
    return maxd  #, di, dj


print(solve())


Measured memory_bytes: 41456
# -*- coding: utf-8 -*-
N = int(input())
strings = []
for i in range(N):
    string = list(input())
    string.sort()
    strings.append(string)
strings.sort()
wordAnagramCou = 0
anagramCou = 0
for i in range(N-1):
    if strings[i+1] == strings[i]:
        wordAnagramCou += 1
    else:
        wordAnagramCou=0
    anagramCou += wordAnagramCou
print(anagramCou)

Measured memory_bytes: 24652
#include <iostream>

using namespace std;

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

    int r=0;

    int t=1;

  

    while(r + a < b){
        r += a-1;
        t++;
    }
    if(b == 1){
        t =0;
    }
    

    cout << t << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<tuple>
#define LL long long
#define TT std::tuple<int,int,int>
int N, MA, MB;
int dp[2][410][410];
std::vector<TT> med;
int INF = 100000000;
int ans = INF;
int main() {
	std::cin >> N >> MA >> MB;
	for (int i = 0; i < N; i++) {
		int a, b, c;
		std::cin >> a >> b >> c;
		med.push_back(TT{ a,b,c });
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j <= 400; j++) {
			for (int k = 0; k <= 400; k++) {
				if (j == 0 && k == 0)continue;
				dp[i][j][k] = INF;
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		int a, b, c;
		std::tie(a, b, c) = med[i - 1];
		for (int j = 1; j <= 400; j++) {
			for (int k = 1; k <= 400; k++) {
				dp[i%2][j][k] = dp[(i - 1)%2][j][k];
				if (j - a >= 0 && k - b >= 0) {
					dp[i%2][j][k] = std::min(dp[i%2][j][k], dp[(i - 1)%2][j - a][k - b] + c);
				}
			}
		}
	}
	int D = 1;
	while (MA*D <= 400 && MB*D <= 400) {
		ans = std::min(ans, dp[N%2][MA*D][MB*D]);
		D++;
	}
	if (ans == INF)ans = -1;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1536
def solve():
  n, k = map(int, input().split())
  
  divList = [0 for _ in range(k)]
  for i in range(1, n+1):
    divList[i % k] += 1
  
  count = 0
  for i in range(k):
    if (i*2) % k ==0:
      count += divList[i] ** 3
  print(count)
solve()

Measured memory_bytes: 4632
X,N = map(int,input().split())
P = list(map(int,input().split()))

L = [0] * 301

for i in P:
    L[i + 100] = 1

for i in range(100):
    if L[-i+ X +100] == 0:
        print(X - i)
        break
    if L[i+X+100] == 0:
        print(X+i)
        break



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

int main() {
	string s;
	cin >> s;

	char s1 = s[0];
	char s2 = s[1];
	char s3 = s[2];

	string result = "Yes";
	if(s1 == s2 && s2 == s3) result = "No";

	cout << result << endl;

    return 0;
}


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

ll dp[2][1000005];

void solve(string s) {
  for(int i=0;i<1000005;i++){
    dp[0][i]=dp[1][i]=0;
  }
  dp[1][0]=1;
  for(int i=0;i<s.size();i++){
    int t = s[i]-'0';
    dp[0][i+1]=min(dp[0][i]+t, dp[1][i]+t+1);
    dp[1][i+1]=min(dp[0][i]+(10-t), dp[1][i]+(10-t-1));
  }

  cout<<min(dp[0][s.size()],dp[1][s.size()]+1)<<endl;
}

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

  string s;
  cin>>s;
  solve(s);

  return 0;
}


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

using namespace std;

int nr, N, Q, t[200009], ev[200009];
pair < int, pair < int, int > > edges[600009];

void addEdge (int x, int y, int z)
{
    edges[++nr] = {z, {x, y}};
}

int tata (int x)
{
    if (t[x] == x) return x;
    return t[x] = tata (t[x]);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &Q);
for (int i=0; i<N; i++)
    ev[i] = 2e9;
while (Q --)
{
    int a, b, c;
    scanf ("%d %d %d", &a, &b, &c);
    addEdge (a, b, c);
    ev[a] = min (ev[a], c - 1);
    ev[b] = min (ev[b], c);
}
bool none = 1;
int mini;
for (int i=1; i<=2 * N; i++)
{
    if (i - 1 < N && ev[i - 1] < 2e9)
    {
        if (ev[i - 1] - 2 * (i - 1) < mini || none)
            mini = ev[i - 1] - 2 * (i - 1), none = 0;
    }
    if (!none)
        addEdge ((i - 1) % N, i % N, mini + 2 * i);
}
sort (edges + 1, edges + nr + 1);
for (int i=0; i<N; i++)
    t[i] = i;
long long ans = 0;
for (int i=1; i<=nr; i++)
{
    int x = edges[i].second.first, y = edges[i].second.second, z = edges[i].first;
    x = tata (x), y = tata (y);
    if (x != y)
        t[x] = y, ans += z;
}
printf ("%lld\n", ans);
return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin>>n;
    int ans=0;
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin>>a;
        while(a%2==0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void)
{
	int a, b;
	scanf("%d%d", &a, &b);
	if((a>=1 && a<=9) && (b>=1 && b<=9)){
		printf("%d", a*b);
	}else{
		printf("%d", -1);
	}
	return 0;
}

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

const int N = 2e5 + 1;
int mod[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.precision(10);
    cout << fixed;

    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i){
        ++mod[i % k];
    }

    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        int m = (k - i % k) % k;
        if (2 * m == k || m == 0){
            ans += 1LL * mod[m] * mod[m];
        }
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

H, W = map(int, input().split())

# corner!!!
if H == 1 or W == 1:
    print(1)
else:
    if H % 2 == 1:
        ans = (H // 2) * W + (W + 1) // 2
    else:
        ans = (H // 2) * W
    print(ans)


Measured memory_bytes: 5588
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 7, maxm = 1e6 + 7;
int D[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int n, m, vis[maxn][maxn];
char r[maxn];

struct Node{
	int x, y;
}node[maxm];
int s = 1, t = 0;

void bfs() {
	int x, y, X, Y;
	while(s <= t) {
		x = node[s].x; y = node[s].y;
		++s;
		for (int i = 0; i < 4; ++i) {
			X = x + D[i][0];
			Y = y + D[i][1];
			if(~vis[X][Y]) continue;
			vis[X][Y] = vis[x][y] + 1;
			node[++t].x = X; node[t].y = Y;
		}
	}
	printf("%d\n", vis[x][y]);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) vis[i][j] = -1;
	for (int i = 1; i <= n; ++i) {
		scanf("%s", r + 1);
		for (int j = 1; j <= m; ++j) if(r[j] == '#') {
			node[++t].x = i; node[t].y = j;
			vis[i][j] = 0;
		}
	}
	bfs();
	return 0;
}

Measured memory_bytes: 15516
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
M=N**2
P=tuple(map(int1,input().split()))
d=[0]*M
for i in range(N):
    for j in range(N):
        d[i*N+j]=min(min(i,N-1-i),min(j,N-1-j))
used=[1]*M
ans=0
que=[]
for p in P:
    ans+=d[p]
    used[p]=0
    que.append(p)
    while que:
        x=que.pop()
        for ddx in (-1,1,-N,N):
            nx=x+ddx
            if 0<=nx<M:
                if used[x]==0 and d[nx]-d[x]>=1:
                    d[nx]-=1
                    que.append(nx)
                elif used[x]==1 and d[nx]-d[x]>=2:
                    d[nx]-=1
                    que.append(nx)
print(ans)



Measured memory_bytes: 171636
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    char a[101];
    char b[101];

    scanf("%s %s", a, b);

    if (strlen(a) == strlen(b)) {

        for (int i = 0; i < strlen(a); i++) {
            if (a[i] > b[i]) {
                printf("GREATER");
                return 0;
            } else if (a[i] < b[i]) {
                printf("LESS");
                return 0;
            } 

        }
        printf("EQUAL");

    } else if (strlen(a) > strlen(b)) {
        printf("GREATER");
    } else {
        printf("LESS");
    }


    return 0;
} 

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner	in = new Scanner(System.in);
		int N = in.nextInt();
		String S = in.next();
		
		boolean a;
		if (S.length() % 2 == 0) {
			a = S.substring(0, S.length()/2).equals(
					S.substring(S.length()/2, S.length()));
			
		} else {
			a = false;
		}
		String answer = (a) ? "Yes" : "No";
		System.out.println(answer);
	}

}


Measured memory_bytes: 22868
import std.stdio, std.conv, std.string, std.bigint;
import std.math, std.random, std.datetime;
import std.array, std.range, std.algorithm, std.container, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	long[] as;
	foreach(i; 0 .. 6) as ~= read.to!long;
	
	// 同じ頂点が3回出ていたら不可
	
	long[long] cnt;
	foreach(a; as) if(a !in cnt) cnt[a] = 1; else cnt[a] += 1;
	
	long max = 0;
	foreach(c; cnt) if(c > max) max = c;
	
	if(max == 3) writeln("NO");
	else writeln("YES");
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
// const long double pi = acos(-1.0);
// cout << fixed << setprecision(1) <<pi<<endl
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld  double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	ld a,b,c,d;
	cin>>a>>b>>c>>d;
	ld ans = 0.0;
	ld x = (c*30)+(d*0.5);
	ld y = d*6;
	ld pi = acos(-1);
	ans = (ld)(a*a)+(ld)(b*b)-(2*a*b*cos((x-y)*(pi/180.0)));
	cout<<fixed<<setprecision(20)<<sqrt(ans)<<endl;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

int digit(int n) {
  int res = 0;
  while (n) {
    res += n % 10;
    n /= 10;
  }
  return res;
}
signed main(int argc, char *argv[]) {
  int n = in();
  int ans = inf;
  for (int a = 1; a < n; ++a) {
    chmin(ans, digit(a) + digit(n - a));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

ll n;
ll A[1000010],F[1000010];

ll f(ll x){
  ll sum=0;
  rep(i,n){
    if(A[i]*F[i]>x){ 
      sum+=A[i]-x/F[i];
    }
  }
  return sum;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll k;
  cin>>n>>k;

  rep(i,n) cin>>A[i];
  rep(i,n) cin>>F[i];
  
  sort(A,A+n);
  sort(F,F+n,greater<int>());
  
  ll l=-1,r=1e12+7;
  while(r-l>1){
    ll mid=(l+r)/2;
    if(f(mid)>k) l=mid;
    else r=mid;
  }
  cout<<r<<endl;
  
  return 0;
}

Measured memory_bytes: 6772
import sys
import numpy as np
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


def main():
    N, K = readnums()
    h = np.sort(np.array([readint() for _ in range(N)]))
    ans = 0
    for i in range(N - K + 1):
        if not i:
            ans = h[i + K - 1] - h[i]
        else:
            ans = min(ans, h[i + K - 1] - h[i])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20012
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;

const int MAXN=100005 ;
int n , E, T , dis[MAXN] ;
long long dp[MAXN] ;

multiset<long long> st;
multiset<long long>::iterator it ;

long long calc_1(int j){
	return dp[j]-2*dis[j+1]-dis[j] ;
}

long long calc_2(int j){
	return dp[j]-dis[j] ;
}

int main(){
	scanf("%d%d%d",&n,&E,&T) ;
	memset(dp,0x3f,sizeof(dp)) ;
	for(int i=1;i<=n;++i) scanf("%d",&dis[i]) ;
	dp[0]=0 ;
	int last=0 ; //第一个满足边界的
	st.insert(calc_2(0)) ;
	long long minn=(1ll<<60)-1 ;
	for(int i=1;i<=n;++i){
		while(last<i && 2*(dis[i]-dis[last+1])>=T){
			long long tmp=calc_2(last) ;
			it=st.find(tmp) , st.erase(it) ;
			minn=min(minn,calc_1(last)) , ++last ;
		}
		dp[i]=minn+(long long)3*dis[i] ;
		if(!st.empty()) dp[i]=min(dp[i],(*st.begin())+T+dis[i]) ;
		st.insert(calc_2(i)) ;
	}
	cout << dp[n]+E-dis[n] << '\n' ;
	return 0 ;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
using namespace std;

int main(void){
    
    long long int l,r;
    cin>>l>>r;
    long long int min = 2020;
    long long int ans;

    if(r-l+1>= 2019){
        cout<<"0"<<endl;
    }else{
        
        for(long long int i=l;i<r;i++){
            for(long long int j=i+1;j<r+1;j++){
                ans = ((i%2019)*(j%2019))%2019;
                if(ans < min) min = ans;
            }
            if(ans < min) min = ans;
        }
        cout<<min<<endl;
    }

    return 0;

}

Measured memory_bytes: 384
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	int n;
	cin>>n;
	vi a(n),b(n);
	for(int &i:a)cin>>i;
	for(int &i:b)cin>>i;
	for(int i=1;i<n;i++)a[i]+=a[i-1];
	for(int i=n-2;i>=0;i--) {
		b[i]+=b[i+1];
	}
	int mx=0;
	REP(i,0,n-1) mx=max(mx,a[i]+b[i]);
	cout<<mx;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int i,n,m,c,color[10004],grid[102][102],j,id;
int main()
{
    cin>>n>>m;
    cin>>c;
    for(i=1;i<=c;i++)cin>>color[i];
    i=0;
    id=0;
    while(true)
    {
        i++;
        if(i%2==1)
        {
            for(j=1;j<=m;j++)
            {
                while(color[id]==0)id++;
                grid[i][j]=id;
                color[id]--;
            }
        }
        else
        {
            for(j=m;j>=1;j--)
            {
                while(color[id]==0)id++;
                grid[i][j]=id;
                color[id]--;
            }
        }
        if(i==n)break;

    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            cout<<grid[i][j]<<" ";
        }
        cout<<endl;
    }



    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int bcost(int a,int b,int c){
	double da=(c+1.)/(1.+a/100.)-0.0001;
	int s=(int)da;
	int t=s*(1.+a/100.);
	if(t!=c)return -1000;
	s=s*(1.+b/100.)+0.0001;
	return s;
}

int main(){
	int a,b,c,d;
	int i,j,k;
	int s=0;
	while(cin>>a>>b>>c){
		if(!a)break;
		s=0;
		for(i=1;i<c;i++){
			d=bcost(a,b,i)+bcost(a,b,c-i);
			if(d>s)s=d;
		}
		cout<<s<<endl;
	}
}



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

int main(){
  char X;
  cin >> X;
  
  if(X == 'A'){
    cout << 'T' << endl;
  }
  else if(X == 'T'){
    cout << 'A' << endl;
  }
  else if(X == 'C'){
    cout << 'G' << endl;
  }
  else{
    cout << 'C' << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<unordered_map>
using namespace std;
#define FORCRD(a,b,c,d) for(int a=c-1;a<=c+1;a++)for(int b=d-1;b<=d+1;b++)if(a>=0&&b>=0&&a<h&&b<w)
int a[100010],b[100010];
unordered_map <long long , int > m1,m2;
int main(void){
	int h,w,n;
	int cnt[10]={0};
	scanf("%d%d%d",&h,&w,&n);
	m1.clear();
	m2.clear();
	for (int i=1;i<=n;i++){
		scanf("%d%d",a+i,b+i);
		a[i]--;
		b[i]--;
		m1[1ll*a[i]*w+b[i]]=1;
	}
	for (int i=1;i<=n;i++){
		FORCRD(p,q,a[i],b[i]){
			long long now=1ll*p*w+q;
			if (p>0&&p<h-1&&q>0&&q<w-1)
			if (m2.find(now)==m2.end()){
				int tot=0;
				FORCRD(x,y,p,q){
					long long tt=1ll*x*w+y;
					if (m1.find(tt)!=m1.end()){
						tot++;
					}
				}
				cnt[tot]++;
				m2[now]=1;
			}
		}
	}
	long long s0=1ll*(h-2)*(w-2);
	for (int i=1;i<=9;i++) s0-=cnt[i];
	printf("%lld\n",s0);
	for (int i=1;i<=9;i++) printf("%d\n",cnt[i]);
}

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

int main() {

	long long K;
	long long ary[50];
	int n = 50;

	cin >> K;

	for (int i = 0; i < n; i++) {
		ary[i] = i + K / n;
	}

	K %= n;

	int min = 0;
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < n; j++) {
			ary[j]--;
		}
		ary[min] += n + 1;
		if (++min == n)min = 0;
	}

	cout << n << endl;
	for (int i = 0; i < n; i++) {
		cout << ary[i] << " ";
	}

	return 0;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         long good = N/K;
         long res = good*good*good;
         if(K%2 == 0)
         {
            //meme
            long cnt = 0;
            for(int i=1; i <= N; i++)
               if(2*(i%K) == K)
                  cnt++;
            res += cnt*cnt*cnt;
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 22484
def main():
    h, w = map(int, input().split())
    ans = 0
    if h == 1 or w == 1:
        print(1)
        exit()
    
    if h % 2 == 0:
        ans = h * w // 2
    else:
        if w % 2 == 0:
            ans = h * w // 2
        else:
            ans = h * w // 2 + 1 
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
	string a, b, c; cin >> a >> b >> c;
	printf("%c%c%c\n", a[0] - 32, b[0] - 32, c[0] - 32);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1e9 + 7;

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

  char c;
  cin >> c;

  printf("%c\n", c + 1);

  return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(v => Number(v))
  const k = input[0]
  const s = input[1]
  let count = 0
  for (let xi = 0; xi <= k; xi = (xi + 1) | 0) {
    for (let yi = 0; yi <= k; yi = (yi + 1) | 0) {
      const tmp = s - (xi + yi)
      if (tmp >= 0 && tmp <= k) count++
    }
  }

  console.log(count)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))



Measured memory_bytes: 7624
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var mCount = 0L;
            var aCount = 0L;
            var rCount = 0L;
            var cCount = 0L;
            var hCount = 0L;
            for (int i = 0; i < N; i++)
            {
                var s = ReadText();
                switch (s[0])
                {
                    case 'M': mCount++; break;
                    case 'A': aCount++; break;
                    case 'R': rCount++; break;
                    case 'C': cCount++; break;
                    case 'H': hCount++; break;
                }
            }

            return
                mCount * aCount * rCount +
                mCount * aCount * cCount +
                mCount * aCount * hCount +
                mCount * rCount * cCount +
                mCount * rCount * hCount +
                mCount * cCount * hCount +
                aCount * rCount * cCount +
                aCount * rCount * hCount +
                aCount * cCount * hCount +
                rCount * cCount * hCount;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 30884
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. TWO_RECTANGLES.
000300 DATA DIVISION.
000301 WORKING-STORAGE SECTION.
000302 01 S PIC X(23).
000303 01 S1 PIC X(05).
000304 01 S2 PIC X(05).
000305 01 S3 PIC X(05).
000306 01 S4 PIC X(05).
000307 01 A PIC 9(05).
000308 01 B PIC 9(05).
000309 01 C PIC 9(05).
000310 01 D PIC 9(05).
000311 01 I PIC 9(01).
000312 01 P PIC 9(09).
000400 PROCEDURE DIVISION.
000401 MAIN SECTION.
000402     ACCEPT S FROM SYSIN.
000403     UNSTRING S DELIMITED BY SPACE INTO S1, S2, S3, S4.
000404     MOVE S1 TO A.
000405     MOVE S2 TO B.
000406     MOVE S3 TO C.
000407     MOVE S4 TO D.
000407     COMPUTE P = FUNCTION MAX(A*B,C*D)
000408     COMPUTE I = 9 - FUNCTION INTEGER(FUNCTION LOG10(P)).
000409     DISPLAY P(I:) UPON SYSOUT.
000410     STOP RUN.

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

int main() {
    int n, x;
    cin>>n >>x;
    vector<int> l(n);
    int ans=1;
    int d=0;
    rep(i,n){
        cin>>l[i];
        d+=l[i];
        if(d<=x) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
mod=10**9+7
x,y=map(int,input().split())
if (x+y)%3!=0:
    print(0)
    exit()
a=min(x,y)
b=max(x,y)
if 2*a<b:
    print(0)
    exit()

k=(x+y)//3
left_x=2*k
left_y=k
r=left_x-x

def factorialmod(n,mod):
    ans=1
    for i in range(2,n+1):
        ans*=i
        ans%=mod
    return ans

fac_k=factorialmod(k,mod)
fac_k_r=factorialmod(k-r,mod)
fac_r=factorialmod(r,mod)
bunbo=fac_k_r*fac_r%mod
print(fac_k*pow(bunbo,mod-2,mod)%mod)

Measured memory_bytes: 62356
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

fn pf_map(mut n: i64) -> BTreeMap<i64, i64> {
    let mut res = BTreeMap::new();
    for i in 2.. {
        if i * i > n {
            break;
        }
        while n % i == 0 {
            n /= i;
            *res.entry(i).or_insert(0) += 1;
        }
    }
    if n != 1 {
        res.insert(n, 1);
    }
    res
}

fn main() {
    input! {
        n:i64
    }
    let ans: i64 = pf_map(n)
        .iter()
        .map(|(_, &index)| {
            (1..)
                .take_while(|&i| index >= i * (i + 1) / 2)
                .last()
                .unwrap()
        })
        .sum();
    println!("{}", ans);
}

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

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const int m=256;
const int INF=1000000000;
int val[300];
int calc(int idx,int a,int c){
    if(val[idx]!=INF)
        return val[idx];
    int res=(a*calc(idx-1,a,c)+c)%m;
    return val[idx]=res;
}

int main(){

    int n;
    while(cin>>n&&n!=0){
        int ap[256];
        int l[300];
        double minTropy=INF;
        int aa,cc,ss;
        for(int i = 0; i < n; i++)
            cin>>l[i];
        for(int s = 0; s <= 15; s++){
            for(int a = 0; a <= 15; a++){
                for(int c = 0; c <= 15; c++){
                    fill(val,val+300,INF);
                    fill(ap,ap+256,0);
                    val[0]=s;
                    if(a==7&&c==9){
        //               cout<<endl;
                    }
                    for(int i = 1; i <= n; i++){
                        ap[(l[i-1]+calc(i,a,c))%m]++;
                    }
                    double sum=0;
                    for(int i = 0; i < 256; i++){
                        if(ap[i]!=0){
                            sum-=(1.0*ap[i]/n)*(log((double)ap[i])/n);
                        }
                    }
                    if(!EQ(sum,minTropy)&&sum<minTropy){
                        minTropy=sum;
                        ss=s;aa=a;cc=c;
                    }
                }
            }
        }
        cout<<ss<<" "<<aa<<" "<<cc<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
do_list = [-1]*D
for i in range(D):
    tmp, res = s[i][0], 0
    for j in range(1,26):
        if tmp<s[i][j]:
            tmp, res = s[i][j], j
    do_list[i] = res
for i in do_list: print(i+1)

Measured memory_bytes: 9396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    sort(all(h), greater<int>());
    
    ll sum = 0;
    rep3(i, k, n) sum += h[i];
    cout << sum << endl;
}


Measured memory_bytes: 1024
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		LinkedList <Integer>tmp = new LinkedList <Integer>();
		
		for (int i=0; i<totalVertex;i++) {
			tmp =adjList.poll();
			for (int j=0; j<totalVertex;j++) {
				if (tmp.contains(j)) {
					adjMatrix[i][j]=1;
					}else {
						adjMatrix[i][j]=0;
					}
				}
			}
		for (int i=0; i<totalVertex;i++) {
			for (int j=0; j<totalVertex;j++) {
				System.out.print(adjMatrix[i][j]);
				if (j<totalVertex-1) {
					System.out.print(" ");
				}}
			System.out.println();
			
				}
			}
			
		}



//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 34520
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int K;
  cin >> K;
  ll sum = 0;
  REPS(a, 1, K + 1) {
    REPS(b, 1, K + 1) {
      REPS(c, 1, K + 1) { sum += gcd(gcd(a, b), c); }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[1100];
int c[1100];
int dp[1100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%d%d",b+i,c+i);
		int t=0;
		for(int i=0;i<a;i++)t+=b[i];
		int m=0;
		for(int i=0;i<a;i++)m=max(m,b[i]);
		if(m+m<=t){
			int ret=0;for(int i=0;i<a;i++)ret+=c[i];
			printf("%d\n",t+ret);
			continue;
		}
		for(int i=0;i<1100;i++)dp[i]=0;
		dp[0]=1;
		for(int i=0;i<a;i++){
			if(m==b[i])continue;
			for(int j=m-(t-m)-c[i];j>=0;j--){
				if(dp[j])dp[j+c[i]]=1;
			}
		}
		int ret=0;for(int i=0;i<a;i++)ret+=c[i];
		int v=0;for(int i=0;i<=m-(t-m);i++)if(dp[i])v=i;
		printf("%d\n",max(t+ret,m*2+ret-v));
	}
}

Measured memory_bytes: 1040
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
A = III()

d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1

A = list(set(A))
A.sort(reverse=True)

l1 = 0
l2 = 0
for a in A:
    if d[a]>=2:
        if l1==0:
            l1 = a
        else:
            l2 = a
            break
        d[a] -= 2
        if d[a]>=2:
            l2 = a
            break
    else:
        continue

print(l1*l2)

Measured memory_bytes: 73984
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

double r(double x1,double y1,double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	
	}

int main() {
	// your code goes here
	int n;
	double x1,x2,y1,y2,r1,r2;
	cin>>n;
	for(int j=0;j<n;j++){
		cin>>x1>>y1>>r1>>x2>>y2>>r2;
		
		if(r(x1,y1,x2,y2)>(r1+r2)){
			cout<<0<<endl;
		}
		else if(r(x1,y1,x2,y2)>=fabs(r1-r2)&&r(x1,y1,x2,y2)<=r1+r2){
			cout<<1<<endl;
		}
		else if(r1>r2){
			cout<<2<<endl;
		}
		else if(r2>r1){
		cout<<-2<<endl;	
		
		}
		
		
	}
	
	return 0;
}

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

#define INF 1000000000000
#define MOD 1000000007

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    
    ll ans=max({a*c, a*d, b*c, b*d});
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define int ll
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=100000005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int a[MAXN],flag[MAXN],num=0;
int get(int x)
{
	int num=0;
	while (x) num+=(x%10),x/=10;
	return num;
}
signed main()
{
	int n=read();
	for (int i=1;i<=8;i++) a[++num]=i;
	for (int i=2,p=1,q=1;i<=16;i++)
	{
		//q 100..0~999..99
		//p 100..000
		a[++num]=((q*10-1)*p+p-1);
		PR lst=MP(a[num],get(a[num]));
//		cout<<lst.fi<<" "<<lst.se<<endl;
		for (int j=q*10-1;j>=q;j--) 
		{
			int t=j*p+p-1;
//			cout<<t<<" "<<get(t)<<endl;
			if (t*lst.se<get(t)*lst.fi) a[++num]=t,lst=MP(t,get(t));
		}
		int t=a[num],lstp=p; p=1;
		while (t%10==9) p*=10,t/=10;
		if (lstp==p) q*=10;
	}
	sort(a+1,a+num+1);
	for (int i=1;i<=n;i++) printf("%lld\n",a[i]);
	return 0;
}
//0 1 2 2 3 4 5 6

Measured memory_bytes: 3600
import math


def primes(N):
    p = [False, False] + [True] * (N - 1)
    for i in range(2, int(N ** 0.5) + 1):
        if p[i]:
            for j in range(i * 2, N + 1, i):
                p[j] = False
    return [i for i in range(N + 1) if p[i]]


N = int(input())
A = list(map(int, input().split()))
maxA = max(A) + 1
g, Ac = A[0], [0] * maxA
P = primes(maxA)

for a in A:
    Ac[a] += 1

ans = "pairwise"
for p in P:
    if sum(Ac[p:maxA:p]) > 1:
        ans = "setwise"
for a in A:
    g = math.gcd(g, a)
print(ans if g == 1 else "not", "coprime")


Measured memory_bytes: 217476
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+8;
int n,m,s,t;
long long ans[N];
struct node{
    int cnt,head[N];
    long long cost[N];
    bool flag[N];
    struct Edge {int next, to; long long cost;} edge[N*2];
	queue<int> q;
	void add(int from,int to,long long cost)
	{
		edge[++cnt].next=head[from];
		edge[cnt].to=to;
		edge[cnt].cost=cost;
		head[from]=cnt;
	}
	void spfa(int s)
	{
		for(int i=1;i<=n;i++) cost[i]=1000000000000000000;
		memset(flag,0,sizeof(flag));
		q.push(s); flag[s]=1; cost[s]=0;
		while(!q.empty())
		{
			int x=q.front();
			q.pop();
			flag[x]=0;
			for(int i=head[x];i;i=edge[i].next)
			{
				int to=edge[i].to;
				if(cost[to]>cost[x]+edge[i].cost)
				{
					cost[to]=cost[x]+edge[i].cost;
					if(!flag[to]) q.push(to),flag[to]=1;
				}
			}
		}
	}
}s_to_i,i_to_t;
long long Min(long long x,long long y)
{
    if(x>y) return y;
    return x;
}
int main()
{
    cin>>n>>m>>s>>t;
    for(int i=1;i<=m;i++)
    {
        int u,v;
        long long yen,snu;
        cin>>u>>v>>yen>>snu;
        s_to_i.add(u,v,yen);
        i_to_t.add(u,v,snu);
        s_to_i.add(v,u,yen);
        i_to_t.add(v,u,snu);
    }
    s_to_i.spfa(s);
    i_to_t.spfa(t);
    ans[n]=s_to_i.cost[n]+i_to_t.cost[n];
    for(int i=n-1;i>0;i--) ans[i]=Min(ans[i+1],s_to_i.cost[i]+i_to_t.cost[i]);
    for(int i=1;i<=n;i++) printf("%lld\n",1000000000000000-ans[i]);
}


Measured memory_bytes: 11392
# longest path

import sys
from collections import defaultdict

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, M = map(int, input().split())
    edge = defaultdict(lambda: [])

    memo = [0] * 110000
    done = [False] * 110000

    def dp(v):
        if done[v]:
            return memo[v]
        ans = 0
        for to in edge[v]:
            ans = max(ans, dp(to) + 1)
        done[v] = True
        memo[v] = ans
        return ans

    for i in range(M):
        u, v = map(int, input().split())
        edge[u].append(v)

    ans = 0
    for v in range(1, N + 1):
        ans = max(ans, dp(v))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 76952
#include <cstdio>

using namespace std;

int main(void) {
    int a, b;
    char op;
    
    while(1){
        scanf("%d %c %d", &a, &op, &b);
    
        switch(op){
            case '+':
                printf("%d\n", a + b);
                break;
            case '*':
                printf("%d\n", a * b);
                break;
            case '-':
                printf("%d\n", a - b);
                break;
            case '/':
                printf("%d\n", (int)((float)a / b));
                break;
        }
        if(op == '?'){
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1032
#include <iostream>
int main()
{
    int N;
    std::cin >> N;
    if (N == 25) {
        std::cout << "Christmas" << std::endl;
    } else if (N == 24) {
        std::cout << "Christmas Eve" << std::endl;
    } else if (N == 23) {
        std::cout << "Christmas Eve Eve" << std::endl;
    } else if (N == 22) {
        std::cout << "Christmas Eve Eve Eve" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const ll INF = 1e18;

//i個までみてxをjこ入れたときのmax
ll dp[200005][4];

int main(void){
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n)cin >> a[i];
  //oxoxoxoxoの並びの中にxを入れる
  //入れる必要のあるxの個数
  //偶数->1
  //奇数->2
  ll k = 1 + n%2;
  REP(i, n+1) REP(j, k+1) dp[i][j] = -INF;
  dp[0][0] = 0;
  REP(i, n) REP(j, k+1){
    //xを入れる->a[i]をスキップする場合
    chmax(dp[i+1][j+1], dp[i][j]);
    ll now = dp[i][j];
    //xを1個入れるとoの位置が1つずれる
    //0 -> そのまま
    //1 -> 1つずれる
    //2 -> もう1つずれてもとに戻る
    if((i+j)%2 == 0) now += a[i];
    chmax(dp[i+1][j], now);
  }
  cout << dp[n][k] << endl;
  return 0;
}

Measured memory_bytes: 11180
#include<stdio.h>
#include<string.h>
int a,b;
char s[11],t[11],u[11];
int main(){
    scanf("%s%s%d%d%s",s,t,&a,&b,u);
    if(strcmp(s,u))b--;
    else a--;
    printf("%d %d",a,b);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] l = new int[n];
		int[] r = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = scan.nextInt();
			r[i] = scan.nextInt();
		}
		int count = 0;
		for (int i = 0; i < n; i++) {
			count = count + (r[i] - l[i]) + 1;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 26196