akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int M = 1046527;
const int L = 14;

char H[M][L];

int getChar(char ch) {
  switch (ch)
  {
    case 'A':
      return 1;
    case 'C':
      return 2;
    case 'G':
      return 3;
    case 'T':
      return 4;
    default:
      return 0;
  }
};

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
};

int h1 (int key) { return key % M; };
int h2 (int key) { return 1 + (key % (M - 1)); };

bool find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0) return true;
    else if (strlen(H[h]) == 0) return false;
  }
  return true;
};

void insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0) return;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return;
    }
  }
  return;
};

int main() {
  char str[L], com[9];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%s %s", com ,str);
    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
};




Measured memory_bytes: 17448
#include <algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
int main(void){

int d[999],a,b,i,j;

cin>>a>>b;

d[0]=1;

for(i=1;i<999;++i)d[i]=d[i-1]+i+1;

for(i=1;i<999;++i){

if(d[i]-d[i-1]==b-a){

cout<<d[i]-b<<endl;

return 0;

}

}

return 0;

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;
vector<ll> divisor(ll n) {
  vector<ll> res;
  for ( int i = 1; i * i <= n; i++ ) {
    if ( n % i == 0 ) {
      res.push_back(i);
      if( i != n / i ) res.push_back(n/i);
    }
  }
  return res;
}
int main() {
  ll N,M; cin >> N >> M;
  vector<ll>data = divisor(M);
  sort(data.begin(),data.end(),greater<int>());
  for ( int i = 0; i < data.size(); i++ ) {
    if ( data[i]*N <= M ) {
      ll tmp = M;
      tmp -= data[i]*(N-1);
      if (  tmp > 0 && tmp % data[i] == 0 ) {
	cout << data[i] << endl;
	return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
    static void Main(){
        char[] c = Console.ReadLine().ToCharArray();
        foreach (var ch in c) Console.Write(Pair(ch));
        Console.WriteLine();
    }

    static char Pair(char c){
        if (c == 'A') return 'T';
        if (c == 'T') return 'A';
        if (c == 'C') return 'G';
        return 'C';
    }
}

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

using namespace std;

//#define FILE_IO

const int NMAX = 3e5 + 5;
const int mod = 1e9 + 7;

int N, M, K;
int fct[4 * NMAX], ifct[4 * NMAX], p3[4 * NMAX];
int cnt[4 * NMAX];

int add(int x, int y) { x += y; if(x >= mod) x -= mod; return x; }
int sub(int x, int y) { x -= y; if(x < 0) x += mod; return x; }
int mul(int x, int y) { return (1LL * x * y) % mod; }

int power(int x, int y)
{
    if(y == 0)  return 1;
    int ans = power( (1LL * x * x) % mod, y >> 1 );
    if(y & 1)   ans = (1LL * ans * x) % mod;
    return ans;
}

void pre(int N)
{
    fct[0] = 1;
    for(int i = 1; i <= N; i++) fct[i] = (1LL * fct[i - 1] * i) % mod;
    ifct[N] = power(fct[N], mod - 2);
    for(int i = N - 1; i >= 0; i--) ifct[i] = (1LL * ifct[i + 1] * (i + 1)) % mod;

    p3[0] = 1;
    for(int i = 1; i <= N; i++) p3[i] = (3LL * p3[i - 1]) % mod;
}

int C(int N, int K)
{
    if(N < 0 || K < 0 || N < K)  return 0;
    int ans = fct[N];
    ans = (1LL * ans * ifct[K]) % mod;
    ans = (1LL * ans * ifct[N - K]) % mod;
    return ans;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    pre(1e6);

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

    cnt[0] = 1;
    int lstst = 0, lstdr = 0, lstans = 1;
    for(int i = 1; i <= M + K; i++)
    {
        int st = max(0, i - K);
        int dr = min(M, i);
        int ans = (2LL * lstans + C(i - 1, lstst - 1) - C(i - 1, lstdr) + mod) % mod;
        while(lstst < st)
        {
            ans = (ans - C(i, lstst) + mod) % mod;
            lstst++;
        }
        lstdr++;
        while(lstdr <= dr)
        {
            ans = (ans + C(i, lstdr)) % mod;
            lstdr++;
        }

        lstst = st, lstdr = dr, lstans = ans;
        cnt[i] = ans;
    }

    int ans = 0;
    for(int i = N; i <= N + M + K; i++)
    {
        int sol = (1LL * C(i - 1, N - 1) * cnt[i - N]) % mod;
        sol = (1LL * sol * p3[N + M + K - i]) % mod;
        ans = (ans + sol) % mod;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 18688
import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
      String[] numbers = reader.readLine().split(" ");
      int h = Integer.parseInt(numbers[0]);
      int w = Integer.parseInt(numbers[1]);
      System.out.println(String.format("%d %d", (h*w), (h+w)*2));
    }
  }
}

Measured memory_bytes: 24620
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
// use std::cmp::*;
use std::collections::VecDeque;
fn main() {
    input! {
    N:usize,
    M:usize,
    AB:[(Usize1,Usize1);M]
    }
    // 部屋iから繋がっている部屋のリスト
    let mut tonari: Vec<Vec<usize>> = vec![Vec::with_capacity(M); N];
    let mut ans: Vec<usize> = vec![N; N];
    for (a, b) in AB {
        tonari[a].push(b);
        tonari[b].push(a);
    }
    //    for i in 0..N {
    //        println!("{}={:?}", i, tonari[i]);
    //    }
    let mut nexts: VecDeque<usize> = VecDeque::new();
    nexts.push_front(0);
    while let Some(i) = nexts.pop_back() {
        //        println!("{}={:?}", i, tonari[i]);
        for &j in tonari[i].iter() {
            if ans[j] == N {
                ans[j] = i;
                nexts.push_front(j);
            }
        }
    }
    println!("Yes");
    for &j in ans.iter().skip(1) {
        println!("{}", j + 1);
    }
}


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

int main(){
	int n,t,a,x;
	cin >> n >> t >> a;
	int ans = 0;
	int anko = 1<<30;
	for(int i = 1; i <= n; ++i){
		cin >> x;
		int d = (1000*t - x*6) - a*1000;
		if(d<0) d = -d;
		if(anko>d){
			anko = d;
			ans = i;
	} 
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

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

int main() {
	int n;
	cin >> n;
	vector<pair<int, int> > a(n);
	rep(i,n){
		int x;
		cin >> x;
		a[i] = make_pair(x, i);
	}
	sort(all(a));
	rep(i,n){
		cout << a[i].second + 1 << " ";
	}
	cout << endl;
}


Measured memory_bytes: 1536
h, w = map(int, input().split())

if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()

ans = min(h, w)

for i in range(w//3, w//3 + 2):
    s = [h * i]
    s.append((w - i) * (h // 2))
    s.append((w - i) * (h - h // 2))
    ans = min(ans, max(s) - min(s))

h, w = w, h

for i in range(w//3, w//3 + 2):
    s = [h * i]
    s.append((w - i) * (h // 2))
    s.append((w - i) * (h - h // 2))
    ans = min(ans, max(s) - min(s))
print(ans)

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  string b; cin >> b;
  REP(i, b.length()) {
    if (b[i] == 'A') cout << 'T' << endl; 
    if (b[i] == 'T') cout << 'A' << endl; 
    if (b[i] == 'C') cout << 'G' << endl; 
    if (b[i] == 'G') cout << 'C' << endl; 
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

int main() {
	string s;
	cin >> s;
	char now;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (i == 0) {
			now = s[0];
		} else {
			if (now != s[i]) {
				now = s[i];
				count++;
			}
		}
	}
	cout << count << endl;
}

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


def main():
    n = int(input())

    # See:
    # https://www.youtube.com/watch?v=fYS-rAUSD5o
    for i in range(111, 1000, 111):
        if i >= n:
            print(i)
            exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
	public static void Main()
	{
		int N = int.Parse(Console.ReadLine());
		var s = Console.ReadLine();
		var t = Console.ReadLine();
		for (int i = 0; i < N; i++)
		{
			if (s.EndsWith(t.Substring(0, N - i)))
			{
				Console.WriteLine(N + i);
				return;
			}
		}
		Console.WriteLine(N * 2);
	}
}

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

int main(){
    int n, c, k;
    cin >> n >> c >> k;

    vector<int> t(n);
    for(int i = 0; i < n; i++) cin >> t[i];

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

    int ans = 0, time = 0, p = 0;
    for(int i = 0; i < n; i++){
        if(t[i] > time || p >= c){
            time = t[i] + k;
            p = 0;
            ans++;
        }
        p++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n= int(sys.stdin.readline())
    p_l= list(map(int, sys.stdin.readline().split()))
    c=0
    for i in range(1,n-1):
        if p_l[i-1]<p_l[i]<p_l[i+1] or p_l[i-1]>p_l[i]>p_l[i+1]:
            c+=1
    print(c)



Measured memory_bytes: 64876
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long X = sc.nextLong();
		long D = sc.nextLong();
		System.out.println(solve(N, X, D));
//		for (long n = 1; n < 10; ++n) {
//			for (long x = -10; x <= 10; ++x) {
//				for (long d = -10; d <= 10; ++d) {
//					if (solve(n, x, d) != exact(n, x, d)) {
//						tr(n, x, d, solve(n, x, d), exact(n, x, d));
//						return;
//					}
//				}
//			}
//		}
	}

	long exact(long N, long X, long D) {
		long[] A = new long[(int) N];
		A[0] = X;
		for (int i = 1; i < A.length; ++i) {
			A[i] = A[i - 1] + D;
		}
		HashSet<Long> set = new HashSet<Long>();
		for (int s = 0; s < 1 << N; ++s) {
			long sum = 0;
			for (int shift = 0; shift < N; ++shift) {
				if ((s >> shift) % 2 == 1) {
					sum += A[shift];
				}
			}
			set.add(sum);
		}
		return set.size();
	}

	long solve(long N, long X, long D) {
		if (D < 0) {
			X *= -1;
			D *= -1;
		} else if (D == 0) {
			if (X == 0) {
				return 1;
			} else {
				return N + 1;
			}
		}
		HashSet<Long> set = new HashSet<>();
		for (int i = 1; i <= N; ++i) {
			set.add(((X * i % D) + D) % D);
		}
		set.add(0L);
		long[] id = new long[set.size()];
		int p = 0;
		for (long v : set) {
			id[p++] = v;
		}
		Arrays.sort(id);
		PriorityQueue<long[]>[] pq = new PriorityQueue[set.size()];
		for (int i = 0; i < pq.length; ++i) {
			pq[i] = new PriorityQueue<long[]>(new Comparator<long[]>() {
				@Override
				public int compare(long[] o1, long[] o2) {
					if (o1[0] != o2[0]) {
						return Long.compare(o1[0], o2[0]); // start, end
					} else {
						return Long.compare(o1[1], o2[1]);
					}
				}
			});
		}
		long ans = 0;
		for (long i = 1; i <= N; ++i) {
			long mod = (X * i % D + D) % D;
			int idx = Arrays.binarySearch(id, mod);
			if (idx < 0)
				throw new AssertionError();
			long start = i * (i - 1) / 2;// 0+1+...+i-1=(1/2)i(i-1)
			long end = N * i - i * (i + 1) / 2;// (n-i)...+(n-2)+(n-1)=ni-i(i+1)/2
			pq[idx].add(new long[] { start * D + X * i, end * D + X * i });
		}
		pq[0].add(new long[] { 0, 0 });
		for (int i = 0; i < pq.length; ++i) {
			while (!pq[i].isEmpty()) {
				long[] a = pq[i].poll();
				while (!pq[i].isEmpty() && a[1] >= pq[i].peek()[0]) {
					if (a[1] > pq[i].peek()[1]) {
						pq[i].poll();
					} else {
						long[] b = pq[i].poll();
						a[1] = b[1];
					}
				}
				ans += (a[1] - a[0] + D) / D;
			}
		}
		return ans;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 22
const int MOD = 1000000007;

int v[maxn][maxn], n, dp[maxn][(1 << 21)];

int solve(int pos, int mask) {
    if (pos == n)return 1;
    int &ans = dp[pos][mask];
    if (ans != -1)return ans;
    ans = 0;
    for (int i = 0; i < n; i++)
        if (v[pos][i] and !(mask >> i & 1)) {
            ans += solve(pos + 1, mask | (1 << i));
            ans %= MOD;
        }
    return ans;
}

void solve() {
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)cin >> v[i][j];
    cout << solve(0, 0);
}

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

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 364092
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    int n;cin>>n;
    ll ans=0;
    V<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    ll pre=0;
    for(ll i=0;i<n;i++){
        if(a[i]==0){
            ans+=pre/2;
            pre=0;
        }
        else{
            a[i]+=pre;
            ans+=a[i]/2;
            a[i]%=2;
            pre=a[i];
        }
    }
    cout<<ans<<Endl;
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------







































Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            long sum = 0;
            int res = 0;
            for (int i = 0; i + 1 < n; ++i) {
                sum += a[i];
                ++res;
                if (2 * sum < a[i + 1]) {
                    res = 0;
                }
            }
            ++res;
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 40720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[110];
bool ok[110];
int main () {
    int x,n;
    cin >> x >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ok[a[i]] = 1;
    }
    int ans = 110;
    int mi = 110;
    for (int i = 0; i <= 101; i++) {
        if (!ok[i]) {
            if (abs(i - x) < mi) {
                mi = abs(i - x);
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main(void){
    long long n;
    int cnt = 0;
    cin >> n;
    string s = {};

    if(n == 0){
        cout << 0 << endl;
        return 0;
    }

    while(n != 0){
        if(n % -2 == 0)
        s += "0";
        else{
            n--;
            s += "1";
        }
        n /= -2;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int A,B,T,sum=0;
	scanf("%d%d%d",&A,&B,&T);
	for(int i=1;i<=T;i++){
		if(i%A==0){
			sum+=B;
		}
	}
	printf("%d\n",sum);
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; int k; cin>>s>>k;
	set<string>ss;
	for(int i=0;i<s.size();++i){
		for(int j=1;j<=min((size_t)k,s.size()-i);++j){
			ss.insert(s.substr(i,j));
		}
	}
	for(int i=0;i<k-1;++i){
		ss.erase(ss.begin());
	}
	cout<<*ss.begin()<<"\n"s;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

long long n;

int main()
{
    scanf("%lld", &n);
    long long ans = 0;
    if(n % 2 == 1)  cout << 0 << endl;
    else{
        ans += n / 10;
        n /= 10;
        while(n > 0){
            ans += n / 5;
            n /= 5;
        }
        cout << ans << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Mod = (ll) (1e9) + 7;
const ll MAX = (ll) (1e6);
const ll PMAX = (ll) (1e3);
set<int> ps,ss;
ll mm[MAX]={},m[MAX]={};
//prepare prime number
void Eratosthenes(const int N){
   bool isprime[PMAX];
   for(int i=0;i<N;i++){
      isprime [i]=true; 
   } 
   for(int i=2;i<N;i++){
   if(isprime [i]){
      for(int j=2*i;j<N;j+=i) {
         isprime [j] =false ;
      }
      ps.insert(i);
   }
   }
}
ll powll(ll n,ll m){
   return m?((m&1)?n:1)*powll(n*n,m>>1):1;
}
void primeStock(ll n){
   set<int> s;
   auto itr=ps.begin();
   ll a=*itr;
   while (itr!=ps.end()&&n>=a*a){
      if(n%a==0){
          n/=a;
          m[a]++;
          s.insert(a);
      } else{
          itr++;
          a=*itr;
      }
   } 
   if(n!=1){
      s.insert(n);
      m[n]++; 
   }
   for (auto i=s.begin();i!=s.end();i++){
      if(m[*i]>mm[*i]){
          mm[*i]=m[*i];
          ss.insert(*i);
      }
      m[*i]=0;
   } 
}
ll primesum(){
    ll sum=1;
    for (auto i=ss.begin();i!=ss.end();i++){
       if(mm[*i]>1)
         sum*=powll(*i,mm[*i]) % Mod;
       else
         sum*=*i;
       sum%=Mod;
    }
    return sum;
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
int main() {
  int n;
  ll a[10000] = { };
  cin >> n;
  Eratosthenes(PMAX);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    //全ての値の最小公倍数を取得
    primeStock(a[i]);
  }
  ll l=primesum();
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    //最小公倍数/aiがbiとなるはず
    sum += (l * modinv(a[i], Mod));
    sum %= Mod;
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 14976
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    string s, t, u;
    cin >> s >> t;
   	int a, b;
    cin >> a >> b;
    // 文字列の入力
    cin >> u;
    // 出力
  	bool c;
  	if (t == u)
	    cout << (a) << " " << (b -1) << endl;
  	else if (s == u)
	    cout << (a - 1) << " " << (b) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        // N=社員数
        int n = int.Parse(Console.ReadLine());
        // 社員番号  社員数の連番に対する同じ数の出現回数を表示
        int[] A = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        int[] ans = new int[n];
 
        foreach(var item in A)
        {
            ans[item - 1]++;
        }

        foreach (var t in ans)
        {
            Console.WriteLine(t);
        }

    }
}




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

int main() {
  string n;
  cin >> n;
  if(n.at(0) == n.at(1) && n.at(1) == n.at(2)){
    cout << "Yes" << endl;
  }
  else if(n.at(1) == n.at(2) && n.at(2) == n.at(3)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  double a = 0;
  double sum = 0;
  REP(i,n){
    cin >> a;
    sum += 1/a;
  }
  double ans = 1/sum;
  cout <<setprecision(10)<< ans << endl;

}


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

int main(){
  int N ; 
  cin >> N ; 
  vector<int> a(N) ; 
  int over = 0 ;
  int cnt = 0 ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> a.at(i) ; 
    a.at(i) = a.at(i)/400 ;
    if(a.at(i) >= 8){
      over++ ; 
    }
    else{
      int T = 0 ; 
      for(int j = 0 ; j <= i ; j++){
        if(a.at(i) == a.at(j)){
          T++ ; 
        }
      }
      if(T == 1){
      cnt++ ; 
      }
    }

    //cout << a.at(i) << " " << cnt << endl ; 
  }
  
  if(cnt == 0 ){
    cout << 1  ; 
  }
  else {
    cout << cnt  ;   
  }
  

  if(  over > 0 ){
    cnt = cnt + over ; 
    }
    
  cout << " " << cnt << endl ; 
  return 0 ; 
  
}


Measured memory_bytes: 3544
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
    string n;
    cin >> n;
    int A[4];
    for (int i = 0; i < 4; i++) {
        A[i] = n[i] - '0';
    }
    
    for (int bit = 0; bit < 8; bit++) {
        int sum = A[0];
        string S = "";
        S += (char)('0' + A[0]);
        for (int i = 0; i < 3; i++) {
            if (bit & (1<<i)) {
                sum += A[i + 1];
                S += '+';
                S += (char)('0'+ A[i + 1]);
            }else{
                sum -= A[i + 1];
                S += '-';
                S += (char)('0'+ A[i + 1]);
            }
        }
        if (sum == 7) {
            cout << S << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int sum=0;
    rep(0,5){
        int x;
        cin >> x;
        sum += x;
    } 
    cout << 15-sum << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include<string>
#define int long long
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;++i) cin>>arr[i];
    int dp[n]={0};
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=2;i<n;++i)
    {
        dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];

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

}


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

using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    int cnt_lr = 0;
    int cnt_rl = 0;
    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] == S[i + 1]) {
            ans++;
        } else if (S[i] == 'L' and S[i + 1] == 'R') {
            cnt_lr++;
        } else if (S[i] == 'R' and S[i + 1] == 'L') {
            cnt_rl++;
        }
    }
    int cnt = 0;
    while (K > 0 and cnt_lr > 0 and cnt_rl > 0) {
        cnt += 2;
        K--;
        cnt_lr--;
        cnt_rl--;
    }
    if (K > 0 and cnt_lr > 0 and (S.at(0) == 'L' or S.at(N - 1) == 'R')) {
        cnt++;
        K--;
    }
    if (K > 0 and cnt_rl > 0 and (S.at(0) == 'R' or S.at(N - 1) == 'L')) {
        cnt++;
        K--;
    }
    ans += cnt;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static void main(String args[]) {
        int debt = 100000;
        int nWeeks = Integer.parseInt(new Scanner(System.in).next());
        for(int i = 0; i < nWeeks; i++) {
            debt = new BigDecimal(debt * 1.05).setScale(-3, RoundingMode.CEILING).intValue();
        }
        System.out.println(debt);

    }
} 

Measured memory_bytes: 17224
import bisect

a, b, q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(a)] + [INF]
t = [-INF] + [int(input()) for i in range(b)] + [INF]
ans = []
for i in range(q):
    x = int(input())
    idxs = bisect.bisect(s, x)
    idxt = bisect.bisect(t, x)
    lis = []
    lis.append(x - min(s[idxs - 1], t[idxt -1]))
    lis.append(x - s[idxs - 1] + (t[idxt] - s[idxs - 1]))
    lis.append(t[idxt] - x + (t[idxt] - s[idxs - 1]))
    lis.append(x - t[idxt - 1] + (s[idxs] - t[idxt - 1]))
    lis.append(s[idxs] - x + (s[idxs] - t[idxt - 1]))
    lis.append(max(s[idxs], t[idxt]) - x)
    ans.append(min(lis))
for i in range(q):
    print(ans[i])





Measured memory_bytes: 16380
#include<iostream>
#include<vector>
using namespace std;
int main(){

  bool Prime[300000]={0},flg = true;
  vector<int> Prime_No;
  for(int i=6;i<300000;i+=(flg?2:5),flg=!flg){
    if(!Prime[i]){
      for(int j=2;i*j<300000;j++) Prime[i*j] = true;
      Prime_No.push_back(i);
    }
  }

  int n;
  while(cin >> n && n!=1){
    cout << n << ":";
    for(int i=0,l=Prime_No.size();i<l;i++){
      if(n % Prime_No[i] == 0) cout << " " << Prime_No[i];
    }
    cout << endl;
  }
}

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

#define ll long long

int main(){
    ll n, d, x[200000], y[200000];
    scanf("%lld%lld", &n, &d);
    for(int i=0;i<n;i++) scanf("%lld%lld", x+i, y+i);

    int ans = 0;
    for(int i=0;i<n;i++){
        if(x[i]*x[i]+y[i]*y[i] <= d*d)
            ans += 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4840
#include <cstdio>
using namespace std;

bool prime[50010];
int ans[50010];

int main(){
	for(int i = 2; i <= 50000; ++i){
		prime[i] = true;
	}
	for(int i = 2; i < 300; ++i){
		if(prime[i]){
			for(int j = i * i; j <= 50000; j += i){
				prime[j] = false;
			}
		}
	}

	int n;
	while(scanf("%d", &n), n){
		int c = 0;
		for(int i = 2; i * 2 <= n; ++i){
			if(prime[i] && prime[n-i]) ++c;
		}
		printf("%d\n", c);
	}
}

Measured memory_bytes: 1080
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

ll dp[100005][2];
vector<vector <int>> v(100000);

ll dfs(int node, int prev_color, int p) {
  if (dp[node][prev_color] != -1) return dp[node][prev_color];
  ll white = 1LL, black = 1LL - ll(prev_color);
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] != p) {
      if (prev_color == 0) {
        white = (white * dfs(v[node][i], 0, node)) % MOD;
        black = (black * dfs(v[node][i], 1, node)) % MOD;
      } else {
        white = (white * dfs(v[node][i], 0, node)) % MOD;
        black = 0LL;
      }
    }
  }
  return dp[node][prev_color] = (white + black) % MOD;
}

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

  for (int i = 0; i < N - 1; i++) {
    int a, b; cin >> a >> b;
    v[a-1].push_back(b-1);
    v[b-1].push_back(a-1);
  }

  for (int i = 0; i < N; i++) {
    dp[i][0] = dp[i][1] = -1;
  }
  cout << dfs(0, 0, -1) << endl;
  return 0;
}



Measured memory_bytes: 15616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1e9+7;

int main()
{
	ll a,b,k;
	cin>>a>>b>>k;
	if(k<=a)
	{
		cout<<a-k<<" "<<b<<endl;
	}
	else
	{
		if(b-(k-a)>=0)
			{b=b-(k-a);
			cout<<0<<" "<<b<<endl;}
		else
		{
			cout<<0<<" "<<0<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define DAY_MIN (30*60)
using namespace std;
struct Pox
{
  int weekday,start;
  Pox(int weekday=-1,int start=-1):weekday(weekday),start(start){}
};
int N,P;
bool used[7][DAY_MIN+1];

int toMin(int v)
{
  int tp = (int)floor(v/100.0);
  int bm = v%100;
  return tp*60 + bm;
}

bool cmp(const Pox &a,const Pox &b)
{
  if(a.weekday != b.weekday)return a.weekday < b.weekday;
  return a.start < b.start;
}

int main()
{

  while(cin >> N , N)
    {
      map<string,Pox> index;
      rep(j,7)rep(i,DAY_MIN+1)used[j][i] = false;
      bool AUTO = false;
      vector<Pox> info(N);
      vector<string> name(N);
      map<string,bool> drowsiness;

      rep(i,N)
	{
	  cin >> name[i] >> info[i].weekday >> info[i].start;
	  info[i].start = toMin(info[i].start);
	  index[name[i]] = info[i];
	}

      /*
      rep(i,N)
      cout << name[i] << " " << info[i].weekday << " " << info[i].start << endl;
      */
      
      cin >> P;
      int cnt = P;
      vector<string> name2(P);
      rep(i,P)
	{
	  cin >> name2[i];
	  Pox pox = index[name2[i]];
	  drowsiness[name2[i]] = true;
	  int week = pox.weekday;
	  if(!AUTO)
	    {
	      //cout << "fill in : " << pox.start << " " << pox.start+30 << " from " << week << " ";
	      REP(j,pox.start,pox.start+30)
		{
		  if(used[week][j])
		    {
		      AUTO = true;
		      break;
		    }
		  used[week][j] = true;
		}
	      //cout << " to " << week << endl;
	    }
	}

      vector<Pox> FIFA;
      rep(i,name.size())
	{
	  //cout << name[i] << " = ";
	  if(!drowsiness[name[i]])
	    {
	      //cout << "IN" << endl;
	      FIFA.push_back(index[name[i]]);
	    }	
	}

      //cout << "------" << endl;

      sort(FIFA.begin(),FIFA.end(),cmp);

      rep(i,FIFA.size())
	{
	  int week = FIFA[i].weekday;
	  bool check = true;
	  //cout << "fill in | " << FIFA[i].start << " " << FIFA[i].start+30 << " : " << week;
	  REP(j,FIFA[i].start,FIFA[i].start+30)
	    {
	      if(used[week][j])
		{
		  check = false;
		  break;
		}
	      used[week][j] = true;
	    }
	  if(check)cnt++;
	  //cout << " to " << week << " cnt = " << cnt << endl;
	}

      if(AUTO)cout << -1 << endl;
      else    cout << cnt << endl;
    }
  return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double pi = acos(-1);
    double A = (h*60+m)/720.0*pi*2, B = m/60.0*pi*2;
    printf("%.10lf\n", sqrt(a*a+b*b-2*a*b*cos(abs(B-A))));
    return 0;
}

Measured memory_bytes: 4228
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1195&lang=jp
// Wの変換後の文字がSと一致する必要条件として、
// Wのn文字目までの変換後の文字がSのn文字目まで一致することが挙げられる。
// よってn=1,2,\dotsと順番にやればいい。

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;

vector<string> V[30];

char c(char a) {
  return (char) ( (int)a + 1 );
}

char d(int n) {
  return (char) (n + (int)'a');
}

int main() {
  string S;
  while (cin >> S && S != "#") {
    for(auto i=0; i<30; i++) {
      V[i].clear();
    }
    int N = S.size();
    V[0].push_back("");
    for (auto i=0; i<N; i++) {
      for (auto j=0; j<V[i].size(); j++) {
	string T = V[i][j];
	string U[2];
	U[0] = T + S[i];
	U[1] = T + c(S[i]);
	for (auto k=0; k<2; k++) {
	  string W = U[k];
	  for (auto l=0; l<25; l++) {
	    auto x = W.find(d(l+1));
	    if (x < N) {
	      W[x] = d(l);
	    }
	  }
	  if (W == S.substr(0, i+1)) {
	    V[i+1].push_back(U[k]);
	  }
	}
      }
    }
    sort(V[N].begin(), V[N].end());
    auto k = V[N].size();
    cout << k << endl;
    if (k <= 10) {
      for (auto i=0; i<k; i++) {
	cout << V[N][i] << endl;
      }
    } else {
      for (auto i=0; i<5; i++) {
	cout << V[N][i] << endl;
      }
      for (auto i=k-5; i<k; i++) {
	cout << V[N][i] << endl;
      }
    }
  }
}

Measured memory_bytes: 4692
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] $) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt(), q = sc.nextInt();
        String s = sc.next();
        int[] AC = new int[n + 1];
        for (int i = 1; i < n; i++) {
            if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {
                AC[i] = 1;
            }
        }
        for (int i = 1; i < n + 1; i++) {
            AC[i] += AC[i - 1];
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt(), r = sc.nextInt();
            int k = 0;
            if (r < n && s.charAt(r - 1) == 'A' && s.charAt(r) == 'C') k++;

            out.println(max(0, AC[r] - AC[l - 1] - k));
        }
        out.close();
    }
}


Measured memory_bytes: 73108
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val b = mutableListOf<Int>()
    b.add(Int.MAX_VALUE)
    repeat(n-1) {
        b.add(sc.nextInt())
    }
    b.add(Int.MAX_VALUE)

    var ans = 0
    for (i in 1..n) {
        ans += Math.min(b[i], b[i - 1])
    }
    println(ans)
}

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

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  int MIN = 1000000;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x < MIN) {
      MIN = x;
      ans++; 
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

//public class Problem0022_MaximumSumSequence {
public class Main {
	public static void main(String[] args) {
		try {
		//	Problem0022_MaximumSumSequence test = new Problem0022_MaximumSumSequence();
			Main test = new Main();
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String line;
			while((line = reader.readLine()) != null) {
				int termNumber = Integer.parseInt(line);
				if(termNumber == 0) {
					break;
				}
				int[] numbers = new int[termNumber];
				for(int i = 0; i < numbers.length; i++) {
					numbers[i] = Integer.parseInt(reader.readLine());
				}
				
				test.showAnswer(numbers);
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
	void showAnswer(int[] array) {
		int[] numbers = array;
		int maxSum = numbers[0];		//®ÌÍÍÍ(-1000 <= a <= 1000)
		for(int i = 0; i < numbers.length; i++) {
			if(-1 < maxSum) {
				if(numbers[i] < 0) {
					//do nothing
				} else {
				//	System.out.println("  :" + i + ":\t" +maxSum);
					int maxCandidate = getMaxSumFromIndex(numbers, i);
					if(maxSum < maxCandidate) {
						maxSum = maxCandidate;
					}
				}
			} else if(0 < numbers[i]) {
				maxSum = getMaxSumFromIndex(numbers, i);
			} else if(maxSum < numbers[i] ) {
				maxSum = numbers[i];
			}
		//	System.out.println("»óF" +i  + ":\t" +  maxSum);
		}
		System.out.println(maxSum);
	}
	private int getMaxSumFromIndex(int[] array, int start) {
	//	System.out.println("getMaxSumFromIndex:start" +start); 
		int maxSum = Integer.MIN_VALUE;
		int summation = 0;
		for(int i = start; i < array.length; i++) {
		//	System.out.println("summation:" + summation + "array[" + i + "] = " + array[i]);
			summation += array[i];
			if(maxSum < summation) {
				maxSum = summation;
			}
		}
		
		return maxSum;
	}
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

set<string> st;
int main(){
    int n;
    cin>>n;
    string s,t;
    rep(i,n){
        cin>>s;
        if(s=="insert"){
            cin>>t;
            st.insert(t);
        }
        else{
            cin>>t;
            if(st.count(t)>0) cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 32572
# coding: utf-8

def solve(*args: str) -> str:
    n = int(args[0])
    A = sorted(map(int, args[1].split()), reverse=True)

    return str(sum([A[i//2] for i in range(1, n)]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 33708
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int d[55][55];
    for(int i=0;i<55;i++){
        for(int j=0;j<55;j++){
            d[i][j]=mod;
        }
    }
    vector<int> a(m),b(m); 
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        d[a[i]][b[i]]=0;
        d[b[i]][a[i]]=0;
    }
    int res=0;
    for(int p=0;p<m;p++){
        int dist[55][55];
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dist[i][j]=d[i][j];
            }
        }
        dist[a[p]][b[p]]=mod;
        dist[b[p]][a[p]]=mod;
        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
                }
            }
        }
        bool bridge=false;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(dist[i][j]!=0)bridge=true;
            }
        }
        if(bridge)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second = i+1;
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout<<a[i].second<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n<<=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1e5;

priority_queue<pii> pq[3][3];
int n, x, y, z, a[N][3];
bool Y[3][N];
pii t[3][3];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> y >> z;
  n = x + y + z;
  FOR(i, 0, n) FOR(j, 0, 3) cin >> a[i][j];
  FOR(i, 0, n){
    int j;
    if(i < x+y+z) j = 2;
    if(i < x+y  ) j = 1;
    if(i < x    ) j = 0;
    Y[j][i] = true;
    FOR(k, 0, 3) pq[j][k].push(pii(a[i][k]-a[i][j], i));
  }
  while(true){
    FOR(i, 0, 3)FOR(j, 0, 3)while(true){
      t[i][j] = pq[i][j].top();
      if(Y[i][t[i][j].se]) break;
      pq[i][j].pop();
    }
    int ma = 0, p[3];
    FOR(i, 0, 3)FOR(j, 0, 3)FOR(k, 0, 3){
      if(i==j || j==k || k==i) continue;
      int d = t[0][i].fi + t[1][j].fi + t[2][k].fi;
      if(d > ma) ma=d, p[0]=i, p[1]=j, p[2]=k;
    }
    if(!ma) break;
    FOR(i, 0, 3){
      int j = t[i][p[i]].se;
      Y[i][j] = false;
      Y[p[i]][j] = true;
      FOR(k, 0, 3) pq[p[i]][k].push(pii(a[j][k]-a[j][p[i]], j));
    }
  }
  ll ans = 0;
  FOR(i, 0, x+y+z)FOR(j, 0, 3) if(Y[j][i]) ans += a[i][j];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6248
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    # N, M = 41, 2
    # A = [5,6]

    max = sum(A)
    ans = N - max
    if ans < 0:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10048
class UnionFind
  def initialize(n)
    @root = Array.new(n)
    @rank = Array.new(n)
    @size = Array.new(n)
    (0...n).each do |i|
      @root[i] = i
      @rank[i] = 0
      @size[i] = 1
    end
  end

  def find(x)
    if @root[x] == x
      x
    else
      @root[x] = find(@root[x])
    end
  end

  def unite(x, y)
    x_root = find(x)
    y_root = find(y)
    return if x_root == y_root

    if @rank[x_root] < @rank[y_root]
      @root[x_root] = y_root
      @size[y_root] += @size[x_root]
    else
      @root[y_root] = x_root
      @size[x_root] += @size[y_root]
      if @rank[x_root] == @rank[y_root]
        @rank[x_root] += 1
      end
    end
    nil
  end

  def size(x)
    x_root = find(x)
    @size[x_root]
  end

  def same?(x, y)
    find(x) == find(y)
  end
end

N, M, K = gets.split.map(&:to_i)
AB = M.times.map { gets.split.map(&:to_i) }
CD = K.times.map { gets.split.map(&:to_i) }

require 'set'
friends = Array.new(N + 1, 0)
blocks = Array.new(N + 1) { Set.new }
uf = UnionFind.new(N + 1)
AB.each do |a, b|
  uf.unite(a, b)
  friends[a] += 1
  friends[b] += 1
end
CD.each do |c, d|
  blocks[c].add(d)
  blocks[d].add(c)
end

ans = Array.new(N)
N.times do |i|
  a = i + 1
  fc = friends[a]
  all = uf.size(a)
  c = all - fc - 1
  blocks[a].each do |b|
    c -= 1 if uf.same?(a, b)
  end
  ans[i] = c
end
puts ans.join(' ')

Measured memory_bytes: 77692