akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

ll gcd(ll a, ll b) {
  if(a < b) gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
  
// Function to find gcd of array of 
// numbers 
ll findGCD(vector<ll> arr, ll n) 
{ 
    ll result = arr[0]; 
    for (ll i = 1; i < n; i++) 
        result = gcd(arr[i], result);
    return result; 
}

int main ()
{
    ll N;cin>>N;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    ll gcd1 = findGCD(A,A.size());
    REP(i,N) A[i] /= gcd1;
    ll onecount = 0;
    REP(i,N){
        if(A[i] == 1) onecount++;
    }
    if(onecount>=2){
        cout<<gcd1<<endl;
        return 0;
    }else if(onecount==1){
        ll tmp;
        vector<ll> B(N);
        REP(i,N){
            B[i] = A[i];
            if(A[i] == 1){
                B[i] = A[i==0 ? i+1:i-1];
            }
        }
        ll gcd2 = findGCD(B,B.size());
        cout<<gcd1 * gcd2 <<endl;
        return 0;
    }
    sort(ALL(A));
    ll smallest = A[1];
    ll gcd2 = 1;
    for (ll i = smallest; i >= 2; i--)
    {
        ll flag = 0;
        REP(j,N){
            if(A[j]%i!=0) flag++;
            if(flag>=2) break;
        }
        if(flag==1){
            gcd2 = i;
            break;
        } 
    }
    cout<<gcd1 * gcd2<<endl;
    return 0;
}

Measured memory_bytes: 1792
N, *A = map(int, open(0).read().split())

ans = [0] * N
for i in range(N):
    ans[0] += A[i] * (-1) ** int(i % 2 != 0)

for i in reversed(range(1, N)):
    ans[i] = 2 * A[i] - ans[(i + 1) % N]
    
print(*ans)

Measured memory_bytes: 71228
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char A[10];
char B[10];
int main(){
	scanf("%s%s",A,B);
	if(A[0]==B[0])printf("H\n");
	else printf("D\n");
}

Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
   int r;
   cin >> r;
   cout << r*r <<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;
ll n,m,l,a,b,c,x,y;
bool h;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int arr[3][3];
  b=200;
  fr(i,9){
 cin>>a;
  arr[i%3][i/3]=a;
  b=min(b,a);
  }
  fr(i,9){
  arr[i%3][i/3]-=b;
  if(arr[i%3][i/3]==0){
    x=i%3;
    y=i/3;
  }
  }
  fr(i,9){
    if(arr[i%3][i/3]!=arr[x][i/3]+arr[i%3][y]){
      h=1;
    }
  }
  if(!h)cout<<"Yes";
  else cout<<"No";
}  

Measured memory_bytes: 256
b = input()

if b == ('A'):
    print('T')

elif b == ('C'):
    print('G')

elif b == ('G'):
    print('C')

elif b == ('T'):
    print('A')

else:
    print('入力に誤りがあります。A,C,G,Tのいずれかを入力して下さい。')

Measured memory_bytes: 8992
#include<stdio.h>

#define N 100

int main(){
  char s[100];
  int n, noStrongKaibun=0;
  scanf("%s",&s);
  n = strlen(s);
//  printf("%d",n);
  
  for(int i=0; i<n-i-1 ;i++){
    if(s[i]!=s[n-i-1]){
      noStrongKaibun=1;
      break;
    }
  }
  
  for(int i=0; i<(n-3)/2-i ;i++){
    if(s[i]!=s[(n-3)/2-i]){
      noStrongKaibun=1;
      break;
    }
  }
  
  for(int i=0; (n+1)/2+i<n-i-1 ;i++){
    if(s[(n+1)/2+i]!=s[n-i-1]){
      noStrongKaibun=1;
      break;
    }
  }
  
  if(noStrongKaibun==1)
    printf("No");
  else
    printf("Yes");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] al = new int[N+1];
        int[] bl = new int[N+1];
        int[] cl = new int[N+1];

        for (int i = 1; i <= N; i++) {
            al[i] = sc.nextInt();
            bl[i] = sc.nextInt();
            cl[i] = sc.nextInt();
        }

        int[][] dp = new int[N+1][3];

        dp[0][0]  = 0;
        dp[0][1]  = 0;
        dp[0][2]  = 0;
        for (int i = 1; i <= N; i++) {
            dp[i][0] =  Math.max(dp[i-1][1], dp[i-1][2]) + al[i];
            dp[i][1] =  Math.max(dp[i-1][0], dp[i-1][2]) + bl[i];
            dp[i][2] =  Math.max(dp[i-1][0], dp[i-1][1]) + cl[i];            
        }
        System.out.println(Math.max(Math.max(dp[N][0], dp[N][1]), dp[N][2]));

    }
}

Measured memory_bytes: 93724
#include<bits/stdc++.h>
using namespace std;
const int maxn=25;
int n,m,ans=0;
int step[maxn][maxn];
char grid[maxn][maxn];
queue<pair<int,int> > q;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
void init(int x,int y)
{
	for(int i=0;i<maxn;i++)
	{
		for(int j=0;j<maxn;j++)
		{
			step[i][j]=1e9;
		}
	}
	step[x][y]=0;
	while(!q.empty())
	{
		q.pop();
	}
	q.push(make_pair(x,y));
}
bool isvalid(int x,int y)
{
	return x>=0&&x<n&&y>=0&&y<m&&step[x][y]==1e9&&grid[x][y]=='.';
}
void BFS(int x,int y)
{
	init(x,y);
	while(!q.empty())
	{
		pair<int,int> t=q.front();
		int nx=t.first,ny=t.second;
		q.pop();
		for(int i=0;i<4;i++)
		{
			int tx=nx+dx[i],ty=ny+dy[i];
			if(isvalid(tx,ty))
			{
				step[tx][ty]=step[nx][ny]+1;
				q.push(make_pair(tx,ty));
			}
		}
	}
}
int FindMax()
{
	int mx=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(step[i][j]!=1e9)
				mx=max(mx,step[i][j]);
		}
	}
	return mx;
} 
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%s",grid[i]);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(grid[i][j]=='#')
				continue; 
			BFS(i,j);
			ans=max(ans,FindMax());
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	long long int n, total = 0;
	scanf("%lld", &n);
	for (int i = 1 ; i <= n; i++)
	{
		if( i % 3 != 0 && i % 5 != 0)
		{
			total += i;
			
		}
	}
	printf("%lld", total);
	return 0;
	
}


Measured memory_bytes: 1736
n=int(input())
ans=float("INF")
for i in range(n+1):
  d=0
  temp=i
  while (temp>0):
    d+=temp%6
    temp//=6
  temp=n-i
  while(temp>0):
    d+=temp%9
    temp//=9
  ans=min(d,ans)
print(ans)

Measured memory_bytes: 40940
#A 

$in_N = <STDIN>;
$in_int_N = int($in_N);
$ans = 0;

if(($in_int_N % 2) == 1){
    $ans = ($in_int_N - 1) / 2;
}else{
    $ans = ($in_int_N / 2) - 1;
}
print "$ans\n";





Measured memory_bytes: 640
word_l = input().split()
dic = {}

for w in word_l:
    try:
        dic[w] += 1
    except:
        dic[w] = 1

l_w = max(word_l, key=len)
p_w = max(dic.items(), key=lambda x:x[1])
print(p_w[0], l_w)



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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	string s; cin >> s;
	int q; cin >> q;
	int rev = 0;
	string f,b;

	rep(i, q){
		int p; cin >> p;
		if(p == 1) rev ++;
		else{
			int a; string c; cin >> a >> c;
			if((rev+a)%2) f += c;
			else b += c;
		}
	}
	if(rev%2){
		reverse(b.begin(), b.end());
		reverse(s.begin(), s.end());
		cout << b << s << f << endl;		
	}else{
		reverse(f.begin(), f.end());
		cout << f << s << b << endl;
	} 
	
}

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

#define rep(i,n) for(i=0;i<(n);i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int i,j;
  int N,D,X; cin >> N >> D >> X;
  int A[N]; rep(i,N){cin >> A[i];}
  rep(i,N){
      for(j=1;j<=D;j+=A[i]){
          X++;
      }
  }
  cout << X << endl;

  return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

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

        // 入力(sPre)
        String sPre = sc.next();
        // 入力(s)
        String s = sc.next();
        // 入力(sPost)
        String sPost = sc.next();

        System.out.println(String.format("A%sC", s.charAt(0)));
        sc.close();
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
#include<math.h>

int main()
{
    int a;
    scanf("%d",&a);
    while(a<1 || a>10)
    {
        printf("Wrong input\n");
        scanf("%d",&a);
    }
    printf("%d",(int)(a+pow(a,2)+pow(a,3)));
    return 0;
}

Measured memory_bytes: 2576
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,s;
  string san[11];
  san[0]="0111111"; 
  san[1]="0000110";
  san[2]="1011011";
  san[3]="1001111";
  san[4]="1100110";
  san[5]="1101101";
  san[6]="1111101";
  san[7]="0100111";
  san[8]="1111111";
  san[9]="1101111";
  while(cin>>n){
    if(n==-1) break;
    string mem="0000000";
    for(int i=0;i<n;i++){
      cin >> s;
      string a;
      for(int i=0;i<7;i++){
	if(san[s][i]==mem[i]) a += '0';
	  else a += '1';
	}
      cout << a << endl;
      mem = san[s];
    }
  }
  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main{

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

        // input
        int dmy = scan.nextInt();
        int index = scan.nextInt() - 1;
        char[] input = scan.next().toCharArray();
        switch(input[index]){
            case 'A':
                input[index] = 'a';
                break;
            case 'B':
                input[index] = 'b';
                break;
            case 'C':
                input[index] = 'c';
                break;
        }

        // answer
        for(int i = 0; i < input.length; i++){
            System.out.print(input[i]);
        }
        System.out.println("");


    }
}

Measured memory_bytes: 23764
module Station
  sub Main(ByVal args() as String)
	dim a,b as integer    
    dim arr as string
	arr=Console.ReadLine()
    b=0
for a = 0 to 2
    if arr(a)="A"c then
    b=b+1
    else
    b=b+2
end if
next

if b mod 3 = 0 then
Console.WriteLine("No")
else
Console.WriteLine("Yes")
end if
end sub
end module

Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;

int main(){
	int x[100];
	int y[100];
	int z[100];
	int n, i, j, hi;
	bool top;
	string a, b;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		// initialize
		for(j=0; j<100; j++){
			x[j] = 0;
			y[j] = 0;
			z[j] = 0;
		}
		cin >> a;
		cin >> b;
		if(a.length() > 80 || b.length() > 80){
			cout << "overflow" << endl;
			continue;
		}
		for (j = 0; j < a.length(); j++){
			x[j] = atoi(a.substr(a.length()-1-j, 1).c_str());
		}
		for (j = 0; j < b.length(); j++){
			y[j] = atoi(b.substr(b.length()-1-j, 1).c_str());
		}
		
		hi = 0;
		for(j=0; j<80; j++){
			z[j] = x[j] + y[j] + hi;
			if(z[j] > 9){
				hi = 1;
				z[j] -= 10;
			}else{
				hi = 0;
			}
		}
		if(hi == 1){
			cout << "overflow" << endl;
		}else{
			top = false;
			for (j = 79; j > -1; j--) {
				if(z[j] == 0 && !top && j != 0){
					continue;
				}else{
					top = true;
					cout << z[j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;

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

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

	int ans = 0;
	bool f = false;
	int next = 0;
	while (ans < n) {
		next = a[next];
		ans++;

		if (next == 1) {
			f = true;
			break;
		}
	}

	if (f) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

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

int main(){
	int n,c=1;
  	string s;
  cin >> n >> s;
  
  rep(i,(n-1))
	if(s[i]!=s[i+1])
      	c+=1;
  cout << c;
      
	return 0;}

Measured memory_bytes: 512
import math

def judge_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

x = int(input())
while True:
  if judge_prime(x):
    print(x)
    exit()
  else:
    x += 1



Measured memory_bytes: 2940
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

alias Pair = Tuple!(long, "p", int, "r");

void main() {
    int n;
    scan(n);

    auto x = new long[](n + 1);
    auto s = new int[](n + 1);

    foreach (i ; 1 .. n + 1) {
        scan(x[i], s[i]);
    }

    auto mh = new BinaryHeap!(Array!Pair)();
    long d;
    long p = s[1];
    long ans = p;

    mh.insert(Pair(s[1], 1));

    foreach (i ; 2 .. n + 1) {
        p += s[i] - (x[i] - x[i-1]);
        mh.insert(Pair(p, i));
        ans = max(ans, p);
    }

    foreach (i ; 1 .. n) {
        d += x[i + 1] - x[i] - s[i];

        while (mh.front.r <= i) {
            mh.popFront();
        }

        debug {
            writeln(d);
            writeln(mh.front);
        }

        ans = max(ans, mh.front.p + d);
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 8636
#include <iostream>
using namespace std;
int main(void){
    
    string S;
    cin >> S;
    
    for(int i = 1; i < S.size(); i++){
        if(S[i-1] == S[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

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

#ifdef PRINTERS
#include "printers.hpp"
using namespace printers;
#define tr(a)		cerr<<#a<<" : "<<a<<endl
#else
#define tr(a)    
#endif

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N,A,B;
	cin>>N>>A>>B;
	if(abs(B-A)%2==0)cout<<"Alice";
	else cout<<"Borys";
}

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

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

using namespace std;

int main()
{
    int n, h;
    int m = -1;
    int cnt = 1;
    cin >> n;
    int array[n];

    for (size_t i = 0; i < n; i++)
    {
        cin >> array[i];
    }
    for (size_t i = 1; i < n; i++)
    {
        if(m < array[i]){
            m = array[i];
        }
        if(array[0] <= array[i] && m <= array[i]){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	long long N;
	scanf("%lld",&N);
	long long n=sqrt(N);
	if((n+1)*(n+1)<=N)n++;
	long long ans=N;
	for(int i=1;i<=n;i++)if(N%i==0){
		ans=min(ans,i+N/i-2);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {
    public static void main(String[] args) {
        new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        long ans = 0;
        if((b - a) % 2 == 0) ans = (b - a) / 2;
        else ans = (b - 1) > (n - a) ? (2 * n - a - b + 1) / 2 : (a + b - 1) / 2;

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k,x,i,a,flag;
    i=a=flag=0,n=5,k=10;
    int arr[n];
    while(i<n) {
      cin>>x;
      arr[i]=x%10;
      while(x%10)
        x--;
      a+=x;
      i++;
    }
    sort(arr,arr+n);
    i=0;
    while(i<n) {
      if(arr[i]>0 && flag==0) {
        flag=1;
        a+=arr[i];
      }
      else if(arr[i]>0)
        a+=10;
      i++;
    } 
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
def partition(a, p, r)
  x = a[r]
  i = p - 1
  p.upto(r-1){|j|
    if a[j] <= x then
      i += 1
      a[i], a[j] = a[j], a[i]
    end
  }
  a[i+1], a[r] = a[r], a[i+1]
  return i+1
end

n = gets.to_i
arr = gets.split.map(&:to_i)

idx = partition(arr, 0, n-1)
arr[idx] = sprintf "[%d]", arr[idx]
puts arr.join(" ")

Measured memory_bytes: 17108
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,a,b,c,INF=1000000000;
vector<ll> node,lazy,v;
void ini(ll n){
    m=1;
    while(m<n)m*=2;
    node.resize(2*m-1,0);
    lazy.resize(2*m-1,0);
    //for(int i=n+m-1;i<2*m-1;i++)node[i]=INF;
    //for(int i=m-2;i>=0;i--)node[i]=min(node[2*i+1],node[2*i+2]);
    return ;
}
void eval(ll k,ll l,ll r){
    if(lazy[k]!=0){
        node[k]+=lazy[k];
        if(r-l>1){
            lazy[2*k+1]+=lazy[k];
            lazy[2*k+2]+=lazy[k];
        }
        //else node[k]+=lazy[k];
        lazy[k]=0;
    }
    return ;
}
void add(ll a,ll b,ll x,ll k,ll l,ll r){
    eval(k,l,r);
    if(r<=a||b<=l)return ;
    if(a<=l&&r<=b){
        lazy[k]+=x;
        eval(k,l,r);
    }
    else{
        add(a,b,x,2*k+1,l,(r+l)/2);
        add(a,b,x,2*k+2,(r+l)/2,r);
        node[k]=min(node[2*k+1],node[2*k+2]);
    }
    return ;
}
ll getsum(ll a,ll b,ll k,ll l,ll r){
    if(a>=r||l>=b)return INF;
    eval(k,l,r);
    if(a<=l&&r<=b)return node[k];
    ll vl=getsum(a,b,2*k+1,l,(r+l)/2);
    ll vr=getsum(a,b,2*k+2,(r+l)/2,r);
    return min(vr,vl);
}
int main(void){
    cin>>n>>k;
    ini(n);
    for(int i=0;i<k;i++){
        cin>>a;
        if(a==0){
            cin>>a>>b>>c;
            add(a,b+1,c,0,0,m);
        }
        else{
            cin>>a>>b;
            cout<<getsum(a,b+1,0,0,m)<<endl;;
        }
        /*for(int i=0;i<2*m-1;i++){
            if(i==7)cout<<"||";
            cout<<node[i]<<"-"<<lazy[i]<<" ";
        }
        cout<<endl;*/
    }
}



Measured memory_bytes: 7028
//
// Created by maze on 2019/11/03.
//

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

#define INF_LL (int64)le18
#define INF (int32)le9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(), x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename M>
class FenwickTree {
public:
  using value_type = typename M::value_type;
  using size_type = size_t;

private:
  vector<value_type> tree;
  size_type N;

  static value_type calc(const value_type& a, const value_type& b) {
    return M::operation(a, b);
  }

public:
  FenwickTree() {}
  FenwickTree(const size_type& N) :N(N+10), tree(N+11, M::identity()) {}

  void update(size_type k, const value_type& diff) {
    for (; k <= N; k+= k & -k) {
      tree[k] = calc(tree[k], diff);
    }
  }

  value_type query(size_type k) const {
    value_type res = M::identity();
    for (; k > 0; k -= k & -k) {
      res = calc(res, tree[k]);
    }
    return res;
  }

  void updatez(size_type k, value_type v) {
    update(k+1, v);
  }

  value_type queryz(size_type k) const {
    return query(k);
  }
};

class v_monoid {
public:
  using value_type = int64;
  static value_type identity() { return 0; }
  static value_type operation(const value_type& a, const value_type& b) {
    return a + b;
  }
};

int main() {
  int64 n;
  cin >> n;
  vector<PII> a(n);
  REP(i, n) {
    cin >> a[i].fs; a[i].sc = i;
  }
  int64 res = 0;
  sort(all(a));

  FenwickTree<v_monoid> bitl(n+1), bitr(n+1);
  REP(i, n) {
    int64 now = a[i].fs;
    vector<PII> vs;
    while (i < n && a[i].fs == now) {
      vs.push_back(a[i++]);
    }
    i--;
    int64 l = 0, r = vs.size();
    while (l != r) {
      int64 costl = vs[l].sc - bitl.queryz(vs[l].sc) - bitr.queryz(vs[l].sc);
      int64 costr = (n - vs[r-1].sc - 1) - (bitl.queryz(n+1) + bitr.queryz(n+1)
        - bitl.queryz(vs[r-1].sc) - bitr.queryz(vs[r-1].sc));
//      cout << bitl.queryz(n+1) << " " << bitr.queryz(n+1) << " " << bitl.queryz(vs[r-1].sc) << " " << bitr.queryz(vs[r-1].sc) << endl;
//      cout << l << " " << r << ": " << costl << " " << costr << endl;
      if (costl <= costr) {
        res += costl;
        bitl.updatez(vs[l].sc, 1);
        l++;
      } else {
        res += costr;
        bitr.updatez(vs[r-1].sc, 1);
        r--;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 7980
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, a, _min = 1000, _max = 0;
    cin >> N;
    REP(i, N) {
        cin >> a;
        amin(_min, a);
        amax(_max, a);
    }
    cout << _max - _min << endl;
    return 0;
}


Measured memory_bytes: 256
#
# abc067 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 3
1 2 3 4 5"""
        output = """12"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """15 14
50 26 27 21 41 7 42 35 7 5 5 36 39 1 45"""
        output = """386"""
        self.assertIO(input, output)


def resolve():
    N, K = map(int, input().split())
    l = list(map(int, input().split()))
    l.sort(reverse=True)
    ans = 0
    for i in range(K):
        ans += l[i]
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16268
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> ans(n-1,0);
    int i,j;
    for(i = 0;i < n-1;++i){
        vector<bool> temp1(123,false);
        vector<bool> temp2(123,false);
        for(j = 0;j <= i;++j){
            temp1.at((int)s.at(j)) = true;
        }
        for(j = i+1;j < n;++j){
            temp2.at((int)s.at(j)) = true;
        }
        for(j = 0;j < 123;++j){
            if(temp1.at(j) && temp2.at(j)){
                ++ans.at(i);
            }
        }
    }
    int max = ans.at(0);
    for(i = 0;i < s.size()-1;++i){
        if(max < ans.at(i)){
            max = ans.at(i);
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;


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

    int sz=s.size();

    for(int i=0;i<sz;i++)
    {
        cout<<"x";
    }

    return 0;
}

/*

*/




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

bool is_prime(int n) {
  for (int i=2; i<=sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  int n;
  cin>>n;
  vector<int> v;
  for (int i=3; i<=55555; i+=2) {
    if (i % 5 == 1 && is_prime(i)) {
      v.push_back(i);
    }
    if (v.size() == n) {
      break;
    }
  }
  for (int i=0; i<n; i++) {
    cout<<v[i];
    if (i != n - 1) {
      cout<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int mod=1e9+7;
const int N=2e5+3;
int f[N],inv[N];
int ncr(int n,int r)
{
	if(n<r)return 0;
	int res=inv[r]*f[n];
	res%=mod;
	res*=inv[n-r];
	res%=mod;
	return res;
}
int modp(int a,int b)
{
	if(b==0)return 1;
	int u=modp(a,b/2);
	u=(u*u)%mod;
	if(b&1)return (a*u)%mod;
	return u;
}
int32_t main()
{	
	#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
	#endif
	f[0]=1;
	for(int i=1;i<N;i++)f[i]=(f[i-1]*i)%mod;
	inv[N-1]=modp(f[N-1],mod-2);
	for(int i=N-2;i>=0;i--)inv[i]=(inv[i+1]*(i+1))%mod;
	int n,m;
	cin>>n>>m;
	vector<int> p;
	int cur=0;
	while(m%2==0){m/=2;cur++;}
	if(cur){p.push_back(cur);cur=0;}
	
	for(int i=3;i<=sqrt(m);i+=2)
	{
		cur=0;
		while(m%i==0){m/=i;cur++;}
		if(cur){p.push_back(cur);cur=0;}
	}
	if(m>1)p.push_back(1);
	int ans=1;
	for(int x:p)
	{
		int tmp=ncr(n+x-1,x);
		ans*=tmp;
		ans%=mod;
	}
	cout<<ans;


}


Measured memory_bytes: 6832
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};


int main() {

    string S; cin >> S;

    bool is_C = 0, is_C_and_F = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'C') is_C = 1;
        else if (S[i] == 'F') 
            if (is_C == 1) 
                is_C_and_F = 1;
    }

    if (is_C_and_F) cout << "Yes\n";
    else cout << "No\n";

}


Measured memory_bytes: 256
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    ll k;
    cin>>k;


    queue<string> q;

    for(int i = 1; i < 10; i++)
    {
        q.push(to_string(i));
    }


    while(!q.empty())
    {
        string p = q.front();
        q.pop();
        k--;
        if(k == 0)
        {
            cout<<p;
            return 0;
        }

        int x = (p.back()-'0');

        string s;
        if(x > 0)
        {
            s = to_string(x-1);
            q.push(p+s);
        }
        s = to_string(x);
        q.push(p+s);
        if(x < 9)
        {
            s = to_string(x+1);
            q.push(p+s);
        }
    }









    return 0;
}

Measured memory_bytes: 13824
import java.util.*;

public class Main{
	public static String[] solve(int h, int m, int s){
		int hour = 2-h;
		int minute = -m;
		if( minute < 0 ){
			minute += 60;
			hour--;
		}
		int second = -s;
		if( second < 0 ){
			second += 60;
			minute--;
			if( minute < 0 ){
				minute += 60;
				hour--;
			}
		}
		String H = "0"+Integer.toString(hour);
		String M = ( minute < 10 ) ? "0"+Integer.toString(minute) : Integer.toString(minute);
		String S = ( second < 10 ) ? "0"+Integer.toString(second) : Integer.toString(second);
		
		int hour3 = 3*hour;
		int minute3 = 3*minute;
		while( minute3 >= 60 ){
			minute3 -= 60;
			hour3++;
		}
		int second3 = 3*second;
		while( second3 >= 60 ){
			second3 -= 60;
			minute3++;
		}
		while( minute3 >= 60 ){
			minute3 -= 60;
			hour3++;
		}
		String H3 = "0"+Integer.toString(hour3);
		String M3 = ( minute3 < 10 ) ? "0"+Integer.toString(minute3) : Integer.toString(minute3);
		String S3 = ( second3 < 10 ) ? "0"+Integer.toString(second3) : Integer.toString(second3);
		String ans1 = H + ":" + M + ":" + S;
		String ans2 = H3 + ":" + M3 + ":" + S3;
		String[] ans = new String[2];
		ans[0] = ans1; ans[1] = ans2;
		return ans;
	}
		
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<String[]> result = new ArrayList<String[]>();
		
		int h = stdIn.nextInt(), m = stdIn.nextInt(), s = stdIn.nextInt();
		while( h != -1 || m != -1 || s != -1 ){
			result.add(solve(h,m,s));
			h = stdIn.nextInt();
			m = stdIn.nextInt();
			s = stdIn.nextInt();
		}
		
		for(String[] ans : result){
			for(String str : ans){
				System.out.println(str);
			}
		}
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C084
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            List<int[]> list = new List<int[]>();
            for (int i = 0; i < N-1; i++)
            {
                int[] a0 = Console.ReadLine().Split(' ').Select(k => int.Parse(k)).ToArray();
                list.Add(a0);
            }

            List<int> xlist = new List<int>();
            for (int i = 0; i < N; i++)
            {
                int time = 0;
                int current = i;
                while (current < N - 1)
                {
                    int departTime = Math.Max(list[current][1], time);
                    int hasuu = departTime % list[current][2];
                    if (hasuu != 0)
                    {
                        departTime += list[current][2] - hasuu;
                    }

                    time = departTime + list[current][0];
                    current++;
                }
                xlist.Add(time);
            }


            foreach(int v in xlist)
            {
                Console.WriteLine(v);
            }
        }

    }
}


Measured memory_bytes: 13396
def main():
    import sys
    readline = sys.stdin.buffer.readline
    import collections

    n, q = map(int, readline().split())
    ab = [list(map(int, readline().split())) for _ in range(n-1)]
    px = [list(map(int, readline().split())) for _ in range(q)]

    c = [[] for _ in range(n)]
    for a, b in ab:
        a, b = a-1, b-1
        c[a].append(b)
        c[b].append(a)

    point = [0] * n
    for p, x in px:
        point[p-1] += x

    parents = [0] * n
    ans = [0] * n
    q = collections.deque()
    q.append(0)
    while q:
        v = q.pop()
        ans[v] = ans[parents[v]] + point[v]
        for i in c[v]:
            if i == parents[v]:
                continue
            parents[i] = v
            q.append(i)
    print(' '.join(list(map(str, ans))))

main()

Measured memory_bytes: 177860
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int a, b;
  cin >> a >> b;
  P(a * b - (a + b - 1));
  return 0;
}



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

using namespace std;

int main(){

  string s;
  bool e=1;
  
  cin>>s;
  
  for(int i=0; i < s.length();i++){
  	if(i%2==0){//奇数番目
    	if(!(s.at(i)=='R'||s.at(i)=='U'||s.at(i)=='D')){
      	e=0;
      	break;
    	}
    }
    else {//偶数番目
    	if(!(s.at(i)=='L'||s.at(i)=='U'||s.at(i)=='D')){
      	e=0;
      	break; 
    	}
 	 }
  }
  if(e==1) cout<<"Yes"<<endl;
  else{ cout<<"No"<<endl;}
    
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define ll long long

const int MAXN = (int)3e5 + 5;

int h[MAXN], dp[MAXN];

int main(){
    int n,k;cin >> n >> k;
    for (int i = 1;i <= n;i ++) {
        cin >> h[i];
        dp[i] = int(2e9);
    }
    dp[1] = 0;
    for (int i = 2;i <= n;i ++) {
        for (int j = 1;j <= k;j ++) {
            int prev_pos = i - j;
            if (prev_pos <= 0) continue;
            dp[i] = min(dp[i], abs(h[i] - h[prev_pos]) + dp[prev_pos]);
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int n;
  cin >> n;
  n %= 10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    cout << "hon\n";
  }
  else if(n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon\n";
  }
  else {
    cout << "bon\n";
  }
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; 
  for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
    sol();
  }
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int power(int x)
{
	return x * x;
}
int main()
{
	int N, a[110];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = mod, num = 0;
	for (int i = -100; i <= 100; i++) {
		num = 0;
		for (int j = 0; j < N; j++) {
			num += power(a[j] - i);
		}
		if (num < ans) {
			ans = num;
		}
	}
	cout << ans << endl;
}


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

def solve():
    N, D = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        x, y = list(map(int, input().split()))
        d = (x**2+y**2)**(1/2)
        if d <= D:
            ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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)*}
    };
}

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! {
        n: u32,
    };
    println!(
        "{}",
        (1..n)
            .map(|x| x
                .to_string()
                .chars()
                .map(|y| y.to_digit(10).unwrap())
                .sum::<u32>()
                + (n - x)
                    .to_string()
                    .chars()
                    .map(|y| y.to_digit(10).unwrap())
                    .sum::<u32>())
            .min()
            .unwrap()
    );
}


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

using namespace std;
typedef long long LL;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  rep(i,B){
    if(A*(i+1)%B==C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int cnt[MAXN];

void solve(){
	int n, a, mx, mn;
	scanf("%d", &n);
	mx = 0;
	mn = INF;
	REP(i, 0, n){
		scanf("%d", &a);
		cnt[a]++;
		mx = max(mx, a);
		mn = min(mn, a);
	}
	if (cnt[mx] == 1){
		printf("Impossible\n");
		return;
	}
	if (mn * 2 < mx || mn * 2 > mx + 1){
		printf("Impossible\n");
		return;
	}
	if (mn * 2 == mx && (cnt[mn] != 1 || cnt[mn + 1] == 1)){
		printf("Impossible\n");
		return;
	}
	if (mn * 2 == mx + 1 && cnt[mn] != 2){
		printf("Impossible\n");
		return;
	}
	for(int i = mx - 1; i > mn; i--){
		if (cnt[i] <= 1){
			printf("Impossible\n");
			return;
		}
	}
	printf("Possible\n");
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Array

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [h,w,k] <- getIntList
    cs <- array ((1,1),(h,w)) . zip [(i,j)|i <- [1..h], j <- [1..w]] . filter (/= '\n') <$> getContents
    let htfs = sequence $ replicate h [False, True]
    let wtfs = sequence $ replicate w [False, True]
    let count cs htf wtf = length $ filter (== '#') [ cs ! (i,j) | i <- [1..h], j <- [1..w], htf !! (i-1), wtf !! (j-1)]
    let ans = length $ filter (== k) [count cs htf wtf| htf <- htfs, wtf <- wtfs]
    print ans

Measured memory_bytes: 3920
#include<vector>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define il inline
using namespace std;
typedef long long ll;
const int maxn=8010,inf=2e8;
il int gi ( ){
    int o=0,fl=1;
    char ch=getchar();
    while(!isdigit(ch))fl^=ch=='-',ch=getchar();
    while(isdigit(ch))o=o*10+ch-'0',ch=getchar();
    return fl?o:-o;
}
vector<int>p[maxn];
char s[maxn];
int f[maxn],v[maxn],dp[maxn],n;
il void dfs(int x){
    for(int i=0;i<p[x].size();i++)dfs(p[x][i]);
    memset(dp,0x3f,sizeof(dp));dp[0]=0;
    for(int ii=0;ii<p[x].size();ii++){
        int k=p[x][ii];
        for(int i=v[x];~i;--i){
            int tmp=inf;
            if(i>=v[k])tmp=min(tmp,dp[i-v[k]]+f[k]);
            if(i>=f[k])tmp=min(tmp,dp[i-f[k]]+v[k]);
            dp[i]=tmp;
        }
    }
    for(int i=v[x];i>=0;i--)
        f[x]=min(f[x],dp[i]);
    return;
}
int main(){
	n=gi();
	for(int i=2;i<=n;++i)p[gi()].push_back(i);
	for(int i=1;i<=n;++i)v[i]=gi(),f[i]=2e9;
	dfs(1);
	if(f[1]==inf)printf("IM");
	puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int i,N,A[100],j,count=0,tmp,min=0;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]); 
  }
  for(i=0;i<N-1;i++){
    min =i;
    for(j=i;j<N;j++){
      if(A[j] < A[min]){
	min =j;
      }
     }
    if(min != i) count++;
    
    tmp = A[i];
    A[i] = A[min];
    A[min] = tmp;
  }
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604