akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    
    public static void nibutan(int array[], int length, int num){
        int pos = -1;
        int lower = 0; //最小index番号
        int upper = length - 1; // 最大index番号
        while (lower <= upper) {
            int mid = (lower + upper) / 2;
            if (array[mid] == num) {
                pos = mid;
                break;
            } else if (array[mid] < num) {
                lower = mid + 1;
            } else {
                upper = mid - 1;
            }
        }
        
        if(pos != -1){
            System.out.println(1);
        }else{
            System.out.println(0);
        }
    }
    
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        //int x = stdIn.nextInt();
        int a[] = new int[n];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        int count = 1;
        a[0] = stdIn.nextInt();
        for(int i = 1; i < n; i++){ //重複しているところは配列に入れない
            int num = stdIn.nextInt();
            if(a[count - 1] != num){
                a[count++] = num;
            }
        }
        
        int q = stdIn.nextInt();
        
        for(int i = 0; i < q; i++){
            int k = stdIn.nextInt();
            nibutan(a, count, k); //左から配列、配列の長さ、探索する数字
        }
        
        //System.out.println();
        //System.out.print();
        stdIn.close();
    }
}





Measured memory_bytes: 120536
#include <stdio.h>

int slectionSort(int A[],int N){
  int i,j,t,s =0,mj;
  for(i=0;i<N-1;i++){
    mj = i;
    for(j=i;j<N;j++){
      if(A[j]<A[mj])mj = j;
    }
    t = A[i];
    A[i] = A[mj];
    A[mj]=t;
    if(i!=mj)s++;
  }
  return s;
}
int main(){
  int A[100],N,i,s;

  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  s=slectionSort(A,N);

  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",s);

  return 0;
}
    



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    LL N;
    cin >> N;
    N--;
    cout << N * (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
# # # # class Segtree # # # #

#      0
#   1     2
# 3   4  5  6
#       :
# leaf i - n-1+i
# parent   - (i-1)//2
# children - 2*i+1, 2*i+2

class Segtree:
    # modify UNIT and oper depending on the reduce operation

    #UNIT = 0  # sum/or:0 and:fff..f min:BIG max:-BIG gcd:0 lcm:1 ..

    #@classmethod
    #def oper(c,x,y):
    #    return x|y  # sum:+ or/and/min/max/gcd/lcm:(same)

    # call like this: sgt = Segtree(n, 0, lambda x,y: max(x,y))

    def __init__(s,l,unit,oper):
        s.unit = unit
        s.oper = oper
        s.n = 1
        while s.n<l:
            s.n *= 2
        s.ary = [s.unit for i in range(2*s.n-1)]

    def get(s,i):
        return s.ary[i+s.n-1]

    def set(s,i,v):
        k = i+s.n-1
        s.ary[k] = v
        while k>0:
            k = (k-1)//2
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def setary(s,a):
        for i,v in enumerate(a):
            s.ary[i+s.n-1] = v
        for k in range(s.n-2,-1,-1):
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def query(s,x,y):
        return s.querycore(x,y,0,0,s.n)

    # x,y: from query  k: suffix at focus l,r: range for k
    # right ends (y,r) not included

    def querycore(s,x,y,k,l,r):
        if r<=x or y<=l:
            return s.unit
        if x<=l and r<=y:
            return s.ary[k]
        vl = s.querycore(x,y,2*k+1,l,(l+r)//2)
        vr = s.querycore(x,y,2*k+2,(l+r)//2,r)
        return s.oper(vl, vr)

# # # # class Segtree end # # # #


inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()

n = inn()
sgt = Segtree(n, 0, lambda x,y: x|y)
ss = ins()
s = []
for i in range(n):
    sgt.set(i, 1<<(ord(ss[i])-ord('a')))

#ddprint("tree")
#for c in alpha:
#    ddprint(c)
#    ddprint(tr[c])

q = inn()
for qq in range(q):
    x,y,z = input().split()
    #ddprint(f"x {x} y {y} z {z}")
    if x == '1':
        i = int(y)-1
        c = z
        sgt.set(i, 1<<(ord(c)-ord('a')))
    else:
        l = int(y)
        r = int(z)
        sm = 0
        v = sgt.query(l-1,r)
        for i in range(26):
            if (v>>i)%2==1:
                sm += 1
        print(sm)



Measured memory_bytes: 115824
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000];
signed main(){
	int n, ans = 0;
	scanf("%lld", &n);
	rep(i,n)scanf("%lld", &a[i]);
	rep(i,n)ans += a[i]-1;
	printf("%lld\n", ans);
	return 0;
}






Measured memory_bytes: 256
package main

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

var (
	nextString func() string
	n, m       int
	a, b       []string
)

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n = nextInt()
	m = nextInt()
	for i := 0; i < n; i++ {
		a = append(a, nextString())
	}
	for i := 0; i < m; i++ {
		b = append(b, nextString())
	}
	for ni := 0; ni < n; ni++ {
		for nj := 0; nj < n; nj++ {
			if judge(ni, nj) {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}

func judge(ni, nj int) bool {
	for i := 0; i < m; i++ {
		for j := 0; j < m; j++ {
			if ni+i >= n || nj+j >= n || b[i][j] != a[ni+i][nj+j] {
				return false
			}
		}
	}
	return true
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  int k;
  cin >> k;
  cout << (k / 2) * (k - k / 2) << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Word
import qualified Data.ByteString as BSW
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST

-- Input: s t
-- Output: arr
--   arr ! (i,j) == length of lcs of (drop i s, drop j t)
lcsTable2 :: BS.ByteString -> BS.ByteString -> UArray (Int,Int) Word16
lcsTable2 s t = runSTUArray $ do
  let !m = BS.length s
      !n = BS.length t
      !n' = n+1
  arr <- newArray ((0,0),(m,n)) 0
  forM_ [m-1,m-2..0] $ \ !i -> do
    let !x = BSW.index s i
        loopY !j !v
          -- v = readArray arr (i,j+1)
          | j < 0 = return ()
          | otherwise = do
              let !y = BSW.index t j
              if x == y
                then do l2 <- readArray arr (i+1,j+1)
                        let !l = l2 + 1
                        writeArray arr (i,j) l
                        loopY (j-1) l
                else do l0 <- readArray arr (i+1,j)
                        let !l = max l0 v
                        writeArray arr (i,j) l
                        loopY (j-1) l
    loopY (n-1) 0
  return arr

main = do
  s <- BS.getLine
  t <- BS.getLine
  -- BS.length s <= 3000, BS.length t <= 3000, BS.all isAsciiLower s, BS.all isAsciiLower t
  let !table = lcsTable2 s t
      !m = BS.length s
      !n = BS.length t
      !n' = n+1
  let recon !i !j | i >= m || j >= n = Nothing
                  | x == y = let !i' = i+1 ; !j' = j+1
                             in Just (x, (i', j'))
                  | table ! (i+1,j) >= table ! (i,j+1) = recon (i+1) j
                  | otherwise = recon i (j+1)
        where x = BSW.index s i
              y = BSW.index t j
      (result, _) = BSW.unfoldrN (fromIntegral $ table ! (0,0)) (\(!i,!j) -> recon i j) (0,0)
  BS.putStrLn result


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

int w,h,gx,gy;

//左下上右
int dx[4] = {-1,0,0,1};
int dy[4] = {0,1,-1,0};

int solve(int count,int stage[20][20],int px,int py){
	int ans = 11;
	if(count == 10){
		return -1;
	}
	

	//左側
	for(int i=0;i<4;i++){
		bool flag = false;
		int bufx = px;
		int bufy = py;
		int c = 0;
		while(true){
			c++;
			bufx += dx[i];
			bufy += dy[i];

			if(bufx < 0 || bufx >= w || bufy < 0 || bufy >= h){
				break;
			}
			if(stage[bufy][bufx] == 1){
				if(c != 1){
					flag = true;
				}
				break;
			}
			//ゴールならカウント足して返す
			if(bufy == gy && bufx == gx){
				return count+1;
			}
		}
		//スライド可能なら
		if(flag){
			stage[bufy][bufx] = 0;
			int d = solve(count+1,stage,bufx+(dx[i]*-1),bufy+(dy[i]*-1));
			if(d != -1){
				ans = min(ans,d);
			}
			stage[bufy][bufx] = 1;
		}
	}

	if(ans == 11){
		return -1;
	}
	return ans;
}

int main(){
	int px,py;
	while(true){
		int stage[20][20];
		cin >> w >> h;
		if(w == 0 && h == 0){
			break;
		}

		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> stage[i][j];
				if(stage[i][j] == 2){
					px = j;
					py = i;
				}
				if(stage[i][j] == 3){
					gx = j;
					gy = i;
				}
			}
		}

		cout << solve(0,stage,px,py) << endl;
	}
}

Measured memory_bytes: 864
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	numbers := strings.Split(s, "")

	var sum int
	for bit := 0; bit < (1 << uint64(len(s)-1)); bit++ {
		var added int

		for i := 0; i < len(s); i++ {
			num, _ := strconv.Atoi(numbers[i])
			added = added*10 + num

			if bit&(1<<uint64(i)) > 0 {
				sum += added
				added = 0
			}
		}
		sum += added
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
s = input()

ans = 0
count = 0

for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        count += 1
        ans = max(ans, count)
    else:
        count = 0

print(ans)


Measured memory_bytes: 9016
from collections import deque

K = int(input())
d = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
pop = 0
now = 0
while K > pop:
    now = d.popleft()
    if now % 10 != 0:
        d.append(now * 10 + (now % 10 - 1))
    d.append(now * 10 + (now % 10))
    if now % 10 != 9:
        d.append(now * 10 + (now % 10 + 1))
    pop += 1
print(now)


Measured memory_bytes: 40944
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

  l,r,d = inp
  ans = 0
  (l..r).each do |dd|
    if dd % d == 0
      ans += 1
    end
  end
  p ans

Measured memory_bytes: 14360
a,b,c=list(input()),list(input()),list(input())
a,b,c=list(reversed(a)),list(reversed(b)),list(reversed(c))
x="a"
while True:
  if x=="a":
    if not a:
      print("A")
      break
    x=a.pop(-1)
  elif x=="b":
    if not b:
      print("B")
      break
    x=b.pop(-1)
  elif x=="c":
    if not c:
      print("C")
      break
    x=c.pop(-1)
  

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;

//(a,b,c)=> left a, right b + trash c<=K
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    REP(i, N)
    {
        cin >> v[i];
    }
    lli maxval = 0;
    REP(i, N + 1)
    {
        REP(j, N + 1)
        {

            if (i + j <= min(N, K))
            {
                vector<int> s(i + j);
                copy(v.begin(), v.begin() + i, s.begin());
                copy(v.end() - j, v.end(), s.begin() + i);
                sort(ALL(s));
                lli sumval = accumulate(s.begin(), s.end(), 0);
                lli sumtmp = 0;
                if (sumval > maxval)
                {
                    maxval = sumval;
                }
                REP(k, min(K - i - j, i + j))
                {
                    sumtmp += s[k];
                    if (sumval - sumtmp > maxval)
                    {
                        maxval = sumval - sumtmp;
                    }
                }
            }
        }
    }
    cout << maxval << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int price[101],amount[101];
  int sum=0,k,n=0;
  int total=0;
  int ave;
  for(k=1;k<=100;k++){
    if(scanf("%d,%d",&price[k],&amount[k])==EOF) break;
    else {
      sum += price[k] * amount[k];
      total += amount[k];
      n++;
    }
  }
  ave = (2 * total + n) / (2 * n);
  printf("%d\n%d\n",sum,ave);
  return 0;
}

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

int main()
{
  long n;
  cin>>n;
  long p=100;
  int step=0;
  while(p<n)
  {
    p += p/100;
    step++;
  }
  cout<<step<<"\n";
  
  return 0;
}

Measured memory_bytes: 3628
//冷静に考えるとk=1, n-1しか必要なくて、数列を回しながらバブルソートするだけ。
#include <iostream>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int p[200];
vector<int> ans;

int main() {
	int i, j;
	
	cin >> n;
	rep(i, n - 1) cin >> p[i + 1];
	cin >> p[0];
	
	rep(i, n) {
		int hanten = 0;
		for (j = 0; j < n - 1; j++) {
			if (p[j] > p[j + 1]) {
				swap(p[j], p[j + 1]);
				ans.push_back(n - 1);
				hanten++;
			}
			ans.push_back(1);
		}
		if (hanten == 0) break;
		ans.push_back(1);
	}
	
	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    long long x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<long long> p(a);
    vector<long long> q(b);
    vector<long long> r(c);

    for(long long i = 0; i < a; i++) cin >> p[i];
    for(long long i = 0; i < b; i++) cin >> q[i];
    for(long long i = 0; i < c; i++) cin >> r[i];

    sort(p.begin(), p.end(), greater<long long>());
    sort(q.begin(), q.end(), greater<long long>());

    vector<long long> eat;

    for(long long i = 0; i < x; i++) eat.push_back(p[i]);
    for(long long i = 0; i < y; i++) eat.push_back(q[i]);
    for(long long i = 0; i < c; i++) eat.push_back(r[i]);

    sort(eat.begin(), eat.end(), greater<long long>());

    long long ans = 0;
    for(long long i = 0; i < x+y; i++) ans += eat[i];

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 9744
#include <iostream>
using namespace std;
int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  for(int i=a; i<=b; i++)
    	if(i%k==0)
        {
          	cout << "OK" << endl;
            return 0;
        }
  cout << "NG" << endl;
  return 0;
}


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

constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string s;
	cin >> s;
	string a, b;
	for (int i = 0; i < s.size(); i++) {
		a += '0' + (int)(i % 2 == 0);
		b += '0' + (int)(i % 2 == 1);
	}
	int tmp1 = 0, tmp2 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (a[i] != s[i])tmp1++;
		if (b[i] != s[i])tmp2++;
	}
	cout << min(tmp1, tmp2) << endl;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, -1, 0, 1};
typedef pair<int, int> P;
const int INF = 100100100;
int main(){//
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    //for(int i=0; i<s.size(); i++) cin >> s[i]; //コンパイルエラーでた
    for(int i=0; i<H; i++) cin >> s[i];
    //BFSして最短経路を見つけ，　
    //そのあと，黒く塗れるマスを数える
    vector<vector<int>> grid(H, vector<int>(W, INF));
    grid[0][0] = 0;
    queue<P> q;
    q.push(P(0, 0));
    while(!q.empty()){
        int y = q.front().first;
        int x = q.front().second;
        q.pop();

        for(int dir=0; dir<4; dir++){
            int next_y = y + dy[dir];
            int next_x = x + dx[dir];
            if(next_y < 0 || H <= next_y) continue;
            if(next_x < 0 || W <= next_x) continue;
            if(s[next_y][next_x] == '#') continue;
            if(grid[next_y][next_x] != INF) continue;
            grid[next_y][next_x] = grid[y][x] + 1;
            q.push(P(next_y, next_x));
        }
    }

    //cout << " BFS is completed ! " << endl;
    int ans = 0;
    if(grid[H-1][W-1] == INF){
        ans = -1;
        cout << ans << endl;
        return 0;
    }
    int min_step = grid[H-1][W-1];
    //gridの中に同じ値が入っていたら数える為のフラグ
    vector<bool> is_double(min_step+5, false); 
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(grid[i][j] > min_step && s[i][j] == '.'){
                ans++;
                continue;
            }
            if(s[i][j] == '#') continue;
            if(is_double[grid[i][j]] == true){
                ans++;
                continue;
            }
            is_double[grid[i][j]] = true;

        }
    }

    cout << ans << endl;



}


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

int main(){
  int N;
  int OddCount = 0;
  float fOut;
  cin >> N;
  
  for(int i=1; i<=N; i++){
    if((i % 2) == 1 ){
      OddCount++;
    }
  }
  fOut = ((float)OddCount/(float)N);
  cout << fOut;
  
  return 0;
}

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

using namespace std;

int main(){
    int n,r;
    cin>>n>>r;
    
    if(n>=10) cout<<r<<endl;
    else {
        int hoge=(10-n)*100;
        cout<<r+hoge<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        int n = in.intNext();
        long k = in.longNext();
        int[] nums = in.nextIntArray(n);
        out.println(solve(k, nums));

        out.close();
    }

    static int solve(long k, int[] nums) {
        HashSet<Integer> seen = new HashSet<>();
        long moves = 0;
        int num = 1;
        while (moves < k) {
            if (seen.contains(num)) break;
            seen.add(num);
            num = nums[num - 1];
            moves += 1;
        }
        ArrayList<Integer> cycle = new ArrayList<>();
        if (moves == k) return num;
        int cursor = num;
        long loop = 0;
        cycle.add(num);
        while (true) {
            cursor = nums[cursor - 1];
            loop++;
            if (cursor == num) break;
            cycle.add(cursor);
        }
        return cycle.get((int) ((k - moves) % loop));
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}


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

int main() {

  int N;
  cin >> N;

  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  int answer = 1;

  for (int i = 1; i < N; i++) {
    bool flg = true;
    for (int j = 0; j < i; j++) {
      if (H[i] < H[j]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      answer++;
    }
  }

  cout << answer << endl;

}

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

int main() {
  int n,sum=0;
  cin >> n;
  while(n--) {
    int a,i;
    cin >> a;
    for(i=1; i*i<=a; i++) {
      if ((a-i)%(2*i+1) == 0) break;
    }
    if(i*i>a) sum++;
  }
  cout << sum << endl;;
}


Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(k,n) for (int k = 0; k < (int)(n); k++)
#define REP(k,n) for (int k = 1; k < (int)(n); k++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(k,x.size()) cout << x[k] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

map<ll,ll> mp;
ll a, b, c, d;

ll dfs(ll n) {
    if (mp.find(n) != mp.end()) return mp[n];
    else {
        ll res = inf_l;
        auto f = [](ll x, ll y) {
            if (inf_l/y < x) return inf_l;
            else return x*y;
        };
        chmin(res,dfs((n+1)/2)+min(a+d*(n%2),f(n-(n+1)/2,d)));
        chmin(res,dfs(n/2)+a+min(d*(n%2),f(n-n/2,d)));
        chmin(res,dfs((n+2)/3)+min(b+d*(3-n%3),f(n-(n+2)/3,d)));
        chmin(res,dfs(n/3)+min(b+d*(n%3),f(n-n/3,d)));
        chmin(res,dfs((n+4)/5)+min(c+d*(5-n%5),f(n-(n+4)/5,d)));
        chmin(res,dfs(n/5)+min(c+d*(n%5),f(n-n/5,d)));
        return mp[n] = res;
    }
}

int main() {
    int t; cin >> t;
    rep(i,t) {
        ll n; cin >> n;
        cin >> a >> b >> c >> d;
        mp.clear();
        mp[0] = 0; mp[1] = d;
        cout << dfs(n) << endl;
    }
}

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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  double h[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> h[i];
    h[i] = a - (t - h[i] * 0.006);
  }

  double select = 100000000;
  for (i = 0; i < n; i++) {
    select = min(select, fabs(h[i]));
  }

  for (i = 0; i < n; i++) {
    if (select == fabs(h[i])) {
      cout << i + 1 << endl;
    }

  }
  return 0;
}


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

#include <iostream>
#include <array>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

array<int, 100002> box; // use key 100001

int n;
int np;
int min_;
int max_;

int solve() {
	cin >> n;
	np = n + 1;
	for (int i = 0; i < n; i++) {
		cin >> min_ >> max_;
		if (min_ > np) {
			continue;
		}
		box[min_ - 1]--;
		max_ = min(max_, np);
		box[max_]++;
	}
	box[np + 2] = 0;
	for (int i = np + 1; i >= 0; i--) {
		box[i] += box[i+1];
		//std::cout << "debug " << i << " " << box[i] << std::endl; // debug
		if (i - 1 <= box[i]) {
			return i - 1;
		}
	}
	return 0;
}

int main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);


	cout << solve() << endl;

	//std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}

Measured memory_bytes: 3552
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

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

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m;
  cin >> n >> m;
  
  vector<ll> a(n + 1);
  for(int i = 1; i <= n; i++){
    cin >> a.at(i);
    a.at(i) += a.at(i - 1);
    a.at(i) %= m;
  }
  
  map<ll, ll> mp;
  ll ans = 0;
  for(int i = 0; i <= n; i++){
    ans += mp[a.at(i)];
    mp[a.at(i)]++;
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
int max(int a, int b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );

     string s;
     cin>>s;
     if ( s == "ARC" ){
          cout<<"ABC"<<endl;
     }else{
          cout<<"ARC"<<endl;
     }
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
  int a[10000] = {};
  for(int i = 0; i < 3; ++i){
    char c; cin >> c;
    a[c]++;
  }
  cout << (a['a']&&a['b']&&a['c'] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define int long long
int weight[110],value[110];
int dp[110][100100] = {0};

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

signed main(){
int n,w;
cin >> n >> w;
for(int i = 0; i < n; i++){
    cin >> weight[i] >> value[i];
}
for(int i = 0; i < n; i++){
    for(int sum_w = 0; sum_w <= w; sum_w++){
        if(sum_w - weight[i] >= 0){
            chmax(dp[i + 1][sum_w],dp[i][sum_w - weight[i]] + value[i]);
        }
        chmax(dp[i + 1][sum_w],dp[i][sum_w]);
    }
}
    cout << dp[n][w] << endl;
}

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

// macros
#define M 1000000007
#define addmod(a,b,m) (a%m + b%m)%m
#define submod(a,b,m) (a%m - b%m)%m
#define mulmod(a,b,m) ((a%m)*(b%m))%m
#define F first
#define S second
#define APSUM(a,b,n) n*((a*.5)+(b*.5))
#define GPSUM(a,b,k) (b*k-a)/(k-1)
#define INFGP(a,k) a/(1-r)
#define CEIL(a,b) ceil(double(a)/double(b))
#define FLOOR(a,b) floor(double(a)/double(b))
#define T(t) while(t--)
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

//typedefs
typedef long long int ll ;
typedef vector<ll> vi ;
typedef pair<ll,ll> pi ;
typedef map<ll,ll> mps;

ll power(ll base,ll val)
{
    ll res=1;
    while(val)
    {
        if(val&1)
    {
        res = (res*base)%M;
    }
     base = (base*base)%M;
     val/=2;
    }
    return res;
}
ll digit(ll n)
{
    double phi = (1 + sqrt(5))/2;
    ll value = round(pow(phi,n)/(sqrt(5)));
    ll count=0;
    while(value)
    {
        count++;
        value/=10;
    }
    return count;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
/*
when files are giving the inputs and outputs
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);

*/
    ll n;
    cin>>n;
    ll sum=0;
   for(int i=1;i<=n;i++)
   {
       if(i%3!=0&&i%5!=0)
       {
           sum+=i;
       }
   }
    cout<<sum<<endl;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define x first
#define y second
#pragma gcc optimize("O3")
#pragma gcc optimize("Ofast")
#pragma gcc optimize("unroll-loops")
using namespace std;
const long long INF = 1e18;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> pi;
typedef pair <ll,ll> pl;
typedef vector <int> vec;
int n;
ll fact[3000005],factInv[3000005],mod = 1e9+7;

ll mpow(ll x,ll m) {
    if(!m) return 1;
    ll tmp = mpow(x,m/2);
    if(m % 2) return tmp*tmp%mod*x%mod;
    else return tmp*tmp%mod;
}

ll Com(ll x,ll r) {
    return fact[x]*factInv[r]%mod*factInv[x-r]%mod;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    fact[0] = 1;
    for(int i = 1;i <= 30000;i++) fact[i] = fact[i-1]*i%mod;
    factInv[30000] = mpow(fact[30000],mod-2);
    for(int i = 29999;i >= 0;i--) factInv[i] = factInv[i+1]*(i+1)%mod;
    int t = 0;
    ll ans = 0;
    while(n-3 >= 0) {
        n -= 3; t++;
        ans += Com(t+n-1,n);
        ans %= mod;
    }
    cout << ans;
}


Measured memory_bytes: 4108
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int h[] = new int[n+1];
		for(int i=1;i<=n;i++) {
			h[i] = scan.nextInt();
		}
		
		int cost[] = new int[n+1];
		cost[1] = 0;
		
		for(int i=2;i<=n;i++) {
			int min = Integer.MAX_VALUE;
			for(int j=1;j<=k;j++) {
				if(i - j <=0) {
					break;
				}
				
				min = Math.min(min, Math.abs(h[i]-h[i-j]) + cost[i-j]);
				
			}
			
			cost[i] = min;
			
		}
		
		System.out.println(cost[n]);
	}
}


Measured memory_bytes: 59304
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, sys.stdin.readline ().split ()))


def num ():
	return map (int, sys.stdin.readline ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


def lcm ( x, y ):
	gg = find_gcd (x, y)
	return (x * y // gg)



mm = 1000000007
def solve ():
	t = 1
	for tt in range (t):
		n=nu()
		a=li()
		a.sort()
		mp={}
		for i in a:
			if(i in mp):
				mp[i]=mp.get(i)+1
			else:
				mp[i]=1
		i=0
		j=n-1
		cc=0
		while(i<j):
			if(mp.get(a[i])==1):
				i+=1
				continue
			if(mp.get(a[j])==1):
				j-=1
				continue
			cc+=2
			mp[a[i]]=mp.get(a[i])-1
			mp[a[j]]=mp.get(a[j])-1
			i+=1
			j-=1
		print(n-cc)
solve()


Measured memory_bytes: 82464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
const int d = 365;
//const int d = 5;
int c[26];
int s[d][26];
int last[26] = {0};
bool llast[d][26] = {false};
vector<int> solution(d,-1);
int myscore = 0;


int score(vector<int> t){
    vector<int> last(26,0);
    int ans = 0;
    rep(i,d){
        ans += s[i][t[i]];
        last[t[i]] = i+1;
        rep(j,26) ans -= c[j] * (i+1-last[j]);
        //cout << ans << endl;
    }
    return ans;
}

// p day contest changes q
void better(int p,int q){
    //cout << myscore << endl;
    int origin = solution[p];
    int newscore = myscore - s[p][origin] + s[p][q];
    int before_origin = 0,before_q = 0;
    int res = 0;
    for(int i=0;i<d;i++){
        if(llast[i][origin]) before_origin = i+1;
        if(llast[i][q]) before_q = i+1;
        res += (c[origin] * (i+1-before_origin) + c[q] * (i+1-before_q));
    }

    llast[p][q] = true;
    llast[p][origin] = false;
    before_origin = 0;
    before_q = 0;

    for(int i=0;i<d;i++){
        if(llast[i][origin]) before_origin = i+1;
        if(llast[i][q]) before_q = i+1;
        res -= (c[origin] * (i+1-before_origin) + c[q] * (i+1-before_q));
    }

    //cout << res << endl;

    newscore += res;
    if(newscore > myscore){
        myscore = newscore;
        solution[p] = q;
    }else{
        llast[p][q] = false;
        llast[p][origin] = true;
    }
}




//day 1-index i_day 's contest is k
int nowscore(int i,int k){
    int res = s[i][k];
    int before = last[k];
    last[k] = i+1;
    rep(j,26) res -= c[j] * (i+1-last[j]);
    last[k] = before;
    return res;
}

int main(){
    clock_t start = clock();

    random_device seed_gen;
    mt19937 mt(seed_gen());
    uniform_int_distribution<int> con(0,26-1);
    uniform_int_distribution<int> day(0,365-1);

    int tmp;
    cin >> tmp;
    rep(i,26) cin >> c[i];
    rep(i,d)rep(j,26) cin >> s[i][j];

    for(int i=0;i<d;i++){
        int id = -1;
        int mx = -INF;
        for(int j=0;j<26;j++){
            int res = nowscore(i,j);
            if(mx < res){
                id = j;
                mx = res;
            }
        }
        solution[i] = id;
        last[id] = i+1; 
        llast[i][id] = true;
        myscore += mx;
    }

    clock_t end = clock();

    while(((double)(end - start)/CLOCKS_PER_SEC) < 1.6){
        better(day(mt),con(mt));
        end = clock();
    }



    rep(i,d) cout << solution[i]+1 << endl;
    /*
    cout << (score(solution) + 1e6) << endl;
    cout << (myscore + 1e6) << endl;
    */

    return 0;
}


Measured memory_bytes: 3716
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int t = sc.nextInt();
		int[] a = new int[t];
		int j = 0;
		while (t-- > 0) {
			a[j] = sc.nextInt();
			j++;
		}
		sc.close();
		Arrays.sort(a);
		int len = a.length;
		int A = 0; //for Alice
		int B = 0; //for Bob

		for (int i = 0; i<len; i+=2) {
			A+=a[i];
		}
		for (int i = 1; i<len; i+=2) {
			B+=a[i];
		}

		int result = Math.abs(A-B);
		System.out.println(result);
	}
}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
#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)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  int sum = 0;
  rep(i, n) {
    cin >> w[i];
    sum += w[i];
  }
  int ans = sum;
  FOR(i, 1, n) {
    int lsum = 0;
    rep(j, i) {
      lsum += w[j];
    }
    int rsum = sum - lsum;
    int dif = max(lsum, rsum) - min(lsum, rsum);
    ans = min(ans, dif);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program {
  static void Main(string[] args) {
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    int c = int.Parse(str[2]);
    int rep = 3;

    if(a == b) --rep;
    if(a == c || b == c) --rep;
    Console.WriteLine(rep);
  }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll res = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; ++i) {
        res += a[i];
    }
    ll cur = 0;
    for (int i = 0; i < n; ++i) {
        cur += b[i];
    }
    res = min(res, cur);
    vector<pll> x(n), y(n);
    cur = 0;
    for (int i = 0; i < n; ++i) {
        x[i] = pll(max(a[i], b[i]), i);
        y[i] = pll(min(a[i], b[i]), i);
        cur += y[i].first;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (x[0].second == y[n - 1].second) {
        res = min(res, min(cur + x[0].first - y[n - 2].first, cur + x[1].first - y[n - 1].first));
    }
    else {
        res = min(res, cur + x[0].first - y[n - 1].first);
    }
    for (int k = 1; k <= n; ++k) {
        ll a1 = x[k - 1].first;
        ll a2 = y[n - k].first;
        if (a2 <= a1)
            break;
        cur = cur + a1 - a2;
        res = min(res, cur);
    }
    cout << res << endl;
    
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<int> ip(mx,0);

bool isprime(int x){
  if(x==2 || x==3){ return true; }
  if(x<2 || x%2==0){ return false; }
  
  int sqrtx = ceil(sqrt(x));
  for(int i=3; i<=sqrtx; i+=2){ if(x%i==0){ return false; } }
  return true;
}

void ipset(int x){                                        //x miman prime set
  for(int i=2; i<x; i++){ ip[i]=(int)isprime(i);}
}

int main(){
  ipset(mx);
  int ans;
  cin >> ans;
  while(ip[ans]==0){
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
    public static void main(String[] args) throws IOException {
        Queue<Integer> qBase = new LinkedList<Integer>();
        BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));
        int inningCount = Integer.parseInt(bReader.readLine());
        int calcCount = 0;
        int point = 0;
        int out = 0;
        qBase.offer(0);
        qBase.offer(0);
        qBase.offer(0);
        while (calcCount != inningCount) {
            String inputStr = bReader.readLine();
            if (inputStr.equals("HIT")) {
                point += qBase.peek();
                qBase.poll();
                qBase.offer(1);
            } else if (inputStr.equals("HOMERUN")) {
                point += qBase.peek();
                qBase.poll();
                point += qBase.peek();
                qBase.poll();
                point += qBase.peek();
                qBase.poll();
                point += 1;
                qBase.offer(0);
                qBase.offer(0);
                qBase.offer(0);
            } else if (inputStr.equals("OUT")) {
                out++;
                if (out == 3) {
                    System.out.println(point);
                    calcCount++;
                    out = 0;
                    point = 0;
                    qBase.clear();
                    qBase.offer(0);
                    qBase.offer(0);
                    qBase.offer(0);
                }
            } else {
            }
        }
    }
}

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

#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)
#define REP(k,n) FOR((k),0,(n))
#define ALL(a) begin(a),end(a)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int  ui;
const int MOD=1000000007;
const double EPS=1e-9;

#define MAX_N 500002
int N,A[MAX_N],temp=0,sum=0;

int main(){
    cin>>N;
    A[0]=0;
    A[N+1]=0;
    FOR(i,1,N+2){
        cin>>A[i];
        sum+=abs(temp-A[i]);
        temp=A[i];
    }
    FOR(i,1,N+1){
        cout<<sum-(abs(A[i]-A[i-1])+abs(A[i+1]-A[i]))+abs(A[i+1]-A[i-1])<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli qsp[100005],qsn[100005];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	lli a;
	qsp[0]=qsn[0]=0;
	for(int i=1;i<=n;++i){
		scanf("%lld",&a);
		qsp[i]=qsp[i-1];
		qsn[i]=qsn[i-1];
		if(a>0)
			qsp[i]+=a;
		else
			qsn[i]+=a;
	}
	lli min=qsp[k],max=qsp[k]+qsn[k],maxidx=k,ans=0;
	for(int i=k;i<=n;++i){
		lli sum=qsp[n];
		if(qsp[i]-qsp[i-k]+qsn[i]-qsn[i-k]>0)
			sum+=qsn[i]-qsn[i-k];
		else
			sum-=qsp[i]-qsp[i-k];
		if(ans<sum)
			ans=sum;
	}
	printf("%lld",ans);
}
/*

10 5
5 -4 -5 -8 -4 7 2 -4 0 7

*/

Measured memory_bytes: 1792
let rec find x uf =
  if uf.(x) < 0 then x
  else 
    let x' = find uf.(x) uf in
    uf.(x) <- x';
    x'
let unite x y uf =
  let x' = find x uf in
  let y' = find y uf in
  if x' <> y' then begin
    if uf.(x') < uf.(y') then begin
      uf.(x') <- uf.(x') + uf.(y');
      uf.(y') <- x';
    end else begin
      uf.(y') <- uf.(x') + uf.(y');
      uf.(x') <- y';
    end
  end
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let edges = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun x y -> x-1, y-1)) in
  let edges = Array.init m (fun i -> edges.(m-1-i)) in
  let uf = Array.make n (-1) in
  Array.fold_left (fun (v, stk) (x, y) -> 
    if find x uf = find y uf then
      (v, v::stk)
    else begin
      let xc = uf.(find x uf) in
      let yc = uf.(find y uf) in
      unite x y uf;
      (v - xc * yc, v::stk)
    end
  ) (n*(n-1)/2, []) edges
  |> snd |> List.iter (Printf.printf "%d\n")
    


Measured memory_bytes: 11136
#include <stdio.h>
#include <string.h>
int main(){
 int K;
 char S[101];
 scanf("%d",&K);
 scanf("%s",S);
 for(int i=0;i<strlen(S);i++){
  if(i<K)printf("%c",S[i]);
   else{
   printf("...");
   break;
   }
 }
 return 0;
}

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

using namespace std;

typedef long long ll;

ll P = 1000000007;

ll power(ll base, ll exp){
    ll ret = 1;
    while(exp > 0){
        if(exp % 2 == 0){
            base *= base;
            base %= P;
            exp /= 2;
        }
        else{
            ret *= base;
            ret %= P;
            exp -= 1;
        }
    }
    return ret;
}

ll inv(ll base){
    return power(base, P-2);
}


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, K;
    cin >> N >> K;
    vector<ll> g(K+1);
    ll ret = 0;
    for(int i = K; i >= 1 ; --i){
        g[i] = power((ll)(K/i), N);
        ll start = 2;
        while(start * i <= K){
            g[i] += (P - g[start * i]);
            g[i] %= P;
            ++start;
        }
        ret += g[i] * i;
        ret %= P;
    }

    cout << ret << endl;

}

Measured memory_bytes: 3984