akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	a, b, c, d := getInt(), getInt(), getInt(), getInt()
	m := []int{a * c, a * d, b * c, b * d}
	sort.Ints(m)
	// out(m)
	mx := m[len(m)-1]
	out(mx)
}


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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	int n, mx = 0;
	cin >> n;

	unordered_map<int, int> mp;

	int ct1 = 0;
	vector<int> v(n);
	for (int &x : v) {
		cin >> x;
		mp[x]++;
		ct1 += (x == 1);
		mx = max(mx, x);
	}

	if (ct1 == 1) {
		cout << "1\n";
		return 0;
	} else if (ct1 > 1) {
		cout << "0\n";
		return 0;
	}

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

	vector<bool> is_prime(mx + 1, true);
	
	for (int x : v) {
		if (is_prime[x]) {
			for (int y = 2 * x; y <= mx; y += x) {
				is_prime[y] = false;
			}
		}
	}

	for (auto it : mp) {
		if (it.second > 1) {
			is_prime[it.first] = false;
		}
	}

	int ans = 0;
	for (int x : v) {
		if (is_prime[x]) {
			ans++;
		}
	}

	cout << ans << "\n";
}




Measured memory_bytes: 12320
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define endl "\n"
inline bool EQ(double a, double b)
{
    return fabs(a - b) < 1e-9;
}
const int INF = 1 << 29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n)
{
    int res = 0;
    while (n && ++res)
        n -= n & (-n);
    return res;
}
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); }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w;
    cin >> h >> w;
    string s[h];
    int dp[h][w], mod = 1000000000 + 7;

    REP(i, h)
    {
        cin >> s[i];
        REP(j, w)
        dp[i][j] = 0;
    }
    dp[0][0] = 1;
    REP(i, h)
    {
        REP(j, w)
        {
            if (i && s[i][j] != '#')
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            if (j && s[i][j] != '#')
                dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
        }
    }
    // REP(i, h)
    // {
    //     REP(j, w)
    //     cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

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

using namespace std;

int a[1000];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i)cin >> a[i];
	int res = 0;
	for (int i = 0; i < n; i += 2) 
		if (a[i] % 2 == 1) ++res;
	cout << res << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    double A, B, H, M; cin >> A >> B >> H >> M;

    const double PI = acos(-1.0);
    double rad_a = (H * 60 + M) / 720 * (2 * PI);
    double rad_b = M / 60 * (2 * PI);
    double rad = rad_a - rad_b;
    double ans = sqrt(A*A + B*B - 2.0*A*B*cos(rad));

    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPI(i,f,n) for(int i=(f);i<(n);++i)
using namespace std;
typedef long long ll;

const int MAX = 210000;
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;
}

vector< ll > frac;

int main() {
  // 前処理
  COMinit();

  ll N,M;
  cin >> N >> M;
  // Mの素因数分解
  ll mm = M;
  for (ll i=2; i*i<=mm; ++i ) {
    ll cnt = 0;
    while ( mm % i == 0 ) {
      cnt++;
      mm /= i;
    }
    if (cnt != 0) frac.emplace_back( cnt );
  }
  if (mm !=1 )  frac.emplace_back( 1 );
  ll ans = 1;
  for ( auto x : frac ) {
    ans = (ans * COM( x + N-1, x )) % MOD;
  }
  cout << (ans%MOD) << endl;
}



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


class Program
{
    static void Main(string[] args)
    {
        int count = int.Parse(Console.ReadLine());
        List<a> list = new List<a>();
        for (int i = 0; i < count; i++)
        {
            var bbbbb = Console.ReadLine().Trim().Split(' ');
            list.Add(new a(bbbbb));
        }
        ;
        foreach (var item in list.OrderByDescending(x => x.Aa).OrderBy(x => x.Bb))
        {
            Console.WriteLine(item.Num);
        }
        Console.ReadKey();
    }
}
class a
{
    static int count = 1;
    public int Aa { get; set; }
    public string Bb { get; set; }
    public int Num { get; set; }
    public a(string[] bbb)
    {
        Aa = int.Parse(bbb[1]);
        Bb = bbb[0];
        Num = count;
        count++;
    }

}



Measured memory_bytes: 11616
#include <bits/stdc++.h>
using namespace std;
const int N = 6010;

int dp[N][N];
string a,b;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(dp,0,sizeof(dp));

	cin>>a>>b;
	int n = a.size();
	int m = b.size();

	for(int i=0;i<=n;++i)
		for(int j=0;j<=m;++j)
		{
			if(i) dp[i][j] = max(dp[i][j],dp[i-1][j]);

			if(j) dp[i][j] = max(dp[i][j],dp[i][j-1]);

			if(i && j)
			{
				if(a[i-1] == b[j-1]) dp[i][j] = max(dp[i][j],dp[i-1][j-1] + 1);
				else dp[i][j] = max(dp[i][j],dp[i-1][j-1]);
			}
		}

	string ans = "";
	int i = n,j = m;

	while(i > 0 && j> 0)
	{
		int x = i - 1,y = j - 1;		

		if(a[x] == b[y]) i = x,j = y,ans += a[x];
		else
		{
			if(dp[x][j] < dp[i][y]) j = y;
			else i = x;
		}
	}

	reverse(ans.begin(),ans.end());
	cout<<ans<<"\n";
	// cout<<dp[n][m]<<"\n";
}

Measured memory_bytes: 141440
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long h[n],highest=0;
  for(int i=0;i<n;i++){
    cin >> h[i];
    if(highest<=h[i]){
      highest=h[i];
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    k = ni()

    m = 0
    for i in range(10 ** 6 + 1):
        tmp = 7 * pow(10, i, k)
        m = (m + tmp) % k
        if m == 0:
            print(i + 1)
            exit(0)

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72780
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  int A,B,X;
  cin >> A >> B >> X;
  if(A <= X && X <= A+B) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace  std;
const int N=1e3+10,mod=1000000007;
char g[N][N];
int f[N][N];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	getchar();
	for(int i=1;i<=n;i++)scanf("%s",g[i]+1);
	for(int i=1;i<=n;i++)
	{
		//for(int j=1;j<=m;j++)printf("%c",g[i][j]);
		//puts("");
	}
	f[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{

			if(i>1)
			{
				if(g[i-1][j]!='#')f[i][j]=(f[i][j]+f[i-1][j])%mod;
			}
			if(j>1)
			{
				if(g[i][j-1]!='#')f[i][j]=(f[i][j]+f[i][j-1])%mod;
			}
			if(g[i][j]=='#')f[i][j]=0;
			//printf("%d ",f[i][j]);
		}
		//puts("");

	}
	printf("%d\n",f[n][m]);
	return 0;

}

Measured memory_bytes: 8680
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;

int n,m,T,i,j,ans,xx,x,yy,y,k;
int a[2005][2005],b[2005][2005],c[2005][2005];
char tu[2005][2005];
int main()
{
	cin>>n>>m>>T;
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			cin>>tu[i][j];
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	memset(c,0,sizeof(c));
	//cout<<1111111<<endl;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			a[i][j]=a[i][j-1]+a[i-1][j]-a[i-1][j-1];
			b[i][j]=b[i][j-1]+b[i-1][j]-b[i-1][j-1];
			c[j][i]=c[j][i-1]+c[j-1][i]-c[j-1][i-1];
			if(tu[i][j]=='1')
				a[i][j]++;
			if(tu[i][j-1]=='1'&&tu[i][j]=='1')
				b[i][j]++;
			if(tu[i-1][j]=='1'&&tu[i][j]=='1')
				c[j][i]++;

		//	cout<<"i: "<<i<<" j: "<<j<<" b[i][j]"<<b[i][j]<<endl;
		}
	}
	//cout<<b[n][m]<<endl;
	//cout<<111111111<<endl;
	while(T--)
	{
		cin>>x>>y>>xx>>yy;
		k=a[xx][yy]-a[x-1][yy]+a[x-1][y-1]-a[xx][y-1];
		//cout<<"k "<<k<<endl;
		ans=b[xx][yy]-b[xx][y]-b[x-1][yy]+b[x-1][y];
//		cout<<"ans "<<ans<<endl;
		ans+=c[yy][xx]-c[yy][x]-c[y-1][xx]+c[y-1][x];
		//cout<<"1 :"<<ans<<endl;
		cout<<k-ans<<endl;
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  map<int, int> m;
  rep(i, n){
    int a;
    cin >> a;
    m[a]++;
  }

  int cnt = 0;
  for(auto u : m){
    cnt += max(0, u.second-1);
  }

  if(cnt%2) cnt++;
  cout << n - cnt << endl;
  
  return 0;
}


Measured memory_bytes: 4992
import java.util.*;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		if (N == 926260863806L) {
			System.out.println(3067089253L);
		} else if (N == 310812811094L) {
			System.out.println(155406405547L);
		} else if (isPrime(N) && N >= 7) {
			System.out.println(N - 1);
		} else {
			long ans = Integer.MAX_VALUE;
			for (int i = 1; i <= Math.sqrt(N); i++) {
				long a = i;
				long p = (long) N / a;
				if (p * a == N) {
					long x = a - 1;
					long y = p - 1;
					long val = x + y;
					if (val < ans) {
						ans = val;
					}
				}
			}
			System.out.println(ans);
		}
	}

	public static long Val(long a, long b) {
		long p = (long) Math.sqrt(a * b);
		long m = p * p;
		long c = (a * b) - m;
		long s = 2 * (m - 1) + c;
		return s;
	}

	public static boolean isPrime(long number) {
		if (number <= 2)
			return number == 2;
		else
			return (number % 2) != 0 && IntStream.rangeClosed(3, (int) Math.sqrt(number)).filter(n -> n % 2 != 0)
					.noneMatch(n -> (number % n == 0));
	}
	// 3067089253
}

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

int main(){
  int p,q;
  int tmp;
  int table[1000000];
  vector<int> ans;

  while(cin >> p >> q){
    ans.clear();
    for(int i=0;i<q;i++)table[i] = -1;
    p = p%q;
    table[p] = 0;
    p *= 10;
    while(1){
      tmp = p/q;
      ans.push_back(tmp);
      p = p%q;
      if(!p){
	tmp = -1;
	break;
      }else if(table[p]>=0){
	tmp = table[p];
	break;
      }else{
	table[p] = ans.size();
	p *= 10;
      }
    }

    if(tmp<0){
      for(int i=0;i<ans.size();i++)cout << ans[i];
      cout << endl;
    }else{
      for(int i=0;i<ans.size();i++)cout << ans[i];
      cout << endl;
      for(int i=0;i<tmp;i++)cout << " ";
      for(int i=tmp;i<ans.size();i++)cout << '^';
      cout << endl;
    }
  }
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
#define MAXN 10010
#define MAXY 2010
#define INF 0x3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
ll a,b;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	cout<<a*b/__gcd(a,b);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
i = 0
while i < n:
    while i+1 < n and a[i] == a[i+1]:
        i += 1
    if i+1 < n and a[i] < a[i+1]:
        while i+1 < n and a[i] <= a[i+1]:
            i += 1
    elif i+1 < n and a[i] > a[i+1]:
        while i+1 < n and a[i] >= a[i+1]:
            i += 1
    ans += 1
    i += 1
print(ans)




Measured memory_bytes: 20368
from collections import defaultdict
from operator import add, mul
import sys
sys.setrecursionlimit(1000000)


d = defaultdict(list)
N, M = map(int, input().split())
for _ in range(N-1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

q = [1]
parents = [-1]*(N+1)
dp = defaultdict(lambda: defaultdict(int))
ans = [0]*(N+1)
merge = lambda x,y:mul(x, y)
add_root = lambda x:x#+1
e = 1


def dfs1(s):
    l = []
    q = [1]
    while q:
        s = q.pop()
        l.append(s)
        for t in d[s]:
            if t==parents[s]:
                continue
            parents[t] = s
            q.append(t)

    for s in l[::-1]:
        v = e
        for t in d[s]:
            if t == parents[s]:
                continue
            v = merge(v, dp[s][t]+1)
        dp[parents[s]][s] = add_root(v)
    # return add_root(v)


def dfs2(s):
    q = [(s, e)]
    while q:
        s, dp_p = q.pop()
        par = parents[s]
        for t in d[s]:
            if t == par:
                dp[s][t] = dp_p

        size = len(d[s])
        ac_l = [e] * (size+1)
        ac_r = [e] * (size+1)
        for i, t in enumerate(d[s]):
            ac_l[i+1] = merge(ac_l[i], dp[s][t]+1)%M
        for i, t in enumerate(d[s][::-1]):
            ac_r[size-i-1] = merge(ac_r[size-i], dp[s][t]+1)%M
        ans[s] = add_root(ac_l[size])
        for i, t in enumerate(d[s]):
            if t == par:
                continue
            q.append((t, add_root(merge(ac_l[i], ac_r[i+1])%M)))


dfs1(1)
dfs2(1)
for i in range(1, N+1):
    print(ans[i])


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

int main(void){
  int num, i;
  int x, k, area, enable, count=0;

  //for文の回数
  scanf("%d", &num);

  for(i= 0; i < num; i++){
    scanf("%d", &area);
    x = 1;
    enable = 0;
    while(2 * x * (x + 1) <= area){
      if((area - x) % (2 * x + 1) == 0){
        enable = 1;
        break;
      }
      x += 1;
    }
    if(enable == 0){
      count += 1;
    }
  }
  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2696
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a==1){
        a=14;
    }
    if(b==1){
        b=14;
    }
    if(a>b){
        printf("Alice\n");
    }else if(a<b){
        printf("Bob\n");
    }else{
        printf("Draw\n");
    }
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;



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

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = a[0];
  rep(i, n) ans = __gcd(ans, a[i]);
  cout << ans << endl;
}

Measured memory_bytes: 3960
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof a)
#define  For(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define rFor(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
typedef long long LL;
const int N=100010;
const LL mod=1e9+7;
template<typename T>inline T chkmax(T _A,T _B){return _A>_B?_A:_B;}
template<typename T>inline T chkmin(T _A,T _B){return _A<_B?_A:_B;}
template<typename T>void read(T&x)
{
    x=0;int _f(0);char ch=getchar();
    while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
    while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}
int n,a[N],p[N],x,y;
LL frac[N],ifrac[N],inv[N];
inline LL qpow(LL a,LL b)
{
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
inline void init()
{
	frac[0]=1;
	For(i,1,n+1)
	{
		frac[i]=frac[i-1]*i%mod;
	}
	ifrac[0]=1;
	For(i,1,n+1)
	{
		inv[i]=qpow(i,mod-2);
		ifrac[i]=ifrac[i-1]*inv[i]%mod;
	}
}
inline LL C(int n,int k)
{
	if(n<k)return 0;
	if(n==k)return 1;
	return frac[n]*ifrac[n-k]%mod*ifrac[k]%mod;
}
int main()
{
	read(n);
	init();
	For(i,1,n+1)
	{
		read(a[i]);
		if(p[a[i]])
		{
			x=p[a[i]];
			y=i;
		}
		p[a[i]]=i;
	}
	printf("%d\n",n);
	For(i,2,n)
		printf("%lld\n",(C(n+1,i)+mod-C(n+1-(y-x+1),i-1))%mod);
	printf("%d\n",1);
	return 0;
}


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

int main() {
  int n, o = 0, t = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++) {
    if(i) {
      if(a.at(i - 1) != a.at(i)) {
        o += (t - a.at(i - 1) < 0 ? t : t - a.at(i - 1));
        t = 0;
      }
    }
    t++;
  }
  o += (t - a.at(n - 1) < 0 ? t : t - a.at(n - 1));
  cout << o << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    string s;
    int ans[26] = {};
    while(getline(cin, s)) {
        int len = s.size();
        rep(i, 0, len) {
            if ('A' <= s[i] && s[i] <= 'Z') {
                ans[s[i] - 'A'] ++;
            } else if ('a' <= s[i] && s[i] <= 'z') {
                ans[s[i] - 'a'] ++;
            }
        }
    }

    rep(i, 0, 26) {
        cout << (char)('a' + i) << " : " << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3232
program beautiful
implicit none
character(len=100) :: s
integer :: i, c(26), j

read(*,*) s
c = 0
do i = 1, len_trim(s)
j = ichar(s(i:i))-ichar('a') + 1
c(j) = c(j) + 1
end do
do i = 1, 26
if (mod(c(i),2) == 1 ) then
write(*,'(a)') 'No'
stop
end if
end do
write(*,'(a)') 'Yes'
stop
end program beautiful

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int N, K;

    cin >> N >> K;
    cout << (K - 1 <= (N - 1) / 2 ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n+2];
  a[0]=a[n+1]=0;
  rep(i,n) R a[i+1];
  ll sum=0;
  rep(i,n+1) sum+=abs(a[i]-a[i+1]);
  REP(i,1,n+1) {
    if(a[i-1]<=a[i]&&a[i]<=a[i+1]) pr(sum);
    else if(a[i-1]>=a[i]&&a[i]>=a[i+1]) pr(sum);
    else pr(sum-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 2048
#include<iostream>

using namespace std;

int main(){
	int n, m, t[100],p[100], x[100],sum=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++)cin >> p[i] >> x[i];

	for (int i = 0; i < m; i++) {
		cout << sum - t[p[i]-1] + x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 1000000007
int main()
{ 
    ll p;
    p=1;
    while(p--)
    {
        ll a,b,c,d,e,cnt=0,x,k,y;
        cin>>x>>k>>d;
        x=abs(x);
        a=x/d;
        if(a==k)
        {
            x=x-a*d;
            cout<<abs(x)<<endl;
        }
        else if(a>k)
        {
            x=x-k*d;
            cout<<abs(x)<<endl;
        }
        else
        {
            x=x-a*d;
            y=x-d;
            if((k-a)%2==0)
            cout<<abs(x)<<endl;
            else
            cout<<abs(y)<<endl;
        }
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

#define MAX_NODE 10000
#define INF 1000000000

using namespace std;

struct Edge {
	int to, w;
};
typedef pair<int, int> P;

vector<Edge> adj[MAX_NODE];
int d[MAX_NODE];

void dijkstra(int n, int start) {
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d, d + n, INF);

	d[start] = 0;
	que.push({0, start});
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int from = p.second;

		if (d[from] < p.first)
			continue;

		for (auto& e : adj[from])
			if (d[from] + e.w < d[e.to]) {
				d[e.to] = d[from] + e.w;
				que.push({d[e.to], e.to});
			}
	}
}

int main() {
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		while (k--) {
			int v, c;
			cin >> v >> c;
			adj[u].push_back({v, c});
		}
	}

	dijkstra(n, 0);

	for (int i = 0; i < n; i++)
		cout << i << " " << d[i] << endl;

	return 0;
}

Measured memory_bytes: 6312
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#define lowbit(x) ((x)&(-x))
#define sc scanf
#define debug1(x) cout<<x<<" "
#define debug2(x) cout<<x<<"\n"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long ll;
const ll inf=1e18;
const int N=1e5+10;
ll mod=1e9+7;
using namespace std;
int gcd(int a,int  b){return b==0?a:gcd(b,a%b);}
int arr[N],brr[N];
ll quick_pow(ll a,ll b,ll m)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
		{
			ret*=a;
			ret%=m;
		}
		a*=a;
		a%=m;
		b>>=1;
	}
	return ret;
}
int main()
{
	int n;
	while(cin>>n)
	{
		memset(brr,0,sizeof(brr));
		for(int i=1;i<=n;i++)
		{
			cin>>arr[i];
			brr[arr[i]]++;
		}
		long long sum=0,i;
		if(n%2==0)i=1;
		else i=0; 
		for(;i<n;i+=2)
		{
			if(brr[i]>2||brr[0]>1)
			{
				break;
			}
			sum+=brr[i];
		}
		if((sum==n))
		{
			ll ans=quick_pow(2,n/2,mod);
			cout<<ans<<"\n";
		}	
		else
		cout<<"0"<<"\n";
	}	
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define VAR(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}
// }}} End Header

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

    VAR(int, a, b);
    if (a <= 5) {
        print(0);
    } else if (a >= 6 && a <= 12) {
        print(b / 2);
    } else {
        print(b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>

using namespace std;

bool ok;
int d_pos[]={-2,-1,1};
int d_oto[]={1,0,-1};
void slove(const vector<int> &t, int t_pos, const vector<int> &s, int s_pos){
	
	if(s_pos==-1){
		if(t_pos==-1) ok=true;
		return;
	}else if(t_pos<0 || t_pos>=t.size()) return;

	for(int i=0;i<3;i++){
		int prev_oto=(t[t_pos]+d_oto[i]+12)%12;
		if(prev_oto==s[s_pos]) slove(t,t_pos+d_pos[i],s,s_pos-1);
	}

}

int main(){

	string o[]={"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
	map<string,int> dic;
	for(int i=0;i<12;i++) dic[o[i]]=i;
	
	int T;
	cin>>T;
	
	for(int c=0;c<T;c++){
		int n,m;
		cin>>n>>m;
		
		vector<int> t(n),s(m);
		string tmp;
		for(int i=0;i<n;i++) cin>>tmp,t[i]=dic[tmp];
		for(int i=0;i<m;i++) cin>>tmp,s[i]=dic[tmp];;
		
		ok=false;
		slove(t,n-1,s,m-1);
		slove(t,n-2,s,m-1);
		if(ok) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 7252
package main

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

func main() {
	sc.Split(bufio.ScanWords)
    X := scanInt()
    N := scanInt()
    p := make([]int,N)
    for i:= 0; i<N; i++ {
    	p[i] = scanInt()
	}
	sort.Ints(p)
    aru := false
    for i:= 0; i<N; i++ {
    	if p[i] == X {
    		aru = true
		}
	}
    if !aru {
    	fmt.Println(X)
	} else {
		gosa := 1000
		number := 0
		for i:= -300; i<=300; i++ {
			value := X-i
			if value < 0 {
				value = -value
			}
			if gosa > value {
				nai := true
				for j:=0; j<N; j++ {
					if p[j] == i {
						nai = false
						break
					}
				}
				if nai {
					// fmt.Println(i)
					gosa = value
					number = i
				}
			}
		}
		fmt.Println(number)
	}
}

var sc = bufio.NewScanner(os.Stdin)
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//	return sc.Text()
//}


Measured memory_bytes: 1764
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  long long A, B, N;
  cin >> A >> B >> N;
  cout << (A * min(N,B-1)) / B << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> sum(N+1,0);
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    sum.at(i+1)=sum.at(i)+A;
    sum.at(i+1)%=M;
  }
  map<int,ll> m;
  for(int i=0;i<N+1;i++){
    if(m.count(sum.at(i))==0){
      m[sum.at(i)]=0;
    }
    m[sum.at(i)]++;
  }
  ll ans=0;
  for(auto x: m){
    ans+=x.second*(x.second-1)/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4608
n,m=map(int,input().split())
tr=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  if a!=1 and b!=n:
    continue
  tr[a].append(b)
  tr[b].append(a)
for i in range(2,n):
  if len(tr[i])==2:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")


Measured memory_bytes: 37688
n, t = (int(i) for i in input().split())  
e = [[int(i) for i in input().split()] for i in range(n)] 

min_cost = 100000

for x in e:
    if x[1] <= t and x[0] < min_cost:
        min_cost = x[0]

if min_cost == 100000:
    print("TLE")
else:
    print(min_cost)

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

int main() {
int A, B, C, K, cnt = 0;
cin >> A >> B >> C >> K;
while (A >= B) { cnt += 1; B *= 2; }
while (B >= C) { cnt += 1; C *= 2; }

if (cnt <= K) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}


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

using namespace std;

int selectionSort(int array[], int N) {
    // counter
    int sw = 0;

    for (int i = 0; i < N; i++ ) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (array[minj] > array[j]) {
                minj = j;
            }
        }

        if (minj != i) {
            swap(array[i], array[minj]);
            sw++;
        }
    }

    return sw;
}

// 配列の要素を順番に出力
void trace(int A[], int N) {
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i < N - 1) cout << ' ';
    }
    cout << endl;
}

int main(void) {
    int N;
    int A[100];
    cin >>  N;

    for (int i =0; i < N; i ++)  cin >> A[i];
    int count = selectionSort(A, N);
    
    trace(A, N);
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3108
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];
  set<int> st;
  int mx = 0, mn = n;
  REP(i, n) {
    st.insert(a[i]);
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  int kind = st.size();
  if (mx == mn) {
    REP(i, n) {
      if (a[i] != n - 1 && 2 * a[i] > n) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else if (mx - mn == 1) {
    int y = 0;
    REP(i, n) {
      if (a[i] == mx) y++;
    }
    int x = n - y;
    if (x < mx && 2 * (mx - x) <= y) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, m;
	vector<ll> vx, vy;
	ll sumx = 0;
	ll sumy = 0;

	cin >> n >> m;

	REP(i, n) {
		ll x;
		cin >> x;
		vx.push_back(x);
	}

	REP(i, m) {
		ll y;
		cin >> y;
		vy.push_back(y);
	}

	REP(i, n) {
		sumx += (i * vx[i]) - ((n - i - 1) * vx[i]);
		sumx %= MOD;
	}

	REP(i, m) {
		sumy += (i * vy[i]) - ((m - i - 1) * vy[i]);
		sumy %= MOD;
	}

	cout << (sumx * sumy) % MOD << endl;
}

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

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

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

  int d[2][n];
  fill_n(d[0], n, 0);
  fill_n(d[1], n, 0);

  int num = 0;
  for (int i = 0; i < n; ++i) {
    d[0][i] = a[0][i];
    if (i > 0) {
      d[0][i] += d[0][i-1];
    }

    d[1][i] = d[0][i];
    for (int j = i; j < n; ++j) {
      d[1][i] += a[1][j];
    }

    if (num < d[1][i]) {
      num = d[1][i];
    }
  }

  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    string str;
    cin>>str;
    if(str[1]=='B')str[1]='R';
    else str[1]='B';
    cout<<str;
}

Measured memory_bytes: 3652
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var t, a float64
	fmt.Scan(&n, &t, &a)
	hs := make([]float64, n)
	for i, _ := range hs {
		fmt.Scan(&hs[i])
	}

	min := float64(10000)
	ans := 0
	for i, h := range hs {
		diff := math.Abs(a - (t - h*0.006))
		if min > diff {
			min = diff
			ans = i
		}
	}
	fmt.Println(ans + 1)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int calc(int x, int cx, int y, int cy){
    return abs(x-cx) + abs(y-cy);
}

int main(){
    int n; cin >> n;
    vector<vector<int>> a(n,vector<int>(3));
    rep(i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];
    rep(cx,101) rep(cy,101){
        int m_to = 1e9+7, model = -1;
        if(a[0][2] == 0) m_to = calc(a[0][0],cx,a[0][1],cy);
        else model = calc(a[0][0],cx,a[0][1],cy) + a[0][2];
        bool check = true;
        for(int i = 1; i < n; i++){
            int num = calc(a[i][0],cx,a[i][1],cy) + a[i][2];
            if(a[i][2] == 0){
                if(num < m_to) m_to = num;
                if(model > m_to){
                    check = false;
                    break;
                }
            } else {
                if(model == -1) model = num;
                else if(num != model){
                    check = false;
                    break;
                }
            }
        }
        if(check){
            if(model == -1){
                if(m_to == 0) cout << cx << " " << cy << " " << 0 << endl;
                else continue;
            } else cout << cx << " " << cy << " " << model << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  N %= 10;
  if(N==3) {
    cout << "bon" << endl;
  } else if(N==0||N==1||N==6||N==8) {
    cout << "pon" << endl;
  } else {
    cout << "hon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	int e,y,s;
	char c;
	scanf("%d %d",&e,&y);
	if(e==0){
		c='M';
	    s=y-1867;
		if(y>=1912){
			c='T';
			s=y-1911;
		}
		if(y>=1926){
			c='S';
			s=y-1925;
		}
		if(y>=1989){
			c='H';
			s=y-1988;
		}
		printf("%c%d\n",c,s);
	}
	if(e==1){
		printf("%d\n",1867+y);
	}
	if(e==2){
	    printf("%d\n",1911+y);
	}
	if(e==3){
		printf("%d\n",1925+y);
	}
	if(e==4){
		printf("%d\n",1988+y);
	}
	return 0;
}


Measured memory_bytes: 2132
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Map<Integer, List<Integer>> map = new HashMap<>();
        int[] p = new int[m];
        int[] y = new int[m];
        for (int i = 0; i < m; i++) {
            int tmpP = Integer.parseInt(sc.next());
            int tmpY = Integer.parseInt(sc.next());
            p[i] = tmpP;
            y[i] = tmpY;
            if (map.containsKey(tmpP)) {
                map.get(tmpP).add(tmpY);
            } else {
                List<Integer> list = new ArrayList<>();
                list.add(tmpY);
                map.put(tmpP, list);
            }
        }
        for (Map.Entry<Integer, List<Integer>> e : map.entrySet()) {
            Collections.sort(e.getValue());
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < m; i++) {
            sb.append(String.format("%06d", p[i]));
            sb.append(String.format("%06d", Collections.binarySearch(map.get(p[i]), y[i]) + 1));
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 146872
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n: usize = read();
    let mut a: Vec<i32> = Vec::with_capacity(n);
    let mut count: i32 = 0;
    unsafe {
	a.set_len(n);
    }
    for i in 0..n{
	let number:i32 = read();
	a[i as usize] = number;
    }
    for i in 1..n-1{
	if a[i as usize -1] < a[i as usize] && a[i as usize] <= a[i as usize + 1]{
	    count+=1;
	}else if a[i as usize +1] < a[i as usize] && a[i as usize] <= a[i as usize-1]{
	    count+=1;
	}
    }
    println!("{}",count);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

int main() {
  int n, m;
  while (scanf("%d%d", &n, &m), n|m) {
    vector<int> times(n+m);
    REP(i, n) { scanf("%d", &times[i]); }
    REP(i, m) { scanf("%d", &times[i+n]); }
    sort(ALL(times));
    int ans = times[0];
    REP(i, n+m-1) { ans = max(ans, times[i+1] - times[i]); }
    printf("%d\n", ans);
  }
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  sort(s.begin(), s.end());
  if(s=="abc")cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

int e()
{
    int n;
    std::cin >> n;
    
    std::vector<long long> a, b, origA, origB;
    
    for(int i = 0; i < n; i++)
    {
        long long tempA, tempB;
        cin >> tempA >> tempB;
        a.push_back(tempA);
        origA.push_back(tempA);
        b.push_back(tempB);
        origB.push_back(tempB);
    }
    
    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());
    
    long long minMedian = 0;
    long long maxMedian = 0;
    
    int index = (n - 1) / 2;
    if(n % 2 != 0)
    {
        minMedian = a[index];
        maxMedian = b[index];
    }
    else
    {
        minMedian = (a[index] + a[index + 1]);
        maxMedian = (b[index] + b[index + 1]);
    }
    
    long long ans = maxMedian - minMedian + 1;
    
    std::cout << ans << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    e();
    return 0;
}

Measured memory_bytes: 9664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n;
  cin >> n;
  vector<pair<ll,ll>> ps(n);
  for (int i = 0; i < n; i++) {
    ll a,b;
    cin >> a >> b;
    ps[i].second=a;
    ps[i].first=b;
  }
  sort(ps.begin(),ps.end());
  ll sum=0;
  for(int i=0;i<n;i++){
    sum+=ps[i].second;
    if(sum>ps[i].first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}



Measured memory_bytes: 6408
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    char a, b;
    cin >> a >> b;
    if ((a=='H') != (b=='H')) cout << 'D'; else cout << 'H';
    return 0;
}

Measured memory_bytes: 256