akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    d, x = map(int, input().split())
    a_ = []
    for _ in range(n):
        a_.append(int(input()))

    cnt = 0
    for a in a_:
        i = 1  # スタート
        while i <= d:
            i += a
            cnt += 1
    print(cnt + x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using P = pair<int, int>;
const int MX = 200005;
int n, x, y, xmax, ymin = 1e9, c[MX], u, e, l = 1e9;
long long ans;
P pr[MX*2];
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d%d", &x, &y);
		if(x > y) swap(x,y);
		xmax = max(xmax, x);
		ymin = min(ymin, y);
		pr[i*2] = P(x,i);
		pr[i*2+1] = P(y,i);
	}
	sort(pr, pr+n*2);
	ans = (long long)(pr[n*2-1].first - ymin) * (xmax - pr[0].first);
	rep(i,n*2-2){
		if(++c[pr[i+1].second] == 1 && ++u == n){
			while(--c[pr[++e].second]);
			l = min(l, pr[i+1].first - pr[e].first);
			u--;
		}
	}
	ans = min(ans, (long long)(pr[n*2-1].first - pr[0].first) * l);
	printf("%lld\n", ans);
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define ll          long long
#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
#define track(x)                cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define ed(i)       i.end()
#define mem(a)      memset(a, 0, sizeof(a))
#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int &b) {a = max(a, b); }
void self_min(int &a, int &b) {a = min(a, b); }
#define hell        1000000007
bool isPrime(long int n) 
{
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}


ll power(int x, unsigned int y, int p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2
        x = (x*x) % p;  
    } 
    return res;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
	ll n, m;
	cin >> n >> m;
	vii A;
	rep(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		A.pb(mp(a, b));
	}
	sort(all(A));
	ll ans = 0;
	rep(i, 0, n) {
		ll t = min(m, A[i].y);
		m -= t;
		ans += (t*A[i].x);
		if(!m)	break;
	}
	cout << ans << endl;

}
int main() {
	// freopen("input.txt", "rt", stdin);
	// freopen("output.txt", "wt", stdout);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  vector<int> d(c);
  rep(i,c)
    cin>>d.at(i);
  vector<int> e(a,b-c);
  rep(i,c){
    e.at(d.at(i)-1)++;
  }
  rep(i,a){
    if(e.at(i)>0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 2176
program main
  implicit none
  integer(8) i, sosa, rensa, N
  character(200000) s 
  read(*, *) s
  N = len_trim(s)
  if (N < 3) then
    sosa = 0
  else
    sosa = 0
    rensa = 0
    do !while(i < N-2)
      if (s(i:i) == 'A') then
        rensa = rensa + 1
      else
        rensa = 0
      endif
      if (rensa > 0 .and. s(i+1:i+2) == 'BC') then
        sosa = sosa + rensa
        rensa = rensa-1
        s(i+2:i+2) = 'A'
        i = i+2
      else
        i = i+1
      end if
      if (i > N-2) then
        exit
      end if
    end do
  end if
  write(* ,*) sosa
end program main

Measured memory_bytes: 1084
import math

def solve(line):
	R = int(line[1:3], 16)
	G = int(line[3:5], 16)
	B = int(line[5:7], 16)
	
	sa_black = math.sqrt(R**2 + G**2 + B**2)
	sa_max = sa_black
	ans_color = "black"
	
	sa_blue = math.sqrt(R**2 + G**2 + (B - 255)**2)
	if sa_blue < sa_max:
		sa_max = sa_blue
		ans_color = "blue"
	
	sa_lime = math.sqrt(R**2 + (G - 255)**2 + B**2)
	if sa_lime < sa_max:
		sa_max = sa_lime
		ans_color = "lime"
	
	sa_aqua = math.sqrt(R**2 + (G - 255)**2 + (B - 255)**2)
	if sa_aqua < sa_max:
		sa_max = sa_aqua
		ans_color = "aqua"
	
	sa_red = math.sqrt((R - 255)**2 + G**2 + B**2)
	if sa_red < sa_max:
		sa_max = sa_red
		ans_color = "red"
	
	sa_fuchsia = math.sqrt((R - 255)**2 + G**2 + (B - 255)**2)
	if sa_fuchsia < sa_max:
		sa_max = sa_fuchsia
		ans_color = "fuchsia"
	
	sa_yellow = math.sqrt((R - 255)**2 + (G - 255)**2 + B**2)
	if sa_yellow < sa_max:
		sa_max = sa_yellow
		ans_color = "yellow"
	
	sa_white = math.sqrt((R - 255)**2 + (G - 255)**2 + (B - 255)**2)
	if sa_white < sa_max:
		sa_max = sa_white
		ans_color = "white"

	return ans_color

while True:
	line = input()
	if line == '0': break
	print(solve(line))

Measured memory_bytes: 7640
#include <bits/stdc++.h>
using namespace std;
int n, p[200010];
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> p[i];
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int cnt = 0;
		while (i == p[i]) i++, cnt++;
		ans += (cnt + 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long int ll;
int main(){
	long long int money;
	int i,j,ns,sum=0;
	cin >> ns >> money;
	for(i=0;i<=ns;i++){
		for(j=0;j<=ns;j++){
			if(i+j > ns)
				break;
			if((i * 10000 + j * 5000 + (ns-(i+j)) * 1000) == money){
				cout << i << " " << j << " " << (ns - (i + j)) << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

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

int main(){
	int a,b,c;
	cin >> a;
	cin >> b;
	cin >> c;
	if(a+b<c){
		cout << "NO" << endl;
	}else if(a>c){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,h[100010],i;
  cin >> n;
  for (i=0;i<n;i++) cin >> h[i];
  int l=0,r=0,ans=0;
  while (r<n){
    while (r<n-1 && h[r+1]<=h[r]) r++;
    if (ans<r-l) ans=r-l;
    r++;
    l=r;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    string S;
    cin >> S;

    int yymmflag = 0;
    int mmyyflag = 0;

    if (S[2] == '0')
    {
    	if (S[3] != '0') yymmflag++;

    }

    if (S[2] == '1')
    {
    	if (S[3] == '1' || S[3] == '0' || S[3] == '2') yymmflag++;
    }

    if (S[0] == '0')
    {
    	if (S[1] != '0') mmyyflag++;

    }

    if (S[0] == '1')
    {
    	if (S[1] == '1' || S[1] == '0' || S[1] == '2') mmyyflag++;
    }

    if (yymmflag == 1 && mmyyflag == 1) cout << "AMBIGUOUS" << endl;
    else if (yymmflag == 1 && mmyyflag == 0) cout << "YYMM" << endl;
    else if (yymmflag == 0 && mmyyflag == 1) cout << "MMYY" << endl;
    else if (yymmflag == 0 && mmyyflag == 0) cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    int N;
    cin>>N;
    map<int, int> map;
    int A;
    for(int i=1;i<N;++i){
        cin>>A;
        A--;
        map[A]++;
    }
    for(int i=0;i<N;++i){
        cout<<map[i]<<endl;
    }
}



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

int main(){

    int N, Y,i,j,k;
    cin >> N >> Y;

    for(i=Y/10000; i>=0; i--){
        for(j=(Y-10000*i)/5000; j>=0; j--){
            k=N-i-j;
            if(10000*i+5000*j+1000*k == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lson (idx*2)
#define rson (idx*2+1)

const int N=2e5+5;
const int INF=1e9;
using namespace std;

struct Node
{
    int l,r;
    int lo,lh,lazy=0;
    bool flag=false;
}s[N*4];
int h,w;

void calc(int idx)
{
    s[idx].lo=min(s[lson].lo,s[rson].lo);
    s[idx].lh=s[lson].lh;
}

void build(int idx,int l,int r)
{
    s[idx].l=l,s[idx].r=r;
    if(l==r) return;
    int mid=(l+r)/2;
    build(lson,l,mid);
    build(rson,mid+1,r);
}

void pushdown(int idx)
{
    if (s[idx].flag)
    {
        int val=s[idx].lh;
        int l=s[idx].l;
        for(int i=lson;i<=rson;i++)
        {
            s[i].lo=s[i].lh=val+s[i].l-l;
            s[i].flag=true;
            s[i].lazy=0;
        }
    }
    else if(s[idx].lazy)
    {
        for(int i=lson;i<=rson;i++)
        {
            s[i].lh+=s[idx].lazy;
            s[i].lo+=s[idx].lazy;
            s[i].lazy+=s[idx].lazy;
        }
    }
    s[idx].flag=false;
    s[idx].lazy=0;
}

void update(int idx,int l,int r,int L)
{
    if(s[idx].l>=l&&s[idx].r<=r)
    {
        s[idx].lo=s[idx].lh=L+s[idx].l-l+1;
        s[idx].flag=true;
        s[idx].lazy=0;
        return;
    }
    pushdown(idx);
    int mid=(s[idx].l+s[idx].r)/2;
    if(l<=mid) update(lson,l,r,L);
    if(mid+1<=r) update(rson,l,r,L);
    calc(idx);
}

void add(int idx,int l,int r)
{
    if(s[idx].l>=l&&s[idx].r<=r)
    {
        s[idx].lh++;
        s[idx].lo++;
        s[idx].lazy++;
        return;
    }
    pushdown(idx);
    int mid=(s[idx].l+s[idx].r)/2;
    if(l<=mid) add(lson,l,r);
    if (mid+1<=r) add(rson,l,r);
    calc(idx);
}

int query(int idx,int l,int r)
{
    if (r<1||l>w) return INF;
    if(s[idx].l>=l&&s[idx].r<=r) return s[idx].lo;
    pushdown(idx);
    int ans=INF;
    int mid=(s[idx].l+s[idx].r)/2;
    if(l<=mid) ans=min(ans,query(lson,l,r));
    if(mid+1<=r) ans=min(ans,query(rson,l,r));
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>h>>w;
    vector<int>l(h),r(h);
    for(int i=0;i<h;i++) cin>>l[i]>>r[i];
    vector<int>ans(h,INF);
    build(1,1,w);
    for(int i=0;i<h;i++)
    {
        if(l[i]>1) add(1,1,l[i]-1);
        if(r[i]<w) add(1,r[i]+1,w);
        int val=query(1,l[i]-1,l[i]-1);
        update(1,l[i],r[i],val);
        ans[i]=min(ans[i],query(1,1,w));
        if(ans[i]==INF) break;
    }
    for(auto&i:ans)cout<<(i==INF?-1:i)<<'\n';
}


Measured memory_bytes: 24292
#include <iostream>
using namespace std;
constexpr int mod = 1000000007;
int n, fact[1000009], inv[1000009], factinv[1000009], val[1000009];
int main() {
	cin >> n;
	fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = 1LL * fact[i - 1] * i % mod;
	}
	inv[1] = 1;
	for (int i = 2; i <= n; i++) {
		inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
	}
	factinv[0] = 1;
	for (int i = 1; i <= n; i++) {
		factinv[i] = 1LL * factinv[i - 1] * inv[i] % mod;
	}
	for (int i = n - 1; 2 * i - n >= 0; i--) {
		val[i] = 1LL * fact[i - 1] * factinv[2 * i - n] % mod * fact[i] % mod;
	}
	int ret = 0;
	for (int i = n - 1; 2 * i - n >= 0; i--) {
		ret = (ret + 1LL * (val[i] - val[i - 1] + mod) * i) % mod;
	}
	cout << ret << "\n";
	return 0;
}

Measured memory_bytes: 13952
#include <iostream>
using namespace std;
int main() {
    string S; cin >> S;
    if ((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3])) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}

Measured memory_bytes: 3628
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	k := sc.ReadInt()

	a := n % k
	b := k - a
	fmt.Println(MinInt(a, b))
}

// util
// * math

func AbsInt(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

// * io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
string solve(vector<Int> a){
  Int n=a.size();
  Int f=1,x=0;
  for(Int i=0;i<n;i++){
    f&=a[i]%2==0;
    x^=a[i];
  }
  if(x>1) return "Alice"s;
  if(x==1) return "Bob"s;
  return (f?"Bob"s:"Alice"s);
}

signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  cout<<solve(a)<<endl;
  return 0;
}



Measured memory_bytes: 4452
#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 63)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef __int128 LL;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

map<LL,int> mp;
int n,m;
vs s;

ostream& operator<<(ostream& os, const LL& v)
{
    if (v == 0) { return (os << "0"); }
    LL num = v;
    if (v < 0) {
        os << '-';
        num = -num;
    }
    string s;
    for (; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
    reverse(s.begin(), s.end());
    return (os << s);
}

int dfs(int nw,LL p)
{
    if(mp.find(p) != mp.end()) return mp[p];
    int ct = 0;
    rep(i,n){
        if(p >> i & (LL)1){
            ct++;
        }
    }
    if(ct == 1) return 0;
    int res = m+1;
    rep(id,m){
        if(!(nw >> id & 1)){
            LL a = 0, b = 0;
            rep(i,n){
                if(p >> i & (LL)1){
                    if(s[i][id] & 1){
                        a |= (LL)1 << i;
                    }else{
                        b |= (LL)1 << i;
                    }
                }
            }
            if(a != 0 && b != 0){
                cmn(res,max(dfs(nw^(1 << id),a),dfs(nw^(1 << id),b))+1);
            }
        }
    }
    mp[p] = res;
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        cin >> m >> n;
        if(m == 0) break;
        s.resize(n);
        mp.clear();
        rep(i,n){
            cin >> s[i];
        }
        LL hoge = 0;
        rep(i,n){
            hoge |= (LL)1 << i;
        }
        cout << dfs(0,hoge) << "\n";
    }
    return 0;
}



Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const long long INF = 1LL << 60;
const int MOD = 1000000007; // 1e9 + 7
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
template <class T> inline bool chmin(T &a, T b) { if ( a > b ) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T &a, T b) { if ( a < b ) { a = b; return 1; } return 0; }
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int N, A;
ll dp[55][55][3333];

int main(int argc, char *argv[]){
    cin >> N >> A;
    vec X(N);
    rep(i, N) cin >> X[i];
    dp[0][0][0] = 1;
    rep(i, N) rep(j, N) rep(k, 2500){
        if(dp[i][j][k]){
            dp[i + 1][j][k] += dp[i][j][k];
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k];
        }
    }
    ll res = 0;
    rfor(i, 1, N + 1) res += dp[N][i][i * A];
    cout << res << endl;
    return 0;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

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

    cin >> a >> b >> c;
    
    if(b-a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}



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

int main(){
string N;
cin >> N;
for(int i = 0; i < 2; i++){ 
     if(N.at(i) == N.at(i + 1) && N.at(i + 1) == N.at(i + 2)) {
         cout << "Yes"<< endl;
         return 0; 
}
}
cout << "No"<< endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(NULL);
#define REP(i,a,n) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)

int main() 
{ 
  FASTIO;
  string s;
  cin>>s;
  int n=s.length();
  string t=s;
  reverse(s.begin(),s.end());
  if(t==s)
  {
  	bool flag=false;
  	int a=0,b=(n+3)/2 - 1;
  	for(int i=0;i<(n-1)/2;++i)
  	{
  	  	if(s[a]!=s[b])
  	  	{
  	  	  flag=true;
			  break;	
		}
	}
	if(flag) cout<<"No"<<"\n";
	else cout<<"Yes"<<"\n";
  }
  else cout<<"No"<<"\n";
  
  
    return 0;
    
} 

Measured memory_bytes: 256
from fractions import gcd

P = 10**9 + 7
n = int(input())

def lcm(p,q):
    return p*q//gcd(p,q)

a = list(map(int, input().split()))
x = a[0]
for i in range(1,n):
    x = lcm(x,a[i])
ans = 0
for i in range(n):
    ans += x//a[i]
    if i%10==0:
        ans = ans%P
print(ans%P)

Measured memory_bytes: 6200
#include <iostream>
#include <iomanip>
#include <limits>
#include <cmath>
using namespace std;
int a[100], b[100], n, i, j, sum;
string s, k;

int countDivisors(int n) 
{ 
    int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main(){
	cin>>n;
	for(j=1; j<=n-1; j++){
		sum+=countDivisors(j);
	}
	cout<<sum;
	return 0;
}



Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int a[9][9],n,m;
long ans;
void dfs(int I)
{
	if(I==n)
	{
		ans++;
		return;
	}
	int id[9]={},sz=0,win=0;
	for(int j=0;j<n;j++)
	{
		if(I!=j)
		{
			if(a[I][j])
			{
				win+=a[I][j]>0;
			}
			else
			{
				id[sz++]=j;
			}
		}
	}
	if(sz==0&&(n-1)/2==win)
	{
		dfs(I+1);
		return;
	}
	if((n-1)/2<win||(n-1)/2-win>sz)return;
	int get=(n-1)/2-win;
	int comb=(1<<get)-1;
	while(comb<1<<sz)
	{
		for(int j=0;j<sz;j++)
		{
			a[I][id[j]]=comb>>j&1?1:-1;
			a[id[j]][I]=-a[I][id[j]];
		}
		dfs(I+1);
		if(get==0)break;
		int x=comb&-comb;
		int y=comb+x;
		comb=(comb&~y)/x/2|y;
	}
	for(int j=0;j<sz;j++)
	{
		a[I][id[j]]=a[id[j]][I]=0;
	}
}
main()
{
	while(cin>>n,n)
	{
		cin>>m;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)a[i][j]=0;
		for(int i=0;i<m;i++)
		{
			int x,y;cin>>x>>y;
			x--,y--;
			a[x][y]=1;
			a[y][x]=-1;
		}
		ans=0;
		dfs(0);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3100
import java.util.*;

public class Main{
	int ans, n;
	int [] garr;

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n == 0) break;
			char []s = sc.next().toCharArray();
			char []g = sc.next().toCharArray();
			int [] sarr = new int[n];
			for(int i = 0; i < n;i++){
				sarr[i] = s[i] - '0';
			}
			garr = new int[n];
			for(int i = 0; i < n; i++){
				garr[i] = g[i] - '0';
			}
			ans = 1 << 24;
			dfs(sarr, 0);
			System.out.println(ans);
		}
	}

	private void dfs(int[] arr, int deep) {
		
		if(Arrays.equals(arr, garr)){
			ans = Math.min(ans, deep);
			return;
		}
		else if(deep == n) return;
		if(ans <= deep) return;
		
		int pos;
		for(pos = deep; pos < n; pos++){
			if(garr[pos] != arr[pos]) break;
		}
		
		int diff1 = (garr[pos] - arr[pos] + 10) % 10;
		//int diff2 = (arr[pos] - garr[pos] + 10) % 10;
		for(int i = pos; i < n; i++){
			for(int j = pos; j <= i; j++){
				arr[j] = (arr[j] + diff1) % 10;
			}
			dfs(arr, deep + 1);
			for(int j = pos; j <= i; j++){
				arr[j] = (arr[j] - diff1 + 10) % 10;
			}
		}
//		
//		for(int i = pos; i < n; i++){
//			for(int j = pos; j <= i; j++){
//				arr[j] = (arr[j] - diff2 + 10) %10;
//			}
//			dfs(arr, deep + 1);
//			for(int j = pos; j <= i; j++){
//				arr[j] = (arr[j] + diff2) % 10;
//			}
//		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 22408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10,lim=1e6,mo=998244353;
ll power(ll a,ll b=mo-2){
	ll ans=1;
	while (b){
		if (b&1)ans=ans*a%mo;
		a=a*a%mo;
		b>>=1;
	}return ans;
}
ll jc[N],ny[N],n,m,ans;
ll C(ll n,ll m){
	return (ny[m]*ny[n-m]%mo*jc[n])%mo;
}
int main(){
	cin>>n>>m;
	jc[0]=1;
	for (int i=1;i<=lim;i++)jc[i]=jc[i-1]*i%mo;
	ny[lim]=power(jc[lim]);
	for (int i=lim;i;i--)ny[i-1]=ny[i]*i%mo;
	for (int i=0;i<=n&&i<=m;i++){
		ans=(ans+power(-1,i)*C(n,i)*C(m,i)%mo*jc[i]%mo*power(m+1,n-i)%mo*power(n+1,m-i))%mo;
	}
	cout<<(ans%mo+mo)%mo<<endl;
}

Measured memory_bytes: 15872
#include <iostream>
using namespace std;
#define int long long
const int Maxn=100005;
const int inf=0x3f3f3f3f3f3f3f3f;
int n,a[Maxn],L,q;
int nxt[Maxn],nxt2[Maxn][20];
void init()
{
	for (int l=1,r=1;l<=n && r<=n && a[r]-a[l]<=L;++l)
	{
		while (r<=n && a[r]-a[l]<=L) r++;
		r--;
		nxt[l]=r;
	}
	nxt[n]=inf;
	for (int i=1;i<=n;++i) nxt2[i][0]=nxt[i];
	for (int i=1;i<=19;++i)
	{
		for (int j=1;j<=n;++j)
		{
			if (nxt2[j][i-1]==inf) nxt2[j][i]=inf;
			else nxt2[j][i]=nxt2[nxt2[j][i-1]][i-1];
		}
	}
}
signed main()
{
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	cin>>L>>q;
	init();
	while (q--)
	{
		int l,r,ans=0;
		cin>>l>>r;
		if (l>r) swap(l,r);
		for (int i=19;i>=0;i--)
		{
			if (nxt2[l][i]<=r)
			{
				ans+=1LL<<i;
				l=nxt2[l][i];
			}
		}
		if (l!=r) ans++;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
constexpr int mod = 1e9+7, MAX = 1e5+30;
int_fast64_t fac[MAX], finv[MAX], inv[MAX];
void cmb_init() {
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
int_fast64_t cmb(int n, int k){
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
map<int_fast64_t, int> primef(int_fast64_t n) {
    map<int_fast64_t, int> M;
    int_fast64_t tmp = n;
    for (int i = 2; i*i <= n; i++) {
        while (tmp%i == 0) {
            M[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1) M[tmp]++;
    return M;
}
void Main(){
    int_fast64_t ans = 1;
    int N = read(), M = read();//N 1e5 M 1e9
    map<int_fast64_t, int> P = primef(M);
    cmb_init();
    for (auto p:P) {
        ans *= cmb(p.second+N-1, p.second);
        ans %= mod;
    }
    printf("%lld\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


Measured memory_bytes: 2560
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string odd, even;
  cin >> odd >> even;
  rep(i, (ll)odd.size()) {
    printf("%c", odd[i]);
    if (i < (ll)even.size()) printf("%c", even[i]);
  }
  cout << endl;

  return 0;
}


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

#define pb push_back 
#define x first 
#define y second 
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair< int , int > PII;
const int dirx[] = {-2,-1,1,2, 1, -1};
const int diry[] = {0,1,1,0, -1, -1};
inline void debugMode() {
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
}

int n, a[100100], b[100100], c[100100];

int main(){
	//	debugMode();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	for (int i = 1; i < n; i++){
		int rs = 0;
		for (int j = i; j < n; j++){
			rs = max(rs, b[j]);
			if (rs % c[j]){
				rs += c[j] - rs % c[j];
			}
			rs += a[j];
		}
		cout << rs << "\n";
	}
	cout << 0;
	return 0;
}


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

int main() {
    int n, N, S, tmp;
    scanf("%d", &n);
    
    N = (int)log10((double)n) + 1;
    S = 0;
    tmp = n;
    for (int i = 0; i < N; i++) {
        S += tmp;
        tmp /= 10;
        S -= tmp * 10;
    }
    
    if (n % S == 0) {
        printf("Yes");
    } else {
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1009];
ll b[1009];
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return (a*b)/(gcd(a,b));
}
int main()
{
    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>a[i]>>b[i];
    }
    ll x=1;
    ll y=1;
    cout<<endl;
    for(int i=1; i<=n; i++)
    {
        if(a[i]>=x&&b[i]>=y)
        {
            x=a[i];
            y=b[i];
            continue;
        }
        else if(a[i]<x&&b[i]<y)
        {
            ll s1=(x+a[i]-1)/a[i];
            ll s2=(y+b[i]-1)/b[i];
            ll m=max(s1,s2);
            x=a[i]*m;
            y=b[i]*m;
            continue;
        }
        else if(a[i]<x&&b[i]>=y)
        {
            ll m=(x+a[i]-1)/a[i];
            x=a[i]*m;
            y=b[i]*m;
            continue;
        }
        else if(a[i]>=x&&b[i]<y)
        {
            ll m=(y+b[i]-1)/b[i];
             x=a[i]*m;
             y=b[i]*m;
             continue;
        }
        //cout<<x<<" "<<y<<endl;
    }
 cout<<x+y<<endl;

}


Measured memory_bytes: 256
using System;

    class ABC116A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int ab = int.Parse(input[0]);
            int bc = int.Parse(input[1]);
            int ca = int.Parse(input[2]);

            Console.WriteLine(ab * bc / 2);
        }
    }


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(2*M);
  for (int i = 0; i < 2*M; i++) cin >> vec.at(i);
  for (int k = 0; k < N; k++) {
    int s = 0;
    for (int j = 0; j < 2*M; j++) {
      if (vec.at(j)== k+1) s++;
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 int main() {
   int H, W, N;
   cin >> H >> W >> N;
   vector<int> a(N);
   rep(i, 0, N) cin >> a.at(i);

   vector<int> c_tmp(H * W);

   int cnt = 0;
   rep(i, 0, N) {
     rep(j, 0, a.at(i)) {
       c_tmp.at(cnt + j) = i + 1;
     }
     cnt += a.at(i);
   }

   vector<vector<int>> c(H, vector<int>(W));
   rep(i, 0, H) {
     rep(j, 0, W) {
       if (i % 2 == 0) c.at(i).at(j) = c_tmp.at(W * i + j);
       else c.at(i).at(W - 1 - j) = c_tmp.at(W * i + j);
     }
   }

   rep(i, 0, H) {
     rep(j, 0, W - 1) cout << c.at(i).at(j) << " ";
     cout << c.at(i).at(W - 1) << endl;
   }
 }


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);



int main(){
	int n;
	cin>>n;
	int sum = 0;
	REP(i, 1, n + 1){
		sum += i;
		if(sum >= n){
			int dif = sum-n;
			REP(j, 1, i+1){
				if(j != dif){
					cout<<j<<endl;
				}
			}
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PB push_back
#define MP make_pair
#define F first
#define S second
int c[100005];
int main()
{      
    int b[102]={0};
    int n,x;
    cin>>x>>n;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        b[t]=1;
    }
    int m=300;
    int ans;
    for(int i=0;i<=101;i++)
    {
        if(b[i]==0)
        {   
            if(abs(i-x)<m)
            {  
               m=abs(i-x);
               ans=i;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		for(int b = 1;b>0;b++){
			String r = scan.next();
			int tot = 0;
			if(r.equals("0")){
				break;
			}
			for(int a = 1; a<=r.length();a++){
				String k = r.substring(a-1,a);
				int K = Integer.parseInt(k);
				tot = tot + K;
			}
			System.out.println(tot);
		}
	}
}

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

#define TRACE
#ifdef TRACE
#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define TR(...)
#endif

typedef long long               LL;
typedef pair<int,int>           II;
typedef vector<int>             VI;
typedef vector<II>              VII;


#define REP(i,i1,n)             for(int i=i1;i<n;i++)
#define REPB(i,i1,n)            for(int i=i1;i>=n;i--)
#define PB                      push_back
#define MP                      make_pair
#define ALL(c)                  (c).begin(),(c).end()
#define F                       first
#define S                       second
#define SZ(a)                   (int)a.size()
#define EPS                     1e-12
#define MOD                     1000000007
#define FAST_IO                 ios_base::sync_with_stdio(false);cin.tie(NULL)
#define SI(c)                   scanf("%d",&c)
#define SLL(c)                  scanf("%lld",&c)
#define PIN(c)                  printf("%d\n",c)
#define PLLN(c)                 printf("%lld\n",c)
#define N                       200010
#define endl                    '\n'
#define FILL(ar,vl)             for(int i=0;i<N;i++)ar[i]=vl
#define FILL2(ar,vl)            for(int i=0;i<N;i++)for(int j=0;j<N;j++)ar[i][j]=vl

inline int mult(int a , int b) { LL x = a; x *= LL(b); if(x >= MOD) x %= MOD; return x; }
inline int add(int a , int b) { return a + b >= MOD ? a + b - MOD : a + b; }
LL powmod(LL a,LL b) { if(b==0)return 1; LL x=powmod(a,b/2); LL y=(x*x)%MOD; if(b%2) return (a*y)%MOD; return y%MOD; }

//--------------------------MAIN CODE STARTS HERE----------------
LL a[N];
int main() {
    int n;
    cin>>n;
    REP(i,1,n+1) {
        cin>>a[i];
    }
    LL ans=0;
    REP(i,1,n+1) {
        ans+=a[i]/2;
        if(a[i]%2==0) a[i]=0;
        else a[i]=1;
        if(a[i]==1) {
            if(a[i+1]>=1) {
                a[i+1]-=1;
                ans+=1;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#define N 1005
using namespace std;

int n, m, mn = 1e9, c[N];
bool v[N];
vector<int> a, ans, gr[N];

void f(int p, int q) {
	int i, t;
	if (c[p]) {
		t = q - c[p];
		if (t < mn) {
			mn = t;
			ans.clear();
			for (i = 1; i <= t; i++) ans.push_back(a[a.size() - i]);
		}
		return;
	}
	if (v[p]) return;
	v[p] = 1;
	c[p] = q;
	a.push_back(p);
	for (i = 0; i < gr[p].size(); i++) {
		f(gr[p][i], q + 1);
	}
	c[p] = 0;
	a.pop_back();
}

int main()
{
	int i, j, t1, t2;
	cin >> n >> m;
	while (m--) {
		scanf("%d %d", &t1, &t2);
		gr[t1].push_back(t2);
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) v[j] = 0;
		f(i, 1);
	}
	if (mn == 1e9) {puts("-1"); return 0;}
	cout << mn << endl;
	for (i = 0; i < mn; i++) printf("%d\n", ans[i]);
    return 0;
}

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<pli> v(N);

  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    v[i] = make_pair(tmp, i);
  }

  sort(v.rbegin(), v.rend());

  // dp[i][j]: 左にi個, 右にj個詰めた時の最大値
  vector<vector<ll>> dp(N+1, vector<ll>(N+1, 0));

  for(ll i = 0; i < N; i++){
    ll pos = v[i].second;
    ll val = v[i].first;
    for(int x = 0; x <= i; x++){
      int y = i - x;
      dp[x+1][y] = max(dp[x+1][y], dp[x][y] + abs(x-pos) * val);
      dp[x][y+1] = max(dp[x][y+1], dp[x][y] + abs(N-y-1-pos) * val);
    }
  }

  ll max_val = 0;
  for(int i = 0; i <= N; i++){
    // cerr << i << " " << N-i << " " << dp[i][N-i] << endl;
    max_val = max(max_val, dp[i][N-i]);
  }
  cout << max_val << endl;

}


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

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, int>> ps(n);
    for (int i = 0; i < n; i++) ps[i] = {1, i + 1};
    for (int i = 0; i < m; i++) {
        int e; cin >> e; e--;
        ps[e].first = -i;
    }
    sort(ps.begin(), ps.end());
    for (auto &p: ps) cout << p.second << endl;
    return 0;
}


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

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,K;
vpint v;
int ans1=0,ans2=0;
int cntcnt[100010];
int cntcntcnt=0;
int memo[100010];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>K;
    v.resize(N);
    rep(i,0,N){
        int a,b;
        cin>>a>>b;
        v[i]=pint(b,a);
    }
    sort(all(v));
    reverse(all(v));
    
    vint used(100010,0);
    int x=0;
    rep(i,0,K){
        x+=v[i].fi;
        if(used[v[i].se]==0){
            used[v[i].se]=1;
            cntcntcnt++;
        }
    }
    x+=cntcntcnt*cntcntcnt;
    
    int tasu=0;
    ans1=0;
    vint used1(100010,0);
    int cnt=0;
    rep(i,0,N){
        if(!cntcnt[v[i].se]){
            used1[i]=1;
            cntcnt[v[i].se]=1;
            ans1+=v[i].fi;
            memo[cnt]=v[i].fi;
            cnt++;
            tasu++;
        }
        if(cnt==K){
            break;
        }
    }
    sort(memo,memo+cnt);
    int memocnt=0;
    rep(i,0,N){
        if(tasu==K)break;
        if(!used1[i]){
            ans1+=v[i].fi;
            used1[i]=true;
            tasu++;
        }
    }
    rep(i,0,N){
        if(used1[i])continue;
        if(ans1+cnt*cnt<=ans1-memo[memocnt]+(cnt-1)*(cnt-1)+v[i].fi){
            ans1-=memo[memocnt];
            ans1+=v[i].fi;
            memocnt++;
            cnt--;
        }
        if(cnt==1)break;
    }
    cout<<max(x,cnt*cnt+ans1)<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

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

using namespace std;

#define ll long long int
#define vi vector<int>
#define prec fixed<<setprecision(15)
#define mod 1000000007
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)

int main(){
	ll w,h,x,y;
	cin >> w >> h >> x >> y;
	cout << prec << (double)w*h/2;
	if(w==2*x && h==2*y)cout << ' ' << 1;
	else cout << ' ' <<0;
	
}


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

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100

int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[ARRAY_SIZE];
	int change_count = 0;

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

	int tmp = 0;
	for(int i = n-1;i > 0;i--){
		for(int j = 0; j < i;j++){
			if(array[j] > array[j+1]){
				tmp = array[j+1];
				array[j+1] = array[j];
				array[j] = tmp;
				change_count++;
			}
		}
	}

	for(int i = 0; i < n; i++){
		if(i != n-1){
			printf("%d ",array[i]);
		}else{
			printf("%d\n",array[i]);
		}
	}
	printf("%d\n",change_count);
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
const ll N = 200001;
using namespace std;


vector<ll> a[N];
ll b[N], fact[N], sz[N], ans1[N];

ll power(ll x, ll y) {
    ll ans = 1;
    ll t = x;
    while (y) {
        if (y % 2) {
            ans = (ans * t) % mod;
        }

        t = (t * t) % mod;
        y /= 2;
    }

    return ans;
}

ll comb(ll n, ll c) {
    ll ans = (fact[n] * power(fact[c], mod - 2)) % mod;
    return (ans * power(fact[n - c], mod - 2)) % mod;
}

void g(ll x, ll p) {
    sz[x] = 1;
    for (ll e : a[x]) {
        if (e != p) {
            g(e, x);
            sz[x] += sz[e];
        }
    }

}

void f(ll x, ll p) {
    for (ll e : a[x]) {
        if (e != p) {
            f(e, x);
        }
    }

    b[x] = 1;
    ll rem = sz[x] - 1;
    for (ll e : a[x]) {
        if (e != p) {
            ll h = (comb(rem, sz[e]) * b[e]) % mod;
            b[x] = (b[x] * h) % mod;
            rem -= sz[e];
        }
    }

}

void final(ll x, ll p, ll n) {
    ans1[x] = 1;
    if (p != -1) {
        ll num = ans1[p];
        ll den = (comb(n - 1, sz[x]) * b[x]) % mod;
        ans1[x] = (num * power(den, mod - 2)) % mod;
    }

    ll rem = n - 1;
    for (ll e : a[x]) {
        if (e != p) {
            ll h = (comb(rem, sz[e]) * b[e]) % mod;
            ans1[x] = (ans1[x] * h) % mod;
            rem -= sz[e];
        }
    }

    for (ll e : a[x]) {
        if (e != p) {
            final(e, x, n);
        }
    }

}


int main() {
//    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll n;
    cin >> n;
    for (ll i = 0; i < n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        a[u].pb(v);
        a[v].pb(u);
    }

    fact[0] = 1;
    for (ll i = 1; i < n + 1; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }

    g(1, -1);
    f(1, -1);
    final(1, -1, n);
    for (ll i = 1; i < n + 1; i++) {
        cout << ans1[i] << '\n';
    }

}

Measured memory_bytes: 20976
N = int(input())
*A, = map(int, input().split())

d1 = [[0]*60 for _ in range(N+1)]
mod = 10**9+7

for i, n in enumerate(A, start=1):
    for j in range(60):
        d1[i][j] = d1[i-1][j] + ((n>>j)&1)

ans = 0
for i, n in enumerate(A, start=1):
    for j in range(60):
        a = d1[N][j]-d1[i][j] # 1
        if (n>>j)&1:
            a = N-a-i # 0

        ans += a*(1<<j)

print(ans%mod)


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

int h,w,cnt;
int color[21][21];
char m[21][21];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

void dfs(int x,int y){
    color[y][x] = 1;
    for(int i=0; i<4; i++){
        int vx = x+dx[i];
        int vy = y+dy[i];
        if(m[vy][vx] == '.' && color[vy][vx] == 0 && vx<w && vx >= 0 && vy<h && vy >=0){
            dfs(vx,vy);
        }
    }
}

int main(){
    while(1){    
        cin>>w>>h;
        cnt=0;
        if(w==0 && h==0) break;
        for(int i=0; i<21; i++){
            for(int j=0; j<21; j++){
                color[i][j]  =0;
            }
        }

        int x,y;

        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                cin>>m[i][j];
                if(m[i][j] == '@'){
                    x = j;
                    y = i;
                }
            }
        }

        dfs(x,y);

        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(color[i][j] != 0) cnt++;
            }
        }

        cout<<cnt<<endl;
    }


}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,H;
	cin >> N >> H;
	ll amax = 0;
	vector<ll> a(N),b(N);
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i];
		amax = max(amax,a[i]);
	}
	sort(ALL(a));
	sort(ALL(b));
	int ans = 0;
	for(int i=N-1;i>=0;i--){
		if(b[i]>=amax){
			H-= b[i];
			ans++;
		}
		if(H<=0)break;
	}
	if(H>0){
		ans += (H+amax-1)/amax;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
 
using namespace std;
typedef long long ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())


int main() {

	std::cin.tie(0);

    double n,m;
    cin >> n>> m;
    double tmp = 0;
    int count =0;
    vector<double> v(n);

    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
        tmp = tmp + v[i]; // total 
    }

    for (int i = 0; i < n; i++)
    {
        if(v[i] >= tmp/4/m) count++;
    }    

    if(count >= m){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;


    return 0;
}

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

int main() {
	int a,b;
	while(1) {
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		if (a > b) cout << b << " " << a << endl;
		else cout << a << " " << b << endl;
	}
	return 0;
}

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

int is_Prime(int m);

int main() {
	int a[10000], n, i;
	int count = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	for (i = 0; i < n; i++) {
		if (is_Prime(a[i])==1) {
			count++;
		}
	}

	printf("%d\n", count);

	return 0;
}

int is_Prime(int m) {
	int i;
	for (i = 2; i <= sqrt(m)+1; i++) {
		if (m >= 3 && m % i == 0) {
			return 0;
		}
	}
	return 1;
}

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

int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  if (abs(B-A) % 2 == 0) {
    cout << abs(B-A) / 2 << endl;
  }
  else {
    cout << min(min(A-1,B-1)+1+abs(A-B)/2,min(N-A,N-B)+1+abs(A-B)/2) << endl;
  }
}


Measured memory_bytes: 256