akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    reverse(all(b));
    map<int,int> x;
    rep(i,n){
        x[a[i]] ++;
        x[b[i]] ++;
    }
    rep(i,n){
        if(x[b[i]]>n){
            No;
            return 0;
        }
    }
    Yes;
    bool f=true;
    int st,fn;
    rep(i,n){
        if(a[i]==b[i] && f){
            f=false;
            st=i;
            fn=i;
        }
        else if(a[i]==b[i]){
            fn=i;
        }
        else if(!f){
            break;
        }
    }
    if(f){
        rep(i,n) cout<<b[i]<<" ";
        cout<<endl;
        return 0;
    }

    rep(i,n){
        if(st>fn) break;
        if(a[i]==b[st]) continue;
        if(b[i]==a[st]) continue;
        if(st<=i && i<=fn) continue;
        swap(b[i],b[st]);
        st ++;
    }
    rep(i,n) cout<<b[i]<<" ";
    cout<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 14236
#include <stdio.h>

int main(){
  int n,u,adj[110][110],k,v[100],i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v[j]);
      adj[u-1][v[j]-1]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==0) printf("%d",adj[i][j]);
      else printf(" %d",adj[i][j]);
    }
    printf("\n");
  }


  return 0;

}

Measured memory_bytes: 1076
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	n, m := readInt(), readInt()

	a := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		a[i] = readInt()
		sum += a[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	var rate float64 = float64(a[m-1]) / float64(sum)

	if rate < 1.0/float64(4*m) {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> L(N, 0);
  for (int i=0;i<N;i++){
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int cnt = 0;
  for (int i=0;i<N-2;i++){
    for (int j=i+1;j<N-1;j++){
      int l = j, r = N - 1, pt;
      while (r - l >= 1){
        if ((r - l) % 2 == 0){
          pt = (r + l) / 2;
        }
        else{
          pt = (r + l + 1) / 2;
        }
        if (L.at(i) + L.at(j) > L.at(pt)){
          cnt += pt - l;
          l = pt;
        }
        else{
          r = pt - 1;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  cout << (N <= M ? "Yes" : "No");
}
#endif


Measured memory_bytes: 256
/*************************************************************************
	> File Name: pyramid.cpp
	> Author: codecode
	> Created Time: 2019年11月07日 星期四 08时31分48秒
 ************************************************************************/

#include<bits/stdc++.h>
using namespace std;
const int maxn=1000000+5;
int n,a[maxn];
inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
inline bool jujuakioi(const int &k){
	 if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;
	 if((a[n-1]>k&&a[n]>k)||(a[n]>k&&a[n+1]>k))return 0;
	 for(int i=1;i<n-1;i++){
		 if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;
		 if((a[n+i]>k&&a[n+i+1]>k)||(a[n-i]>k&&a[n-i-1]>k))return 0;
	 }
	 return a[1]<=k;
}
int main(){
	cin>>n;
	for(int i=1;i<n*2;i++)a[i]=read();
	int l=1,r=n*2-1;
	while(l<r){
		int mid=(l+r)/2;
		if(jujuakioi(mid))r=mid;
		else l=mid+1;
	}
	cout<<l;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int i = 0;
        
        while(true){
            int x = sc.nextInt();
        if ( x == 0 )
                break;
            System.out.println("Case "+ ++i + ": " + x);
        }
    }
}


Measured memory_bytes: 41836
import heapq
 
n,m=map(int,input().split())
mm=10**5+5
c=[[0] for i in range(mm)]
 
for i in range(n):
  a,b=map(int,input().split())
  c[a].append(b)
 
#print(c)
 
ans=0
h=[]
for i in reversed(range(m)):
  d=m-i
  for j in c[d]:
    heapq.heappush(h,-j)
  #heapq.heapify(h)
  ans+=-heapq.heappop(h)
 
print(ans)

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

using namespace std;

const int maxn=1e5+500;
long long a[maxn];
long long b[maxn];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	long long minx=1000000000;
	for(int i=k-1;i<n;i++){
		minx=min(a[i]-a[i-k+1],minx);
	} 
	cout<<minx;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
const int mod = 1e9 + 7;
int main()
{
	string a , b;
	cin >> a >> b;
	int sum = a.length() + b.length();
	int cnt1 = 0 , cnt2 = 0;
	for(int i = 1 ; i <= sum ; i++)
	{
		if(i % 2 == 1)cout << a[cnt1++];
		else cout << b[cnt2++];
		}
	cout << endl;
	return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    for (int i = 0; i < x; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < y; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < z; i++)
    {
        cin >> c[i];
    }

    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());

    priority_queue<ll, vector<ll>, greater<ll>> q;
    for (ll ai = 0; ai < x; ai++)
    {
        for (ll bi = 0; bi < y; bi++)
        {
            for (ll ci = 0; ci < z; ci++)
            {
                ll val = (a[ai] + b[bi] + c[ci]);
                if (q.size() >= k)
                {
                    if (q.top() > val)
                    {
                        break;
                    }
                    else
                    {
                        q.pop();
                        q.push(val);
                    }
                }
                else
                {
                    q.push(val);
                }
            }
        }
    }

    vector<ll> ans(k);
    for (int i = 0; i < k; i++)
    {
        ans[i] = q.top();
        q.pop();
    }

    for (int i = k - 1; i >= 0; i--)
    {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int vis[N],mu[N],a[N];
void get_mu(int n){
	int cnt=0; /*vis[1]=1;*/ mu[1]=1;
	repeat(i,2,n+1){
		if(!vis[i])
			a[cnt++]=i,mu[i]=-1;
		repeat(j,0,cnt){
			if(i*a[j]>n)break;
			vis[i*a[j]]=1;
			if(i%a[j]==0){
				mu[i*a[j]]=0;
				break;
			}
			mu[i*a[j]]=-mu[i];
		}
	}
}
int n,k;
ll ans;
signed main(){
	cin>>n>>k;
	get_mu(k+1);
	repeat(d,1,k+1)
	repeat(c,1,k/d+1){
		ans=(ans+d*mu[c]%mod*qpow(k/d/c,n))%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4488
S = input()

n = len(S)

ans = 0
for i in range(2**(n-1)):
    tmp = 0
    t = 0
    for j in range(n-1):
        if (i>>j)&1: 
            tmp += int(S[t:j+1])
            t = j+1
    tmp += int(S[t:])
    ans += tmp
print(ans)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=4000100,mod=1e9+7;
int n,k,fac[N],inv[N],f[2100][2100],ans;

int ksm(int x,int y){
	int s=1;
	for (;y;y>>=1,x=(ll)x*x%mod) if (y&1) s=(ll)s*x%mod;
	return s;
}

void init(int n){
	fac[0]=1;
	rep (i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	for (int i=n-1;~i;i--) inv[i]=(ll)inv[i+1]*(i+1)%mod;
}

int C(int n,int m){return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;}

void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}

int main(){
	scanf("%d%d",&n,&k); init(n*k+1);
	if (k==1) return puts("1"),0;
	f[0][0]=1;
	rep (i,0,n) rep (j,0,i){
		if (i==n&&j==n){
			printf("%lld\n",(ll)f[n][n]*fac[n]%mod);
			break;
		}
		if (i<n) upd(f[i+1][j],f[i][j]);
		if (j<n) upd(f[i][j+1],(ll)f[i][j]*C(n*k-i-j*(k-1)-1,k-2)%mod);
	}
	return 0;
}

Measured memory_bytes: 47744
# -*- coding: utf-8 -*-


def main():
    from sys import setrecursionlimit

    setrecursionlimit(10 ** 7)

    n, m = map(int, input().split())
    graph = [[] for _ in range(n)]
    dp = [-1 for _ in range(n)]

    for _ in range(m):
        xi, yi = map(int, input().split())
        xi -= 1
        yi -= 1
        graph[xi].append(yi)

    # See:
    # https://qiita.com/drken/items/03c7db44ccd27820ea0d#g-%E5%95%8F%E9%A1%8C---longest-path
    def rec(v):
        if dp[v] != -1:
            return dp[v]

        result = 0

        for next_v in graph[v]:
            result = max(result, rec(next_v) + 1)

        dp[v] = result

        return dp[v]

    ans = 0

    for i in range(n):
        ans = max(ans, rec(i))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 143052
a, b, k = (int(i) for i in input().split())

len_ab = b-a+1

if (len_ab+1) // 2 <= k:
    for i in range(a, b+1):
        print(i)

else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) cin >> d[i];
    int ans = 0;

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "d"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

#if defined(LOCAL)
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#endif

vl get_possible(l a, vvl& adj, vl& value) {
  set<l> used;
  l wild = 0;
  for (auto b : adj[a]) {
    if (value[b] == -1) {
      wild++;
    } else {
      used.emplace(value[b]);
    }
  }
  l i = 0;
  vl v;
  F(j, 0, wild + 1) {
    while (used.count(i)) i++;
    if (i > adj[a].size()) break;
    v.emplace_back(i);
    i++;
  }
  return v;
}

bool find_assignment(vvl& adj, vvl& back, vl outgoing, vl value, l check) {
  queue<l> q;
  l n = adj.size();
  // assign obvious ones
  F(i, 0, n) if (value[i] == -1 and outgoing[i] == 0) q.emplace(i);
  while (not q.empty()) {
    l a = q.front(); q.pop();
    auto p = get_possible(a, adj, value);
    L("possible", a, p);
    if (p.empty()) return false;
    assert(p.size() == 1);
    if (value[a] != -1 and value[a] != p[0]) return false;
    value[a] = p[0];
    for (auto b : back[a]) {
      outgoing[b]--;
      if (outgoing[b] == 0) q.emplace(b);
    }
  }
  F(i, 0, n) {
    if (value[i] != -1) continue;
    for (auto b : back[i]) outgoing[b]--;
    auto p = get_possible(i, adj, value);
    L("possible", p);
    for (auto j : p) {
      value[i] = j;
      if (find_assignment(adj, back, outgoing, value, i)) return true;
    }
    return false;
  }
  return true;
}

void solve(istream& cin, ostream& cout) {
  l n;
  while (cin >> n) {
    L("------------");
    vvl adj(n), back(n);
    vl outgoing(n);
    vl value(n, -1);
    F(i, 0, n) {
      l a; cin >> a; a--;
      adj[a].emplace_back(i);
      outgoing[a]++;
      back[i].emplace_back(a);
    }
    if (find_assignment(adj, back, outgoing, value, -1)) {
      cout << "POSSIBLE" << lf;
    } else {
      cout << "IMPOSSIBLE" << lf;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  maybe_run_tests(cin, cout);
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
#else
  solve(cin, cout);
#endif
}


Measured memory_bytes: 30336
# https://atcoder.jp/contests/abc162/tasks/abc162_b


N = gets.to_i

ans = 0

N.times do |i|
  i += 1
  if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0)
  else
    ans += i
  end
end

puts ans


Measured memory_bytes: 14424
#include<bits/stdc++.h>
using namespace std;
int f(int x){
  if(x%2==0)return x/2;
  else return 3*x+1;
}
int main(){
  int a;
  cin>>a;
  set<int>v;
  v.insert(a);
  int i=1;
  while(1){
    a=f(a);
    v.insert(a);
    i++;
    if(v.size()!=i) {
      cout<<v.size()+1<<endl;
      break;
    }
}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;
int dp[3005][3005];
int main() {
	string s, t;
	cin >> s >> t;
	for (int i = 1; i <= s.size(); i++) {
		for (int j = 1; j <= t.size(); j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	int i = s.size(), j = t.size();
	string sol = "";
	while (dp[i][j] != 0) {
		if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		else {
			sol = s[i-1] + sol;
			i--;
			j--;
		}
	}
	cout << sol;
}

Measured memory_bytes: 35456
x, n = map(int, input().split())
p = list(map(int, input().split()))
if not p:
    print(x)
    exit()
left_x = right_x = x
if x not in p:
    print(x)
    exit()
while 1:
    left_x = left_x - 1
    right_x = right_x + 1
    if left_x not in p:
        print(left_x)
        exit()
    elif right_x not in p:
        print(right_x)
        exit()

Measured memory_bytes: 61660
#include <bits/stdc++.h>
using namespace std;
int main(){
  int sss , s1 , s2 , s3;
  cin >> sss;
  s1 = sss/100;
  s2 = sss/10 - s1*10;
  s3 = sss - s1*100 - s2*10;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int N;
const int MAX_N = 100;
int L[MAX_N];

int main() {
	cin >> N;
	int max = 0, sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
		sum += L[i];
		if (max < L[i]) {
			max = L[i];
		}
	}
	if ((max - (sum-max)) < 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

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

#define FOR(x,y,z) for(int x=y,x##_=z;x<=x##_;++x)
#define DOR(x,y,z) for(int x=y,x##_=z;x>=x##_;--x)
#define FOR_(x,y,z,s) for(int x=y,x##_=z;x<=x##_;x+=s)
#define FOR__(x,y,z) for(int x=y,x##_=z;x<=x##_;x<<=1)
#define EOR(x,y) for(int x##_=head[x],y=edge[x##_].e;x##_;y=edge[x##_=edge[x##_].to].e)
#define EGOR(x,y,z) for(int x##_=head[x],y=edge[x##_].e,z=edge[x##_].c;x##_;y=edge[x##_=edge[x##_].to].e,z=edge[x##_].c)

#define clr(x,y) memset(x,y,sizeof(x))
#define szf(x) sizeof(x)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)

#define read2(x,y) read(x),read(y)
#define read3(x,y,z) read(x),read(y),read(z)
#define read4(x,y,z,w) read3(x,y,z),read(w)
#define reads(str) sf("%s",str)

#define ts (*this)
#define sf scanf
#define pf printf

#define ll long long
#define ull unsigned long long
#define db double
#define ct clock_t
#define ck() clock()
#define rd rand()
#define rmx RAND_MAX
#define RD T*(rd*2-rmx)


using namespace std;

template<class T>bool tomin(T &x,T y){return y<x?x=y,1:0;}
template<class T>bool tomax(T &x,T y){return x<y?x=y,1:0;}
template<class T>void read(T &x){
    char c;
    x=0;
    int f=1;
    while(c=getchar(),c<'0'||c>'9')if(c=='-')f=-1;
    do x=(x<<3)+(x<<1)+(c^48);
    while(c=getchar(),c>='0'&&c<='9');
    x*=f;
}

const db Pi=acos(-1);
const int maxn=2e5+5;
int n;
int A[maxn];
bool ans[maxn];
int main(){
    srand(time(NULL));
    read(n);
    FOR(i,1,n)read(A[i]);
    DOR(i,n,1){
        ans[i]=A[i];
        FOR_(j,i+i,n,i)ans[i]^=ans[j];
    }
    int cnt=0;
    FOR(i,1,n)if(ans[i])cnt++;
    pf("%d\n",cnt);
    FOR(i,1,n)if(ans[i])pf("%d ",i);
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> d;
  int k;
  for(int i=0;i<n;i++){
    cin >> k;
    d.push_back(k);
  }
  int sum = 0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
/*input
coffee
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    if(s[4] == s[5] && s[2] == s[3]) cout << "Yes";
    else cout << "No";

    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;		     
}

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right!=NIL)return treeMinimum(x->right);

  Node y = x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;

  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->right=x;
  else y->parent->right=x;

  if(y!=z)z->key=y->key;


}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;
  
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20476
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

int binpow(int a, int b) {
    if (b == 0)
        return 1;
    int res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}
string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,x;
    double k,t,pi=3.14159265359,r,d;
    cin>>a>>b>>x;
    k=2*x-(a*a*b);
    k/=(a*a);
    //cout<<"k: "<<k<<"\n";
    if (k>=0)
    {
        t=b*b+k*k+a*a;
        t-=(2*b*k);
        t=sqrt(t);
        //cout<<"t: "<<t<<"\n";
        r=a/t;
        //cout<<"r: "<<r<<"\n";
    }
    else
    {
        k=2*x;
        k/=(a*b);
        //cout<<"new k: "<<k<<"\n";
        t=(k*k+b*b);
        t=sqrt(t);
        //cout<<t<<"\n";
        r=k/t;
        //cout<<"r: "<<r<<"\n";
    }
    r=asin(r);
    //cout<<"r (asined): "<<r<<"\n";
    d=r*180;
    d/=pi;
    cout<<setprecision(10)<<90-d;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int A = scanner.nextInt();
		    int B = scanner.nextInt();
		    int K = scanner.nextInt();
		    
		    for(int i = 0; i < K; i++) 
		    {
		    	if( A + i <= B ) 
		    	{
		    		System.out.println(A + i);
		    	}
		    }
		    for(int i = 0; i < K; i++) 
		    {
		    	if( B - K + i + 1 > A + K - 1 )
		    	System.out.println(B - K + i + 1);
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll f(ll x,ll y,ll s){
    ll sq=(ll)sqrt(s);
    if(x<=sq){
	return min(x,s/y);
    }
    
    ll sh=s/(sq+1);
    if(sh==s/sq)sh--;
    return min(x-sq,sh-y+1)+sq;
}
int main(){
    int q;cin>>q;
    lol(u,q){
	ll a,b;cin>>a>>b;
	ll x=f(a-1,b+1,a*b-1);
	ll y=f(b-1,a+1,a*b-1);
	cout<<x+y+min(a-1-x,b-1-y)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠀⠀⠺⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⠀⠈⢿⣦⣄⣈⣁⣀⣠⣴⣦⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⣶⡄⠙⢿⣿⣿⣿⣿⣿⡿⠓⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠙⣿⣿⠿⠛⠛⠛⠛⣿⣿⡄⠀⠈⠉⠉⠉⣁⣀⡀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⣸⣿⡇⠀⠀⠀⣴⣿⣿⡿⠿⢷⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠠⣤⣤⣴⣾⣿⡿⠁⠀⢀⣾⣿⣿⠏⠀⠀⠈⣿⣧⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣏⠀⠀⣠⣾⣿⣿⠏⠀⠀⠀⠀⢹⣿⡄⠀⠀
⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠻⣿⣿⡟⠻⠿⠛⠁⠀⠀⠀⠀⠀⣾⣿⡇⠀⠀
⠀⠀⠘⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⡄⠀⣄⠀⠀⠀⠀⠀⣰⣿⣿⠇⠀⠀
⠀⠀⠀⢿⡄⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⠇⠀⠹⣷⣤⣤⣤⣾⣿⣿⡟⠀⠀⠀
⠀⠀⠀⠈⢿⣦⣄⣀⠀⠀⣀⣠⣾⣿⣿⡟⠀⠀⠀⠘⠻⣿⣿⣿⠿⠋⠀⠀⠀⠀
⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⡿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠛⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

           KRISHNA ASHOK⠀
*/

#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Tree;
// order_of_key(k), find_by_order(k)


#define dbg(x) cout<<#x<<"="<<x<<'\n'
#define ll long long
#define pr pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define For(i,n) for(int i=0;i<(n);++i)
#define Forr(i,n) for(int i=n-1;i>=0;i--)
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")
#define fin ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define sz(a) (int)a.size()
#define Fill(a,b) memset(a,b,sizeof(a));
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
const int INF=1e9;
#define endl '\n'
#define fit(i,x) for(auto i:x)
#define gcd(a,b) __gcd(a,b)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define vt vector




void solve(){
    string s,t;
    cin>>s>>t;
    int ssize=s.size(),tsize=t.size();
 
    int ans=INT_MAX;
 
    for(int i=0;i<ssize-tsize+1;i++)
    {
        int temp=0;
 
        for(int j=0;j<tsize;j++) //brute force
        {
            if(s[i+j]!=t[j]) temp++;
        }
        ans=min(ans,temp);
    }
 
    cout<<ans<<endl;

}



int main()
{
    fin;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

/*
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;
 */

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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max({A * C, B * C, B * D, A * D}) << "\n";
}




Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;

const ll inf = 1000000000000;//10の12乗
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
};

int main() {
    ll n,k;
    cin >> n >> k;
    vector<mint> v(n+1000002,0),vv(n+1000002,0);
    v[0]=1;
    Vi vl(k),vr(k);
    rep(i,k) cin >> vl[i] >> vr[i];
    rep(i,n){
        if(i!=0)v[i]=v[i-1].x+vv[i].x;
        rep(j,k){
            int x=vl[j];
            int y=vr[j]+1;
            vv[i+x]+=v[i];
            vv[i+y]-=v[i];
        }
    }

    cout << vv[n-1].x << endl;
}

Measured memory_bytes: 21992
import java.util.*

fun main(args: Array<String>?): Unit {
    while(true){
        val (n, m, h, k) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val rails = Array(n){arrayListOf<Train>()}
        repeat(m){
            val (a, b, c, hr, r) = readLine()!!.trim().split(' ').map(String::toInt)
            rails[a - 1].add(Train(b - 1, c, hr, r - 1))
            rails[b - 1].add(Train(a - 1, c, hr, r - 1))
        }
        val (start, goal) = readLine()!!.trim().split(' ').map{it.toInt() - 1}
        val passports = List(readLine()!!.toInt()){
            val info = readLine()!!.trim().split( ' ').map(String::toInt)
            Passport(info[1], info.takeLast(info[0]).map{it - 1})
        }
        val minPassportPrice = IntArray(1 shl k){Int.MAX_VALUE}.also{it[0] = 0}
        for (p in passports) for (i in minPassportPrice.indices.reversed()) if (minPassportPrice[i] != Int.MAX_VALUE && minPassportPrice[p.company.flag or i] > minPassportPrice[i] + p.price) {
            minPassportPrice[p.company.flag or i] = minPassportPrice[i] + p.price
        }
        val memo = Array(h + 1){IntArray(n){Int.MAX_VALUE}}
        val queue = PriorityQueue<Triple<Int, Int, Int>>(compareBy(Triple<*, *, Int>::third))
        var min = null as Int?
        for (passport in minPassportPrice.withIndex().filter{it.value != Int.MAX_VALUE}.map{Passport(it.value, Flag(it.index))}) {
            memo.forEach { it.fill(Int.MAX_VALUE) }
            queue.clear()
            memo[0][start] = passport.price
            queue.add(Triple(0, start, passport.price))
            while(queue.isNotEmpty() && queue.peek().second != goal){
                val (hour, current, cost) = queue.poll()
                for (train in rails[current]) {
                    if (passport.company.isOn(train.company) && hour + train.time <= h && memo[hour + train.time][train.to] > cost) {
                        memo[hour + train.time][train.to] = cost
                        queue.add(Triple(hour + train.time, train.to, cost))
                    }else if (passport.company.isOff(train.company) && hour + train.time <= h && memo[hour + train.time][train.to] > cost + train.cost) {
                        memo[hour + train.time][train.to] = cost + train.cost
                        queue.add(Triple(hour + train.time, train.to, cost + train.cost))
                    }
                }
            }
            if (queue.isNotEmpty() && queue.peek().second == goal && (min == null || min > queue.peek().third)) min = queue.peek().third
        }
        println(min ?: -1)
    }
}
data class Train(val to: Int, val cost :Int, val time: Int, val company: Int)
data class Passport(val price: Int, val company: Flag) {
    constructor(price: Int, flags: List<Int>): this(price, Flag(flags))
}
data class Flag(val flag: Int) {
    constructor(flags: List<Int>): this(flags.fold(0){a, b -> a or (1 shl b)})
    fun isOn(value: Int): Boolean = (flag and (1 shl value)) != 0
    fun isOff(value: Int): Boolean = !isOn(value)
    fun add(value: Int): Flag = Flag(flag or (1 shl value))
    fun merge(other: Flag): Flag = Flag(flag or other.flag)
}



Measured memory_bytes: 257468
/*
 * Talk is cheap, show me the code.
 * Author:  JiangDingyuan
 * Created Time:  2017/9/2 20:22:10
 * File Name: 12345.cpp
 */
#include <time.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#define PI acos(-1.0)
#define LL long long
#define bug printf("bug!\n");
#define RD freopen("in.txt", "r", stdin);
#define LD freopen("out.txt", "w", stdout);

using namespace std;

int main() {
    int x,t;
    cin >>x>>t;
    cout << (x>t?x-t:0)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
int main(){
IOS;
int a,b;
cin>>a>>b;
cout<<max(a+b,max(a-b,a*b))<<endl;
}


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

int main() {
    int n;
    cin >> n;
    long ans = 1;
    int prev = -1;
    unordered_map<int, int> counter;
    for (int i = 0; i < n; i++) {
        int c;
        cin >> c;
        if (c != prev) {
            ans += counter[c];
            ans %= MOD;
        }
        prev = c;
        counter[c] = ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8520
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int N;
    int A[100009], B[100009], C[100009];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }
    for (int i = 0; i < N; i++){
        cin >> B[i];
    }
    for (int i = 0; i < N; i++){
        cin >> C[i];
    }
    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);
    long long total = 0; 
    for (int i = 0; i < N; i++){
        total += (lower_bound(A, A + N, B[i]) - begin(A)) * (N - (upper_bound(C, C + N, B[i]) - begin(C)));
    }
    for (int i = 0; i < N; i++){
       // cout << lower_bound(A, A + N, B[i]) - begin(A) << endl;
    }
    cout << total << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	string s;
	while(getline(cin,s)){
		ll n=s.length();
		while(1){
			if(s.find("this")!=string::npos) break;
			if(s.find("that")!=string::npos) break;
			if(s.find("the")!=string::npos) break;
			rep(i,n){
				if(s[i]!=' ' && s[i]!='.'){
					if(s[i]=='z') s[i]='a';
					else s[i]++;
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
ll dp[101][100001];
ll ar[101][2];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,w,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	// memset(dp,1e15,sizeof(dp));
    	cin>>n>>w;
    	for(int i=1;i<=n;i++)
    		cin>>ar[i][0]>>ar[i][1];
    	for(int i=0;i<=n;i++)
    		for(int j=1;j<=1000*n;j++)
    			dp[i][j]=1e18;

    		for(int i=1;i<=n;i++)
    	{
    	for(int v=1;v<=1000*n;v++)
    		{
    			if(v>=ar[i][1])
    			dp[i][v] = min(dp[i-1][v], dp[i-1][v-ar[i][1]]+ar[i][0]);
    			else
    			dp[i][v] = dp[i-1][v];
    			// cout<<i<<' '<<v<<" "<<dp[i][v]<<endl;
    		}
    	}
    	ll ans = 0;
    	for(ll i=1;i<=1000*n;i++)
    	{
    		if(dp[n][i]<=w)
    			ans = max(i,ans);
    	}
    	cout<<ans<<endl;

    }
    return 0;
}

Measured memory_bytes: 79232
using System;
using System.Collections.Generic;
					
public class my
{
	public static void Main()
	{
		var n = my.GetInt();
		Console.WriteLine(my.Factrial(n));
	}
	
	private static long Factrial(long n)
	{
		if(n==1)	return 1;
		else return n * my.Factrial(n-1);
	}

	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
		private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}

	private static int[] GetIntArray(int n)
	{
		var A = new int[n];
		var s = Console.ReadLine().Split(' ');

		for(int i = 0; i < n; i++) {
			A[i] = int.Parse(s[i]);
		}
		return A;
	}

	private static int[] GetIntArray(char c)
	{
		return Array.ConvertAll(Console.ReadLine().Split(c), int.Parse);
	}
	
	public static string Reverse(string s)
	{
		var c = s.ToCharArray();
		Array.Reverse(c);
		
		return new String(c);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}

	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
}

Measured memory_bytes: 9096
N=int(input())
C=[0]
S=[0]
F=[0]
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(1,N):
    time = 0
    time += S[i]
    for j in range(i,N-1):
        time += C[j]
        if S[j+1]>=time:
            time=S[j+1]
        else:
            if (time-S[j+1])%F[j+1]!=0:
                time += F[j+1]-int((time-S[j+1])%F[j+1])
    time += C[N-1]
    print(time)

print(0)

Measured memory_bytes: 3188
#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 <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int A = rei();
	int B = rei();
	for(int i=0;i<2000;i++){
		if(i*8/100 == A && i*10/100 == B){
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> num = new List<int>();

            for (int i = 0; i < 10; i++)
            {
                string data = Console.ReadLine();
                num.Add(Convert.ToInt32(data));
            }

            num.Sort();
            num.Reverse();
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(num[i]);
            }
        }
    }
}

Measured memory_bytes: 5832
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
 
    void solve (){
        int H,W;
        cin>>H>>W;
        int h,w;
        cin>>h>>w;
        int total=(H*W)-(h*W + H*w)+(h*w);
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,b; cin >> a >> b;
  string s; cin >> s;
  if(s[a]!='-'){  cout << "No" << endl; return 0; }
  rep(i,a){ if('0'<=s[i]&&s[i]<='9'){}else{cout << "No" << endl; return 0;}}
  rep(i,b){ if('0'<=s[i+a+1]&&s[i+a+1]<='9'){}else{cout << "No" << endl; return 0;}}
  
  cout << "Yes" << endl; return 0;
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int32_t main(){
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
        // for debug in error.txt
        freopen("error.txt", "w", stderr);
    #endif
    int t = 1;
    while(t--) {
        ll x;
        cin >> x;
        if(x == 1) {
            cout << 0 << '\n';
        }else if(x==0){
            cout << 1 << '\n';
        }
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<long long> a(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += a[i] / 2;
        if (a[i] % 2 == 1 && a[i + 1] > 0) {
            ans++;
            a[i + 1]--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

const int e = 2e5 + 69;

ll cnt[e];

int main()
{
    ll n;
    cin >> n;
    set<ll>s;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        cnt[x] ++;
        s.insert(x);
    }
    ll ans = 0;
    for(auto j : s){
        ans += cnt[j]*j;
    }
    int q;
    cin >> q;
    while(q -- ){
        int a, b;
        cin >> a >> b;
        ans += b*cnt[a];
        cnt[b] += cnt[a];
        ans -= cnt[a]*a;
        cnt[a] = 0;
        cout << ans <<"\n";
    }
}


Measured memory_bytes: 7336