akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <utility>
#include <map>

constexpr intmax_t INF = 2e9;

std::pair<intmax_t, intmax_t> parse(const std::string& s, size_t& i, intmax_t n) {
  std::deque<std::deque<intmax_t>> expr;
  intmax_t res = 0;

  char op = '+';
  while (i < s.length() && s[i] != ')') {
    intmax_t m;
    if (isdigit(s[i])) {
      m = s[i++]-'0';
    } else if (s[i] == '(') {
      auto tmp = parse(s, ++i, n);
      assert(s[i] == ')');
      ++i;
      m = tmp.first;
      res += tmp.second;
    }

    if (op == '+') expr.emplace_back();
    expr.back().push_back(m);

    if (i < s.length() && s[i] != ')') {
      assert(s[i] == '+' || s[i] == '*');
      op = s[i++];
    }
  }

  size_t il = 0;
  size_t jl = 0;
  size_t ir = 0;
  size_t jr = 0;
  std::deque<intmax_t> prod;
  std::pair<size_t, size_t> one_ends(0, 0);
  intmax_t sum = 0;
  while (il < expr.size()) {
    while (ir < expr.size() && sum < n) {
      if (jr == 0 || prod.empty()) {
        sum += expr[ir][jr];
        prod.push_back(expr[ir][jr]);
      } else {
        sum -= prod.back();
        prod.back() *= expr[ir][jr];
        sum += prod.back();
      }

      if (++jr == expr[ir].size()) {
        ++ir;
        jr = 0;
      }
    }

    if (sum == n) {
      ++res;
      if (ir < expr.size() && jr != 0) {
        if (ir == one_ends.first && jr < one_ends.second) {
          res += (one_ends.second - jr);
        } else {
          intmax_t cur = 0;
          one_ends = {ir, expr[ir].size()};
          for (size_t k=jr; k<expr[ir].size(); ++k) {
            if (expr[ir][k] != 1) {
              one_ends = {ir, k};
              break;
            }
            ++cur;
          }
          res += cur;
        }
      }
    }

    sum -= prod.front();
    prod.front() /= expr[il][jl];
    sum += prod.front();

    if (++jl == expr[il].size()) {
      ++il;
      jl = 0;
      sum -= prod.front();
      prod.pop_front();
    }
    if (ir < il || (ir == il && jr <= jl)) {
      sum = 0;
      prod.clear();
    }
  }

  assert(sum == 0);
  for (size_t i=0; i<expr.size(); ++i) {
    intmax_t cur = 1;
    for (intmax_t x: expr[i]) {
      cur *= x;
      if (cur > INF) return {INF, res};
    }
    sum += cur;
    if (sum > INF) break;
  }

  return {sum, res};
}

int testcase_ends() {
  int n;
  scanf("%d", &n);
  if (n == 0) return 1;

  char buf[2097152];
  scanf("%s", buf);
  std::string s = buf;

  size_t i = 0;
  printf("%jd\n", parse(s, i, n).second);
  assert(i == s.length());
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 689924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> cnt(n + 1, 0);
  for (ll x = 1; x * x <= n; x++) {
    for (ll y = 1; y * y <= n; y++) {
      for (ll z = 1; z * z <= n; z++) {
        ll f = (x + y + z) * (x + y + z) - (x * y + y * z + z * x);
        if (1 <= f && f <= n) {
          cnt[f]++;
        }
      }
    }
  }

  FOR(i, 1, n + 1) { cout << cnt[i] << endl; }
}

Measured memory_bytes: 3652
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
static long[] f;
//......................................@uthor_Alx..............................................

   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	int[] x=int_arr();
	        		  	int n=x[0],m=x[1],k=x[2];
	        		  	long[] a=long_arr();
	        		  	long[] b=long_arr();
	        		  	for(int i=1;i<n;i++){
	        		  		a[i]+=a[i-1];
	        		  	}
	        		  	for(int j=1;j<m;j++){
	        		  		b[j]+=b[j-1];
	        		  	}
	        		  	int max=0;
	        		  	for(int i=0,j=m-1;i<n;i++){
	        		  		long xx=(long)k-a[i];
	        		  		while(j>=0&&xx<b[j]){
	        		  			j--;
	        		  		}
	        		  		long tmp=i>=0?a[i]:0;
	        		  		tmp+=j>=0?b[j]:0;
	        		  	   if(tmp<=(long)k){
	        		  	   	max=Math.max(max,j+1+i+1);
	        		  	   }
	        		  	}
	        		  	for(int i=0;i<n;i++){
	        		  		if(a[i]<=k){max=Math.max(max,i+1);}
	        		  	}
	        		  	for(int i=0;i<m;i++){
	        		  		if(b[i]<=k){max=Math.max(max,i+1);}
	        		  	}
	        		  	
	        		  	
	        		  	out.write(max+"");
                      	out.flush();
	        		 
	}
}
	       


Measured memory_bytes: 77456
N = int(input())
A = [int(input()) for i in range(N)]


# 全体のxorを計算
XOR = 0
for a in A:
    XOR ^= a


ans = 0
for i in reversed(range(30)):
    if not ((1 << i) & XOR):
        continue

    for j, a in enumerate(A):
        a_bit = bin(a)[2:].zfill(30)
        if a_bit[30 - i - 1:] == '1' + '0' * i:
            ans += 1
            XOR ^= a
            XOR ^= (a - 1)
            del A[j]
            break
    else:
        print(-1)
        exit()

print(ans)


Measured memory_bytes: 7072
import sys
N = int(input())
S = [input() for s in range(N)]
s = set(S)
if len(S) != len(s):
	print("No")
	sys.exit()
for i in range(N-1):
	if S[i][-1] != S[i+1][0]:
		print("No")
		sys.exit()
print("Yes")

Measured memory_bytes: 9076
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val counter = hashMapOf<Int, Boolean>()
    repeat(n) {
        val a = readLine()?.toInt() ?: return
        if (counter.containsKey(a)) {
            counter[a] = !counter[a]!!
        } else {
            counter[a] = true
        }
    }
    println(counter.count { it.value }.toString())
}

Measured memory_bytes: 45968
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Ord
import Data.Bits

main=do
    [n,k]<-map read.words<$>getLine::IO[Int]
    as<-unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getLine::IO[Int]
    print $ sol k as

sol k as = sum $ unfoldr (f k) (2^40, ss)
    where
        ss = concatMap (scanl1 (+)) $ tails as

f k (bm,ss)
    | bm == 0 = Nothing
    | length ks >= k = Just(bm, (bm`div`2, ks))
    | otherwise = Just(0, (bm`div`2, ss))
    where
        ks = filter (\s-> s.&.bm /= 0) ss


Measured memory_bytes: 34172
if __name__ == "__main__":
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    history = []
    visited = [False] * n 
    for i in range(n):
        a[i] -= 1
    
    now = 0

    while k > 0 and not visited[now]:
        visited[now] = True
        history.append(now)

        now = a[now]
        k -= 1
    
    if k == 0:
        print(now + 1)
    else:
        index = 0
        while history[index] != now:
            index += 1
        
        size = len(history) - index
        print(history[index + (k % size)] + 1)

Measured memory_bytes: 32372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = 0;
		int B = 0;
		if(N == 2) {
			A = Integer.parseInt(sc.next());
			B = Integer.parseInt(sc.next());
		}


		sc.close();
		if(N == 1) {
			System.out.println("Hello World\r\n" +
					"");
		}else if(N == 2) {
			System.out.println(A + B);
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    
    int len = (int)s.length();

    if (len == 2) {
        if (s[0] == s[1]) {
            cout << "1 2" << endl;
        } else {
            cout << "-1 -1" << endl;
        }
        
    } else {
        for (int i = 0; i < len-2; i++) {
            if (s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]) {
                cout << to_string(i+1) << " " << to_string(i+3) << endl;
                return 0;
            }
        }
        
        cout << "-1 -1" << endl;
    }
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        String S = sc.next();
        int topping = 0;

        for (int i = 0; i < S.length(); i++) {
            if ('o' == S.charAt(i)) {
                topping++;
            }
        }

        System.out.print(700 + (topping * 100));
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 +7;
const ll MAXN = 2e5 + 5;

ll h[MAXN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;cin>>n>>k;
	for(int i=0;i<n;i++) cin>>h[i];
	sort(h,h+n);
	ll cnt=0;
	for(int i=0;i<n-k;i++){
		cnt+=h[i];
	}
	cout<<cnt;
	return 0;
}


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

int main(){
	int x,y;
	while(1){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}else if(x>y){
			cout << y << " " << x << endl;
		}else{
			cout << x << " " << y << endl;
		}
	}
}

Measured memory_bytes: 2992
a,b=map(int, input().split())
f_inf = float('inf')
a_x,b_x = [],[]
cnt = 0
for i in range(1,int(100/0.08)+1):
    if int(0.08 * i) == a:
        a_x.append(i)
        cnt += 1
if cnt != 0:
    cnt = 0
    for i in a_x:
        if int(0.1 * i) == b:
            b_x.append(i)
            cnt +=1
if cnt != 0:
    print(min(b_x))
else:
    print(-1)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int n, k;
    std::cin >> n >> k;
    std::vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        std::cin >> p[i];
    }

    std::sort(p.begin(), p.end());
    int sum = 0;
    for (int i = 0; i < k; i++)
    {
        sum += p[i];
    }
    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	 	Scanner scanner = new Scanner(System.in);
	 	int x = scanner.nextInt();
	 	int y = 0;
	 	int z = 0;
	 	y = x / 500;
	 	x = x % 500;
	 	z = x / 5;
	 	System.out.println(y*1000+z*5);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <utility>
using namespace std;
#define LL long long
#define INF (LL)pow(10, 10);

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<pair<LL, LL>> ab(M);
    for(LL i=0; i<M; i++)ab[i]=make_pair(a[i],b[i]);
    sort(ab.begin(), ab.end());
    LL cnt=0;
    LL r=-INF; LL l=-INF;
    for(auto p: ab){
        if(p.first < r){
            r=min(r, p.second);
        }else{
            cnt++;
            r=p.second;
        }
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 3328
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    int w=a*100,s=0;
    for(int ai=0;ai*100*a<=f;ai++){
        for(int bi=0;(ai*a+bi*b)*100<=f;bi++){
            if(ai==0&&bi==0)continue;
            int cap = min(f-(ai*a+bi*b)*100, (ai*a+bi*b)*e);
            for(int ci=0;ci*c<=cap;++ci){
                int t = cap-ci*c;
                t -= (t%d);
                t += ci*c;
                if(t*(s+w)>s*(t+(ai*a+bi*b)*100)){
                    s = t;
                    w = (ai*a+bi*b)*100;
                    //cout << ai << "-" << bi << ":" << s << " " << w << endl;
                }
            }
        }
    }

    cout << s+w << " " << s << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

int main(){

    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;

    for (int i = 0; i < S.length(); i++){
        if (i == A){
            if(S[i] != '-'){
                //printf("%d : haihun\n", i);
                puts("No");
                return 0;
            }
        }else{
            if (isdigit(S[i])){
                continue;
            }else{
                //printf("%d : not digit\n", i);
                puts("No");
                return 0;
            }
        }
    }

    puts("Yes");

    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    SN = 0
    n = N
    while n > 0:
        SN += n % 10
        n //= 10

    if N % SN == 0:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9092
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        ABC152a pro = new ABC152a(sc);
        pro.solve(out);

        out.flush();
    }

}

class ABC152a {

    private final int N;
    private final int M;

    ABC152a(FastScanner sc) {
        N = sc.nextInt();
        M = sc.nextInt();
    }

    void solve(PrintWriter out) {
        out.println(N == M ? "Yes" : "No");
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
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: 21588
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, X: "List[int]", L: "List[int]"):

    # 区間に変換する
    segs = [(x-l, x+l) for x, l in zip(X, L)]
    segs.sort(key=lambda x: x[1])  # 尻でソート

    # DP i個目の区間まで考えた時の残せる数
    DP = [0]*N
    DP[0] = 1
    for i in range(1, N):
        # 重なっていなければ
        if segs[i-1][1] <= segs[i][0]:
            DP[i] = DP[i-1]+1
        else:
            # 加えないか
            DP[i] = DP[i-1]
            # 重なるものを抜いた場合の個数+1
            left = -1
            right = i-1
            while right-left > 1:
                mid = (right+left)//2
                if segs[mid][1] <= segs[i][0]:
                    left = mid
                else:
                    right = mid
            # すべて重なるケースは区別
            if left == -1:
                buf = 1
            else:
                buf = DP[left]+1
            DP[i] = max(buf, DP[i-1])
    print(DP[-1])

    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
    X = [int()] * (N)  # type: "List[int]"
    L = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        L[i] = int(next(tokens))
    solve(N, X, L)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27540
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	strs := scanstrings(s, N)
	m := map[string]int{}
	for _, str := range strs {
		m[str] = 1
	}
	cnt := len(m)
	if cnt == 3 {
		fmt.Println("Three")
	} else {
		fmt.Println("Four")
	}
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N=in();
	auto A=vecin(N);
	int M=in();
	auto B=vecin(M);
	vector<int> C;
	set_union(ALL(A),ALL(B),back_inserter(C));
	
	for(auto& x:C){
		out(x);
	}
	return 0;
}


Measured memory_bytes: 6432
e=list(map(int, input().split()))
a=e[0]
b=e[1]
c=e[2]
d=e[3]
if a%d==0:
    aoki=a//d
else:
    aoki=a//d+1

if c%b==0:
    taka=c//b
else:
    taka=c//b+1
    
if taka>aoki:
    print('No')
else:
    print('Yes')



Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    int sum=0;
    vector <int> s(n);
    for(int i=0;i<n;i++){
       cin>>s[i]; 
       sum+= s[i];
    }
    sort(s.begin(),s.end());
    if(sum%10!=0) {cout<<sum<<endl; return 0;}
    for(int i=0;i<n;i++){
        if((sum-s[i])%10!=0) {cout<<sum-s[i]<<endl; return 0;}
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#ifdef _MSC_VER

#include <conio.h>

#else

#define getch()

#include <climits>

#define _CRT_INT_MAX INT_MAX

#endif



inline int Abs(int A){

	return A>=0?A:-A;

}



int main(){

	//Declaring variables

	int N=0;

	int M=0;

	int A[50]={};

	int B[50]={};

	int C[50]={};

	int D[50]={};

	//Input

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

	for(int i=0;i<N;i++){

		scanf(" %d %d",&A[i],&B[i]);

	}

	for(int i=0;i<M;i++){

		scanf(" %d %d",&C[i],&D[i]);

	}

	//Solve and output

	for(int i=0;i<N;i++){//Students

		int NowMin=_CRT_INT_MAX;

		int NowMinNum=0;

		for(int j=0;j<M;j++){//Checkpoints

			if(Abs(C[j]-A[i])+Abs(D[j]-B[i])<NowMin){

				NowMin=Abs(C[j]-A[i])+Abs(D[j]-B[i]);

				NowMinNum=j;

			}

		}

		printf("%d\n",NowMinNum+1);

	}

	getch();

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a*b, c) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>
#include<numeric>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int X, K;
vector<pii> events;
const int REV = -1;

void normalize(int &a) {
    if (a < 0)a = 0;
    if (a > X)a = X;
}

signed main() {
    cin >> X >> K;
    rep(i, K) {
        int r;
        cin >> r;
        events.push_back(pii(r, REV));
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
        int t, a;
        cin >> t >> a;
        events.push_back(pii(t, a));
    }
    sort(events.begin(), events.end());
    int b = 0, c = X, ans0 = 0, ansX = X, ansM = 0;//f(t,x)=ans0(x<=b),df(t,x)/dt=1(b<x<c),f(t,x)=ansX(c<=x)
    int pre = 0;
    bool Aup = true;
    rep(i, events.size()) {
        pii p = events[i];
        if (p.second == REV) {
            int d = p.first - pre;
            if (Aup) {
                ans0 -= d;
                ansX -= d;
                ansM -= d;
                b = max(b, -ansM);
            } else {
                ans0 += d;
                ansX += d;
                ansM += d;
                b = max(b, -ansM);
                c = min(c, X - ansM);
            }
            pre = p.first;
            Aup = !Aup;
            normalize(ans0);
            normalize(ansX);
            normalize(b);
            normalize(c);
        } else {
            int a = p.second;
            int ans;
            if (a <= b) ans = ans0;
            else if (a < c) ans = ansM + a;
            else ans = ansX;

            if (Aup)ans -= p.first - pre;
            else ans += p.first - pre;
            normalize(ans);
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6512
import math

def f(X):
    for i in range(1, int(math.sqrt(X)) + 1):
        if X%i == 0:
            ret = f2(X, i)
            if ret != None:
                return (ret+i, ret)

            ret = f2(X, X//i)
            if ret != None:
                return (ret+X//i, ret)


def f2(X, d):
    d2 = X//d

    v1 = 0
    v2 = math.ceil((d2/5)**.25)
    
    while v1+1 < v2:
        v = (v1+v2)//2
        a, b = v+d, v
        y = a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4
        if y == d2:
            return v

        if y < d2:
            v1 = v
        else:
            v2 = v

    return None


def g(X):
    for a in range(int(X**.2)):
        b = int((X-a**5)**.2 + 0.5)
        if a**5 + b**5 == X:
            return (b, -a)


X = int(input())
ans = f(X)
if ans == None:
    ans = g(X)

print(ans[0], ans[1])



Measured memory_bytes: 9408
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        
        if(K==1){
            System.out.println(0);
        }else{
            System.out.println(N-K);
        }
    }
}

Measured memory_bytes: 35832
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <array>
using namespace std;

int main()
{
	int N;
	array<long long int, 5> MARCH = {};
	string s;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s;
		if (s[0] == 'M')
			MARCH[0]++;
		if (s[0] == 'A')
			MARCH[1]++;
		if (s[0] == 'R')
			MARCH[2]++;
		if (s[0] == 'C')
			MARCH[3]++;
		if (s[0] == 'H')
			MARCH[4]++;
	}
	long long int ans = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += MARCH[i] * MARCH[j] * MARCH[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVLI(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVLI(a, b, c, d)                                                      \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll count1 = 0;
  ll N;
  cin >> N;
  FOR(i, 2, 55555) {
    bool ok = true;
    FOR(j, 2, min(i, (ll)237)) {
      if (i % j == 0) {
        ok = false;
        break;
      }
    }
    if (ok && i % 5 == 1) {
      count1++;
      if (count1 < N)
        cout << i << " ";
      else {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}


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

bool check(vector<vector<int>>&has,vector<bool>&sumi,int now,int N,int time){
  if(now==N)
    return true;
  if(sumi.at(now))
    return false;
  if(time>=2)
    return false;
  sumi.at(now)=true;
  bool ans=false;
  for(int i=0;i<has.at(now).size();i++){
    ans=ans||check(has,sumi,has.at(now).at(i),N,time+1);
  }
  return ans;
}

int main(){
  int N,M,b,bb;
  cin >> N >> M;
  vector<vector<int>>br(N);
  for(int i=0;i<M;i++){
    cin >> b >> bb;
    br.at(b-1).push_back(bb-1);
    br.at(bb-1).push_back(b-1);
  }
  vector<bool>sumi(N,false);
  cout << (check(br,sumi,0,N-1,0)?"POSSIBLE":"IMPOSSIBLE") << endl;
  return 0;
}
  

Measured memory_bytes: 14988
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n, ans = 0, p = 0; cin >> n;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		if (p < h)ans += h - p;
		p = h;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
   static int Main()
    {
        string[] in1 = Console.ReadLine().Split(' '),in2;
        int n = int.Parse(in1[0]), q = int.Parse(in1[1]),l,r;
        int[] ac = new int[n];
        string s = Console.ReadLine();
        for (var i = 1; i < n; i++)
        {
            if (s[i - 1] == 'A' && s[i] == 'C')
            {
                ac[i] = ac[i - 1] + 1;
            }
            else {
                ac[i] = ac[i - 1];
            }
        }
        for (var i = 0; i < q; i++)
        {
            in2 = Console.ReadLine().Split(' ');
            l = int.Parse(in2[0])-1;
            r = int.Parse(in2[1])-1;
            Console.WriteLine((ac[r] - ac[l]).ToString("d"));
        }
        return 0;
    }
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n, k;
int a[100001];
const int inf = 1000000000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;:w
#endif
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = inf;
  for (int start = 0; start + k <= n; start++) {
    int s = a[start];
    int g = a[start + k - 1];
    int len = 0;
    if (s >= 0) {
      len = g;
    }else if (g <= 0) {
      len = -s;
    }else {
      len = min(-2 * s + g, -s + 2 * g);
    }
    ans = min(ans, len);
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);

	printf("%d\n",min(N*A,B));

	return 0;
}


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

#define int long long

int N;
int A[6000];

int memo[4000][6000];
int dfs(int l,int r){
    if(~memo[l][r])return memo[l][r];

    int ret;
    int cnt=r-l-1;

    if(cnt==N)ret=0;
    else if(cnt&1){
        if(A[l]>A[r])ret=dfs(l-1,r);
        else ret=dfs(l,r+1);
    }
    else{
        ret=max(dfs(l-1,r)+A[l],dfs(l,r+1)+A[r]);
    }

    return memo[l][r]=ret;
}

signed main(){
    cin.tie();
    ios_base::sync_with_stdio(false);

    cin>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        A[i]=A[N+i]=A[N*2+i]=a;
    }

    memset(memo,-1,sizeof(memo));

    int ans=0;
    for(int i=0;i<N;i++)ans=max(ans,dfs(N+i-1,N+i+1)+A[i]);

    cout<<ans<<endl;
}

Measured memory_bytes: 188808
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.length()-1]==b[0]&&c[0]==b[b.length()-1])
    cout<<"YES";
    else
    cout<<"NO";}

Measured memory_bytes: 3612
N, M = map(int, input().split())
edges = []
E = [[] for _ in range(N)]

for _ in range(M):
    fr, to, cost = map(int, input().split())
    fr -= 1
    to -= 1
    edges.append((fr, to, -cost))
    E[to].append(fr)

def canGo():
    st = [N - 1]
    visited = [False] * N
    visited[N - 1] = True
    while st:
        for to in E[st.pop()]:
            if visited[to]:
                continue
            visited[to] = True
            st.append(to)
    return visited

V = canGo()

minDist = [float('inf')] * N
minDist[0] = 0

for i in range(N + 1):
    for fr, to, cost in edges:
        d = minDist[fr] + cost
        if minDist[to] > d:
            if i == N and V[to]:
                print('inf')
                exit()
            minDist[to] = d

print(-minDist[N - 1])

Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;
int main() {
	int R0, W0, C, R;
	while(cin >> R0 >> W0 >> C >> R,R0) {
		if (C*W0 >= R0) {
			cout << (C*W0 - R0 + R - 1) / R << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;

int main() {
  ll N, M, cnt = 0, sum = 0;
  cin >> N >> M;
  vector<ll> A(N);
  for(ll i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  for(ll i = 0; i < N; i++) {
    if(A.at(i) >= double(sum) / (4 * M))  cnt++;
  }
  if(cnt >= M) cout << "Yes" << endl;
  else cout << "No" << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  string s;
  cin >> s;
  string ans = "";
  rep(i,3){
    ans += s[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<int>> s(h, vector<int>(w, 0));
  int black = 0;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++){
      char c;
      cin >> c;
      if(c == '.'){
        s[i][j] = 1;
      }else{
        black++;
      }
    }
  }
  vector<vector<int>> dist(h, vector<int>(w, 1001001001));
  dist[0][0] = 0;
  queue<pair<int, int>> que;
  que.push({0, 0});
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  while(!que.empty()) {
    int x = que.front().first;
    int y = que.front().second;
    que.pop();
    for(int i = 0; i < 4; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx < 0 || nx >= h || ny < 0 || ny >= w){
        continue;
      }
      if(dist[nx][ny] != 1001001001){
        continue;
      }
      if(s[nx][ny] == 0){
        continue;
      }
      dist[nx][ny] = dist[x][y] + 1;
      que.push({nx, ny});
    }
  }
  /*
  cout << dist[h - 1][w - 1] << endl;
  cout << black << " ";
  */
  if(dist[h - 1][w - 1] == 1001001001){
    cout << -1 << endl;
    return 0;
  }
  cout << h * w - (dist[h - 1][w - 1] + 1) - black << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

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

	if(s == "Sunny"){
		cout << "Cloudy" << endl;
		
	}else if(s == "Cloudy"){
		cout << "Rainy" << endl;
	}else{
		cout << "Sunny" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)

void solve(){
	string a, b;
	cin>>a>>b;
	a+=b;
	int k = stoi(a);
	if((ll)sqrt(k) * (ll)sqrt(k) == k)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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



Measured memory_bytes: 256
init_input=map(int, raw_input().split())

mem=raw_input()
mem_list=list(mem)

man=init_input[0]
jap=init_input[1]
ove=init_input[2]

jas=0
ovs=0

for i in range(man):
    if mem[i]=="a" and jas+ovs<jap+ove:
        jas+=1
        print "Yes"
    elif mem[i]=="b" and jas+ovs<jap+ove and ovs<ove:
        ovs+=1
        print "Yes"
    else:
        print "No"

Measured memory_bytes: 7044
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

const int di[] = {1, -1, 4, -4};

int main()
{
    map<string, int> memo;
    queue<string> que;
    string st = "01234567", ss;
    que.push(st);
    memo[st] = 0;
    while(!que.empty()) {
        string s = que.front(); que.pop();
        int a = s.find('0');
        for(int i = 0; i < 4; i++) {
			if(a%4==0 && i==1)continue;
			if(a%4==3 && i==0)continue;
            int b = a + di[i];
            if(b < 0 || b >= 8) continue;
            ss = s;
            swap(ss[a], ss[b]);
            if(memo.find(ss) != memo.end()) continue;
            que.push(ss); memo[ss] = memo[s] + 1;
        }
    }
        
    string str(8, ' ');
    while(cin >> str[0]) {
        for(int i = 1; i < 8; i++) cin >> str[i];
        cout << memo[str] << endl;
    }
}

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

int main(){
    int K,N; cin >> N >> K;
    int p[1000];
    
    for(int i = 0;i < N;i++)
        cin >> p[i];

    int min = 0;
    sort(p,p+N);

    for(int i = 0;i < K;i++)
        min += p[i];

    cout << min << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    rep(i,n) cin>>a[i];
    reverse(all(a));
    rep(i,n){
        if (i!=0) cout<<" ";
        cout<<a[i];
    }
    cout<<"\n";
    return 0;
}



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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    bool ok = true;
    rep(i, m) if (a[i] * 4 * m < sum) ok = false;
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Linq;

namespace ProgrammingContest001
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).Aggregate((x, y) => x * y);

            Console.WriteLine(input % 2 == 0 ? "Even" : "Odd");

        }
    }
}


Measured memory_bytes: 11220
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; ; i++)
            {
                string[] num = Console.ReadLine().Split();

                if (int.Parse(num[0]) == 0 && int.Parse(num[1]) == 0) return;

                for (int j = 1; j <= int.Parse(num[0]); j++)
                {
                    for (int k = 1; k <= int.Parse(num[1]); k++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                Console.WriteLine("");
            }
        }
    }
}



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

int main()
{
	int ret;
	int K,A,B,i;
	int hit = 0;
	ret = scanf("%d", &K);
	ret = scanf("%d %d", &A, &B);

	for (i = A; i <= B ; i++) {
		if (i % K == 0)
			hit = 1;
	}
	
	if (hit)
		printf("OK");
	else
		printf("NG");
	fflush(stdout);
	return EXIT_SUCCESS;
}


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

using ll = long long;

int main() {
    //dp[i][j] i番目までで重さj以下の価値の最大値
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0));
    rep(i, N) {
        rep(j, W + 1) {
            dp[i + 1][j] = dp[i][j];
            if (j >= w[i]) dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }
    cout << dp[N][W] << "\n";
}


Measured memory_bytes: 6836
import  math
lis = []

N,M = [int(i) for i in input().split()]

for i in range(1,int(math.sqrt(M))):
    if M % i == 0:
        lis.append(i)
        lis.append(M//i)


lis.sort()
i =1
for i in lis:
    if i >= N:
        break

print(M//i )


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	smallest := 0
	for i := 1; i < n; i++ {
		a := i
		b := n - i
		asum := sum_digits(a)
		bsum := sum_digits(b)
		totalsum := asum + bsum

		if smallest > totalsum || i == 1 {
			smallest = totalsum
		}
	}
	fmt.Println(smallest)
}

func sum_digits(n int) int {
	total := 0
	for n > 0 {
		total += n % 10
		n /= 10
	}
	return total
}


Measured memory_bytes: 1832
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        String S = sc.next();
        
        if(S.length()<=N){
        System.out.println(S);
        }else{
        System.out.println(S.substring(0,N)+"...");
        }
	}
}

Measured memory_bytes: 38596
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int h, w;
const int INF = (1 << 30) - 1;

struct pos {
    int x, y;
};

const vector<pos> moves{{1,  0},
                        {-1, 0},
                        {0,  1},
                        {0,  -1}};

bool inRange(pos p) {
    return 0 <= p.x && p.x < h && 0 <= p.y && p.y < w;
}

int calc(vector<string> &ban, pos start, pos end) {
    vector<vector<int>> dis(h, vector<int>(w, INF));
    dis[start.x][start.y] = 0;
    deque<pos> que;
    que.push_back(start);

    while (!que.empty()) {
        pos now = que.front();
        que.pop_front();

        for (auto &move:moves) {
            pos next = {now.x + move.x, now.y + move.y};
            if (!inRange(next) || ban[next.x][next.y] == '#') continue;

            if (dis[next.x][next.y] > dis[now.x][now.y]) {
                dis[next.x][next.y] = dis[now.x][now.y];
                que.push_front(next);
            }
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (abs(i) + abs(j) <= 1)continue;

                pos next = {now.x + i, now.y + j};
                if (!inRange(next) || ban[next.x][next.y] == '#') continue;

                if (dis[next.x][next.y] > dis[now.x][now.y] + 1) {
                    dis[next.x][next.y] = dis[now.x][now.y] + 1;
                    que.push_back(next);
                }
            }
        }
    }

    return dis[end.x][end.y];
}

int main() {
    cin >> h >> w;
    pos start, goal;
    cin >> start.x >> start.y >> goal.x >> goal.y;
    start.x--, start.y--, goal.x--, goal.y--;

    vector<string> ban(h);
    for (int i = 0; i < h; i++)cin >> ban[i];

    int ret = calc(ban, start, goal);
    cout << (ret == INF ? -1 : ret) << endl;
    return 0;
}

Measured memory_bytes: 9440
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
  int input[100];
  int n;
  cin >> n;
  for(int i = 0; i < n;	i++)
    cin	>> input[i];
  reverse(input, input + n);
  for(int i = 0; i < n - 1; i++)
    cout << input[i] << " ";
  cout << input[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1164