akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        System.out.print(a[n-1]);
        for(int i = n-2; i >= 0; i--){
            System.out.printf(" %d", a[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26424
#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);

  int n;string s;
  cin>>n>>s;
  int x=0;
  int res=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I')x++;
    else x--;
    res=max(res,x);
  }
cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

x_1,y_1,x_2,y_2=map(int,input().split())
b=y_2-y_1
a=x_2-x_1
print('{} {} {} {}'.format(x_2-b,y_2+a,x_1-b,y_1+a))


        


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
typedef long long ll;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int main() {
    int n, m; cin >> n >> m;
    int maxl = 1, minr = n;
    rep(i, m) {
        int l, r; cin >> l >> r;
        chmax(maxl, l);
        chmin(minr, r);
    }
    int ans = minr - maxl + 1;
    cout << max(ans, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 4000000000000000000
int dx8[8]={-1,0,1,1,1,0,-1,-1};
int dy8[8]={1,1,1,0,-1,-1,-1,0};
int dx4[4]={-1,0,1,0};
int dy4[4]={0,-1,0,1};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int uni[100010];
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]); 
}
bool connect(int a,int b){
    a=root(a);
    b=root(b);
    if(a==b)return false;
    if(uni[a]>uni[b]){
        swap(a,b);
    }
    uni[a]=uni[a]+uni[a];
    uni[b]=a;
    return true;
}
signed main(void){
    int n;cin>>n;cout<<(n+1)/2<<endl;
    
}
        


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using sii = tuple<string, int, int>;

bool compair(sii left, sii right) {
  if (get<0>(left) != get<0>(right)) {
    return get<0>(left) < get<0>(right);
  }
  else {
    return get<1>(left) > get<1>(right);
  }
}

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

  vector<sii> review(N);
  for (int i = 0; i < N; i++) {
    string S;
    int P;
    cin >> S >> P;
    review.at(i) = make_tuple(S, P, i+1);
  }

  sort(review.begin(), review.end(), compair);

  for (int i = 0; i < N; i++) {
    cout << get<2>(review.at(i)) << endl;
  }
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [x,a] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print $ if x < a then 0 else 10


Measured memory_bytes: 380
import sys

# S = input()
# N, M = map(int, input().split())
# As = [int(input()) for _ in range(N)]
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    print(solve())


def solve():
    N, M = map(int, input().split())

    scs = [list(map(int, input().split())) for _ in range(M)]

    minimum = 10 ** (N-1)
    if minimum == 1:
        minimum = 0
    maximum = 10 ** N - 1

    ans = -1
    for i in range(minimum, maximum+1):
        candidate = str(i)
        ok = True
        for s, c in scs:
            if candidate[s-1] != str(c):
                ok = False
                break
        if ok:
            ans = int(candidate)
            break

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=100000+10,maxtot=maxn*25;
ll ans[maxn],cnt[maxn],a[maxn],b[maxn],tree[maxtot],p[maxn][70][2];
int root[maxn],left[maxtot],right[maxtot],rk[maxn];
int len[maxn];
int i,j,k,l,t,n,m,tot,top,num;
int newnode(int x){
    tree[++tot]=tree[x];
    left[tot]=left[x];
    right[tot]=right[x];
    return tot;
}
void insert(int &x,int l,int r,int a,int b){
    x=newnode(x);
    tree[x]=b;
    if (l==r) return;
    int mid=(l+r)/2;
    if (a<=mid) insert(left[x],l,mid,a,b);else insert(right[x],mid+1,r,a,b);
}
int query(int x,int l,int r,int a,int b){
    if (!x||a>b) return 0;
    if (l==a&&r==b) return tree[x];
    int mid=(l+r)/2;
    if (b<=mid) return query(left[x],l,mid,a,b);
    else if (a>mid) return query(right[x],mid+1,r,a,b);
    else return max(query(left[x],l,mid,a,mid),query(right[x],mid+1,r,mid+1,b));
}
void solve(int x,ll l){
    int t=upper_bound(b+1,b+num+1,l)-b-1;
    int y=query(root[x-1],1,num,1,t);
    if (!y){
        if (l>=n){
            p[i][++top][0]=0;
            p[i][top][1]=l/n;
            l%=n;
        }
        p[i][++top][0]=l;
        return;
    }
    p[i][++top][0]=y;
    p[i][top][1]=l/a[y];
    solve(y,l%a[y]);
}
int main(){
	//freopen("1.in","r",stdin);
	//freopen("2.out","w",stdout);
    scanf("%d%d",&n,&m);
    a[0]=n;
    fo(i,1,m) scanf("%lld",&a[i]),b[i]=a[i];
    //b[++m]=n;
    sort(b+1,b+m+1);
    num=unique(b+1,b+m+1)-b-1;
    b[++num]=2000000000000000000;
    fo(i,1,m) rk[i]=lower_bound(b+1,b+num+1,a[i])-b;
    fo(i,1,m){
        root[i]=root[i-1];
        insert(root[i],1,num,rk[i],i);
    }
    fo(i,1,m){
        top=0;
        solve(i,a[i]);
        len[i]=top;
    }
    cnt[m]=1;
    fd(i,m,1){
        fo(j,1,len[i]-1)
            cnt[p[i][j][0]]+=cnt[i]*p[i][j][1];
        ans[p[i][len[i]][0]]+=cnt[i];
    }
    ans[n]+=cnt[0];
    fd(i,n,1) ans[i]+=ans[i+1];
    fo(i,1,n) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 148224
#include<bits/stdc++.h>
#define loop(_i,_v,_n)  for(int _i=_v;_i<_n;++_i)
using namespace std;
typedef vector<vector<int>> vv;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int a, b, c;
  cin >> a >> b >> c;
  if (a > c)  
    cout << "NO" << endl;
  else if (a + b >= c)
    cout << "YES" << endl;
  else 
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for i := 1; ; i++ {
		a := nextInt()
		if a == 0 {
			break
		}
		fmt.Printf("Case %d: %d\n", i, a)
	}

}



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

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    ll n,m;cin>>n>>m;
    vector<ll>a(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    int cnt=0;
    int sum=0;
    for(int i=0;i<n;i++)sum+=a[i];
        //cout<<sum<<endl;
    bool abc=0;if(sum%(4*m)!=0)abc=1;
    sum/=(4*m);sum+=abc;
    
    for(int i=0;i<n;i++)if(a[i]>=sum)cnt++;
        if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<Endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Li Chao Tree */

template<typename T>
struct LiChaoTree {
  using Line = pair<T, T>; // first * x + second

  int segn2;
  vector<Line> data;
  vector<T> X;

  template<typename S>
  LiChaoTree(vector<S> pos) {
    int N = pos.size();
    for (segn2 = 1; segn2 < N; segn2 *= 2);
    data.assign(segn2 * 2, {0, INF});
    X.assign(segn2, INF);
    for (int i=0; i<(int)pos.size(); i++)
      X[i] = pos[i];
  }

  inline T f(Line line, T x) {
    return line.first * x + line.second;
  }

  void addLine(int a, int b, Line line, int l = 0, int r = -1, int k = 0) {
    if (r == -1) r = segn2;
    int m = (l + r) / 2;

    if (r <= a || b <= l) return;
    if (l < a || b < r) {
      addLine(a, b, line, l, m, k*2+1);
      addLine(a, b, line, m, r, k*2+2);
      return;
    }
    if (data[k].second == INF) { //isNull
      data[k] = line;
      return;
    }

    bool fl = f(line, X[l])   < f(data[k], X[l]);
    bool fm = f(line, X[m])   < f(data[k], X[m]);
    bool fr = f(line, X[r-1]) < f(data[k], X[r-1]);

    if (fl == fr) {
      if (fl) data[k] = line;
      return;
    }
    if (fm) swap(data[k], line);

    if (fl ^ fm) addLine(a, b, line, l, m, 2*k+1);
    else addLine(a, b, line, m, r, 2*k+2);
  }

  void addLine(Line line) { addLine(0, segn2, line); }

  T query(int k) {
    T x = X[k], res = LLINF;
    k += segn2-1;

    while(1){
      if (data[k].second != INF) //isNotNull
        res = min(res, f(data[k], x));
      if (!k) break;
      k = (k - 1) / 2;
    }

    return res;
  }
};

ll dp[SIZE];

int main(){
  int N;
  ll C, h[SIZE];
  vector<ll> pos;

  scanf("%d%lld", &N, &C);

  for (int i=0; i<N; i++) {
    scanf("%lld", h+i);
    pos.push_back(h[i]);
  }

  dp[0] = 0;

  LiChaoTree<ll> tree(pos);

  for (int i=0; i<N-1; i++) {
    tree.addLine({-2*h[i], h[i]*h[i] + C + dp[i]});
    dp[i+1] = tree.query(i+1) + h[i+1]*h[i+1];
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 15344
#include <bits/stdc++.h>
#define MOD (int)(1e9 + 7)
#define MAX (int)(2e5 + 9)

using namespace std;

int mult (int a, int b) {
	return (a * 1LL * b) % MOD;
}

int add (int a, int b) {
	b = (b + MOD) % MOD;
	a = (a + MOD) % MOD;
	return (a + b) % MOD;
}

int f[MAX];

int pw (int a, int b) {
	int r = 1;
	while (b) {
		if (b & 1) {
			r = mult (r, a);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return r;
}

int nck (int n, int k) {
	if (k > n || n < 0 || k < 0) {
		return 0;
	}
	return mult (f[n], pw (mult (f[n - k], f[k]), MOD - 2));
}

int sum (int n) {
	if (n <= 0) {
		return 0;
	}
	int a = n, b = n + 1;
	if (a & 1) {
		b >>= 1;
	}
	else {
		a >>= 1;
	}
	return mult (a, b);
}

int main()
{
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = k; i <= n + 1; i++) {
		int mi = sum (i - 1), ma = sum (n) - sum (n - i);
		ans = add (ans,  add (1, add (ma, -mi)));
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,head[MN+5],cnt=0,b[MN+5],ans=1;
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;	
}
void dfs(int x,int fa)
{
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa) dfs(e[i].to,x);
	if(!b[x])
	{
		if(fa&&!b[fa]) b[fa]=b[x]=1;
		else ans=0;	
	}
}
int main()
{
	n=read();
	for(int i=1;i<n;++i) ins(read(),read());
	dfs(1,0);
	puts(ans?"Second":"First"); 
	return 0;
}



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

int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;
    if (s.at(a) == '-')
    {
        int count = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (s.at(i) == '-')
            {
                count++;
            }
        }
        if (count == 1)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
  var n,m,x int
  sc := bufio.NewScanner(os.Stdin)
  fmt.Scanf("%d %d %d", &n, &m, &x)
  allText := make([][]int, n)

  // 参考書情報を取得する
  for i := 0; i < n; i++ {
    sc.Scan()
    s := sc.Text()
    allText[i] = stringToSliceInt(s)
  }

  ans := 9223372036854775807

  for mask := 0; mask < (1 << uint64(n)); mask++ {
    var cost int
    isUnderX := true
    abilitys := make([]int, m)
    for i := 0; i < n; i++ {
      if mask >> uint64(i) & 1 != 0 {
        cost += allText[i][0]
        for j := 1; j <= m; j++ {
          abilitys[j-1] += allText[i][j]
        }
      }
    }

    for _, v := range abilitys {
      if v < x {
        isUnderX = false
        break
      }
    }

    if isUnderX {
      ans = int(math.Min(float64(ans), float64(cost)))
    }
  }

  if ans == 9223372036854775807 {
    fmt.Println(-1)
  } else {
    fmt.Println(ans)
  }
}

// 標準出力の数字一覧を文字列として取得しているので、[]intに変換する
func stringToSliceInt(s string) []int {
  sls := strings.Split(s, " ")
  sli := make([]int, len(sls))
  for i, v := range sls {
    // strconv.Atoi(v string) (int, error)
    // →string型をint型に変換する
    re, _ := strconv.Atoi(v)
    sli[i] = re
  }
  return sli
}


Measured memory_bytes: 2236
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
/*迷路移動*/const int dx[4]={1,0,-1,0};const int dy[4]={0,1,0,-1};
llfor;//ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll a[2],b[2],c[2],d[2];
 cin>>a[0]>>a[1]>>b[0]>>b[1];
  
 ll x=b[0]-a[0];//0
 ll y=b[1]-a[1];//1
 c[0]=b[0]-y;
 c[1]=b[1]+x;
 d[0]=a[0]-y;
 d[1]=a[1]+x;
  
 cout<<c[0]<<" "<<c[1]<<" "<<d[0]<<" "<<d[1]<<endl;
 return 0;}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	constexpr int MAX_W = 100000;
	int N;
	cin >> N;
	vector<int> V(N), W(N);
	REP(i, N) scanf("%d %d", &V[i], &W[i]);
	
	int Q;
	cin >> Q;
	vector<int> vert(Q), L(Q);
	REP(i, Q) scanf("%d %d", &vert[i], &L[i]), --vert[i];
	
	int t9 = 1 << 9;
	chmin(t9, N);
	
	vector<vector<int>> dp(t9, vector<int>(MAX_W + 1, -INF));
	
	dp[0][0] = 0;
	dp[0][W[0]] = V[0];
	REP(i, MAX_W) chmax(dp[0][i + 1], dp[0][i]);
	
	FOR(i, 1, t9) {
		int p = (i - 1) / 2;
		
		REP(j, MAX_W + 1) {
			int cur = dp[p][j];
			if (j - W[i] >= 0) {
				int val = dp[p][j - W[i]];
				if (val != -INF) chmax(cur, val + V[i]);
			}
			dp[i][j] = cur;
			if (j < MAX_W) chmax(dp[i][j + 1], dp[i][j]);
		}
	}
	
	REP(i, Q) {
		// vert[i], L[i]
		if (vert[i] < t9) {
			printf("%d\n", dp[vert[i]][L[i]]);
			continue;
		}
		
		vector<int> v;
		int curp = vert[i];
		while (curp >= t9) {
			v.emplace_back(curp);
			curp = (curp - 1) / 2;
		}
		int ans = -INF;
		REP(s, 1 << v.size()) {
			int curv = 0, curw = 0;
			REP(j, v.size()) if (s >> j & 1) {
				curv += V[v[j]];
				curw += W[v[j]];
			}
			if (L[i] - curw >= 0) chmax(ans, dp[curp][L[i] - curw] + curv);
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 207400
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1<<30;
enum full = (1<<26) - 1;

void main() {
    string s;
    scan(s);

    int n = s.length.to!int;
    auto dp = new int[](n + 1);
    dp[n] = 1;
    auto next = new int[][](n + 1, 26);
    fillAll(next, inf);
    int b = 0;

    foreach_reverse (i ; 0 .. n) {
        b |= (1<<(s[i] - 'a'));
        if (b == full) {
            dp[i] = dp[i+1] + 1;
            b = 0;
        }
        else {
            dp[i] = dp[i+1];
        }

        foreach (j ; 0 .. 26) {
            if (s[i] - 'a' == j) {
                next[i][j] = i;
            }
            else {
                next[i][j] = next[i+1][j];
            }
        }
    }

    debug {
        writeln(dp);
        writeln;
        writefln("%(%s\n%)", next);
    }

    auto ans = new char[](dp[0]);
    ans[] = '#';
    int pos = 0;

    foreach (i ; 0 .. dp[0]) {
        foreach (c ; 0 .. 26) {
            if (next[pos][c] == inf) {
                ans[i] = ('a' + c).to!char;
                break;
            }
            if (dp[pos] == dp[next[pos][c]+1] + 1) {
                ans[i] = ('a' + c).to!char;
                pos = next[pos][c]+1;
                break;
            }
        }
    }

    writeln(ans);
}










































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 35256
#include<bits/stdc++.h>
using namespace std;
#define LL long long

const int mo=998244353;
const int maxn=32768;

int len,n,m,fac[maxn],ifac[maxn];
char t1[maxn],t2[maxn];
int f[maxn],F[maxn];
int A[maxn],B[maxn],C[maxn];
int N,step,rev[maxn],wn[maxn];

int power(int x,int k)
{
	int res=1;
	while (k)
	{
		if (k&1) res=(LL)res*x%mo;
		x=(LL)x*x%mo;
		k>>=1;
	}
	return res;
}

void fft(int a[],int flag)
{
	int i,j,k;
	for (i=0;i<N;i++)
		if (i<rev[i]) swap(a[i],a[rev[i]]);
	for (k=1;k<N;k<<=1)
	{
		int p=N+flag*N/(k<<1);
		for (i=0;i<N;i+=k<<1)
		{
			for (j=0;j<k;j++)
			{
				int x=a[i+j];
				int y=(LL)a[i+j+k]*wn[(LL)p*j%N]%mo;
				a[i+j]=(x+y)%mo;
				a[i+j+k]=(x+mo-y)%mo;
			}
		}
	}
	if (flag==-1)
	{
		int invN=power(N,mo-2);
		for (i=0;i<N;i++)
			a[i]=(LL)a[i]*invN%mo;
	}
}

void multi(int a[],int b[])
{
	int i;
	memcpy(A,a,sizeof(A));
	memcpy(B,b,sizeof(B));
	fft(A,+1);
	fft(B,+1);
	for (i=0;i<N;i++)
		C[i]=(LL)A[i]*B[i]%mo;
	fft(C,-1);
	for (i=n+1;i<N;i++) C[i]=0;
	memcpy(a,C,sizeof(C));
}

void solve()
{
	int i,w;
	for (N=1,step=0;N<=n<<1;N<<=1,step++);
	for (i=1;i<N;i++)
		rev[i]=rev[i>>1]>>1|(i&1)<<(step-1);
	w=power(5,(mo-1)/N);
	wn[0]=1;
	for (i=1;i<N;i++)
		wn[i]=(LL)wn[i-1]*w%mo;
	for (i=0;i<=n;i++)
		f[i]=ifac[i+1];
	F[0]=1;
	int k=m;
	while (k)
	{
		if (k&1) multi(F,f);
		multi(f,f);
		k>>=1;
	}
	int Ans=0;
	for (i=0;i<=n;i++)
		(Ans+=F[i])%=mo;
	Ans=(LL)Ans*fac[n]%mo;
	Ans=(LL)Ans*fac[m]%mo;
	Ans=(LL)Ans*fac[n+m]%mo;
	printf("%d\n",Ans);
}

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i;
	fac[0]=1;
	for (i=1;i<=30000;i++)
		fac[i]=(LL)fac[i-1]*i%mo;
	ifac[30000]=power(fac[30000],mo-2);
	for (i=30000;i>=1;i--)
		ifac[i-1]=(LL)ifac[i]*i%mo;
	scanf("%s",t1+1);
	scanf("%s",t2+1);
	len=strlen(t1+1);
	for (i=1;i<=len;i++)
		if (t1[i]=='1') t2[i]=='1'?n++:m++;
	solve();
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

using P = pair<int,int>;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int n; cin >> n;
	string A; cin >> A;
	int N = 1<<n;
	rep(i,N) rep(j,N){
		if((i&j) == j && A[i] == '1' && A[j] == '0'){
			cout << "Impossible" << endl;
			return 0;
		}
	}
	V<int> minimal0s;
	rep(i,N) if(A[i] == '0'){
		bool minimal = true;
		rep(j,i) if((i&j) == j && A[j] == '0') minimal = false;
		if(minimal) minimal0s.pb(i);
	}
	auto rev = [&](string s){
		reverse(all(s));
		for(char& c: s){
			if(c == 'l' || c == 'r') c ^= 'l'^'r';
			else c ^= 'u'^'d';
		}
		return s;
	};
	string ans;
	if(false){
		minimal0s.clear();
		n = 8; N = 1<<n;
		rep(i,N){
			if(__builtin_popcount(i) == 7) minimal0s.pb(i);
//			minimal0s.pb(i);
		}
	}
	for(int s: minimal0s){
		show(s);
		V<int> xs = {0};
		rep(i,n) if(s&1<<i) xs.pb(i+1);
		{
			V<int> ds;
			rep(i,xs.size()-1) ds.pb(xs[i+1]-xs[i]);
			xs = ds;
		}
		string t;
		int K = xs.size();
		for(int i=K-1;i>=0;i--){
			if(i == K-1){
				t = string(xs[i],'r') + "dlu" + string(xs[i]-1,'l');
			}else{
				string nt;
				nt += string(xs[i],'r');
				nt += t;
				nt += "ldru";
				nt += rev(t);
				nt += "dlu";
				nt += string(xs[i]-1,'l');
				t = nt;
			}
		}
		ans += t;
	}

	cout << "Possible" << endl;
	cout << ans.size() << endl;
//	return 0;
	int x=0,y=0; cout << x << " " << y << endl;
	for(char c: ans){
		if(c == 'r') x++;
		if(c == 'l') x--;
		if(c == 'd') y++;
		if(c == 'u') y--;
		cout << x << " " << y << endl;
	}
}

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define int long long int
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()

// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	int n;
	cin>>n;
	int abc[n][3];
	int dp[n][3];

	for(int i=0;i<n;i++) {
		for(int j=0;j<3;j++) {
			cin>>abc[i][j];
			dp[i][j] = abc[i][j];
		}
	}

	for(int i=1;i<n;i++) {
		dp[i][0] = abc[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = abc[i][1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = abc[i][2] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int LL;
typedef long int L;
typedef long double LD;

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

    int a, b, c;
    cin >> a >> b >> c;
    
    int d = b / a;
    
    int ans;
    if(d >= c) ans = c;
    else ans = d;
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = (0 until n)
            .map {
                val (a, b) = readLine()!!.split(' ').map { it.toLong() }
                a to b
            }
            .sortedByDescending { it.first + it.second }
    val ans = xs.mapIndexed { index, pair -> if (index % 2 == 0) pair.first else -pair.second }.sum()
    println(ans)
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  ll A[3];
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A+3);
  cout << abs(A[1] - A[0]) + abs(A[2] - A[1]) << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using namespace atcoder;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

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

  dsu d(n);
  rep(i, q) {
    int query, v1, v2;
    cin >> query >> v1 >> v2;
    if (query == 0) {
      d.merge(v1, v2);
    } else {
      bool same = d.same(v1, v2);
      cout << ((same) ? "1" : "0") << endl;
    }
  }
}


Measured memory_bytes: 4060
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"time"
)

var D int
var cs []int
var ss [][]int

var used = [366][27]bool{}

func main() {
	D = ReadInt()
	cs = ReadInts(26)
	ss = make([][]int, D)
	for i := 0; i < D; i++ {
		ss[i] = ReadInts(26)
	}

	// naives
	answers := []int{}
	last := make([]int, 26)
	for d := 1; d <= D; d++ {
		maxT, maxScore := -1, math.MinInt32
		for i := 0; i < 26; i++ {
			s := ss[d-1][i] - cs[i]*(d-last[i])
			if s > maxScore {
				maxT, maxScore = i, s
			}
		}
		last[maxT] = d
		answers = append(answers, maxT+1)
	}

	rand.Seed(12345682)

	lastAnswers := answers
	lastScore := scores(lastAnswers)

	start := time.Now()
	timeout := 1930 * time.Millisecond
	for time.Now().Sub(start) < timeout {
		d, q := rand.Intn(D)+1, rand.Intn(26)+1
		if used[d][q] {
			continue
		}
		used[d][q] = true
		newAnswers := Dup(lastAnswers)
		newAnswers[d-1] = q
		newScore := scores(newAnswers)
		if newScore >= lastScore {
			lastAnswers, lastScore = newAnswers, newScore
		}
	}

	for _, v := range lastAnswers {
		fmt.Println(v)
	}
}

func Dup(xs []int) []int {
	return append([]int{}, xs...)
}

func scores(answers []int) int {
	last := make([]int, 26)
	score := 0
	for d := 1; d <= D; d++ {
		t := answers[d-1] - 1
		score += ss[d-1][t]
		last[t] = d
		for i := 0; i < 26; i++ {
			score -= cs[i] * (d - last[i])
		}
	}
	return score
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

struct node{
  int parent, left, right;
};
struct node *t;

void pre(int u){
  if(u == -1){
    return;
  }
  printf(" %d", u);
  pre(t[u].left);
  pre(t[u].right);
}

void in(int u){
  if(u == -1){
    return;
  }
  in(t[u].left);
  printf(" %d", u);
  in(t[u].right);
}

void pos(int u){
  if(u == -1){
    return;
  }
  pos(t[u].left);
  pos(t[u].right);
  printf(" %d", u);
}

int root(int n){
  int i;
  for(i = 0; i < n; i++){
    if(t[i].parent == -1){
      return i;
    }
  }
}

int main(void){
  int i, n, x;
  scanf("%d", &n);
  t = (struct node *)malloc(n * sizeof(struct node));
  for(i = 0; i < n; i++){
    t[i].parent = -1;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d", &x);
    scanf("%d %d", &t[x].left, &t[x].right);
    if(t[x].left != -1){
      t[t[x].left].parent = x;
    }
    if(t[x].right != -1){
      t[t[x].right].parent = x;
    }
  }

  x = root(n);

  printf("Preorder\n");
  pre(x);
  printf("\n");
  printf("Inorder\n");
  in(x);
  printf("\n");
  printf("Postorder\n");
  pos(x);
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a <= 8 && b <= 8 ? "Yay!": ":(") << endl;
}


Measured memory_bytes: 256
fun main() {
  val (N, K) = readInts()
  val P = readInts().map { it - 1 }
  val C = readInts()

  fun f(begin: Int): Long {
    val visited = Array(N) { false }
    val scores = Array(N) { Long.MIN_VALUE } // i ステップの時の score
    var p = begin
    visited[begin] = true
    var score = 0L
    var stepNum = 0
    for (i in 0 until K) {
      stepNum++
      visited[p] = true
      score += C[p]
      scores[i] = score
      p = P[p]
      if (visited[p]) break
    }
    val lastScore = scores[stepNum - 1]
    if (K <= stepNum || lastScore <= 0L) {
      return scores.max()!!
    } else {
      var loopNum = K / stepNum
      if (K % stepNum == 0) loopNum--
      val bonus = lastScore * loopNum
      val k = K - stepNum * loopNum
      return bonus + ((0 until k).map { scores[it] }.max() ?: 0L)
    }
  }

  val results = (0 until N).map { f(it) }
  println(results.max())
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

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

int main() {
    int h,a;
    cin>>h>>a;

    cout<<(h+a-1)/a<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int X=2e5+10;
char s[X];
int sum,x,ans=0;
void init(){
	scanf("%s",s+1);
	sum=x=strlen(s+1);
}
void work(){
	for(int i=0;++i<=x;)
		if(s[i]=='S') ++ans;
		else if(ans) --ans,sum-=2;
}
void prin(){
	printf("%d",sum);
}
int main(){
	init();
	work();
	prin();
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>

using namespace std;

int main(){
 int n,k;
  cin >> n >> k;
 int x[n];
  
  int res=0;
  for(int i=0;i<n;i++) {
    cin >> x[i];
   if(2*x[i]<=k) res+=2*abs(x[i]);
   else res+=2*abs(x[i]-k);
  }
  cout << res << endl;
}

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

int main() {
  vector<int> A(3);
  for(int i=0; i<3; i++){
    cin >> A.at(i);
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());

  cout << A.at(0)*10+A.at(1)+A.at(2) << endl;

return 0;  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  string ret = "NO";
  int k = 0;
  int a = 0;
  if(4 < s.size() && s.size() < 10){
    for(int i = 0; s.size() > i; i++){
      if(k == 0){
        if(s[i] == 'K')k++;
        else if(s[i] == 'A'){
          a++;
          if(a > 1)break;
        }else break;
      } else if(k == 1){
        if(s[i] == 'I')k++;
        else break;
      } else if(k == 2){
        if(s[i] == 'H')k++;
        else break;
      } else if(k == 3){
        if(s[i] == 'B')k++;
        else if(s[i] == 'A'){
          a++;
          if(a > 2 || s[i-1] == 'A')break;
        } else break;
      } else if(k == 4){
        if(s[i] == 'R'){
          if(s.size()-1 == i)ret="YES";
          else if(s.size()-2 == i){
            if(s[i+1] == 'A')ret="YES";
            else break;
          } else break;
        } else if(s[i] == 'A'){
          a++;
          if(a > 3 || s[i-1] == 'A')break;
        } else break;

      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int a,b;
  cin >> a >> b;
  if(a >= 13) cout << b;
  else if(a <= 5) cout << 0;
  else cout << b/2;
  hinata;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
  string s;
  cin >> s;

  if(s == "Sunny"){
    cout << "Cloudy";
  }else if(s == "Cloudy"){
    cout << "Rainy";
  }else {
    cout << "Sunny";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

string a,b,ans;


int main(){
  int N;
  cin >> N;
  cin >> a >> b;
  rep(i,N){
    string c,d;
    c = a[i];
    d = b[i];
    ans += (c + d); 
  }
  cout << ans << endl;
  
  return 0;
}



// int gcd(int a, int b){
//   if (b==0) return a;
//   else return gcd(b,a%b);
// }


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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


Measured memory_bytes: 256
/*input
46 4 40 5
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 and c>0){
        c-=b;
        if(c<=0){
            cout<<"Yes";
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No";
            return 0;
        }
    }
}


Measured memory_bytes: 3652
#include<stdio.h>
#define N 100000

typedef struct Card{
  char mark;
  int num, index;

}Card;

int Partition( Card A[], int p, int r ){
  int a, i, j;
  Card c;
  a = A[r].num;
  i = p - 1;
  for( j = p; j < r; j++ ){
    if( A[j].num <= a){
      i++;
      c = A[i];
      A[i] = A[j];
      A[j] = c;
    }
  }
  c = A[i+1];
  A[i+1] = A[r];
  A[r] = c;

  return i+1;
}

void QuickSort( Card A[], int p, int r ){
  int q;
  if( p < r ){
    q = Partition( A, p, r );
    QuickSort( A, p, q-1 );
    QuickSort( A, q+1, r );
  }
}

int isStable( Card A[], int n ){
  int i;
  for( i = 1; i < n; i++ ){
    if( A[i-1].num == A[i].num ){
      if( A[i-1].index > A[i].index ){
    return 0;
      }
    }
  }
    return 1;
}

main(){
  int i, n;
  Card A[N];

  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    scanf(" %c %d", &A[i].mark, &A[i].num);
    A[i].index = i;
  }

  QuickSort( A, 0, n-1 );

  if( isStable(A, n) == 1 ){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  for( i = 0; i < n; i++ ){
    printf("%c %d\n", A[i].mark, A[i].num);
  }
    return 0;
}



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

using namespace std;

long long inf=1000000007;

int main(){
	int n;
	cin>>n;
	vector<pair<long long,long long>> p(n);
	for(int i=0;i<n;i++){
		long long x,l;
		cin>>x>>l;

		p.at(i).first=x+l;
		p.at(i).second=x-l;
	}

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

	long long ans=0;
	long long now=inf*-1;

	for(auto a:p){
		if(a.second>=now){
			ans++;
			now=a.first;
		}
	}

	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int H,W;
int dp[1500][1500];

int main(void){
	cin >> H >> W;
	int ans=0;
	rep(i,H)rep(j,W){
		int cur;
		cin >> cur;
		dp[i][j]=(cur==0);
		if(dp[i][j]&&i-1>=0&&j-1>=0) dp[i][j]+=min({dp[i-1][j],dp[i][j-1],dp[i-1][j-1]});
		ans=max(ans,dp[i][j]);
	}
	cout << ans*ans << endl;
	return 0;
}

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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  if (s1s2s3/10>=10) {
   cout << s1s2s3/100+s1s2s3/10-10+s1s2s3%10 << endl;
  }
  else {
    cout << s1s2s3/100+s1s2s3/10+s1s2s3%10 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n, a[101], w[101], m, dp[101][100001];
int main() {
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	cin >> a[i] >> w[i];
	for (int i = 1;i <= n;i++)
	{
		for (int j = 0;j <= m;j++)
		{
			if (j < a[i])
			dp[i][j] = dp[i - 1][j];
			else
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a[i]] + w[i]);
		}
	}
	cout << dp[n][m];
}

Measured memory_bytes: 78336
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Numerics;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int itemCount = int.Parse(Reader.ReadLine());
        NumList = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        long ans = this.GetAns();

        Console.WriteLine(ans);


    }

    private int[] NumList;

    private long GetAns()
    {
        long minCost = long.MaxValue;
        for (int i = -100; i <= 100; i++)
        {
            long cst = this.GetCost(i);
            minCost = Math.Min(minCost, cst);
            if (minCost == 0)
            {
                return minCost;
            }
        }
        return minCost;
    }

    private long GetCost(long cost)
    {
        return NumList.Sum(a => (cost - a) * (cost - a));

    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

4
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100

";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3032
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int sum = 0;
		int time[] = new int[5];
		int amari[] = new int[5];
		
		for(int i=0; i< 5; i++){
			time[i] = keyboard.nextInt();
			amari[i] = time[i]%10;
			sum += ((time[i]  +9)/10)*10;
		}
		
		Arrays.sort(amari);
		
		int ans = 10;
        for(int j = 0; j <5; j++){
        	if(amari[j] != 0){
	        	ans = amari[j];
		        break;
				}
			}
			
		System.out.println(sum - (10-ans));
		keyboard.close();	
	}
}


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

int main(){
  vector<int> A(5);
  int a = 0;
  int ans = 0;
  rep(i,5){
    cin >> A[i];
    if(A[i]%10 == 0) ans += A[i];
    else{
      ans += (A[i]+10)/10*10;
      a = max(a,10 - A[i]%10);
    }
  }
  cout << ans - a << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int r,c,e=0;
	r=scan.nextInt();
	c=scan.nextInt();
	int a[][]=new int[r][c];
	
	for(int i=0;i<r;i++)
	    {
		int b=0;
		for(int j=0;j<c;j++)
		    {
			a[i][j]=scan.nextInt();
			b+=a[i][j];			
			System.out.print(a[i][j]+" ");
		    }
		e+=b;
		System.out.println(b);			
	    }
	for(int i=0;i<c;i++)
	    {
		int d=0;
		for(int j=0;j<r;j++)
		    {
			d+=a[j][i];				
		    }
		System.out.print(d+" ");	
	    }
	System.out.println(e);
    }
}

Measured memory_bytes: 32184
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int MAXN=100000+10;
char s[MAXN];
int main()
{
	scanf("%s",s);
	for(register int i=0;i<strlen(s);++i)
		if(!(i&1))printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int cake = 4;
    int donuts = 7;

    for (int i = 0; i <= (100/cake); i++){
        for (int j = 0; j <= (100/donuts); j++){
            if (i*cake + j*donuts == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256