akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        int len = s.length();
        if(k >= len){
            System.out.println(s);
        }else{
            System.out.println(s.substring(0,k)+"...");
        }
    }
    
    private static double toRadians(double deg)
    {
        return deg * Math.PI / 180.0;
    }
}
 
class Point{
    int cnt,x,y;
    public Point(int cnt, int y, int x){
        this.cnt = cnt;
        this.x = x;
        this.y = y;
    }
}
 
class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
 
    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
 
    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }
 
    public long nextLong() {
        return Long.parseLong(next());
    }
 
    public int nextInt() {
        return Integer.parseInt(next());
    }
 
    public double nextDouble() {
         return Double.parseDouble(next());
    }
 
    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }
 
    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main(){
	int coun = 0;
	int coun_2 = 0;
	int N;
	string a;
	cin>>a;
	cin>>N;
	for(int i = 0;i < N;i++){
		string ring;
		cin>>ring;
		ring += ring;
		for(int u = 0;u < ring.size();u++){
			if(ring[u] == a[coun_2]){
				coun_2++;
				if(coun_2 == a.size()){
					coun++;
					break;
				}
			}
			else{
				if(ring[u] == a[0])
					coun_2 = 1;
				else
					coun_2 = 0;
			}
		}
		coun_2 = 0;	
	}
	cout<<coun<<endl;
}

Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>

using namespace std;

int change(int a){
  int cc = 0;
  while(a>0){
    if (a%10>=5){
      cc++;
      a-=5;
    }
    cc+=a%10;
    a/=10;
  }
  return cc;
}

int main(){
  int p,n[6];
  int money[6] = {500,100,50,10,5,1};
  while(true){
    cin >> p;
    if (p==0)
      break;
    cin >>n[5] >>n[4] >>n[3] >>n[2] >>n[1] >>n[0]; 
    int count = 0;
    if (p/money[0]<=n[0]){
      count += p/money[0];
      n[0] -= p/money[0];
      p%=money[0];
    }
    else{
      count += n[0];
      p -= n[0]*money[0];
      n[0] = 0;
    }
    int min = 10000;
    int nn[6];
    int m,c;
    for(int i=p;i<=p+500;i++){
      m = i;
      c = 0;
      copy(n,n+6,nn);
      for(int j=0;j<6;j++){
	if (m/money[j]<=nn[j]){
	  c += m/money[j];
	  nn[j] -= m/money[j];
	  m %= money[j];
	}
	else{
	  c += nn[j];
	  m -= nn[j]*money[j];
	  nn[j] = 0;	
	}
      }
      if (m==0&&min>(c+count+change(i-p))){
	min = c+count+change(i-p);
      }
    }
    cout << min << endl;
  }
  return 0;
}

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

const int N = 100005;
int n, m, k, x, y, bk[N], kz[N], km;
vector<int> v[N], ve[N];

void sgd(int dg) {
	bk[dg] = km;
	++kz[km];
	for(int i = 0; i < v[dg].size(); ++i) {
		if(bk[v[dg][i]] == 0) {
			sgd(v[dg][i]);
		}
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> k;
	for(int i = 0; i < m; ++i) {
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(int i = 0; i < k; ++i) {
		cin >> x >> y;
		ve[x].push_back(y);
		ve[y].push_back(x);
	}
	for(int i = 1; i <= n; ++i) {
		km = i;
		if(bk[i] == 0) {
			sgd(i);
		}
	}
	for(int i = 1; i <= n; ++i) {
		int vms = kz[bk[i]] - (int)v[i].size() - 1;
		for(int mz : ve[i]) {
			if(bk[mz] == bk[i]) {
				--vms;
			}
		}
		cout << vms << " ";
	}
	return 0;
}


Measured memory_bytes: 12672
s=list(map(int,list(input())[::-1]))
n=len(s)
cnt=[0]*2019
cnt[0]+=1
c=0
for i in range(n):
  c+=s[i]*pow(10,i,2019)%2019
  cnt[c%2019]+=1
ans=0
for i in cnt:
  if i<=1:
    pass
  else:
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 12104
#!/usr/bin/env python3
import sys
import bisect


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    X, N = IL(int)
    if N > 0:
        P = IL(int)
        A = set(range(-2, 102)) - set(P)
    else:
        A = set(range(-2, 102))

    A = list(A)
    A.sort()
    i = bisect.bisect(A, X)
    print(min(A[i - 1: i + 1], key=lambda x: abs(X - x)))


solve()


Measured memory_bytes: 9172
#include <bitset>
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = 2005;
int a[N];
int BASE = N;

bitset <N * N> cb;

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i] );
        sum += a[i];
    }
    cb[0] = 1;
    for (int i = 0; i < n; i++)
        cb |= (cb << a[i] );
    sum = (sum + 1) / 2;
    while (!cb[sum])
        sum++;
    printf("%d\n", sum);


	return 0;
}



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

int main(void){
  string a, b;

  cin >> a >> b;

  if(a.size() > b.size()) cout << "GREATER" << endl;
  else if(a.size() < b.size()) cout << "LESS" << endl;
  else{
    if(a > b) cout << "GREATER" << endl;
    else if(a < b) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;

vector<vector<int>> nextIndex(const string &s){
    int n = s.length();
    vector<vector<int>> ret(n+1,vector<int> (26,n));
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) ret[i][j] = ret[i+1][j];
        ret[i][s[i]-'a'] = i;
    }
    return ret;
}


int main(){
    string s;cin >> s;
    int n = s.length();
    auto p = nextIndex(s);
    vector<int> dp(n+2,INF);
    vector<P> res(n+2,make_pair(',',n));
    dp[n+1] = 0;
    for (int i = n; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            int ni;
            if(i>=n) ni = n;else ni = p[i][j];
            if(dp[i] > dp[ni+1]+1){
                dp[i] = dp[ni+1]+1;
                res[i] = make_pair('a'+j,ni+1);
            }
        }
    }
    int indx = 0;
    string ans = "";
    for (int k = 0; k < dp[0]; k++) {
        ans += res[indx].fs;
        indx = res[indx].sc;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 30980
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	l, _ := strconv.Atoi(s)
	if l == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 1772
import math 
n,m=map(int,input().split())
x=list(map(int,input().split()))

a=[]

x.append(m)
x.sort()
for i in range(n):
    a.append(x[i+1]-x[i])
count=a[0]

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

for i in range(1,len(a)):
    count=gcd(count,a[i])
print(count)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
int A,B; cin>>A>>B;
int res=-1;


FOR(i,0,1010){
   //cout<<i<<':'<<(i*10)/100<<" "<<(i*8)/100<<endl;
  if((i*10)/100==B&&(i*8)/100==A){   
  	res=i;
    break;
   
  }
  
}
 if(res!=-1)
  cout << res << endl;
  else
    cout << "-1" << endl;


}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn calc_score(t: &Vec<usize>, c: &Vec<isize>, s: &Vec<Vec<isize>>) -> isize {
    let n = c.len();
    let d = t.len();
    let mut last = vec![0; n];
    let mut score = 0;
    for i in 0..d {
        let ti = t[i];
        score += s[i][ti];
        last[ti] = i + 1;
        for j in 0..n {
            score -= c[j] * (i + 1 - last[j]) as isize;
        }
    }
    score
}

fn main() {
    let n = 26;
    input! {
        d: usize,
        c: [isize; n],
        s: [[isize; n]; d],
        mut t: [Usize1; d],
        m: usize,
        dq: [(Usize1, Usize1); m],
    }
    // let mut score = calc_score(&t, &c, &s);
    for &(di, qi) in &dq {
        // let old = t[di];
        t[di] = qi;
        let new_score = calc_score(&t, &c, &s);
        // if new_score <= score {
        //     t[di] = old;
        // } else {
        //     score = new_score;
        // }
        println!("{}", new_score);
    }
}


Measured memory_bytes: 4440
#include<bits/stdc++.h> 
     
using namespace std ; 
     
long long n , m; 

vector<string> ans ; 

void solve(int i, string s){
    if(s[s.size()-1]>='a'+n)
        return  ; 
    if(i==n){
        ans.push_back(s) ; 
        return  ; 
    }
    char mx = 'a';
    set<char> c ; 
    for(auto u : s){
        mx = max(mx , u) ; 
        c.insert(u) ; 
    }
    mx++;
    if(mx < 'a'+n){
        c.insert(mx) ; 
    }
    for(auto u : c){
        solve(i+1 , s + char(u) ) ; 
    }
}


int main(){
   // freopen("in.in" , "r" , stdin ) ; 
    cin>>n; 
    solve(1 , "a");  
    
    for(auto u : ans){
        cout<<u<<"\n" ;
    }

    return 0 ; 
}

Measured memory_bytes: 7796
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    
    word = {}

    for s in S:
        if s not in word.keys():
            word[s] = 1
        else:
            word[s] = word[s] + 1

    max_n = max(word.values())

    max_w = [key for key in word.keys() if word[key] == max_n]

    max_w.sort()

    for st in max_w:
        print(st)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	int N;
	cin >> N;
	rep(i, N) {
		char C;
		cin >> C;
		if (C == 'Y') { co("Four"); return 0; }
	}
	
	co("Three");
	Would you please return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let A: u32 = read();
    let B: u32 = read();
    let C: u32 = read();
    let X: u32 = read();

    let mut count = 0;
    
    for a in 0..(A+1) {
        for b in 0..(B+1) {
            for c in 0..(C+1) {
                if a*500 + b*100 + c*50 == X {
                    count += 1;
                }
            }
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	int r, g;
	cin >> r >> g;
	cout << g + (g - r) << endl;
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

const ll INF = 1e+18;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> p(n);
	vector<ll> c(n);
	vector<bool> seen(n, false);
	rep(i, n) {
		cin >> p[i];
		p[i]--;
	}
	rep(i, n) cin >> c[i];
	ll ans = - INF;
	rep(i, n) {
		//サイクル成分に分ける。scoreに同一サイクル上で加算されるスコアをいれる。
		if (!seen[i]) {
			int id = i;
			vector<ll> score;
			while (1) {
				seen[id] = true;
				score.push_back(c[id]);
				id = p[id];
				if (id == i) break;
			}
			ll L = score.size();
			ll sum = 0;
			rep(j, L) sum += score[j];
			//サイクル内で始点と終点を全て試す。一周してスコアの和が正なら, できるだけ周回する。始点a,終点b
			for (int a = 0; a < L; ++a) {
				ll ab_length = 0; //始点と終点の距離
				ll ab_cost = 0; //
				for (int b = a + 1; b <= L + a; ++b) {
					ll temp = b % L;
					ab_cost += score[temp];
					ab_length++;
					if (ab_length > k) break;
					ll max_cost = ab_cost + max(sum, ll(0)) * ((k - ab_length) / L);
					ans = max(ans, max_cost);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3824
# include <iostream>
# include <vector>
# include <limits>
# include <algorithm>
using namespace std;

int main() {
	int p = numeric_limits<int>::max(), j = numeric_limits<int>::max();
	int a;
	for (int i = 0; i < 3; i++) {
		cin >> a;
		p = min(p, a);
	}
	for (int i = 0; i < 2; i++) {
		cin >> a;
		j = min(j, a);
	}
	cout << p + j - 50 << endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    int res{};
    REP( i, (int)S.size() )
    {
        S[ i ] == '+' ? res++ : res--;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [0]*m
x = [0]*m
for i in range(m):
    p[i],x[i] = map(int,input().split())

for j in range(m):
    print(sum(t)+x[j]-t[p[j]-1])

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  
  if(c<=a)
    cout<<"delicious"<<endl;
  
  else if(c>a){
    if(c-b<=a)
      cout<<"safe"<<endl;
    else if(c-b>a)
      cout<<"dangerous"<<endl;
  }
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N = int(readline())

stack = [3,5,7]
ans = 0

def isOk(x):
  s = str(x)
  for c in "357":
    if c not in s:
      return False
  return True
  
while stack:
  num = stack.pop()
  if num > N:
    continue
  if isOk(num):
    ans += 1
  for i in (3,5,7):
    stack.append(num * 10 + i)
  
print(ans)

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

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for (int i=0;i<N;i++)
		cin >> A.at(i);

	sort(A.begin(), A.end());

	cout << A.at(N-1) - A.at(0) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int Add(int a, int b){
    return a + b;
}

int Sub(int a, int b){
    return a - b;
}

int main(){
    int N, ans[4], count = 0, all = 0;
    scanf("%4d", &N);
    ans[3] = N % 10;
    ans[2] = (N / 10) % 10;
    ans[1] = (N / 100) % 10;
    ans[0] = (N / 1000) % 10;
    for(int i = 0; i < 8; i++){
        all = ans[0];
        for(int j = 0; j < 3; j++){
            if(j > 0){
                if((i / (j * 2)) % 2 == 0){
                    all = Add(all, ans[j + 1]);
                }else{
                    all = Sub(all, ans[j + 1]);
                }
            }else{
                if(i % 2 == 0){
                    all = Add(all, ans[j + 1]);
                }else{
                    all = Sub(all, ans[j + 1]);
                }
            }
        }
        if(all == 7){
            for(int j = 0; j < 3; j++){
                printf("%d", ans[j]);
                if(j > 0){
                    if((i / (j * 2)) % 2 == 0){
                        printf("+");
                    }else{
                        printf("-");
                    }
                }else{
                    if(i % 2 == 0){
                        printf("+");
                    }else{
                        printf("-");
                    }
                }
            }
            printf("%d=7\n", ans[3]);
            break;
        }
    }
}

Measured memory_bytes: 256
S=input()
a=0
for i in range(len(S)):
  b=0
  for j in range(i,len(S)):
    if S[j]=='A' or S[j]=='C' or S[j]=='G' or S[j]=='T':
      b+=1
    else:
      break
  if b>a:
    a=b
print(a)

Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))
count2 = len([0 for n in a if n % 2 == 0])
count4 = len([0 for n in a if n % 4 == 0])
count2 -= count4
print("Yes") if N - (2 * count4 + 1) <= 0 or N - (2 * count4) <= count2 else print("No")


Measured memory_bytes: 14252
#include <stdio.h>
int main(void){
	int n;
	scanf("%d",&n);
	int a[n];
	int i;
	int min = 1000000000;
	int max = 1;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if( min > a[i] ){
			min = a[i];
		}
		if( max < a[i] ){
			max = a[i];
		}
	}
		printf("%d",max-min);
		return 0;
}

Measured memory_bytes: 128
//#define __popcnt __builtin_popcount
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using ll = long long;
#define all(v) ((v).begin()),((v).end())
#define allr(v)	     ((v).rbegin()), ((v).rend())
#define sz(v) ((int)(v).size())
#define clr(v, d)        memset(v, d, sizeof(v))
const double PI = acos(-1.0);
template<class Int> Int __gcd(Int a, Int b) { return (b == 0 ? abs(a) : __gcd(b, a % b)); }
int dx[] = { 0,0,-1,1 };
int dy[] = { -1,1,0,0 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
}
const int N = 1e5 + 10;
vector<int>v;
map<pair<int, ll>, bool>mp;
bool solve(int idx, ll m) {
	if (idx == sz(v))
		return m == 0;
	//cout << idx << endl;
	if (mp.count({ idx,m }))
		return mp[{idx, m}];
	int ret = solve(idx + 1, m);
	ret |= solve(idx + 1, m + v[idx]);
	ret |= solve(idx + 1, m -= v[idx]);
	return mp[{idx, m}] = ret;
}
int main() {
	//cout << setprecision(4) << fixed;
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//file();
	//freopen("pocnitoare.in", "r", stdin);
	//freopen("pocnitoare.out", "w", stdout);
	//
	int n;
	cin >> n;
	vector<ll>v(n);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
		sum += v[i];
	}
	ll ans = 1e18;
	ll l = 0;
	for (int i = 0; i < n; i++) {
		sum -= v[i];
		l += v[i];
		ans = min(ans, abs(l - sum));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1920
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //日付を入力する
            string[] input = Console.ReadLine().Split(' ');
            string s = input[0];
            string t = input[1];

            //月が同じなら月末、それ以外は別
            Console.Write(t);
            Console.Write(s);
                
        }
    }

Measured memory_bytes: 11092
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private class Num implements Comparable<Num>{
		private int index = 0;
		private int num = 0;
		
		public Num(int index, int num) {
			this.index = index;
			this.num = num;
		}
		
		public boolean isEvenOrOdd(int evenOrOdd) {
			return (this.index % 2 == evenOrOdd);
		}

		@Override
		public int compareTo(Num o) {
			return Integer.compare(this.num, o.num);
		}
	}
	
	public long solve() {
		LinkedList<Num> list = new LinkedList<Num>();
		try (Scanner in = new Scanner(System.in)) {
			int N = in.nextInt();
			
			for (int i=0; i<N; i++) {
				list.addLast(new Num(i, in.nextInt()));
			}
		}
		list.sort(null);
		
		long count = 0;
		int index = 0;
		for (Num n : list) {
			if (n.isEvenOrOdd(index % 2) == false) {
				count++;
			}
			index++;
		}
		
		return count / 2;
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		System.out.println(main.solve());
	}
}

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

#define ll long long
#define pll pair<ll,ll> 

map<pll,ll> M;
ll func(ll A[],ll n,ll x){
	if(n<0)
		return INT_MAX;
	if(n==0)
		return abs(A[n]-x);
	
	if(!M.count({n,x})){
		M[{n,x}]=min(func(A,n-1,A[n])+abs(A[n]-x), func(A,n-2, A[n])+abs(A[n]-x));
	}
	return M[{n,x}];
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll n;
	cin>>n;
	ll A[n];
	M.clear();
	for(ll i=0;i<n;i++)
		cin>>A[i];
	cout<<func(A,n-1,0)-A[n-1];

}


Measured memory_bytes: 23036
using System;

namespace ABC088
{
    class C
    {
        static void Main(string[] args)
        {

            int[,] c = new int[3, 3];

            string[] input;
            for (int i = 0; i < 3; i++)
            {
                input = Console.ReadLine().Split();
                c[i, 0] = int.Parse(input[0]);
                c[i, 1] = int.Parse(input[1]);
                c[i, 2] = int.Parse(input[2]);
            }

            int[] a = new int[3];
            int[] b = new int[3];

            for (int i = 0; i <= Math.Max(Math.Max(c[0, 0], c[0, 1]), c[0, 2]); i++)
            {
                a[0] = i;
                for (int j = 0; j < 3; j++)
                {
                    b[j] = c[0, j] - a[0];
                }

                for (int j = 0; j <= Math.Max(Math.Max(c[1, 0], c[1, 1]), c[1, 2]); j++)
                {
                    if (c[1, 0] == j + b[0] && c[1, 1] == j + b[1] && c[1, 2] == j + b[2]) { a[1] = j; break; }
                    a[1] = -1;
                }

                for (int j = 0; j <= Math.Max(Math.Max(c[2, 0], c[2, 1]), c[2, 2]); j++)
                {
                    if (c[2, 0] == j + b[0] && c[2, 1] == j + b[1] && c[2, 2] == j + b[2]) { a[2] = j; break; }
                    a[2] = -1;
                }
            }

            if (0 <= a[1] && 0 <= a[2]) Console.WriteLine("Yes");
            else Console.WriteLine("No");

        }
    }
}


Measured memory_bytes: 11092
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]


up = [[0] * W for i in range(H)]  # あるマスから上に連続していくつ障害物のないマスが続くか
right = [[0] * W for i in range(H)]  # あるマスから右に連続していくつ障害物のないマスが続くか
down = [[0] * W for i in range(H)]  # あるマスから下に連続していくつ障害物のないマスが続くか
left = [[0] * W for i in range(H)]  # あるマスから左に連続していくつ障害物のないマスが続くか


# up
for w in range(W):
    for h in range(1, H):
        if G[h - 1][w] == '#':
            continue
        up[h][w] = up[h - 1][w] + 1

# right
for h in range(H):
    for w in reversed(range(W - 1)):
        if G[h][w + 1] == '#':
            continue
        right[h][w] = right[h][w + 1] + 1

# down
for w in range(W):
    for h in reversed(range(H - 1)):
        if G[h + 1][w] == '#':
            continue
        down[h][w] = down[h + 1][w] + 1

# left
for h in range(H):
    for w in range(1, W):
        if G[h][w - 1] == '#':
            continue
        left[h][w] = left[h][w - 1] + 1


ans = 0
for h in range(H):
    for w in range(W):
        if G[h][w] == '#':
            continue
        ans = max(ans, up[h][w] + right[h][w] + down[h][w] + left[h][w] + 1)

print(ans)


Measured memory_bytes: 359524
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

def main():
	N, K = MAP()
	A = LIST()

	for i in range(K, N):
		if A[i-K] < A[i]:
			print("Yes")
		else:
			print("No")

if __name__ == '__main__':
	main()



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

using namespace std;
using ll = long long;

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<ll, ll>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    ll x = a[0].first, y = a[0].second;
    for (int i = 1; i < n; i++) {
        ll n = max((x + a[i].first - 1LL) / a[i].first, (y + a[i].second - 1LL) / a[i].second);
        x = a[i].first * n;
        y = a[i].second * n;
    }
    cout << x + y << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
 
int main(int argc, char const *argv[])
{
	int d;
	cin >> d;

	if(d==22) cout << "Christmas Eve Eve Eve" << endl;
	if(d==23) cout << "Christmas Eve Eve" << endl;
	if(d==24) cout << "Christmas Eve" << endl;
	if(d==25) cout << "Christmas" << endl;
	return 0;
}

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

using namespace std;

vector<int> D;

int get(int x) {
  return x == D[x] ? x : D[x] = get(D[x]);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  D.assign(N, 0);
  vector<pair<int, int>> A(N), B(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i] = make_pair(a, i);
    D[i] = i;
  }
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    B[i] = make_pair(b, i);
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  int swap = 0;
  for (int i = 0; i < N; i++) {
    if (A[i].first > B[i].first) {
      cout << "No" << '\n';
      return 0;
    }
    int x = get(A[i].second), y = get(B[i].second);
    if (x != y) {
      swap++;
      D[x] = y;
    }
  }

  if (swap <= N - 2) {
    cout << "Yes" << '\n';
    return 0;
  }

  for (int i = 1; i < N; i++) {
    if (A[i] <= B[i - 1]) {
      cout << "Yes" << '\n';
      return 0;
    }
  }

  cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    char k;
    cin>>a;
    string b="";
    for(int i=a.length()-1;i>=0;i--)
    {
        k=a[i];
        switch(k)
        {
            case 'b':b+="d";break;
            case 'd':b+="b";break;
            case 'p':b+="q";break;
            case 'q':b+="p";break;
        }
    }
    if(a==b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  
  long long ans=0;
  
  ans +=min(a,k);
  
  if(b<k-a) ans -=min(k-a-b,c);
  
  cout << ans << endl;
  return 0;
}


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

int main (void)
{
    unsigned long n, i, m; 
    unsigned long a[200000] = {0};

    scanf("%lu", &n);

    for (i = 1; i < n; i++) {
        scanf("%lu", &m);
        a[m-1]++;
    }

    for (i = 0; i < n; i++) {
        printf("%lu\n", a[i]);
    }

    return 0;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     sd                  " "
#define     nl                  "\n"
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IOS()               ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     siz(a)              sizeof(a)/sizeof(a[0])
#define     out(a)              for (auto i: a) cout<<i<<" "; cout<<"\n"
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     itos(a)             to_string(a)
#define     ctoi(a)             int(a)-48
#define     setd(val,n)         cout<<fixed;cout<<setprecision(n)<<val<<"\n"

ll mod(ll a){return ((a%MOD)+MOD)%MOD;}

ll fpow(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%MOD;
        base=(base*base)%MOD;
        expo>>=1;}
    return res;}

ll modinv(ll a){return mod(fpow(mod(a), MOD-2));}

void solve(){
    int n;cin>>n;
    cout<<pow(n,3)<<nl;
}

signed main() { 
    IOS();

    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
} 


Measured memory_bytes: 384
import static java.util.Arrays.deepToString;
import static java.util.Arrays.fill;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = sc.nextInt();
			int res = 0;
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					if (a[i] > a[j]) res++;
				}
			}
			System.out.println(res);
		}
	}
}

Measured memory_bytes: 20916
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

type vert struct {
	a int
	num int
}

func main() {
	sc.Split(bufio.ScanWords)

	n,m := scanInt(), scanInt()
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		u,v := scanInt()-1,scanInt()-1
		g[u] = append(g[u], v)
	}
	s,t := scanInt()-1, scanInt()-1
	
	q := make([]vert, 0)
	q = append(q,vert{s,0})

	g3 := make([][]int,n)
	for i := 0; i < n; i++ {
		g3[i] = append(g3[i], []int{-1,-1,-1}...)
	}
	g3[s][0] = 0

	for ;len(q)>0; {
		a,num := q[0].a,q[0].num
		for _, e := range g[a] {
			if g3[e][(num+1)%3] != -1 {
				continue
			}
			g3[e][(num+1)%3] = g3[a][num] + 1
			q = append(q,vert{e,(num+1)%3})
		}
		q = q[1:]
	}

	if g3[t][0] == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(g3[t][0]/3)
	}

}


Measured memory_bytes: 20736
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define ceil_div(a,b) ((a+(b-1))/b)
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}


int main(){
    int n; IN(n);
    vector<int> d(n)$in(d, n);
    int ans = 0;
    rep(j, 1, n) rep(i, 0, j){
        ans += d[i] * d[j];
    }
    cout << ans << el;
    return 0;
}


Measured memory_bytes: 3180
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N;
  invec<int> P(N), Q(N);
  vector<int> now(N);
  int nr = 1, a=0,b=0;
  
  REP(i,N)
    now[i] = i + 1;
  
  do {
    if (now == P)
      a = nr;
    if (now == Q)
      b = nr;
    nr++;
  } while (bst::next_permutation(now));

  return abs(a-b);
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}





Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int H,W,N;
    cin >> H >> W >> N;
    int div=max(H,W);
    cout << (N+div-1)/div << endl;
}


Measured memory_bytes: 256
#include "cstdio"
#include<algorithm>

using namespace std;

int main(){
int a[3];
scanf("%d %d %d",&a[0],&a[1],&a[2]);
sort(a,a+3);
printf("%d %d %d\n",a[0],a[1],a[2]);
return 0;
}

Measured memory_bytes: 2712
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n, m;
    cin >> n >> m;

    if (n % 2 == 1) {
        for (int i = 1; i <= m; i++) {
            cout << i << " " << n - i << "\n";
        }
    } else {
        int k = (m + 1) / 2;
        for (int i = 1; i <= k; i++) {
            cout << i << " " << n - i + 1 << "\n";
        }
        for (int i = k + 1; i <= m; i++) {
            cout << i << " " << n - i << "\n";
        }
    }
}

Measured memory_bytes: 3616
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    	Scanner s=new Scanner(System.in);
    	String st=s.next();
    	long sum=0;
        for(int i=0;i<st.length();i++)
        {
          	sum+=Integer.parseInt(""+st.charAt(i));
        }
       if(sum%9==0)
         System.out.println("Yes");
    	else
          System.out.println("No");
  }
}

Measured memory_bytes: 51556
#include <iostream>
using namespace std;
int main(void){
    int n;
    std::cin >> n;
    long long int name[5]={};
    for (int i = 0; i < n; i++) {
        string s;
        std::cin >> s;
        if(s[0]=='M')name[0]++;
        if(s[0]=='A')name[1]++;
        if(s[0]=='R')name[2]++;
        if(s[0]=='C')name[3]++;
        if(s[0]=='H')name[4]++;
    }
    long long int ans=0;
    ans+=name[0]*name[1]*name[2];
    ans+=name[0]*name[1]*name[3];
    ans+=name[0]*name[1]*name[4];
    ans+=name[0]*name[2]*name[3];
    ans+=name[0]*name[2]*name[4];
    ans+=name[0]*name[3]*name[4];
    ans+=name[1]*name[2]*name[3];
    ans+=name[1]*name[2]*name[4];
    ans+=name[1]*name[3]*name[4];
    ans+=name[2]*name[3]*name[4];
    std::cout << ans << std::endl;

    
}


Measured memory_bytes: 256
s=input()
Acnt = 0
Zcnt = len(s)-1
while 1:
    if s[Acnt] == 'A':
        Acnt += 1
        break
    else:
        Acnt += 1
while 1:
    if s[Zcnt] == 'Z':
        Zcnt += 1
        break
    else:
        Zcnt -= 1
print(Zcnt-Acnt+1)

Measured memory_bytes: 64212
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define Endl cout << endl;
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
    ll x;
    cin >> x;
    cout << ((x/100)*5>=x%100?1:0) << endl;
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int ans=0;
    for(int i=0;i<n;i++){
        if(i%2==0)ans+=a[i];
        else{
            ans-=a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<char> S(N);
    int count_f = 0, count_b = 0;
    int count = 0;
    for (int i = 0; i < N; i++){
        cin >> S.at(i);
    }
    for (int i = 0; i < N; i++){
        char x = S.at(i);
        if (x == '('){
            if (count < 0) count = 0;
            count++;
        }
        if (x == ')'){
            count--;
            if (count < 0){
                count_f ++;
            }
        }
    }
    
    reverse(S.begin(), S.end());
    count = 0;
    for (int i = 0; i < N; i++){
        char x = S.at(i);
        if (x == ')'){
            if (count < 0) count = 0;
            count++;
        }
        if (x == '('){
            count--;
            if (count < 0){
                count_b ++;
            }
        }
    }
    reverse(S.begin(), S.end());
    
    //cout << count_f << " " << count_b << endl;
    for (int i = 0; i < count_f; i++) cout << '(';
    for (int i = 0; i < N; i++) cout << S.at(i);
    for (int i = 0; i < count_b; i++) cout << ')';
    cout <<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		int [] rank = new int[10];
		int space;
	

		for(int i=0;i<rank.length;i++){
			rank[i] = scan.nextInt();
		}
		
		for(int k = 0;k<rank.length;k++){
			for(int j = 0;j<rank.length;j++){
				if(rank[k]>rank[j]){
					space = rank[k];
					rank[k] = rank[j];
					rank[j] = space;
				}
			}
		}
		for(int j = 0;j<3;j++){
			System.out.println(rank[j]);
		}
		
	}
}

Measured memory_bytes: 17348
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double a,b,n;
    cin >> a >> b >> n;
    cout << floor(a*min(b-1,n)/b) << endl;
    
}




Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int num[1000010];

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        num[a[i]]++;
    }
    sort(all(a));
    vector<bool> ok(1000010,true);
    for(int i=1;i<1000010;i++){
        if(num[i]==0) continue;
        for(int j=i+i;j<1000010;j+=i){
            ok[j]=false;
        }
    }
    rep(i,n){
        if(num[a[i]]>1) ok[a[i]]=false;
    }

    int ans=0;
    rep(i,n){
        if(ok[a[i]]) ans++;
    }

    cout<<ans<<endl;
} 


Measured memory_bytes: 7936
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);
const long double PI=3.14159265358979;

// Required random number generators

// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(K);
    READAR(A,N);
    ll lo=1,hi=1e9;
    while (lo<hi)
    {
        ll mid=(lo+hi)/2;
        ll cnt=0;
        FORI(i,0,N)
        {
            cnt+=((A[i]+mid-1)/mid)-1;
        }
        if(cnt<=K)
        {
            hi=mid;
        }
        else
        {
            lo=mid+1;
        }
    }
    cout<<lo<<endl;
    

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 5316
#include<iostream>
#include<algorithm>
using namespace std;
int prime[2000];
int main(){
	int top=0;
	for(int i=2;i<10000;i++){
		bool ok=true;
		for(int j=0;j<top;j++)if(i%prime[j]==0)ok=false;
		if(ok){
			prime[top]=i;
			top++;
		}
	}
	int n;
	while(true){
		cin>>n;
		if(n==0)break;
		int ans=0;
		for(int i=0;i<top;i++){
			int cnt=prime[i];
			int k=i+1;
			while(true){
				if(cnt==n)ans++;
				if(cnt>=n)break;
				if(k==top)break;
				cnt+=prime[k];
				k++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int[] x = new int[w];
		for(int i = 0;i < w;i++){
			x[i] = i+1;
		}
		int n = scan.nextInt();
		for(int i = 0;i < n;i++){
			String str = scan.next();
			String[] strAry = str.split(","); 
			int a = Integer.parseInt(strAry[0]) - 1;
			int b = Integer.parseInt(strAry[1]) - 1;
			int t = x[a];
			x[a] = x[b];
			x[b] = t;
		}
		for(int i = 0;i < w;i++){
			System.out.println(x[i]);
		}
	}
}

Measured memory_bytes: 12000
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int someOfdigit(int n)
{
	int total=0;
	while(n>0)
	{

		total+=n%10;
		n/=10;


	}return total;

}
int main() {

	int n;cin>>n;
	if(n%someOfdigit(n)==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;










    return 0;
}


Measured memory_bytes: 256
n = int(input())

for i in range(3, n+1):
    if i % 3 == 0:
        print('', i, end='')
        continue

    x = i

    while x >= 1:
        if x % 10 == 3:
            print('', i, end='')
            break

        x = int(x/10)

print()

Measured memory_bytes: 8248