akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);
		
		int n=sc.nextInt()-1;
		long lcm=sc.nextLong();
		while(n-->0){
			long t=sc.nextLong();
			long g=gcd(lcm, t);
			lcm=(lcm/g)*t;
		}
		pw.println(lcm);
		pw.flush();
		pw.close();
	}
	
	static long gcd(long a,long b){
		return b==0? a : gcd(b,a%b);
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}

Measured memory_bytes: 23124
#include <iostream>

int main() {
  auto pow5 = [](int i) -> int64_t {
    return (int64_t)i * i * i * i * i;
  };

  int n;
  std::cin >> n;
  for (int i = 0; i < 120; ++i) {
    int64_t x = pow5(i);
    for (int j = -120; j < i; ++j) {
      int64_t y = pow5(j);
      if (x - y == n) {
        std::cout << i << " " << j << std::endl;
        // std::cout << x << " " << y << std::endl;
        return 0;
      }
    }
  }
}


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

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

  // ここにプログラムを追記
  int i;
  string S;
  int TypeP=0;
  int TypeW=0;
  int TypeG=0;
  int TypeY=0;
  for(i=0;i<N;i++){
    cin >> S;
    if(S == "P")
    {
      TypeP=1;
    }
    else if(S == "W"){
      TypeW=1;
    }
    else if(S == "G"){
      TypeG=1;
    }
    else
    {
      TypeY=1;
    }
  }
  
  if((TypeP+TypeW+TypeG+TypeY)==3){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
    
  
  
}


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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H + 2, vector<char>(W + 2, '#'));
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      cin >> s[i][j];
    }
  }
  vector<vector<int>> d(H + 2, vector<int>(W + 2, -1));
  d[1][1] = 1;
  queue<pair<int, int>> Q;
  Q.push(make_pair(1, 1));
  while (!Q.empty()){
    int y = Q.front().first;
    int x = Q.front().second;
    Q.pop();
    for (int i = 0; i < 4; i++){
      int y2 = y + dy[i];
      int x2 = x + dx[i];
      if (d[y2][x2] == -1 && s[y2][x2] == '.'){
        d[y2][x2] = d[y][x] + 1;
        Q.push(make_pair(y2, x2));
      }
    }
  }
  if (d[H][W] == -1){
    cout << -1 << endl;
  } else {
    int ans = 0;
    for (int i = 1; i <= H; i++){
      for (int j = 1; j <= W; j++){
        if (s[i][j] == '.'){
          ans++;
        }
      }
    }
    ans -= d[H][W];
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

int n, k;

void make_dp(unsigned a[5010], int skip, unsigned dp[5010]) {
    memset(dp, 0, sizeof(unsigned) * 5010);
    dp[0] = 1;
    rep (i, n) {
        if (i == skip) continue;
        static unsigned ndp[5010];
        memset(ndp, 0, sizeof(unsigned) * 5010);
        for (int j = 0; j <= k; ++j){
            ndp[j] += dp[j];
            ndp[min<unsigned>(k,j+a[i])] += dp[j];
        }
        memcpy(dp, ndp, sizeof(unsigned) * 5010);
    }
}

int main() {
    while(cin >> n >> k){
        unsigned a[5010];
        rep(i, n) scanf("%ud", a + i);
        sort(a, a + n);
        unsigned org[5010];
        make_dp(a, -1, org);
        auto check = [&](int i){
            int x = a[i];
            unsigned rem[5010];
            make_dp(a, i, rem);
            for (int j = 0; j < k; ++j) {
                if (rem[j] != 0 && j + x >= k) {
                    return false;
                    break;
                }
            }
            return true;
        };
        int l = -1, r = n;
        while (l + 1 < r) {
            int m = l + (r - l) / 2;
            if (check(m)) l = m;
            else r = m;
        }
        cout << r << endl;
    }
}


Measured memory_bytes: 384
num = input().split()
a, b, c = [1,3,5,7,8,10,12], [4,6,9,11], [2]
print('Yes') if int(num[0]) in a and int(num[1]) in a or int(num[0]) in b and int(num[1]) in b or int(num[0]) in c and int(num[1]) in c else print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = c-(a-b);
        System.out.println(ans >= 0? ans: 0);
    }
}

Measured memory_bytes: 21844
//
//  main.cpp
//  CompetitiveProgramming
//
//  Created by Yuma Kikuchi on 2018/03/02.
//  Copyright © 2018年 yumarimo. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;
    
    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }
    
    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

int main() {
    int k, s;
    cin >> k >> s;
    
    int cnt = 0;
    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            if (0 <= s - x- y && s - x - y <= k) ++cnt;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
S = input()
K = int(input())

if len(set(S))==1:
  ans = int(len(S)*K/2)
elif K == 1:
  ans = 0
  serial = 1
  #print(serial)
  for i in range(len(S)-1):
    if S[i] == S[i+1]:
      serial += 1
    else:
      ans += int(serial/2)
      serial = 1
  ans += int(serial/2)
else:
  #first
  first=0
  serial = 1
  for i in range(len(S)-1):
    if S[i] == S[i+1]:
      serial += 1
    else:
      first += int(serial/2)
      serial = 1
  initial = 1
  for i in range(len(S)-1,1,-1):
    if S[i]==S[i-1]:
      initial += 1
    else:
      break
  cnt = 0
  serial = initial
  #print(serial)
  for i in range(len(S)):
    if S[i] == S[i-1]:
      serial += 1
    else:
      cnt += int(serial/2)
      serial = 1
    #print(cnt)
  #last
      
  #print(cnt)
  last = 0
  serial = initial
  for i in range(len(S)):
    if S[i] == S[i-1]:
      serial += 1
    else:
      last += int(serial/2)
      serial = 1
  last += int(serial/2)
  #print(first,cnt,last)
  ans = first+(K-2)*cnt+last

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli dp[100100][13];

lli calc(lli now,lli num,lli ten){
	REP(i,0,13){
		dp[now][(i+num*ten)%13] += dp[now-1][i];
		dp[now][(i+num*ten)%13] %= MOD;
	}
}

signed main(){

	string s;
	cin>>s;
	reverse(s.begin(),s.end());

	dp[0][0]=1;
	lli ten=1;
	REP(i,0,s.size()+1){
		if(DEBUG){
			REP(j,0,13)cout<<dp[i][j]<<endl;
			cout<<endl;
		}
		if(i==s.size())break;

		if(s.at(i)=='?'){
			REP(j,0,10){
				calc(i+1,j,ten);
			}
		}
		else{
			calc(i+1,s.at(i)-'0',ten);
		}
		ten *= 10;
		ten %= 13;
	}

	cout<<dp[s.size()][5]<<endl;

	return 0;
}

Measured memory_bytes: 10624
#include<iostream>

using namespace std;

typedef long long int ll;

ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main(void) {
	int n;
	ll t[101];
	ll result = 0;


	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> t[i];
	}

	result = t[1];

	for (int i = 2; i <= n; i++) {
		result = lcm(result, t[i]);
	}

	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 256
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

X,Y = imn()

if (X+Y)%3 != 0:
    print(0)
    exit()

M = (2*Y-X)//3
N = (-2*M)+Y

MAX = 10**6
fact = [1,1]
factinv = [1,1]
inv = [0,1]
for i in range(2, MAX+1):
    fact.append((fact[-1]*i) % MOD)
    inv.append((-inv[MOD%i]*(MOD//i))%MOD)
    factinv.append((factinv[-1]*inv[-1])%MOD)

def cmb(n,r,p):
    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % p
print(cmb(M+N, M, MOD))




Measured memory_bytes: 123920
import itertools
L,R = map(int,input().split())

if R-L>=2019:
    print(0)
    exit()
b = 2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        a = (i*j)%2019
        b = min(b,a)
        if b == 0:
            break
print(b)

Measured memory_bytes: 3060
def findSumOfDigits(num):
  sum = 0
  while num > 0:
    sum += num % 10
    num //= 10
  return sum
  
if __name__ == '__main__':
  N = int(input())
  min_total = 1000
  for i in range(1, N):
    A = i
    B = N - A
    total = findSumOfDigits(A) + findSumOfDigits(B)
    if total < min_total:
      min_total = total
  print(min_total)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstdlib>

using namespace std;

#define rep2(x,from,to) for(long long (x)=(from);x<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
long long n;
long long a;
long long b;
long long now;
long long maxh;
long long ll;
long long rr;
long long deC;
long long h[100005];
long long cc;
long long hh[100005];
int main()
{
  cin>>n;
  cin>>a>>b;
  a-=b;
  rep(i,n)cin>>h[i];
  rep(i,n)maxh=max(maxh,h[i]);
  rr=maxh/b+1;
  while(1)
    {
      if(ll>=rr-1)
	{
	  cout<<rr<<endl;
	  return 0;
	}
      now=(ll+rr)/2;
      deC=now*b;
      cc=0;
      rep(i,n)
	{
	  hh[i]=h[i]-deC;
	  if(hh[i]>0)
	    {
	      cc+=(long long)(hh[i]/a);
	      if(hh[i]%a!=0)cc++;
	    }
	}
      if(cc>now)ll=now;
      else rr=now;
    }
  return 0;
}


Measured memory_bytes: 1792
A,B,M= map(int,input().split(' '))

a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))

min=min(a)+min(b)
for i in range(M):
    x,y,m= map(int,input().split(' '))
    cost= a[x-1]+b[y-1]-m
    if cost<min:
        min=cost
print(min)

Measured memory_bytes: 18608
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long

int c[10];

int32_t main() {
	int n;
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		if (s == "AC")
			c[0]++;
		if (s == "TLE")
			c[1]++;
		if (s == "WA")
			c[2]++;
		if (s == "RE")
			c[3]++;
	}
	cout << "AC x " << c[0] << '\n';
	cout << "WA x " << c[2] << '\n';
	cout << "TLE x " << c[1] << '\n';
	cout << "RE x " << c[3] << '\n';
	return 0;
}


Measured memory_bytes: 3604
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

const debug = true

func (p *problem) solve() {
	for i := 0; i < 3; i++ {
		l := p.next()
		p.printf("%v", string([]rune(l)[i]))
	}
}

func main() {
	if debug {
		log.SetOutput(os.Stdout)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) printi(d int) {
	if err := p.out.WriteByte(byte(d)); err != nil {
		panic(err)
	}
}

func (p *problem) printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) nextInt() int {
	return stoi(p.next())
}

func (p *problem) nextInts() []int {
	line := p.nextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) nextSSLine() []string {
	return strings.Split(p.next(), " ")
}

// Next reads line and return string.
func (p *problem) next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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;
}

const ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,s.size()){
        if(s.at(i)!=t.at(i)){
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using priority_queue_reverse = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = 1'000'000'000LL + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
vector<string> split(const string &str, const char delemiter) {vector<string> res;stringstream ss(str);string buffer; while( getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
int msb(int x) {return x?31-__builtin_clz(x):-1;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    ll X,K,D; cin >> X >> K >> D;
    X = abs(X);
    ll M = X / D;
    corner(K <= M, abs(X-K*D));
    K -= M;
    X = abs(X-M*D);
    if(K%2) X = abs(X-D);
    cout << abs(X) << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}



int main() {
  LL n,k=-1,sum=0,a=0,b=0,c=0,d=0,ans=0;
  LL MOD = 1000000007;
  LL INF = 1LL << 60;
  string S="",T="",U="";
  cin >> a >> b >> c;
  cout << max(a,max(b,c)) - min(a,min(b,c)) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A;
    //Aを定義
    int B;
    //Bを定義
    cin >> A >> B;
    //A,Bの順で標準入力
    if ((A + B) < 10){
        cout << A + B << endl;
        //A + Bが10より小さい場合A + Bをそのまま計算して出力
    } else if((A + B) >= 10){
        cout << "error" << endl;
        //A + B が10以上の場合代わりにerrorと出力
    }
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        Set<String> gift = new HashSet<String>(); 
        int N = sc.nextInt();
        sc.nextLine();
        
        for (int i = 0; i < N; i++) {
            gift.add(sc.nextLine());
        }

        System.out.println(gift.size());

    }
}

Measured memory_bytes: 79572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

class UnionFind{
private:
    vec<int> p,s;
    int cnt;
public:
    UnionFind(){}
    UnionFind(int N):cnt(N),s(N,1),p(N){
        iota(p.begin(),p.end(),0);
    }
    int find(int x){
        if(p[x]==x) return x;
        else return p[x] = find(p[x]);
    }
    void unite(int x,int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(s[x]>s[y]) swap(x,y);
        p[x] = y;
        s[y] += s[x];
        cnt--;
    }
    bool is_same_set(int x,int y) {return find(x)==find(y);}
    int size(int x) {return s[find(x)];}
    int compnents_number(){return cnt;}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> X(N),Y(N);
    for(int i=0;i<N;i++){
        cin >> X[i] >> Y[i];
        X[i]--,Y[i]--;
    }
    UnionFind uf(N);
    vec<int> idx(N),idy(N);
    iota(all(idx),0);
    iota(all(idy),0);
    sort(all(idx),[&](int i,int j){return X[i]<X[j];});
    sort(all(idy),[&](int i,int j){return Y[i]>Y[j];});
    int r = -1;
    int mi = N,id = -1;
    for(int i:idy){
        int x = X[i];
        if(x<r) continue;
        if(mi<Y[i]) uf.unite(id,i);
        for(int j=r+1;j<=x;j++){
            uf.unite(idx[j],i);
            if(chmin(mi,Y[idx[j]])){
                id = i;
            }
        }
        r = x;
    }
    for(int i=0;i<N;i++) cout << uf.size(i) << "\n";
}

Measured memory_bytes: 7900
import java.io.*;

class Main
{
    public static void main (String[] args) throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int k=0;
        if(n<600) k=8;
        else if(n<800) k=7;
        else if(n<1000) k=6;
        else if(n<1200) k=5;
        else if(n<1400) k=4;
        else if(n<1600) k=3;
        else if(n<1800) k=2;
        else k=1;
        System.out.print(k);
    }
}

Measured memory_bytes: 32452
#include <stdio.h>

int main(void){
	int n;
	int i,j,k,l;
	int count;

	while(scanf("%d", &n) != -1){
		if(n >= 37){
			printf("0\n");
		}else{
			count = 0;
			for(i=0;i<=9;i++){
				for(j=0;j<=9;j++){
					for(k=0;k<=9;k++){
						for(l=0;l<=9;l++){
							if(i+j+k+l == n){
								count++;
							}
						}
					}
				}
			}
			printf("%d\n", count);
		}
	}
	return 0;
}

Measured memory_bytes: 0
import bisect

n=int(input())
l=sorted(map(int,input().split()))

t=0
for i in range(n):
  for j in range(i+1,n):
    a = j+1
    b = bisect.bisect_left(l,l[i]+l[j])
    t += b-a if b>a else 0

print(t)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
using namespace std;

int mod=1000000007;

int main(){
    int n;
    cin>>n;
    int ans=1,c[100010]={};
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        c[a]++;
        if(c[a]>2){
            cout<<"0"<<endl;
            return 0;
        }
        else if(c[0]>1){
            cout<<"0"<<endl;
            return 0;
        }
    }
    int che=0;
    for(int i=0;i<100001;i++){
        if(c[i]==2)ans*=2;
        else if(c[i]==1)che++;
        if(che==2){
            cout<<"0"<<endl;
            return 0;
        }
        ans%=mod;    
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	bool MarkA=false,MarkB=false;
	for (int i=0;i<3;++i)
		if (s[i]=='A') MarkA=true;
		else MarkB=true;
	if (MarkA && MarkB) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int ,input().split()))
A = 0
B = 0
for i in range(N) :
    A += max(list(a))
    a.remove(max(list(a)))
    a.append(0)
    B += max(list(a))
    a.remove(max(list(a)))
    a.append(0)



print(A - B)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int A, B;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B;

  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static exMath;
using static exReadLine;


class Program
{
    static void Main(string[] args)
    {
        long R;
        longReadLine(out R);
        WriteLine(R * 2 * PI);
        //ReadLine();
    }
}

static class exReadLine
{
    public static void intReadLine(out int a)
    {
        a = int.Parse(ReadLine());
    }
    public static void intReadLine(out int a, out int b)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void intReadLine(out int a, out int b, out int c)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void intReadLine(out int a, out int b, out int c, out int d)
    {
        int[] input = ReadLine().Split().Select(int.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }

    public static void longReadLine(out long a)
    {
        a = long.Parse(ReadLine());
    }
    public static void longReadLine(out long a, out long b)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
    }
    public static void longReadLine(out long a, out long b, out long c)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
    }
    public static void longReadLine(out long a, out long b, out long c, out long d)
    {
        long[] input = ReadLine().Split().Select(long.Parse).ToArray();
        a = input[0];
        b = input[1];
        c = input[2];
        d = input[3];
    }
    
    public static int[] intArrayReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static long[] longArrayReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToArray();
    }

    public static List<int> intListReadLine()
    {
        return ReadLine().Split().Select(int.Parse).ToList();
    }

    public static List<long> longListReadLine()
    {
        return ReadLine().Split().Select(long.Parse).ToList();
    }
}

static class exMath
{
    // 最大公約数
    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var r = a % b;
            a = b;
            b = r;
        }
        return a;
    }

    // 最小公倍数
    public static long Lcm(int a, int b)
    {
        return BigMul(a, b) / Gcd(a, b);
    }
    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }
}

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

int main(){
 int n;
 cin >> n;
 vector<int> v(n);
 vector<int> c(n);
 for(int i=0;i<n;i++){
    cin >> v.at(i);
 }
 for(int i=0;i<n;i++){
    cin >> c.at(i);
 }
 int ans = 0;
 for(int k=0;k<n;k++){
    if(v[k]>c[k]) ans +=v[k]-c[k];
 }
 cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
ll com[55][55];

int main(){
    int n,a,b; cin >> n >> a >> b;
    rep(i, 55){
        rep(j, i+1){
            if(i == 0 || j == i) com[i][j] = 1LL;
            else com[i][j] = com[i-1][j-1] + com[i-1][j];
        }
    }
    double amax = 0;
    ll cnt = 0;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(RALL(v));
    double sum = 0.0;
    rep(i,a) sum += v[i];
    amax = sum / (double)a;
    int var = 0, num = 0;
    rep(i,a) if(v[i] == v[a-1]) var++;
    rep(i,n) if(v[i] == v[a-1]) num++;
    cnt = com[num][var];
    if(v[0] == v[a-1]){
        cnt = 0;
        FOR(i,a,b+1) cnt += com[num][i];
    }
    cout << setprecision(10);
    cout <<  fixed << amax << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(int argc, char const *argv[])
{	
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a % 2 && b % 2)	printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b;
    double c=0;
    scanf("%d%d",&a,&b);
    if(a==b || a<b )//根本不可能满足打错了应该是||
    {
       for(int i=0;i<=b-1;i++)
       {
           c= pow(10,i)*a+c;//c每次都会变成一个新的数而不是累加
       }
    }
    else
    {
        for (int j=0;j<=a-1;j++)
        {
             c=pow(10,j)*b+c;
        }
    }
    printf("%.0f",c);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const int N = (int)5e3 + 5;
const ll x[2] = {11, 137};
const ll M[2] = {998244353, 1000000007};

int n;
string s;
ll h[2][N], xp[2][N];

pair<ll, ll> subhash(int i, int len) {
  return {(h[0][i + len - 1] - h[0][i - 1] * xp[0][len] % M[0] + M[0]) % M[0], (h[1][i + len - 1] - h[1][i - 1] * xp[1][len] % M[1] + M[1]) % M[1]};
}
bool ok(int len) {
  for(int i = 1 ; i + len - 1 <= n ; ++i) {
    pair<ll, ll> hv1 = subhash(i, len);
    for(int j = i + len ; j + len - 1 <= n ; ++j) {
      pair<ll, ll> hv2 = subhash(j, len);
      if(hv1 == hv2) return true;
    }
  }
  return false;
}

void init() {
  cin >> n >> s;
  h[0][0] = h[1][0] = 0;
  xp[0][0] = xp[1][0] = 1;
  for(int i = 1 ; i <= (int)s.size() ; ++i) xp[0][i] = xp[0][i - 1] * x[0] % M[0], xp[1][i] = xp[1][i - 1] * x[1] % M[1];
  for(int i = 1 ; i <= (int)s.size() ; ++i) h[0][i] = (h[0][i - 1] * x[0] % M[0] + s[i - 1] - 'a' + 1) % M[0], h[1][i] = (h[1][i - 1] * x[1] % M[1] + s[i - 1] - 'a' + 1) % M[1];
}
void solve() {
  int L = 0, R = (int)s.size() / 2 + 1;
  while(L + 1 < R) {
    int mid = (L + R) / 2;
    if(ok(mid)) L = mid;
    else R = mid;
  }
  cout << L << '\n';
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  init();
  solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;

int N, M;
pii A[55];
pii B[55];

int dist(int a, int b, int x, int y) {
  return abs(a - x) + abs(b - y);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> M;
  for(int i = 1; i <= N; i++) {
    cin >> A[i].first >> A[i].second;
  }
  for(int i = 1; i <= M; i++) {
    cin >> B[i].first >> B[i].second;
  }
  for(int j = 1; j <= N; j++) {
    int best = 1e9, bestid = 0;
    for(int i = 1; i <= M; i++) {
      if(dist(A[j].first, A[j].second, B[i].first, B[i].second) < best) {
        best = dist(A[j].first, A[j].second, B[i].first, B[i].second);
        bestid = i;
      }
    }
    cout << bestid << "\n";
  }
}

Measured memory_bytes: 256
//
//
//

#include <iostream>
using namespace std;

int main() {
	int N,M;
	
	cin >> N >> M;
	
	int K[M+1];
	for(int i=1; i<=M; i++) K[i] = 0;
	
	for(int i=0; i<N; i++) {
		int k;
		cin >> k; 
		for(int j=0; j<k; j++) {
			int x;
			cin >> x;
			K[x]++; 
		}
	}	
			
	int counter=0;
	for(int i=1; i<=M; i++) {
		if (K[i] == N) counter++;
	}
	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
L = list(map(int, input().split()))
 
sL = sorted(L)
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if sL[i] == sL[j]: continue
        for k in range(j+1, n):
            if (sL[i] == sL[k]) or (sL[j] == sL[k]): continue
            if (sL[i] + sL[j]) > sL[k]:
                ans += 1
 
print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SP << " " 

using namespace std;

void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	string s;

	cin>> s;

	if(s=="ABC") cout<< "ARC" << endl;
	else cout<< "ABC" << endl;

	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int ns = s.size(),nt=t.size();
    int sum_s[ns+1]={},sum_t[nt+1]={};
    rep(i,ns){
        sum_s[i+1] = (s[i]=='A' ? 2 : 1) + sum_s[i];
    }
    rep(i,nt){
        sum_t[i+1] = (t[i]=='A' ? 2 : 1) + sum_t[i];
    }
    int q;cin>>q;
    rep(i,q){
        int a,b,c,d;cin>>a>>b>>c>>d;
        a--;c--;
        cout << ((sum_s[b]-sum_s[a])%3 == (sum_t[d]-sum_t[c])%3 ? "YES" : "NO") << endl;
    }
    return 0;
}


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

int main()
{
	int a, b, c;

	int l, r;
	for (int i = 0; i < 3; i++)
	{
		ios::sync_with_stdio(false);
		cin.tie(0);
		cin >> a >> b >> c;

		if (!i)
		{
			l = abs(a - b);
			r = abs(b - c);
		}
		if (l != abs(a - b) || r != abs(b - c))
		{
			cout << "No" << endl;
			return (0);
		}
	}
	cout << "Yes" << '\n';
	return (0);
}


Measured memory_bytes: 3656
// AOJ 2658: Pruning
// 2018.1.4 bal4u@uu

#include <stdio.h>

typedef struct { short c, p, ch, sib; char mk; } T;
T t[1002];

short to[1002][1002], cost[1002][1002];
short len[1002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void mktree(int par)
{
	int i, f, sib, tp;

	if (t[par].mk) return;
	t[par].mk = 1;

	f = 0;
	for (i = 0; i < len[par]; i++) {
		tp = to[par][i];
		if (t[tp].mk) continue;
		if (!f) t[par].ch = tp; 
		t[tp].p = cost[par][i];
		if (f) t[sib].sib = tp; else f = 1;
		sib = tp;
		mktree(sib);
	}
}

int calc(int par)
{
	int p, s, tp;

	p = t[par].p;
	if (t[par].c) return p;
	s = 0, tp = t[par].ch;
	while (tp) {
		s += calc(tp);
		if (s >= p) return p;
		tp = t[tp].sib;
	}
	return s;
}

int main()
{
	int n, u, v, p, i, k;

	n = in();
	for (i = 2; i <= n; i++) t[i].c = in();
	i = n-1; while (i--) {
		u = in()+1, v = in()+1, p = in();
		k = len[u]++, to[u][k] = v, cost[u][k] = p;
		k = len[v]++, to[v][k] = u, cost[v][k] = p;
	}
	mktree(1);
	t[1].p = 0x7fff;

	printf("%d\n", calc(1));
	return 0;
}


Measured memory_bytes: 5620
#include <cstdio>
#include <vector>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)
const int N=1e5;
int n, q, fa[N], size[N];
long long m;
std::vector<std::pair<int, int>> dif;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar(), c-'0'>9&c!='-');
	for(a=(b=c=='-')?0:c-'0'; (c=getchar()-'0')<=9; a=a*10+c);
	return b?-a:a;
}
int find(int x) {return fa[x]==x?x:(fa[x]=find(fa[x]));}
int main() {
	int (*rd)()=read<int>;
	n=rd(), m=read<long long>()-n+1, q=rd();
	for(int i=0; i<n; ++i) fa[i]=i, size[i]=1;
	while(q--) {
		int u=rd(), v=rd(), c=rd();
		if(c) dif.emplace_back(u, v); else {
			u=find(u), v=find(v);
			if(u!=v) fa[v]=u, size[u]+=size[v];
		}
	}
	if(m==0) {
		puts(dif.empty()?"Yes":"No");
		return 0;
	}
	for(auto &e: dif) {
		e.first=find(e.first);
		e.second=find(e.second);
		if(e.first==e.second) {
			puts("No");
			return 0;
		}
	}
	int cnt=0;
	for(int i=0; i<n; ++i) cnt+=fa[i]==i;
	puts(cnt>=3&&m<=(cnt-2ll)*(cnt-1ll)/2?"Yes":"No");
	return 0;
}


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

int main(void)
{
	float x1, y1, x2, y2, x3, y3;
	float a, b, c;
	float xp, yp, r;
	float S;
	int n;
	
	scanf("%d", &n);
	
	while (n){
		scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);
		
		a = (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1);
		b = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
		c = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);
		a = sqrt(a);
		b = sqrt(b);
		c = sqrt(c);
		r = a * b * c;    
		r /= sqrt( (a+b+c) * (-a+b+c) * (a-b+c) * (a+b-c) );
		xp = ((y1 - y3) * (y1 * y1 - y2 * y2 + x1 * x1 -x2 * x2) - (y1 - y2) * (y1 * y1 - y3 * y3 + x1 * x1 - x3 * x3)) / (2 * (y1 - y3) * (x1 - x2) -2 * (y1 - y2) * (x1 - x3));
		yp = ((x1 - x3) * (x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2) - (x1 - x2) * (x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3)) / (2 * (x1 - x3) * (y1 - y2) -2 * (x1 - x2) * (y1 - y3));
		
		printf("%.3f %.3f %.3f\n", xp, yp, r);
		n--;
	}
	return (0);
}
 
 

Measured memory_bytes: 652
#include<iostream>

using namespace std;

int a[200000];
long long cs[200000];
int n;

int main() {
    cin >> n;
    cs[0] = 0LL;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (i != 0) cs[i] = cs[i - 1];
        cs[i] += (long long)a[i];
    }

    long long ans = cs[n - 1];
    for (int i = 1; i < n - 2; ++i) {
        int j = upper_bound(cs, cs + i, cs[i] / 2) - cs;
        if (j > 0) {
            if (abs(cs[j]- (cs[i] -cs[j])) > abs(cs[j - 1]- (cs[i] -cs[j - 1]))) j--;
        }
        int k = upper_bound(cs + i + 1, cs + n, cs[i] + (cs[n - 1] - cs[i]) / 2) - cs;
        if (k > i) {
            if (abs(cs[n - 1] - cs[k] - (cs[k] - cs[i])) > abs(cs[n - 1] - cs[k - 1] - (cs[k - 1] - cs[i]))) k--;
        }
        //cout << i << " " << j << " " << k << " --";
        long long vals[4] = {cs[j], cs[i] - cs[j], cs[k] - cs[i], cs[n - 1] - cs[k]};
        long long d = *max_element(vals, vals + 4) - *min_element(vals, vals + 4);
        ans = min(d, ans);
        //cout << d << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2688
N,*M=`dd`.split.map &:to_i;X,Y,*A,_=M.shift N;D=[*0..1e6];s=0;A.map{|e|1.upto(e){|j|D.unshift D[j*2-1]};s+=e};M.map{|e|p (D[e]||e-s)+X-Y}

Measured memory_bytes: 88512
#include <iostream>
#include <string>
using namespace std;
int main(){
string arr[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
string s;
cin>>s;
int n;
for (int i = 0; i <7 ; ++i) {

    if(s==arr[i]) {
     cout << 7 - i;
 }
}}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $k);
$a = range(1, $n);

for ($i=0; $i<$k; $i++) {
    fgets(STDIN);
    foreach (explode(' ', fgets(STDIN)) as $v) unset($a[$v-1]);
}
echo count($a);


Measured memory_bytes: 16144
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <climits>


#define MAX 100


using namespace std;


int main()
{
    vector< vector<int> > adj(MAX + 1, vector<int>(MAX, INT_MAX));
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int cost;
            cin >> cost;
            if (cost >= 0)
                adj[i][j] = cost;
        }
    }

    vector<int> parent(MAX);
    vector<int> in_tree(MAX, false);
    vector<int> min_dists(MAX, INT_MAX);
    int tree_count = 0;

    int acc = 0;
    min_dists[0] = 0;
    for (int tc = 0; tc < n; tc++) {
        int min_cost = INT_MAX;
        int min_v = -1;
        for (int i = 0; i < n; i++) {
            if (min_cost > min_dists[i] && !in_tree[i]) {
                min_cost = min_dists[i];
                min_v = i;
            }
        }

        acc += min_cost;
        in_tree[min_v] = true;

        for (int i = 0; i < n; i++) {
            if (min_dists[i] > adj[min_v][i] && !in_tree[i]) {
                min_dists[i] = adj[min_v][i];
                parent[i] = min_v;
            }
        }
    }

    cout << acc << endl;

    return 0;
}



Measured memory_bytes: 3180
<?php
# 文字列の入力
fscanf(STDIN, "%s", $s);

$len = strlen($s);

for($i=0;$i<$len;$i++){
  $count = substr_count ($s, substr($s,$i,1));
  if ($count > 1) {
    echo "no\n";
    exit;
  }
}
echo "yes\n";
?>

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
long long n,ans;
void f(int x){
	long long nn=n;
	while(nn%x==0)nn/=x;
	if(nn%x==1)++ans;	
}
int main(){
	//freopen("F.in","r",stdin); 
	//freopen("F.out","w",stdout); 
	
	scanf("%lld",&n);
	
	ans=0;
	for(long long i=1;i*i<=n;++i){
		if((n-1)%i==0){
			++ans;
			if(i*i!=n-1)++ans;
		}
	}
	
	for(long long i=2;i*i<=n;++i)if(n%i==0)f(i);
	
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
grid = [list(map(int, input().split())) for i in range(n)]

for i in range(n - 1):
    if (grid[i][0] + grid[i][1]) % 2 != (grid[i + 1][0] + grid[i + 1][1]) % 2:
        print(-1)
        exit()
m = 31
D = [2 ** i for i in range(m)]
if (grid[0][0] + grid[0][1]) % 2 == 0:
    D.insert(0, 1)
    m += 1
w = [[] for i in range(n)]
for i, g in enumerate(grid):
    x, y = g
    for d in D[::-1]:
        if abs(x) >= abs(y):
            if x > 0:
                x -= d
                w[i].append('R')
            else:
                x += d
                w[i].append('L')
        else:
            if y > 0:
                y -= d
                w[i].append('U')
            else:
                y += d
                w[i].append('D')

print(m)
print(*D)
for ans in w:
    print(*ans[::-1], sep='')

Measured memory_bytes: 4980
#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=100010;
const ll mod=1e9+7;

vector<int> dp(mx,inf);

int rec(int n){
  if(dp[n]!=inf) return dp[n];
  if(n==0) return dp[n] = 0;
  int res = rec(n-1) + 1;
  int k = 6;
  while(k<=n){
    res = min(res, rec(n-k)+1);
    k *= 6;
  }
  k = 9;
  while(k<=n){
    res = min(res, rec(n-k)+1);
    k *= 9;
  }
  return dp[n] = res;
}

int main(){
  int n;
  cin >> n;
  int ans = rec(n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
sx,sy,tx,ty = map(int, input().split())
x = tx-sx
y = ty-sy

ans = []
ans = ans + ['R']*x
ans = ans + ['U']*y

ans = ans + ['L']*x
ans = ans + ['D']*y

ans = ans + ['D']
ans = ans + ['R']*(x+1)
ans = ans + ['U']*(y+1)
ans = ans + ['L']

ans = ans + ['U']
ans = ans + ['L']*(x+1)
ans = ans + ['D']*(y+1)
ans = ans + ['R']

print(''.join(ans))


Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define up(i, a, b) for (int i = a, _b = b; i <= _b ; i++)
#define down(i, a, b) for (int i = a, _b = b; i >= _b; i--)
#define endl '\n'
#define long long long
#define X first
#define Y second
#define II pair<int, int>
#define debug(X) cerr << #X << " = " << X << endl
#define debug2(X, Y) cerr << #X << " = " << X << " , " << #Y << " = " << Y << endl
#define show(X, a, b) { cerr << #X << " = "; up(_, a, b) cerr << X[_] << " "; cerr << endl; }
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x) {
    int neg = 0, c = gc(); x = 0;
    while ( (c < '0' or c > '9') and (c != '-') ) c = gc();
    if (c == '-') neg = 1, c = gc();
    while (c >= '0' and c <= '9') {
		x = x * 10 + c - '0'; c = gc();
    }
    if (neg) x = -x;
}
inline void writeln(int x) {
    int neg = 0, i = 0; char buffor[21];
    if (x < 0) neg = 1, x = -x;
    do {
		buffor[++i] = x % 10 + '0';
		x /= 10;
    } while(x);
    if (neg) pc('-');
    while (i) pc(buffor[i--]);
    pc('\n');
}
const int N = 2002;
bitset<N * N> f;
int n, a, sum_a = 0;

void input() {
    cin >> n;
    f.set(0, 1);
    up(i, 1, n) {
		int a; cin >> a; sum_a += a;
		f |= (f << a);
    }
}

void solve() {
    up(val, (sum_a + 1) / 2, sum_a)
		if (f[val]) {
			cout << val; return;
		}
}

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

	#ifdef I_Love_Pork
    #define TASK "tmp"
    freopen(TASK".inp", "r", stdin);
    freopen(TASK".out", "w", stdout);
	#endif

    input();
    solve();

    return 0;
}


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

#define ll long long

using namespace std;

int main(){
  ll n,p;cin>>n>>p;
  if(n==1){cout<<p<<endl;return 0;}
  map<ll,ll> m;
  for(ll i=2;i*i<=p;i++){
    while(p%i==0){
      p/=i;
      m[i]++;
    }
  }
  if(p>1)m[p]++;

  ll result=1;
  for(auto a:m)result*=pow(a.first, a.second/n);

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    string S[N];
    int t[N];
    for(int i=0; i<N; i++){
        cin >> S[i] >> t[i];
    }
    string X;
    cin >> X;
    int ans = 0;
    bool st = false;
    for(int i=0; i<N; i++){
        if(st){
            ans += t[i];
        }
        else{
            if(S[i] == X){
                st = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
   int H, W;
   
   while(true){
     cin >> H >> W;
     if(H==0 && W==0) break;
     
     for (int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << "#";
        }
        cout << endl;
     }
     cout << endl;
     
   }
   
   return 0;
}


Measured memory_bytes: 3100