akhauriyash/Code-Regression huggingface dataset:
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int f[N],n,res;
void dfs(int u,int fa){
	R int s=0;
	go(u)if(v!=fa)dfs(v,u),s|=(f[u]&f[v]),f[u]|=f[v];
	if(!f[u])return f[u]=1,void();
	R int c=0;
	while((1<<c)<=s||(f[u]>>c&1))++c;
	f[u]=((f[u]>>c|1)<<c),cmax(res,c);
//	printf("%d %d %d\n",u,f[u],c);
}
int main(){
	scanf("%d",&n);
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	dfs(1,0);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 7168
H,W=map(int,input().split())
b=[]
for i in range(H):
    a=list(str(input()))
    if '#' in a:
        b.append(a)

count=[0]*W

for i in b:

    for j in range(W):

        if i[j]=='#':
            count[j] += 1

ans=['']*len(b)

for i in range(len(b)):

    for j in range(W):

        if count[j]!=0:
            
            ans[i] += b[i][j]

for k in ans:

    print(k)




Measured memory_bytes: 3188
a,b,c,d,e,f = map(int,input().split())

syokuen=[0]

if c == 1 or d == 1:
  for i in range(1500+1):
    syokuen.append(i)
else:
  for i in range(1500//a+1):
    for j in range(1500//b+1):
      if c*i+d*j not in syokuen and c*i+d*j <=1500 :
        syokuen.append(c*i+d*j) 

mizu=[0]
for i in range(30):
  for j in range(30):
      if a*i*100 + b*j*100 not in mizu and a*i*100 + b*j*100<=f:
        mizu.append(a*i*100 + b*j*100)
        
noudo_max = 0.0
for i in range(len(syokuen)):
  for j in range(len(mizu)):
    if mizu[j]+syokuen[i] != 0:
      noudo = syokuen[i]/(mizu[j]+syokuen[i])
      if mizu[j]+syokuen[i] <= f and noudo <= e/(100+e) and noudo >= noudo_max:
        noudo_max = noudo
        ans_syokuen = syokuen[i]
        ans_mizu = mizu[j]

print(ans_syokuen+ans_mizu,ans_syokuen)

Measured memory_bytes: 3064
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

string s[35], t[35];
int h, w, k, cnt[35][35];

int sim() {
  int mul = 1, score = 0;
  bool update = true;
  while(update) {
    update = false;
    //落とす
    FOR(i2, 1, h) {
      for(int i=h-1; i>0; --i) REP(j, w) {
        if(t[i][j] == '-') {
          t[i][j] = t[i-1][j];
          t[i-1][j] = '-';
        }
      }
    }
    // REP(i, h) {
    //   cout << t[i] << endl;
    // }
    // cout << "kesu\n";

    //水平に何個隣り合っているか
    REP(i, h) {
      cnt[i][0] = 1;
      FOR(j, 1, w) {
        if(t[i][j] == t[i][j-1] && t[i][j] != '-') {
          cnt[i][j] = cnt[i][j-1] + 1;
        } else {
          cnt[i][j] = 1;
        }
      }
    }

    //消せるやつを消して空白に&&スコアプラス
    REP(i, h) {
      int tmp = 0;
      for(int j=w-1; j>=0; --j){
        if(tmp == 0 && cnt[i][j] >= k) {
          tmp = cnt[i][j];
          score += mul*(t[i][j]-'0')*cnt[i][j];
          update = true;
        }
        if(tmp > 0) t[i][j] = '-', tmp--;
      }
    }
    mul *= 2;
    // REP(i, h) {
    //   cout << t[i] << endl;
    // }
  }
  return score;
}


signed main(void)
{
  cin >> h >> w >> k;
  REP(i, h) cin >> s[i];

  int ret = 0;
  REP(i, h) REP(j, w) {
    // cout << i << " " << j << "-------------" << endl;
    REP(i2, h) t[i2] = s[i2];
    t[i][j] = '-';
    ret = max(ret, sim());
    // cout << "ret:" << ret << endl;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
hw = [int(i) for i in input().split()]
a = [list(input()) for _ in range(hw[0])]
for i in range(2):
  c = 0
  for ai in a:
    if all([aij == "." for aij in ai]):
      c += 1
  for j in range(c):
    a.remove(["."] * len(a[i]))
  a = [list(ai) for ai in zip(*a)]
for ai in a:
  print("".join(ai))

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
struct Bit {
    vector<T> bit[2];
    int N;

    Bit(int n): N(n) { for (int i = 0; i < 2; i++) bit[i].assign(n + 1, 0); }

    //[1, n]
    void init(int n) {
        for (int i = 0; i < 2; i++) bit[i].assign(n + 1, 0);
        N = n;
    }

    T sub_sum(int p, int i) {
        T s = 0;
        while (0 < i) {
            s += bit[p].at(i);
            i -= i & -i;
        }
        return s;
    }
    // 1-indexed
    T sum(int i) { return sub_sum(0, i) + sub_sum(1, i) * i; }
    // [a, b]
    T sum(int a, int b) { return sum(b) - sum(a - 1); }

    void sub_add(int p, int i, T v) {
        while (i <= N) {
            bit[p].at(i) += v;
            i += i & -i;
        }
    }
    //[a, b] 1-indexed
    void add(int a, int b, T v) {
        sub_add(0, a, -v * (a - 1));
        sub_add(1, a, v);
        sub_add(0, b + 1, v * b);
        sub_add(1, b + 1, -v);
    }
};  

int main() {
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> m(n);
    for (int i = 0; i < n; i++) {
        int x, h;
        cin >> x >> h;
        m.at(i) = make_pair(x, h);
    }
    sort(m.begin(), m.end());

    Bit<ll> bit(n);
    //bit.init(n + 1);
    for (int i = 0; i < n; i++) {
        bit.add(i + 1, i + 1, m.at(i).second);
    }

    ll cnt = 0;
    for (int l = 0; l < n; l++) {
        ll h = bit.sum(l + 1, l + 1);
        if (h <= 0) continue;

        int r = upper_bound(m.begin(), m.end(), m.at(l).first + d * 2,
            [](ll a, pair<ll, ll> b){ return a < b.first; }
        ) - m.begin() - 1;
        ll c = (h + a - 1) / a;
        cnt += c;
        bit.add(l + 1, r + 1, c * -a);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 6528
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"24"# => "No",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        a: usize,
        b: usize,
    }

    let na = n * a;
    if na > b { b } else { na }.to_string()
}

Measured memory_bytes: 4352
use proconio::{input, fastout};
#[fastout]
fn main() {
    input!{
        n: usize,
        mut k: usize,
        a: [usize; n],
    }

    let mut s: Vec<usize> = Vec::new();
    let mut ord: Vec<i32> = vec![-1; n+1];
    let _c = 1;
    let _l: usize = 0;

    let mut v: usize = 1;
    while ord[v] == -1 {
        ord[v] = s.len() as i32;
        s.push(v);
        v = a[v - 1];
    }
    let c = s.len() as i32 - ord[v];
    let l = ord[v] as usize;

    if k < l {
        println!("{}", s[k]);
    } else {
        k -= l;
        k %= c as usize;
        println!("{}", s[l+k]);
    }
}


Measured memory_bytes: 7076
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int N,s=0;
  cin >> N;  
  for(int i = 1; i <= N; i++ ){   
    std::string str = std::to_string(i);
    if( str.size() % 2 == 1 ){
      s += 1;
    }   
  }
  cout << s;
}

Measured memory_bytes: 256
# A
import math
A_B_C = list(map(int,input().split()))

if A_B_C[0] % 2 == 0 or A_B_C[1] % 2 == 0 or A_B_C[2] % 2 == 0:
  print(0)
else:
  max_v = max(A_B_C)
  max_i = A_B_C.index(max_v)
  ans = 1
  for i in range(len(A_B_C)):
    if max_i == i:
      ans *= (math.ceil(max_v/2) - math.floor(max_v/2))
    else:
      ans *= A_B_C[i]
    
  print(ans)


Measured memory_bytes: 9148
#include<iostream>//动态规划剪枝是么从dp0开始
#include<cmath>
#include<algorithm>
#include<string>//stl和数据结构应该一起训练
#include<memory.h>
using namespace std;
int W;
int n;
const int inf=1e9+7;
const int maxl=10007;
	int dp[maxl+2];
int main()
{
	fill(dp,dp+maxl+1,inf);//是不是容易TE,学会
	cin>>n>>W;
	
	for(int i=1;i<=n;i++)
	{	int k=i;
		int v,w;
		cin>>v>>w;
		dp[0]=0;
		for(int j=maxl;j>=v;j--)
			dp[j]=min(dp[j],dp[j-v]+w);

	}int maxn=0;
	for(int i=maxl;i>=0;i--)
		if(W>=dp[i])
{
	maxn=max(maxn,i);
	break;
}
	cout<<maxn<<endl;
	return 0;
	


	
	
}


Measured memory_bytes: 3148
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ans = [[] for _ in range(n + 1)]
for a, b in ab:
    ans[a].append(b)
    ans[b].append(a)

for i in range(1, n + 1):
    print(len(ans[i]))


Measured memory_bytes: 3060
let k = Int(readLine()!)!
let i = readLine()!
    .split(separator: " ")
    .map { Int($0)! }
let (a, b) = (i[0], i[1])
let x = (a...b).contains { $0.isMultiple(of: k) }
let y = (a == b) && (a == k)
print(x || y ? "OK" : "NG")

Measured memory_bytes: 8312
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

const int MAX = 1e5+5;
const int mod = 1e9+7;

int arr[3], k;

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//#ifndef ONLINE_JUDGE
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//#endif

	cin >> arr[0] >>  arr[1] >> arr[2] >> k;

	sort(arr, arr+3);

	cout << arr[0] + arr[1] + arr[2] * (1<<k) << endl;
	

	return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input_string = '';

process.stdin.on('data', (chunk) => {
    input_string += chunk;
});

process.stdin.on('end', () => {
    let lines = input_string.split('\n');

    const xs = lines[0].split(' ').map(x => parseInt(x)).sort().join(' ');
    console.log(xs);
});


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

using namespace std;

int
main(void){
	int n, w; cin >> n >> w;
	vector<pair<int, int> > vec(n);
	for(int i = 0; i < n; i++) cin >> vec[i].first >> vec[i].second;
	
	vector<long long> dp(w + 1, 0); // dp[i] contains the maximum value of objects with weight atmost i.
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = w; j >= vec[i].first; j--){
			dp[j] = max(dp[j], dp[j - vec[i].first] + vec[i].second);
		}
	}
	
	//for(int i = 0; i <= w; i++) cout << dp[i] << " ";
	cout << dp[w];
		
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int a,b,c,d,e,f[3]={3,1,2},i;
	
	scanf("%d",&a);
	
	scanf("%d",&b);
	
	for(i=0;i<b;i++){
		scanf("%d %d",&c,&d);
		if(c>=a/2){
			c=a-c+1;
		}
		if(d>=a/2){
			d=a-d+1;
		}
		if(c<=d){
			e=c%3;
		}else{
			e=d%3;
		}
		printf("%d\n",f[e]);
	}
	return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

R, C, K = map(int, readline().split())
data = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r,c,k = map(int,readline().split())
    data[r][c] = k
    
dp = [0]*(C+1)

for i in range(1,R+1):
    di = data[i]
    ndp = [0]*(C+1)
    kdp = [0]*4
    for j in range(1,C+1):
        kdp[0] = max(kdp[0],dp[j])
        for k in range(2,-1,-1):
            kdp[k+1] = max(kdp[k+1],kdp[k]+di[j])
        ndp[j] = max(kdp)
    dp = ndp
print(dp[C])

Measured memory_bytes: 155308
#include<stdio.h>

#define ll long long

ll M=998244353;
ll fact[300001],ifact[300001];

ll mpow(ll x,ll n){
  ll ans=1;
  while(n != 0){
    if(n&1) ans=ans*x%M;
    x=x*x%M;
    n=n>>1;
  }
  return ans;
}

ll combi(ll n,ll x){
  if(n==0&&x==0)return 1;
  if(n<x||n<0)return 0;
  return fact[n]*ifact[n-x]%M*ifact[x]%M;
}

int main(){
  ll i,n,a,b,k,j,ans;
  scanf("%lld %lld %lld %lld",&n,&a,&b,&k);
  fact[0]=1;
  ifact[0]=1;
  for(i=0;i<n;i++){
    fact[i+1]=fact[i]*(i+1)%M;
    ifact[i+1]=ifact[i]*mpow(i+1,M-2)%M;
  }
  for(i=0;i<=n;i++){
    ll j=(k-i*a)/b;
    if(0<=j&&j<=n&&i*a+j*b==k)ans=(ans+combi(n,i)*combi(n,j))%M;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 4864
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
import core.memory : GC;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }
 
void main() {
    GC.disable();
    int n, m; readf("%d %d\n", &n,&m);
    int[] ps = readints();
 
    auto uf = new UnionFind(n);
    foreach (_; 0..m) {
        int[] xy = readints();
        uf.unite(xy[0] - 1, xy[1] - 1);
    }
 
    //iota(n).filter!(i => uf.same(i, ps[i] - 1)).array.length.writeln;
    int cnt;
    foreach (i; 0..n) cnt += uf.same(i, ps[i] - 1);
    writeln(cnt);
    string _ = readln;
}
 
class UnionFind {
    import std.algorithm.mutation;
    int[] p;
    this(int n) {
        p.length = n;
        p[0..$] = -1;
    }
    bool unite(int u, int v){
        u = root(u); v = root(v);
        if (u == v) return false;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v]; p[v] = u;
        return true;
    }
    bool same(int u, int v){ return root(u) == root(v); }
    int root(int u){ return p[u] < 0 ? u : (p[u] = root(p[u])); }
    int size(int u){ return -p[u]; }
}


Measured memory_bytes: 22076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int cnt(int h, int a) {
  return h % a ? h / a + 1 : h / a;
}
int main() {
  ll n, d, a, sum=0,x=0;
  int h, k=0, l=0;
  cin >> n >> d >> a;
  vector<pair<ll, int>> c(n),v(n);
  rep(i,n)
    cin >> c[i].first >> c[i].second;
  sort(c.begin(), c.end());
  rep(i,n){
    for (int j=k; j<l;++j)
      if(v[j].first<c[i].first){
        k++;
        x-=v[j].second;
      }else break;
    c[i].second-=x;
    if (c[i].second > 0) {
      h = cnt(c[i].second, a);
      sum += h;
      h *= a;
      x+=h;
      v[l].first = c[i].first+2*d;
      v[l].second = h;
      l++;
    }
  }
  cout << sum;
}


Measured memory_bytes: 6528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            string[] read = Console.ReadLine().Split(' ');//標準入力用配列
            int a = int.Parse(read[0]);//A 窓の長さ
            int b = int.Parse(read[1]);//B カーテンの長さ

            if (a - 2 * b <= 0)//全体が隠れるかの計算のif
            {
                Console.Write(0);//出力
            }
            else Console.Write(a - 2 * b);//出力
        }
    }


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)

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

  int max = 1;
  int max_cnt = 0;
  int num;
  int cnt;
  for (int i = 1; i < N + 1; i++)
  {
    num = i;
    cnt = 0;
    while (num > 0){
      if (num % 2 == 0){
        cnt += 1;
        num /= 2;
      }
      else
      {
        break;
      }
      
    }
    if (cnt > max_cnt){
      max_cnt = cnt;
      max = i;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){ return (a%m + b%m+2*m)%m;}

ll mul(ll a, ll b, ll m = MOD){ return ((a%m+m)*(b%m+m))%m;}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 400+5;

int n;
int a[N];
ll prefix[N];
bool vis[N][N];
int choice[N][N];
ll memo[N][N];

ll getSize(int l, int r){
	if(r <= l) return 0LL;
	return l == 0? prefix[r] : prefix[r] - prefix[l-1];
}

ll DP(int l, int r){
	if(r <= l) return 0LL;
	if(l + 1 == r) return a[l]+a[r];
	if(vis[l][r]) return memo[l][r];
	ll ans = 1LL<<45;
	for(int k=l; k<r; k++){
		ll cand = DP(l,k) + getSize(l,r) + DP(k+1,r);
		if(ans > cand){
			choice[l][r] = k;
			ans = cand;
		}
	}
	vis[l][r] = true;
	return memo[l][r] = ans;
}

int main(){
	ri(n);
	for(int i=0; i<n; i++){
		ri(a[i]);
		prefix[i] = a[i];
		if(i > 0) prefix[i] += prefix[i-1];
	}
	cout << DP(0,n-1) << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int n,a; cin >> n >> a;
    cout << n*n-a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#define ll long long	
using namespace std;
int a[3], b[3];
int main()
{
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	sort(a, a + 3);
	b[0] = 0;
	b[1] = a[1] - a[0];
	b[2] = a[2] - a[1];
	int ans = b[0] + b[1] + b[2];
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  ll sum = 0;
  ll mn = 1e10;
  REP(i,n) {
    ll a,b;
    cin>>a>>b;
    sum += a;
    if (a>b) {
      mn = min(mn, b);
    }
  }
  if (mn > 1e9) {
    cout<< 0<<endl;
  } else {
    cout << sum - mn << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    lst = [None, ]
    for _ in range(n):
        x, y = LI()
        lst.append((x,y))

    per = itertools.permutations(range(1,n+1))
    sm = 0
    oc = math.factorial(n)
    for p in per:
        dist = 0
        before = p[0]
        for place in p[1:]:
            dist += math.sqrt((lst[place][0]-lst[before][0])**2 + (lst[place][1]-lst[before][1])**2)
            before = place
        sm += dist
    ans = sm/oc
    print(ans)
main()


Measured memory_bytes: 74808
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

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

int main() 
{
    arena
    ll n,m;
    cin>>n>>m;
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    
    ll cnt=0,flag=0;
    for(ll i=0;i<n;i++)
    {
        if(i==0)
        {
            ll temp=arr[i];
            while(temp%2==0)
            {
                temp=temp/2;
                cnt++;
            }
            continue;
        }
        
        ll cnt1=0;
        ll temp1=arr[i];
        while(temp1%2==0)
        {
            temp1=temp1/2;
            cnt1++;
        }
        if(cnt1!=cnt)
        {
            flag=1;
            break;
        }
    }
    
    if(flag==1)
    {
        cout<<"0";
        return 0;
    }
    
    for(ll i=0;i<n;i++)
    {
        arr[i]=arr[i]/2;
    }
    
    ll ans=arr[0];
    for(ll i=1;i<n;i++)
    {
        ans=lcm(ans,arr[i]);
    }
    
    ll x=m/ans;
    if(x%2==0)
    cout<<x/2;
    else
    cout<<x/2+1;
}

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

int main(){
  string s;
  cin >> s;
  
  int num = 0;
  for(int i=0; i < s.size(); i++){
    if(s[i] == '+') num++;
    if(s[i] == '-') num--;
  }
  cout << num << endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
count = True
for i in range(n-1):
  if h[i+1]-h[i] < -1:
    count = False
    break
  elif h[i+1]-h[i] == -1:
    h[i+1] += 1
if count == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14252
n = int(input())
b = [int(i) for i in input().split()] 

l = [b[0]]
if n>=3:
  for i in range(0, len(b)-1):
      test =  b[i+1] - b[i]
      if test>=0:
          l.append(b[i])
      else:
          l.append(b[i+1])
  l.append(b[-1])
  print(sum(l))
else:
  print(b[0]*2)

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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 (b<a) { a=b; return 1; } return 0; }


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

    vector<ll>w(N);
    vector<ll>v(N);
    rep(i,N) cin >> w[i] >> v[i];

    vector<vector<ll> > dp(N+1, vector<ll>(W+1,0));

    rep(i,N)
    {
        rep(j,W+1)
        {
            chmax(dp[i+1][j], dp[i][j]);
            if( j >= w[i] ) chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 80256
#include <stdio.h>

//insertionSort(A,n,g)
//	for i = g to n-1
//		v = A[i]
//		j = i - g
//		while j >= 0 && A[j] > v
//			A[j+g] = A[j]
//			j = j - g
//			cnt++
//		A[j+g] = v

//ShellSort(A, n)
//	cnt = 0
//	m = ?
//	G[] = {?, ?, ..., ?}
//	for i = 0 to m-1
//		insertionSort(A, n, G[i])

int insertionSort ( int *Arr, int last_point, int begin_point );
int ShellSort ( int *Arr, int length );

int main(void)
{
	int length = 0;
	int Arr[1000000] = {};
	int i = 0;
	
	scanf("%d\n", &length);
	
	for ( i = 0; i < length; i++ ) {
		scanf("%d\n", &Arr[i]);
	}
	
	ShellSort ( Arr, length );
	
	for ( i = 0; i < length; i++ ) {
		printf("%d\n", Arr[i]);
	}
}

//insertionSort(A,n,g)
int insertionSort ( int *Arr, int last_point, int v )
{
	int i = 0;			/* ループ 				  */
	int j = 0;			/* ループ 				  */
	int tmp = 0;		/* 入れ替えのためのダミー */
	static int cnt = 0;	/* カウント */

	for ( i = v; i < last_point; i++ ) {
		tmp = Arr[ i ];
		j = i - v;
		while ( j >= 0 && Arr[ j ] > tmp ) {
			Arr[ j + v ] = Arr[ j ];
			j = j - v;
			cnt++;
		}
		Arr[ j + v] = tmp;
	}
	
	return cnt;
}
//ShellSort(A, n)
int ShellSort ( int *Arr, int length )
{
//	cnt = 0
	int cnt = 0;
	int m = 0;
	int i = 0;
	int G[13] = {
		797161 ,
		265720 ,
		88573  ,
		29524  ,
		9841   ,
		3280   ,
		1093   ,
		364    ,
		121    ,
		40     ,
		13     ,
		4      ,
		1
	};
	
	for ( m = 12; m >= 0; m-- ) {
		if ( G[m] > length ) {
			break;
		}
	}
	
	printf( "%d\n", 12 - m );
	
	for ( i = m+1; i < 12; i++ ) {
		
		printf( "%d ", G[i] );
	}
	
	printf("1\n");
	
	for ( i = m+1; i < 13; i++ ) {
		cnt = insertionSort(Arr, length, G[i]);
	}
	printf("%d\n", cnt);
	
	return 0;
}


Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final int N = scn.nextInt();
			final char[] S = scn.next().toCharArray();

			Set<Double> bs = new HashSet<>(4000);
			for (int b = 0; b < N; b++) {
				if (S[b] != 'B')
					continue;
				bs.add((double) b);
			}

			List<Integer> gs = new ArrayList<>(4000);
			for (int g = 0; g < N; g++) {
				if (S[g] != 'G')
					continue;
				gs.add(g);
			}

			long sum = 0;
			for (int r = 0; r < N; r++) {
				if (S[r] != 'R')
					continue;
				for (int g = 0; g < gs.size(); g++) {
					double max = Math.max(r, gs.get(g));
					double min = Math.min(r, gs.get(g));
					sum += bs.size()
							- (bs.contains(max - (max - min) * 2) ? 1 : 0) //bnx
							- (bs.contains(max - (max - min) / 2) ? 1 : 0)//nbx
							- (bs.contains(max + (max - min)) ? 1 : 0)//nxb
					;
				}
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 47728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int k,x;
    cin >> k >> x;
    if(k*500 >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 384
function Main(input) {
  let sum = 0;
  for (let i = 1; i <= input; i++) {
    if (i % 3 !== 0 && i % 5 !== 0) {
      sum += i;
    }
  }

  console.log(sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 35028
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,b[20][20],m,A[20],B[20][20],d[20],two[110000],ans;
const int mo=1e9+7;
void get(int k,int now,int way){
//	cout<<"fa "<<k<<" "<<now<<" "<<way<<endl;
	if (k==2){
	//	for (int i=1;i<=n;i++) cout<<A[i]<<" "; cout<<endl;
	//	for (int i=0;i<=n;i++) cout<<B[1][i]<<" "; cout<<endl;
	//	for (int i=0;i<=n;i++) cout<<B[2][i]<<" "; cout<<endl;
		int rem=d[1]+d[2],tot=1; if (b[1][2]) rem--;
		for (int w=0;w<=now;w++){
			rem-=B[1][w]+B[2][w];
			ans=(ans+((1ll*way*tot%mo)<<rem))%mo;
		//	cout<<"update "<<way<<" "<<tot<<" "<<rem1<<" "<<rem2<<endl;
			if (B[1][w]==0||B[2][w]==0) break;
			tot=1ll*tot*((1<<B[1][w]+B[2][w])-(1<<B[1][w])-(1<<B[2][w])+1)%mo;
		}
		return;
	}
	int rem=d[k]; int tot=1;
	for (int w=0;w<=now;w++){
		for (int i=1;i<k;i++) if (b[i][k]) B[i][w]++; 
		rem-=B[k][w];
		get(k-1,max(w+1,now),((1ll*way*tot%mo)<<rem)%mo);
		for (int i=1;i<k;i++) if (b[i][k]) B[i][w]--;
	//	cout<<k<<" "<<w<<" "<<B[k][w]<<endl;
		if (B[k][w]==0) break;
		tot=1ll*tot*(two[B[k][w]]-1)%mo;
	}
}
int main(){
//	freopen("data.in","r",stdin);
	scanf("%d%d",&n,&m); int prem=m; two[0]=1;
	for (int i=1;i<=m;i++) two[i]=two[i-1]*2%mo;
	if (n==2){
		printf("%d\n",m); return 0;
	}
	for (;m;m--){
		int k1,k2; scanf("%d%d",&k1,&k2); b[k1][k2]=1; d[k1]++;
	}
	get(n,0,1); //cout<<ans<<" "<<two[prem]<<endl;
	ans=(two[prem]-ans+mo)%mo;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	int mode;
	cin>>mode;
	if(mode==1){
		cout<<"Hello World";
	}	else if(mode==2){
		int A, B;
		cin>>A>>B;
		int sum=A+B;
		cout<<sum;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		long s = sc.nextLong();
		int m = 1000000000;
		int a = (int)ceil(s/m);
		if(a != 1000000000) a = a + 1;
		int c = (int)(a * m - s);
		System.out.println("0 0 " + a + " 1 " + c + " " + m);

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(vector<pair<int, int> > &ev, int start, int tot){
    int L = 1, R = tot;
//    for (int i=0;i<ev.size();i++) cout << ev[i].first << " " << ev[i].second << endl;
//    cout << endl;
    for (int i=ev.size() - 1; i >= 0; i--){
        if (ev[i].first == -1 && ev[i].second == 0){
            L++;
        }
        if (ev[i].first == 1 && ev[i].second == 0){
            R--;
        }
        if (ev[i].first == -1 && ev[i].second == 1){
            R=min((int) tot, R+1);
        }
        if (ev[i].first == 1 && ev[i].second == 1){
            L = max(1LL, L-1);
        }
        if (L > R){
            cout << "NO";
            exit(0);
        }
        //cout << "!!" << L << " " << R << endl;
    }
    if (start < L || start > R){
        cout << "NO";
        exit(0);
    }
}
main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int w, h, n;
    cin >> h >> w >> n;
    int a, b;
    cin >> a >> b;
    vector<pair<int, int> > hor, vert;
    string s, t;
    cin >> s >> t;
    for (int i=0; i < n; i++){
        if (s[i] == 'U'){
            vert.push_back({-1, 0});
        }
        if (s[i] == 'D'){
            vert.push_back({1, 0});
        }
        if (s[i] == 'L'){
            hor.push_back({-1, 0});
        }
        if (s[i] == 'R'){
            hor.push_back({1, 0});
        }
        if (t[i] == 'U'){
            vert.push_back({-1, 1});
        }
        if (t[i] == 'D'){
            vert.push_back({1, 1});
        }
        if (t[i] == 'L'){
            hor.push_back({-1, 1});
        }
        if (t[i] == 'R'){
            hor.push_back({1, 1});
        }
    }
    solve(vert, a, h);
    solve(hor, b, w);
    cout << "YES" << endl;
}


Measured memory_bytes: 10832
N = int(input())
D1 = list(map(int,input().split()))
D2 = list(map(int,input().split()))
sum1 = [0]
for i in range(N):
    n = sum1[i]+D1[i]
    sum1.append(n)
sum1.pop(0)

sum2 = [0]
D2R = D2[::-1]
for i in range(N):
    n = sum2[i]+D2R[i]
    sum2.append(n)
sum2.pop(0)
sum2 = sum2[::-1]

ans = 0
for i in range(N):
    ans = max(ans, sum1[i]+sum2[i])

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>> date(n,vector<int>(m+1));
    rep(i,n){
        rep(j,m+1){
            cin>>date.at(i).at(j);
        }
    }
    int ans=100010001;
    bool can=false;
    for(int i=0;i<(1<<n);i++){
        vector<int> master(m);
        bitset<12> s(i);
        int cost=0;
        rep(j,12){
            if(s.test(j)){
                rep(k,m) master.at(k)+=date.at(n-1-j).at(k+1);
                cost+=date.at(n-1-j).at(0);
            }
        }
        bool MASTER=true;
        rep(i,m){
            if(master.at(i)<x) MASTER=false;
        }
        if(MASTER){
            can=true;
            ans=min(ans,cost);
        }
    }
    if(can) cout<<ans;
    else cout<<"-1";
}

Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int inf = 1e7;

struct E{
	E(){}
	E(int f, int t, int c): f(f), t(t), c(c){}

	int f, t, c;
};

int n, m, r;
E g[2000];
int d[1000];

int main(){
	scanf("%d%d%d", &n, &m, &r);
	rep(i, m){
		int f, t, c;
		scanf("%d%d%d", &f, &t, &c);
		g[i] = E(f, t, c);
	}

	fill_n(d, n, inf);

	d[r] = 0;
	rep(a, n){
		bool update = false;
		rep(i, m){
			E e = g[i];
			if(d[e.f] != inf && d[e.t] > d[e.f] + e.c){
				d[e.t] = d[e.f] + e.c;
				update = true;
			}
		}
		if(!update){
			break;
		}
		if(a == n - 1){
			puts("NEGATIVE CYCLE");
			return 0;
		}
	}

	rep(i, n){
		if(d[i] == inf){
			puts("INF");
		}
		else{
			printf("%d\n", d[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1056
def check_size arr
  case a=arr.shift
  when /[A-Z]+/
    a.size
  when /\d+/
    a.to_i*check_size(arr)
  when ?(
    ans=0
    ans+=check_size(arr) while arr[0]!=?)
    arr.shift
    ans
  end
end

def get_ch arr,n
  while a=arr.shift
    case a
    when /[A-Z]+/
      l=a.size
      break a[n] if n<l
      n-=l
    when /\d+/
      tarr=arr.dup
      l=check_size(tarr)
      break get_ch(arr,n%l) if n<l*a.to_i
      arr=tarr
      n-=l*a.to_i
    end
  end
end

while (a,b=gets.split)!=[?0]*2
  puts get_ch(a.scan(/[A-Z]+|\(|\)|\d+/),b.to_i)||0
end

Measured memory_bytes: 6200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    if(a==25){
       cout<<"Christmas"<<endl;
    }
    else if(a==24){
        cout<<"Christmas Eve"<<endl;
    }
    else if(a==23)
    {
        cout<<"Christmas Eve Eve"<<endl;
    }
    else{
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
    return 0;
}



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

#define rep(type, i, n) for (type i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))
#define swap(type, a, b) { type temp = a; a = b; b = temp; }

const ll mod = 1000000007;

ll powmod(ll x, ll y) {
  ll res = 1;
  rep(ll, i, y) {
    res *= x;
    res %= mod;
  }
  return res;
}

int main() {
  ll N;
  scanf("%lld", &N);

  ll a = powmod(10, N);
  // printf("a: %lld\n", a);

  ll b = powmod(9, N);
  // printf("b: %lld\n", b);

  ll c = b;
  // printf("c: %lld\n", c);

  ll d = powmod(8, N);
  // printf("d: %lld\n", d);

  ll ans = (a + d) - (b + c);
  ans %= mod;
  ans = (ans + mod) % mod;

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

  return 0;
}


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

using namespace std;

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

    int S,W;
    cin>>S>>W;

    if(W>=S)
        cout<<"unsafe";
    else
        cout<<"safe";

   
    return 0;   
}   


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<long long, long long> P;


void solve()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	for (long long i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	long long  ans = 1;
	for (long long i = 1; i * i <= A[0]; ++i)
	{
		if (A[0] % i == 0)
		{
			int cnt = 1;
			for (int j = 1; j < N; ++j)
			{
				if (A[j] % i == 0)
				{
					++cnt;
				}
			}
			if (cnt >= N - 1)
			{
				ans = max(ans, i);
			}

			cnt = 1;
			for (int j = 1; j < N; ++j)
			{
				if (A[j] % (A[0] / i) == 0)
				{
					++cnt;
				}
			}
			if (cnt >= N - 1)
			{
				ans = max(ans, A[0] / i);
			}
		}
	}
	for (long long i = 1; i * i <= A[1]; ++i)
	{
		if (A[1] % i == 0)
		{
			int cnt = 1;
			for (int j = 0; j < N; ++j)
			{
				if (j == 1)
				{
					continue;
				}
				if (A[j] % i == 0)
				{
					++cnt;
				}
			}
			if (cnt >= N - 1)
			{
				ans = max(ans, i);
			}

			cnt = 1;
			for (int j = 1; j < N; ++j)
			{
				if (j == 1)
				{
					continue;
				}
				if (A[j] % (A[1] / i) == 0)
				{
					++cnt;
				}
			}
			if (cnt >= N - 1)
			{
				ans = max(ans, A[1] / i);
			}
		}
	}
	cout << ans << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int cnt[100005];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n) {
		int l, r;
		scanf("%d%d", &l, &r);
		r++;
		int mi = 1e9;
		FOR(jump, 1, 320) {
			int tl = (l - 1) / jump + 1;
			int tr = min((r - 1) / jump + 1, mi);
			mi = min(mi, tl);
			cnt[tl]++;
			cnt[tr]--;
			if (mi < 320)break;
		}
		FOR(d, 1, mi) {
			if (((l - 1) / d + 1) * d < r) {
				cnt[d]++;
				cnt[d + 1]--;
			}
		}
	}
	REP(i, m)cnt[i + 1] += cnt[i];
	REP(i, m)printf("%d\n", cnt[i + 1]);
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int n;
  int i,j,k,ans=0;
  vector <int> v,w;
  
  cin>>n;
  for(i=0;i<n;i++){
    cin>>j;
    v.push_back(j);
  }
  for(i=0;i<n;i++){
    cin>>j;
    w.push_back(j);
  }
  for(i=0;i<n;i++){
    if(v[i]>w[i])
      ans+=v[i]-w[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N,M;
	int A[1000];
	int count[1000];
	int Ai,Bj,i,j;
	int max=0;
	int game=0;

	scanf("%d %d",&N,&M);
	for(i=0;i<N;i++){
		scanf("%d",&Ai);
		A[i]=Ai;
		count[i]=0;
	}
	for(j=0;j<M;j++){
		scanf("%d",&Bj);
		for(i=0;i<N;i++){
			if(A[i]<=Bj){count[i]++;
				break;
			}
		}
	}
	for(i=0;i<N;i++){
		if(max<count[i]){
			max=count[i];
			game=i;
		}
	}

	printf("%d\r\n",game+1);
}

Measured memory_bytes: 2672
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

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

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

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	x, _ := strconv.Atoi(fmt.Sprintf("%d%d", a, b))

	y := int(math.Sqrt(float64(x)))
	if y*y == x {
		println("Yes")
	} else {
		println("No")
	}

}


Measured memory_bytes: 640
#include <stdio.h>
 
int main(void){

	int m, f, r;

	while (1){
		scanf("%d %d %d",&m,&f,&r);
		if((m==-1)&&(f==-1)&&(r==-1)){
			break;
	}

	if((m!=-1)&&(f!=-1)){
		if((m+f)>=80){
			printf("A\n");
	}

	else if((m+f)>=65){
		printf("B\n");
	}

	else if(((m+f)>=50)||(r>=50)){
		printf("C\n");
	}

	else if((m+f)>=30){
		printf("D\n");
	}

		else{
			printf("F\n");
		}
	}
		else{
			printf("F\n");
		}
    }

	return 0;
}

Measured memory_bytes: 584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String [] str = bufferedReader.readLine().split(" ");
        Integer a = Integer.parseInt(str[0]);
        Integer b = Integer.parseInt(str[1]);
        Integer c = Integer.parseInt(str[2]);
        if (a < b && b < c)  {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}
 

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

int	main() {
	vector<int> C(3);
	for (int i=0; i<3; i++)
		cin >>C.at(i);
	sort(C.begin(), C.end());
	C.erase(unique(C.begin(), C.end()), C.end());
	cout <<C.size() <<endl;
	return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


void dfs(const vector<vector<int> > &g,int from,int now,vector<long long> &weight){
    for (auto i : g[now]){
        if (i == from) continue;
        weight[i] += weight[now];
    }

    for (auto i : g[now]){
        if (i == from) continue;
        dfs(g,now,i,weight);
    }
}

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

    vector<long long> weight(N,0);

    for (int i = 0; i < Q; i++){
        long long p,x; cin >> p >> x;
        p--;
        weight[p] += x;
    }

    for (int i = 0; i < g[0].size(); i++){
        weight[g[0][i]] += weight[0];
        dfs(g,0,g[0][i],weight);
    }
    for (int i = 0; i < N; i++){
        cout << weight[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 27392
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 100000000700000;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll pow_MOD(ll x,ll n){//x^n
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    res %= MOD;
    return res;
    
}

int main(){
    ll N;
    cin >> N;
    if(N == 0) cout << 0;
    vector<int> ans(0);
    int cnt = 1;
    while(N != 0){
        if(N % pow_MOD(2, cnt) == 0){
            ans.push_back(0);
        }else{
            ans.push_back(1);
            if(cnt % 2){
                N -= pow_MOD(2, cnt-1);
            }else{
                N += pow_MOD(2, cnt-1);
            }
        }
        cnt++;
    }
    for(int i = ans.size()-1; i >= 0; i--){
        cout << ans.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
package main

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

func answer4() bool {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	N, _ := strconv.Atoi(scanner.Text())

	prev := -1

	for i := 0; i < N; i++ {
		scanner.Scan()
		h, _ := strconv.Atoi(scanner.Text())

		if prev > h {
			return false
		} else if prev < h {
			h--
		}

		prev = h
	}

	return true
}

func main() {
	if answer4() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 2176