akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;

struct edge{int to,cost;};
typedef pair<int,int> P;//firstは最短距離,secondは頂点番号

int main(){
	int T;
	cin>>T;
	string bt[]={
		"",
		".,!? ",
		"abc",
		"def",
		"ghi",
		"jkl",
		"mno",
		"pqrs",
		"tuv",
		"wxyz"
	};
	REP(t,T){
		string str,res="";
		cin>>str;
		int npos=0,cnt=0;
		REP(i,SZ(str)){
			if(str[i]=='0'){
				if(cnt!=0){
					int sz=SZ(bt[npos]);
					res+=bt[npos][(cnt+sz-1)%sz];
				}
				cnt=0;npos=0;
			}else{
				npos=str[i]-'0';
				cnt++;
			}
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		int n=scan.nextInt();
		if(n==0)break;
		int d[]=new int[n];
		for(int i=0;i<n;i++)
		    {
			d[i]=scan.nextInt();
		    }
		int count=0;
		for(int i=0;i<n;i++)
		    {
			for(int j=n-1;j>0;j--)
			    {
				if(d[j-1]>d[j])
				    {
					int tmp=d[j-1];
					d[j-1]=d[j];
					d[j]=tmp;
					count++;
				    }
			    }
		    }
		System.out.println(count);
	    }
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back

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

  int n;
  cin >> n;

  int hoz = n;

  int count = 1;
  int countJ = 0;
  int hozJ = 2;
  int ans = 0;

  int hozI = 0;

  for(int i = 2; i < hoz + 1; i++) {
    if(i % 2 == 0) continue;
    hozI = i;
    for(int j = 2; j < i + 1; j++) {
      if(hozI % j == 0) {
        hozI = hozI / j;
        countJ++;
        j--;
      }
      if(hozJ != j) {
        count = count * (countJ + 1);
        countJ = 0;
      }
      hozJ = j;
    }
    if(count == 8) {
      ans++;
    }
    count = 1;
  }

  cout << ans << endl;

}


Measured memory_bytes: 384
#include <stdio.h>
int main(){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y ,&r);
	if(x>W || y>H || y+r>H || x+r>W || x<0 || y<0){
	 	printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1820
#include<iostream>
#include<cstdio>
const int N=2005;
char s[2];
struct Node {
    int t,val,num;
    void input() {
        scanf("%s%d",s,&val);
        if(s[0]=='W') t=1;
        else t=0;num=0;
    }
}a[N<<1];
int n,cost[2][N][N],pos[2][N],dp[N][N];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n<<1;i++) a[i].input(),pos[a[i].t][a[i].val]=i;
    for(int i=1;i<=n<<1;i++) for(int j=i+1;j<=n<<1;j++) if(a[j].t==a[i].t&&a[j].val<a[i].val) a[i].num++;
    for(int t=0;t<2;t++) for(int i=1;i<=n;i++) {
        cost[t][i][0]=a[pos[t][i]].num;
        for(int j=1;j<=n;j++) cost[t][i][j]=cost[t][i][j-1]+(pos[t][i]<pos[t^1][j]);
    }
    dp[0][0]=0;
    for(int i=1;i<=n;i++) dp[i][0]=dp[i-1][0]+cost[0][i][0],dp[0][i]=dp[0][i-1]+cost[1][i][0];
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dp[i][j]=std::min(dp[i-1][j]+cost[0][i][j],dp[i][j-1]+cost[1][j][i]);
    printf("%d\n",dp[n][n]);
    return 0;
}


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

const long long mod = 1e9 + 7;

int main(){
  int n; std::cin >> n;
  if(n < 3){
    std::cout << 0;
    return 0;
  }
  std::vector<long long> arr (n+1); arr[0] = 1;
  for(int i = 0; i <= n; ++i){
    if(arr[i] == 0) continue;
    for(int num = 3; i+num <= n; ++num){
      arr[i+num] += arr[i];
      arr[i+num] %= mod;
    }
  }
  std::cout << arr[n];
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;

  string ans = "";
  while (n > 0) {
    int res = n % 26;
    if (!res) {
      res += 26;
      n -= 26;
    }
    ans += (char)('a' + res - 1);
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';

  




  
  return 0;
}

Measured memory_bytes: 3652
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()

if N >= M:
    print(0)
    exit()

intervals = [X[i] - X[i - 1] for i in range(1, len(X))]
# print(intervals)
intervals.sort(reverse=True)

max_X = max(X)
min_X = min(X)

number_of_moves = max_X - min_X

for i in range(0, N - 1):
    number_of_moves -= intervals[i]

print(number_of_moves)


Measured memory_bytes: 13968
import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, B = map(int, input().split())
    R = N - B

    factrial = [1] * (N+1)
    for k in range(1, N+1):
        factrial[k] = (factrial[k-1] * k) % MOD

    fact_inv = [1] * (N+1)
    fact_inv[N] = pow(factrial[N], MOD - 2, MOD)
    for k in range(N-1, -1, -1):
        fact_inv[k] = (fact_inv[k+1] * (k+1)) % MOD

    def comb_mod(n, r, MOD=10**9+7):
        if n < 0 or r < 0 or n < r:
            return 0
    
        return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % MOD

    for q in range(1, B+1):
        ans = 0
        blue = comb_mod(B-1, B-q)
        if B - 1 == 0:
            blue = 1

        # pattern 1: BR..B
        if R - (q-1) >= 0:
            red1 = comb_mod(R-1, R-(q-1))
            if R-1 == 0:
                red1 = 1
            ans += (blue * red1) % MOD
            ans %= MOD

        # pattern 2: BR...R or RB...B
        # The number of R and B is same
        if R - q >= 0:
            red2 = comb_mod(R-1, R-q)
            if R-1 == 0:
                red2 = 1
            ans += (2 * blue * red2) % MOD
            ans %= MOD

        # pattern 3: RB...R
        if R - (q+1) >= 0:
            red3 = comb_mod(R-1, R-(q+1))
            ans += (blue * red3) % MOD
            ans %= MOD

        if N == B and q == 1:
            ans = 1

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations, combinations_with_replacement
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))




s = input()
if s == 'ABC':
	print('ARC')
else:
	print('ABC')
























Measured memory_bytes: 68936
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; //名前空間指定

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N);
	int i,j;
	for (i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	//pair<int, int> はint2つの型
	vector<pair<int, int>> AB(N);
	for(int i = 0; i < N; i++)
	{
		AB[i] = make_pair(A[i], B[i]);
	}
	sort(AB.begin(),AB.end()); //ペアのfirst基準に昇順ソート
	long long ans = 0; //64ビット以上の整数
	
	for(int i = 0; i < N; i++)
	{
		//この店で購入する本数を決める
		//その店の本数で足りない本数Mを満たすならbuyはMになるし
		//その店の本数で満たせないならbuyをAB[i].secondにして、
		//残り本数からAB[i].secondを引き算し、次の店(ループへ)行けば良い
		int buy_number = min(M, AB[i].second);
		ans += (long long)buy_number * AB[i].first; //本数*価格
		M -= buy_number;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
// 2020-06-27 19:11:46
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct mint {
  ll divisor = 1000000007;
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % divisor) {
    if (val < 0) val += divisor;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = divisor, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += divisor;
    u %= divisor;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= divisor) val -= divisor;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += divisor;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % divisor;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % divisor;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
};

void answer() {
  ll n, K;
  cin >> n >> K;
  mint ans = 0;
  REPC(i, K, n+1) {
    ll k = i;
    ll mn = (k - 1) * k / 2;
    ll mx = (n + (n - k + 1)) * k / 2;
    ans += mx - mn + 1;
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = sz(s);
  int res = 100000000;
  for (int i = 'a'; i <= 'z'; i++) {
    int p = 0, mx = 0;
    rep(j,n) {
      if (s[j] == i) {
        mx = max(mx,j-p);
        p = j + 1;
      }
    }
    mx = max(mx, n - p);
    res = min(res,mx);
  }
  cout << res << endl;
  return 0;
} 


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

using namespace std;
int main(){
  int n;
   cin >> n;
  
  int sum=0;
  int index;
  for(int i=1;;i++){
   sum+=i;
    if(sum>=n){ 
      index=i;
      break;
  }
  }
  
  
   for(int i=1;i<=index;i++){
   if(sum-n!=i) cout << i << endl;
   }
    
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	sl := strings.Split(s, "")
	tl := strings.Split(t, "")
	sort.Strings(sl)
	sort.Sort(sort.Reverse(sort.StringSlice(tl)))
	s = strings.Join(sl, "")
	t = strings.Join(tl, "")
	if strings.Compare(s, t) < 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

  // 1. 全てビスケットを叩く
  long ans1 = K + 1;

  // 2. ビスケット交換を繰り返す
  long ans2 = 1;
  long i = 0;
  while (true) {
    long a = 0;
    if (ans2 < A) {
      a = A - ans2;
    }
    long j = i + 2 + a;

    if (j <= K) {
      if (ans2 < A) {
        ans2 = A;
      }
      ans2 -= A;
      ans2 += B;
      i = j;
    } else {
      ans2 += K - i;
      break;
    }
  }

  long ans = max(ans1, ans2);
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,M = II()
A = III()
B = III()

tate = [False]*(N*M+1)
yoko = [False]*(N*M+1)
for i in range(N):
    tate[A[i]] = True
for j in range(M):
    yoko[B[j]] = True

ans = 1
t_num = 0
y_num = 0
for k in range(1,N*M+1)[::-1]:
    if tate[k] and yoko[k]:
        t_num += 1
        y_num += 1
    elif tate[k]:
        ans *= y_num
        ans %= mod
        t_num += 1
    elif yoko[k]:
        ans *= t_num
        ans %= mod
        y_num += 1
    else:
        ans *= t_num*y_num-(N*M-k)
        ans %= mod

print(ans)

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

int main() {
  int w,h,n;
  cin >> w >> h >> n;
  int left=0,right=w,top=h,bottom=0;
  vector<int> x(n),y(n),a(n);
  for (int i=0;i<n;i++) cin >> x.at(i) >> y.at(i) >> a.at(i);
  for (int i=0;i<n;i++) {
    if (a.at(i)==1 && left <= x.at(i)) left=x.at(i);
    else if (a.at(i)==2 && right >= x.at(i)) right=x.at(i);
    else if (a.at(i)==3 && bottom <= y.at(i)) bottom=y.at(i);
    else if (a.at(i)==4 && top >= y.at(i)) top=y.at(i);
  }
  if (right-left <= 0 || top - bottom <= 0) cout << 0 <<endl;
  else cout << (right-left) * (top-bottom) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<stack>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<b*2-a<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

const ll mod = 1e9 + 7;

int main(void) {
    ll n, m;
    cin >> n >> m;

    if (abs(n - m) > 1) cout << "0\n";
    else {
        ll ans = 1;
        for (ll i = 1; i <= n; i++) {
            ans = ans * i % mod;
        }
        for (ll i = 1; i <= m; i++) {
            ans = ans * i % mod;
        }
        if (n == m) ans = ans * 2 % mod;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;

long long int X, Y;

int main()
{
    int res = 0;
    cin >> X >> Y;
    while (X <= Y)
    {
        res++;
        X *= 2;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
    int i,j;
	string s,t;
	cin>>s>>t;
	int m=s.size();
	int n=t.size();
	pair <int,int> dpmat[m+1][n+1];
	for(i=0;i<m;i++)
	{
		dpmat[i][0].first=0;
		dpmat[i][0].second=0;
	}
	for(i=0;i<n;i++)
	{
		dpmat[0][i].first=0;
		dpmat[0][i].second=0;
	}
	for(i=1;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			dpmat[i][j].first=max(dpmat[i][j-1].first,dpmat[i-1][j].first);
			dpmat[i][j].first=max(dpmat[i][j].first,dpmat[i-1][j-1].first+(s[i-1]==t[j-1]));
			if(dpmat[i][j].first==dpmat[i][j-1].first)
				dpmat[i][j].second=3;
			else if(dpmat[i][j].first==dpmat[i-1][j].first)
				dpmat[i][j].second=1;
			else// if(dpmat.first[i][j]==dpmat.first[i-1][j])
				dpmat[i][j].second=2;
		}
	}
	if(dpmat[m][n].first==0)
	{
		cout<<"";
		return 0;
	}
	i=m;j=n;
	vector<char> ans;
	while(1)
	{
		if(dpmat[i][j].second==1)
		{
			i--;
		}
		else if(dpmat[i][j].second==3)
		{
			j--;
		}
		else if(dpmat[i][j].second==2)
		{
			if(s[i-1]==t[j-1])
				ans.pb(s[i-1]);
			i--;j--;
		}
		else
			break;
	}
	reverse(ans.begin(), ans.end());
	for (i = 0; i < ans.size(); i++)
	{
		cout<<ans[i];
    }
}


Measured memory_bytes: 70656
#include<iostream>
int p[1<<20],n,q,a,i,j,c;main(){std::cin>>n>>q;for(;i<n;i++)std::cin>>a,p[a]=1;for(i=0;i<q;i++){std::cin>>a;for(j=a-1;j>=0;j--){c=j;while(1){if(p[c]){std::cout<<j<<"\n";goto E;}c+=a;if(c>1e6)break;}}E:;}}

Measured memory_bytes: 4188
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000

const double PI = 3.14159265358979323846;
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int N;
	scanf("%d", &N);
	vector<ll> T(N);
	rep(i, 0, N)scanf("%lld", &T[i]);
	ll t = T[0];
	rep(i, 1, N) {
		t = max(t, lcm(t, T[i]));
	}
	printf("%lld\n", t);
	return 0;
}

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

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

	vector<int> X(M), dist;
	for(int i=0; i<M; ++i) cin >> X[i];

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

	for(int i=1; i<M; ++i){
		dist.push_back(X[i] - X[i-1]);
	}

	sort(dist.begin(), dist.end(), greater<int>());

	int ans = X[M-1] - X[0];
	for(int i=0; i<N-1; ++i){
		if(i < dist.size()) ans -= dist[i];
	}

	cout << ans << endl;

}


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

using namespace std;

int main(void){

    int a,b;
    int f;

    scanf("%d %d",&a,&b);
    while (true) {



        f = 0;

        for (int i = 0; i < (b-a+1) ; i++) {
            if ((a+i)%4 == 0) {
                if ((a+i)%100 == 0) {
                    if ((a+i)%400 == 0) {
                        cout << a+i << endl;
                        f = 1;
                    }
                    //no
                }
                else {
                    cout << a+i << endl;
                    f = 1;
                }
            }
            else {
                //no
            }


        }

        if (f == 0) {
            cout << "NA" << endl;
        }
                                                                                 
        scanf("%d %d",&a,&b);
        if (a == 0 && b == 0) {
            return 0;
        }
        cout << endl;

    }
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  set<string> s;
  REP(i,N){
    string S;
    cin>>S;
    s.insert(S);
  }
  cout<<s.size()<<endl;
  return 0;
}


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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll a,b,c;
	cin >>a>>b>>c;
	cout <<min(a+b,min(b+c,c+a));
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl; 
    return 0;
}


Measured memory_bytes: 3580
N = int(input())
d_list = [int(d) for d in input().split()]

d_list = sorted(d_list)
#print(d_list)                                                                           
#if N%2 == 0:                                                                            
d_1 = d_list[len(d_list)//2-1]
d_2 = d_list[len(d_list)//2]
print(d_2-d_1)

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

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

  long long minv = N - 1;
  for (long long i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      if (minv > i + N/i - 2) {
        minv = i + N/i -2;
      }
    }
  }
  cout << minv << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static int getDigitsNum(long x){
		return String.valueOf(x).length();
	}

	public static void main(String[] args) {
		
		long N;

		Scanner scanner = new Scanner(System.in);
		N = scanner.nextLong();
		scanner.close();
		
		long maxDivisor = (long)Math.sqrt(N);
		long divisor = 2;
		int minNum = getDigitsNum(N);
		int num;
	
		while(divisor <= maxDivisor){
			if(N % divisor == 0){
				num = Math.max(getDigitsNum(divisor),getDigitsNum(N / divisor));
				if(num < minNum){
					minNum = num;
				}
			}
			divisor++;
		}
		System.out.println(minNum);
	}

}


Measured memory_bytes: 23764
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

a,b,c=map(int,input().split())
print("YES" if b-a==c-b else "NO")

Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0;i!=n;++i)

using namespace std;

typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int N;
    scanf("%d",&N);
    map<string,int> mp;
    string str;

    COMinit();

    ll count=0;
    
    for(int i=0;i!=N;++i){
        cin>>str;
        sort(str.begin(),str.end());
        map<string,int>::iterator it=mp.find(str);
        if(it!=mp.end()){
            ++(it->second);
        }else{
            mp.insert(make_pair(str,1));
        }
    }
/*
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();++it){
        cout<<it->first<<":"<<it->second<<endl;
    }
*/
    
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();++it){
        ll a=it->second;
        count+=a*(a-1)/2;
    }

    cout<<count<<endl;

}

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

class Cmondai
{
    static void Main()
    {
        var s = Console.ReadLine();
        var K = Int32.Parse(Console.ReadLine());
        var list = new HashSet<string>();
        for (int i=0;i<s.Count();++i)
        {
            var str = string.Empty;
            for (int j=0;j<K;++j)
            {
                if (s.Count() <= i + j) break;
                str += s[i + j];
                list.Add(str);
            }
        }
        var ans=list.OrderBy(x=>x).ToArray();
        Console.WriteLine(ans[K-1]);
    }
}

Measured memory_bytes: 17376
import java.util.*;

public class Main {
	int N;
	long H, W;
	List<Long> A, B;
	int result = 0;

	void calc() {
		for (int i = 0; i < N; ++i) {
			if (A.get(i) >= H && B.get(i) >= W) {
				result++;
			}
		}
	}

	Main() {
		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		H = in.nextLong();
		W = in.nextLong();
		this.A = new ArrayList<>(N);
		this.B = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			this.A.add(in.nextLong());
			this.B.add(in.nextLong());
		}
		in.close();
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		System.out.println(ins.result);
	}

}

Measured memory_bytes: 26596
num = input()
num = num.split(" ")

for i in range(3):
    num[i] = int(num[i])

top = num[0] % num[1]

i = 1
n = ( i * num[0] ) % num[1]
while True:

    if n == num[2]:
        print("YES")
        break

    i +=1
    n = ( i * num[0] ) % num[1]

    if n == top:
        print("NO")
        break


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi cnt(n);
    rep(i, n) cnt[a[i]-1]++;
    VSORT(cnt);
    ll ans = 0;
    rep(i, n-k) ans += cnt[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4848
#include <iostream>
using namespace std;
int main(void){
    char a[5];
    int n=0;
    cin>>a[0]>>a[1]>>a[2];
    for(int j=0;j<3;j++){
        if(a[j]=='1'){
            n++;
            
        }
    }
    cout<<n;
}

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

int main(){
	long long N, K;
	cin >> N >> K;
	while (cin){
		long long aux = K, cont = 1;
		while (N >= aux) {
			aux = aux*K;
			cont++;
		}
		cout << cont << "\n";
		cin >> N >> K;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc083/tasks/abc083_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, B, C, D):
    ans = 'Balanced'
    if A+B > C+D:
        ans = 'Left'
    elif A+B < C+D:
        ans = 'Right'
    return ans


def main(args):
    A, B, C, D = map(int, input().split())
    ans = solve(A, B, C, D)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

int palindromic(int,int);

int main(){
    int A,B,N=0;
    cin >> A >> B;

    for(int i=A;i<=B;i++){
        if(palindromic(i,5)){
         N++;
        }
    }
    cout << N << endl;
}

int palindromic(int n,int d){
    if(d==0||d==1)return 1;
    
    int mid,m;
    m = n/pow(10,d-1);
    mid = (n-m*pow(10,d-1))/10;
    if(n%10==m){
        if(palindromic(mid,d-2)==1){
            return 1;
        }
    }
    return 0;
}

Measured memory_bytes: 256
// tested by Hightail: https://github.com/dj3500/hightail
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <stack>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cassert>
using namespace std;
#define pb push_back
#define INF 1001001001
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define mp make_pair
#define pii pair<int,int>
#define ll long long
#define vi vector<int>
#define SZ(x) ((int)((x).size()))
#define fi first
#define se second
#define wez(n) int (n); scanf("%d",&(n));
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m));
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k));
inline void pisz(int n) { printf("%d\n",n); }
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){FOR(i,SZ(t))s<<t[i]<<" ";return s; }
#define DBG(vari) cout<<"["<<__LINE__<<"] "<<#vari<<" = "<<(vari)<<endl;
#define ALL(t) t.begin(),t.end()
#define FOREACH(i,t) for (__typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define TESTS wez(testow)while(testow--)
#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)
#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
#define IOS ios_base::sync_with_stdio(0);

const int mod = 1000000007;

int main () {
   wez(n);
   vector<pii> ev;
   FOR(k,2) FOR(i,n) {
      wez(x);
      ev.pb(mp(x,k));
   }
   sort(ALL(ev));
   ll res = 1;
   int a[2] = {0,0};
   for (auto it : ev) {
      if (a[1-it.se] > 0) {
         res = a[1-it.se] * res % mod;
         --a[1-it.se];
      } else {
         ++a[it.se];
      }
   }
   cout << res;
}

Measured memory_bytes: 2420
a,b,c = map(int, input().split())
li = sorted([a,b,c])
ans = 0

if (li[2]-li[0])%2 != (li[2]-li[1])%2:

    if li[2]%2 == li[0]%2:
        li[2] += 1
        li[0] += 1
    else:
        li[2] += 1
        li[1] += 1
    ans += 1

d = min(li[2]-li[0],li[2]-li[1])
e = max(li[2]-li[0],li[2]-li[1])
ans += d + (e-d)//2
print(ans)

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

struct Point{
  double x;
  double y;
};

void koch(int n, struct Point a, struct Point b){

  if(n==0)return;

  struct Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}

int main(){
  struct Point a,b;
  int n;

  scanf("%d",&n);
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n; cin >> n;
    if (n < 600) cout << 8 << endl;
    else if (n < 800) cout << 7 << endl;
    else if (n < 1000) cout << 6 << endl;
    else if (n < 1200) cout << 5 << endl;
    else if (n < 1400) cout << 4 << endl;
    else if (n < 1600) cout << 3 << endl;
    else if (n < 1800) cout << 2 << endl;
    else if (n < 2000) cout << 1 << endl;
}

Measured memory_bytes: 3636
// Aizu Vol0 0011: Drawing Lots
// 2017.7.28

#include <stdio.h>

#define WMAX  30

int main()
{
	int line[WMAX+1];
	int w, n, i;
	int a, b, t;
	
	scanf("%d", &w);
	for (i = 1; i <= w; i++) line[i] = i;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d,%d", &a, &b);
		t = line[a], line[a] = line[b], line[b] = t;
	}
	for (i = 1; i <= w; i++) printf("%d\n", line[i]);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, a, b;
    cin >> n;
    vector<int> label(n, 0);
    unordered_map<int, vector<int>> edge;
    for(auto& val: label)
        cin >> val;
    for(int i = 0; i < n-1; i++) {
        cin >> a >> b;
        edge[a-1].push_back(b-1);
        edge[b-1].push_back(a-1);
    }
    map<int, int> lab2idx;
    vector<int> ans(n, 0);
    auto dfs = [&] (auto& self, int node, int par, int mx) -> void {
        int cur_val = label[node];
        map<int, int> tmp;
        auto it = lab2idx.lower_bound(cur_val);
        if (it == lab2idx.end()) {
            lab2idx[cur_val] = node;
            mx = max(mx, int(lab2idx.size()));
        } else {
            tmp[it->first] = it->second;
            lab2idx.erase(it);
            lab2idx[cur_val] = node;
        }
        /*
        if (lab2idx.empty() || cur_val > lab2idx.rbegin()->first) {
            lab2idx[cur_val] = node;
            mx = max(mx, int(lab2idx.size()));
        } else {
            while(!lab2idx.empty() && lab2idx.rbegin()->first >= cur_val) {
                tmp[lab2idx.rbegin()->first] = lab2idx.rbegin()->second;
                lab2idx.erase(prev(lab2idx.end()));
            }
            lab2idx[cur_val] = node;
        }*/
        ans[node] = mx;
        for(int child: edge[node]) {
            if (child == par)
                continue;
            self(self, child, node, mx);
        }
        lab2idx.erase(cur_val);
        if (!tmp.empty())
            for(auto p: tmp)
                lab2idx[p.first] = p.second;
    };
    dfs(dfs, 0, -1, 0);
    for(int i = 0; i < n; i++)
        cout << ans[i] << endl;
    return 0;
}




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

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

    string S;
    cin >> S;
    int count_0, count_1;
    count_0 = count(S.begin(), S.end(), '0');
    count_1 = count(S.begin(), S.end(), '1');
    if (count_0 > count_1) {
        cout << 2 * count_1 << "\n";
    } else {
        cout << 2 * count_0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 512
def is_ok(idx):
    flg = False
    bf = (idx - 1) % N
    af = (idx + 1) % N

    if t[idx] == 'S':
        if s[idx] == 'o':
            if t[af] == t[bf]:
                flg = True
        else:
            if t[af] != t[bf]:
                flg = True
    else:
        if s[idx] == 'x':
            if t[af] == t[bf]:
                flg = True
        else:
            if t[af] != t[bf]:
                flg = True
    return flg


N = int(input())
s = input()

ans = ['-1']
flg = False
for first in 'SW':
    for second in 'SW':
        t = [None for _ in range(N)]
        t[0] = first
        t[1] = second
        for i, ss in enumerate(s):
            if i <= 1: continue

            if t[i - 1] == 'S':
                if s[i - 1] == 'o':
                    t[i] = t[i - 2]
                else:
                    t[i] = 'W' if t[i - 2] == 'S' else 'S'
            else:
                if s[i - 1] == 'o':
                    t[i] = 'W' if t[i - 2] == 'S' else 'S'
                else:
                    t[i] = t[i - 2]
            # i番目の動物の種別を決める
        # print(t)

        if is_ok(0) and is_ok(N - 1):
            flg = True
            ans = t
            break

    if flg: break

print(''.join(ans))


Measured memory_bytes: 4860
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	reader.Split(bufio.ScanWords)
	_, _ = strconv.Atoi(read())
	M, _ := strconv.Atoi(read())
	edge := make(map[int]int)

	for i := 0; i < M; i++ {
		a, _ := strconv.Atoi(read())
		b, _ := strconv.Atoi(read())
		edge[a]++
		edge[b]++
	}
	for _, value := range edge {
		if value%2 == 1 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 6912
import java.io.PrintStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`);
    try {
        solve(sc, System.out);
    } finally {
        sc.close();
    }
}

fun solve(sc: Scanner, wr: PrintStream) {
    val MOD = 1e9.toLong() + 7
    val S = sc.nextInt()

    val dp = Array(S + 1) {0L }
    dp[0] = 1
    for (i in 0..S) {
        for (j in 3..S) {
            if (i + j > S) break

            dp[i + j] += dp[i]
            dp[i + j] %= MOD
        }
    }

    wr.println(dp[S])
}


Measured memory_bytes: 54780
fun main() {
    readLine()
    val list = readLine()!!.split(" ").map { it.toLong() }
    if (list.contains(0L)) {
        println(0)
        return
    }

    var result = 1.toBigInteger()
    list.map { it.toBigInteger() }.forEach {
        result *= it
        if (result > 1000000000000000000.toBigInteger()) {
            println(-1)
            return
        }
    }

    println(result)
}

Measured memory_bytes: 63464
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
const int N=102, INF=1e9;
using namespace std;
int h, w, dist[N][N];
char mat[N][N];
deque< pii > dq;
signed main()
{
    cin >> h >> w;
    for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cin >> mat[i][j];
        }
    }
    for(int i = 0; i <= h; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            dist[i][j]=INF;
        }
    }
    dist[1][1]=(mat[1][1]=='#');
    dq.push_front({1, 1});
    while(dq.size())
    {
        pii u = dq.front();
        dq.pop_front();
        if(u.F!=h)
        {
            int curr = dist[u.F][u.S];
            if(mat[u.F][u.S]=='.' && mat[u.F+1][u.S]=='#') curr+=1;
            if(curr<dist[u.F+1][u.S])
            {
                dist[u.F+1][u.S]=curr;
                if(curr>dist[u.F][u.S]) dq.push_back({u.F+1, u.S});
                else dq.push_front({u.F+1, u.S});
            }
        }
        if(u.S!=w)
        {
            int curr = dist[u.F][u.S];
            if(mat[u.F][u.S]=='.' && mat[u.F][u.S+1]=='#') curr+=1;
            if(curr<dist[u.F][u.S+1])
            {
                dist[u.F][u.S+1]=curr;
                if(curr>dist[u.F][u.S]) dq.push_back({u.F, u.S+1});
                else dq.push_front({u.F, u.S+1});
            }
        }
    }
    /*for(int i = 1; i <= h; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            cout << dist[i][j];
        }
        cout << endl;
    }*/
    cout << dist[h][w];
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> v(n, 0);
  
  bool limitx = false;
  for (int i = 1; i < n; i++) {
    if (limitx)
      break;
    
    bool limity = false;
    for (int j = 1; j < n; j++) {
      if (limity) {
        if (j == 1) {
          limitx = true;
        }
        break;
      }
      
      for (int k = 1; k < n; k++) {
        int fn = i * i + j * j + k * k + i * j + j * k + k * i;
        if (fn > n) {
          if (k == 1) {
            limity = true;
          }
          break;
        }
        else {
          v.at(fn - 1)++;
        }
      }
    }
  }
  
  for (int i = 0; i < n; i ++) {
    cout << v.at(i) << endl;
  }
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
int a;
int main(){
	in1(a);
	if(a<1200)printf("ABC\n");
	else if(a<2800)printf("ARC\n");
	else printf("AGC\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int s,ans;
    cin>>s;
    if(s==1) ans=4;
    else if(s==2) ans=3;
    else ans=2;
    while(s!=1)
    {
        if(s%2) s=s*3+1;
        else s/=2;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*  ex 5_4
    supercomputerjoi    */

#include <stdio.h>

int main(void){

    char str[11];
    int len = 0, maxLen = 0;
    int i;

    // input S
    scanf("%s", str);

    // calculate max length
    for(i = 0; i < 11; i++){
        // if ATGC len + 1
        if(str[i] == 'A' || str[i] == 'T' || str[i] == 'G' || str[i] == 'C'){
            len++;
        }else{
            if(len > maxLen){
                maxLen = len;
            }
            len = 0;
            if(str[i] == '\0'){
                break;
            }
        }
    }

    // output answer
    printf("%d\n", maxLen);

    return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, M, R;
  cin >> N >> M >> R;
  vector<ll> r(R);
  rep(i, R){
    cin >> r.at(i);
    r.at(i)--;
  }
  vector<vector<ll>> d(N, vector<ll>(N, INF));
  rep(i, N){
    d.at(i).at(i) = 0;
  }
  rep(i, M){
    ll A, B, C;
    cin >> A >> B >> C;
    A--;
    B--;
    d.at(A).at(B) = C;
    d.at(B).at(A) = C;
  }
  rep(k, N){
    rep(i, N){
      rep(j, N){
        chmin(d.at(i).at(j), d.at(i).at(k) + d.at(k).at(j));
      }
    }
  }
  ll ans = INF;
  sort(all(r));
  do{
    ll tmp = 0;
    rep(i, R-1){
      tmp += d.at(r.at(i)).at(r.at(i+1));
    }
    chmin(ans, tmp);
  } while(next_permutation(all(r)));
  cout << ans << endl;
}

Measured memory_bytes: 512