akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n, sum = 0;
  cin >> n;
  //std::vector<int> v(n);
  for(int i = 0; i < n ;i++){
    int a  = i+1;
    if((a % 5 == 0) && (a % 3 == 0)){
      continue;
    }
    else if(a % 5 == 0){
      continue;
    }
    else if(a % 3 == 0) {
      continue;
    }
    else sum += a;
  }
  cout << sum;
  return 0;
}

/*
         ,--"""",--.__,---[],-------._         
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________
 
*/

Measured memory_bytes: 3604
n = int(input())
d1=[]
d2=[]

for i in range(n):
    a = list(map(int,input().split()))
    d1.append(a[0])
    d2.append(a[1])

flg=0
for i in range(n):
    if d1[i] == d2[i]:
        flg+=1
        if flg == 3:
            break
    else:
        flg=0

if flg != 3:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 62568
import std.stdio, std.typecons, std.array, std.conv, std.algorithm, std.string, std.ascii;

alias Tuple!(int, "from", int, "to", int, "value") Player;

bool is_digit(string str) {
  bool ans = true;
  foreach(s; str)
    ans &= isDigit(s);
  return ans;
}

bool is_correct(int i, string str) {
  if ((i % 15) == 0) {
    if (str == "FizzBuzz") return true;
    else return false;
  }
  else if ((i % 3) == 0) {
    if (str == "Fizz") return true;
    else return false;
  }
  if ((i % 5) == 0) {
    if (str == "Buzz") return true;
    else return false;
  }
  else if (is_digit(str) && str.to!(int) == i) return true;
  else return false;
}

void main() {
  for(int count, number; readf("%d %d\n", &number, &count), (number + count) != 0;) {
    Player[int] players;

    for(int i = 2; i < number; i++) {
      players[i] = Player(i - 1, i + 1, i);
    }
    players[1] = Player(number, 2, 1);
    players[number] = Player(number - 1, 1, number);

    int id = 1;
    for(int i = 1; i <= count; i++) {
      string s = readln.chomp;
      if (players.length == 1) continue;
      if (is_correct(i, s)) {
        id = players[id].to;
      }
      else {
        int to = players[id].to;
        int from = players[id].from;
        players.remove(id);
        players[from].to = to;
        players[to].from = from;
        id = to;
      }
    }
    players.keys.sort.map!(to!(string)).array.join(" ").writeln;
  }
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
ll n; 
  cin>>n;
  ll lyu[87];
  lyu[0]=2;
  lyu[1]=1;
  for(int i=2;i<=86;i++){
    lyu[i]=lyu[i-1]+lyu[i-2];
  }
  cout<<lyu[n]<<endl;
  
  
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll D[105];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> D[i];
    }

    ll sum = 0;
    REP(i, N)
    {
        FOR(j, N, i + 1)
        {
            sum += D[i] * D[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
#include<map>
#include <cassert>
#include<sstream>
#include<fstream>
#include <cstring>
using namespace std;
typedef pair<int, string>p;
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
const int MAX =1;
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string ans = "No";
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '7')ans = "Yes";
	}
	cout << ans;
}



Measured memory_bytes: 3656
#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>



using namespace std;


const int INF = 100000;

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

char maze[100][101];

ll n, m;
ll k;
int sx, sy;

int gx, gy;



//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

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

int main() {

	cin >> n >> k;
	ll sum = 0;
	if (k == 0) {
		sum = n * n;
		cout << sum << endl;
		return 0;
	}
	for (int i = k + 1; i <= n; i++) {
		sum += (n / i)*(i - k);
		int res = n - n / i * i;
		if (k <= res) sum += res-k+1;
	}
	cout << sum << endl;
	int qqq; cin >> qqq;
	return 0;

}

Measured memory_bytes: 256
from math import sqrt
N = int(input())
if N == 1:
    print(0)
    import sys
    sys.exit()
ans = [0] * (N+1)
x = int(sqrt(N-2))+1
for j in range(1, x):
    for k in range(1, x):
        for l in range(1, x):
            y = j**2+k**2+l**2+j*k+k*l+l*j
            if y <= N:
                ans[y] += 1
for n in ans[1:N+1]:
    print(n)

Measured memory_bytes: 69356
/*8.20*/
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
#define P pair<int,int>
#define mp make_pair
#define fi first
#define se second
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
const int MN=262200;
int N,S,ans;
P a[MN];
P Merge(P a,P b){if(a.fi<b.fi)swap(a,b);return mp(a.fi,max(a.se,b.fi));}
int main()
{
	N=read();S=1<<N;
	reg int i,j;
	for(i=0;i<S;++i)a[i]=mp(read(),0);
	for(j=0;j<N;++j)for(i=0;i<S;++i)if(i>>j&1)
		a[i]=Merge(a[i],a[i^(1<<j)]);
	for(i=1;i<S;++i)ans=max(ans,a[i].fi+a[i].se),printf("%d\n",ans);
	return 0;
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N, M;
    cin >> N >> M;
    int64_t sum = 0;
    if (M >= N*2) {
        sum += N;
        sum += (M - (2 * N)) / 4;
        cout << sum << endl;
    } else {
        cout << M / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int a = 0;
		Set<Character> valid = new HashSet<>(Arrays.asList('A', 'G', 'C', 'T'));
		for (int i = 0; i < s.length(); i++) {
			int count = 0;
			int j = i;
			while (j < s.length() && valid.contains(s.charAt(j++))) count++;
			a = Math.max(a, count);
		}

		System.out.println(a);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for(int i=0; i<M; i++) cin >> A[i];
    int sum = accumulate(A.begin(), A.end(), 0);
    if(sum > N) cout << -1 << endl;
    else cout << N-sum << endl;
    return 0;

}

Measured memory_bytes: 3636
use proconio::input;

fn main() {
    input! { n: usize }
    let mut a = vec![];
    let mut ac = vec![0; 1000_000 + 1];
    let mut ma = 0;
    for _ in 0..n {
        input! { ai: usize }
        a.push(ai);
        ac[ai] += 1;
        ma = ma.max(ai);
    }

    let mut pc = true;
    for i in 2..=ma {
        let mut c = 0;
        for j in (i..=ma).step_by(i) {
            c += ac[j];
        }
        if c > 1 {
            pc = false;
            break;
        }
    }

    println!("{} coprime", if pc {
        "pairwise"
    } else {
        let mut v = a[0];
        for i in 1..n {
            v = num_integer::gcd(v, a[i]);
        }
        if v == 1 {
            "setwise"
        } else {
            "not"
        }
    });
}


Measured memory_bytes: 20580
import sys
from math import sqrt, gcd, ceil, log
# from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
# from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# sys.setrecursionlimit(5*10**6)

def f(n):
	i = 0
	while n%10 == 7:
		n //= 10
		i += 1
	return((n,i))
def f2(a, b):
	return(b + [0, 10][a > b] - a)
	
def main():
	n = int(input()); 
	dic = defaultdict(int)
	for i in range(1, 10):
		for j in (1, 3, 7, 9):
			dic[(j, (i*j)%10)] = i

	if n%10 in (1, 3, 7, 9):
		t = n%10; ans = 0
		m, ans = f(n*(dic[(t, n%10)]))

		while m != 0:
			m += n*dic[(t, f2(m%10, 7))]
			m, y = f(m)
			ans += y
		print(ans)
	else:print(-1)





if __name__ == "__main__":
	main()

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

typedef pair<int,int> pii;

const int inf = 1<<30;

vector<vector<int> > tree;

vector<vector<int> > cost;

void dfs(int start,int pre,int now,int depth){
  cost[start][now] = depth;
  for(auto it=tree[now].begin(),e=tree[now].end();it!=e;it++){
    if(pre == (*it)) continue;
    dfs(start,now,*it,depth+1);
  }
}

int main(){
  int N,K;
  cin>>N>>K;
  tree.resize(N);
  vector<pii> piilist;
  cost = vector<vector<int> >(N,vector<int>(N,inf));
  for(int i=0;i<N-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
    piilist.push_back(make_pair(a,b));
  }
  for(int i=0;i<N;i++) dfs(i,i,i,0);
  int ans = inf;
  if(K%2 == 0){
    for(int i=0;i<N;i++){
      int cnt = 0;
      for(int j=0;j<N;j++){
	if(cost[i][j] > K/2) cnt++;
      }
      ans = min(ans,cnt);
    }
  }else{
    for(int i=0;i<N-1;i++){
      pii p = piilist[i];
      int cnt = 0;
      for(int j=0;j<N;j++){
	if(min(cost[p.first][j],cost[p.second][j]) > (K-1)/2) cnt++;
      }
      ans = min(ans,cnt);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
  string a, b;
  cin >> a >> b;
  istringstream s = istringstream(a + b);
  int num;
  s >> num;
  int sq = sqrt(num);
  if (pow(sq, 2) == num)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

#define pb push_back
#define ff first
#define ss second

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

int n, a, b;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b;
	cout << min(n * a, b);
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

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

#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
#define ff first
#define ss second
#define Clear(x) memset(x,0,sizeof(x))
#define all(x) (x).begin(),(x).end()

void checkpoint1()
{
	/******think more code less******/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pair< ll,ll > &a,pair< ll,ll > &b)
{
	if(a.ff!=b.ff)
		return a.ff<b.ff;
	else
	{
		if(a.ss>b.ss)
			return b.ss<a.ss;
		else if(a.ss<b.ss)
			return a.ss<b.ss;
	}
	return a.ff>b.ff;
}

ll powe(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		{
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
int main()
{
	checkpoint1();
	ll n;
	cin>>n;
	ll a[n];
	a[0]=0;
	for(ll i=0;i<n;i++)
		cin>>a[i];
	ll dp[n];
	dp[0]=0;
	for(ll i=1;i<n;i++)
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),(i-2)>=0 ?dp[i-2]+abs(a[i]-a[i-2]):inf);
	cout<<dp[n-1];
	return 0;
}

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

// edit by  (xcode)

using namespace std;

#define int         long long
#define ll          long long
#define double      long double
#define pb          push_back
#define in          insert
#define mp          make_pair
#define f           first
#define s           second
//#define x           first
//#define y           second
#define all(el)     el.begin(), el.end()
#define allr(el)    el.rbegin(), el.rend()
#define sz(el)      (int)el.size()
#define endl        "\n"

inline int chkmax(int &x, int y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

inline int chkmin(int &x, int y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

const int maxn = 2 * 1e5 + 100;
const int mod = 998244353;

int fact[maxn];

int bin_pow(int x, int p) {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int ans = bin_pow(x, p / 2);
        return (ans * ans) % mod;
    }
    return (bin_pow(x, p - 1) * x) % mod;
}

int C(int n, int k) {
    int a = fact[n];
    int b = (fact[n - k] * fact[k]) % mod;
    b = bin_pow(b, mod - 2);
    return (a * b) % mod;
}

int mul(int a, int b) {
    return (a * b) % mod;
}

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n, m, k;
    cin >> n >> m >> k;
    
    fact[0] = 1;
    for (int i = 1; i < maxn; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    
    int ans = 0;
    
    for (int i = k; i >= 0; i--) {
        ans += (((C(n - 1, i) * m) % mod) * bin_pow(m - 1, n - i - 1)) % mod;
        //cout << ans << ' ' << C(n - 1, k) << endl;
        ans %= mod;
    }
    cout << ans;
    
    return 0;
}



Measured memory_bytes: 5212
a,b,c,x,y = list(map(int, input().split()))
m = 0
cheap = min(a+b, c*2)
if x >= y:
    m += y*cheap
    x -= y
    cheap = min(a, c*2)
    m += x*cheap
else:
    m += x*cheap
    y -= x
    cheap = min(b, c*2)
    m += y*cheap
print(m)

Measured memory_bytes: 3064
const main = (input) => {
  const [a, b] = input.trim().split('\n')
  const [, K] = a.split(' ').map(v => Number(v))
  const prices = b.split(' ').map(v => parseInt(v, 10)).sort((a, b) => a - b)

  return console.log(prices.slice(0, K).reduce((a,b) => a + b, 0))
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29724
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll a, b, c; cin >> a >> b >> c;
	ll k; cin >> k;
	bool flag = false;

	while (k > 0 && a >= b) {
		k--, b *= 2;
	}
	while (k > 0 && b >= c) {
		k--, c *= 2;
	}

	if (a<b&&b<c)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3632
#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 ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


 ll bit[5*100000+1]; // declare bit as a map if necessary.
ll n=0; // will be taken as input in main
// take care of i,use idx not i.
// 1-based
void add(ll idx,ll v){
for(ll i=idx;idx<=n;idx+=(idx&-idx))
	bit[idx]+=v;
}
void update(ll l,ll r,ll v){     // for range update(we have 2,for point use 1)
	add(l,v);
	add(r+1,-v);
}

ll query(ll idx){                // point query,for range query (sub 2 point query etc.)
	ll sum=0;
	for(ll i=idx;idx>0;idx-=(idx&-idx))
		sum+=bit[idx];
	return sum;
}
const ll maxn=5*100000+5;
ve <pair<ll,ll> > adj[maxn];

int main(){



    FAST
//	PRECISE


ll q;
cin>>n>>q;
ve <ll> v(n);
FOR(i,0,n)cin>>v[i];
FOR(i,0,q){
	ll x,y;cin>>x>>y;
	adj[y-1].pb({x,i});
}
ve <ll> last(maxn);
ve <ll> ans(q);
FOR(i,0,n){
	srt(adj[i]);
	if(last[v[i]]==0){
		add(i+1,1);
		last[v[i]]=i+1;
	}
	else{
		add(last[v[i]],-1);
		add(i+1,1);
		last[v[i]]=i+1;
	}
	for(auto j:adj[i]){
		ll x1=j.F;ll x2=j.S;
		ans[x2]=query(i+1)-query(x1-1);
	}
}
for(auto i:ans)
cout<<i<<"\n";


return 0;
 }



Measured memory_bytes: 44156
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1000003;
int f[N], invf[N], lg[N], d[N], a[N];
int cnt;
vector < int > g[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int cnk(int n, int k){
    return f[n] * invf[n - k] % mod * invf[k] % mod;
}
void dfs(int v, int p = -1){
    cnt++;
    d[v] = a[cnt];
    for (auto u: g[v]){
        if (u != p) dfs(u, v);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int s = 0;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        s += a[i];
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    s -= a[1];
    cnt = 0;
    dfs(1);
    cout << s << endl;
    for (int i = 1; i <= n; i++) cout << d[i] << " ";
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main() {
  cin.sync_with_stdio(false);
  int x;
  cin >> x;
  vector<int> p;
  p.pb(1);
  repl(i, 2, x + 1) {
    int tmp = i * i;
    while(tmp <= x) {
      p.pb(tmp);
      tmp *= i;
    }
  }
  sort(all(p));
  cout << p[p.size() - 1] << endl;
  return 0;
}


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

int next_turn(char c) {
  return int(c) - int('a');
}

int main()
{
  string S[3];
  cin >> S[0] >> S[1] >> S[2];
  int pos[3] = {0};
  int turn = 0;
  for (;;) {
    if (pos[turn] >= S[turn].length()) {
      cout << char(int('A')+turn) << endl;
      break;
    }
    int next = next_turn(S[turn][pos[turn]]);
    pos[turn]++;
    turn = next;
  }
  return 0;
}


Measured memory_bytes: 3632
import sys

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

if sum(A)<=sum(B):
    print(-1)
    sys.exit()

Y=0
K=0
Q=[]

for i in range(N):
    k=A[i]-B[i]
    if k>0:
        Q.append(k)
    elif k<0:
        K+=1
        Y+=-k

Q.sort()

while Y>0:
    q=Q.pop()
    Y-=q
    K+=1

print(K)    


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

using namespace std;

void hawawa(){
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i += 2) {
		int cnt = 0;
		for (int j = 1; j <= i; j += 2) {
			cnt += !(i % j);
		}
		ans += cnt == 8;
	}
	cout << ans << "\n";
}

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


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout << x << '\n';

#define INF (1 << 29)

#define FAST cin.tie(0), ios::sync_with_stdio(false)
inline int chmax(int &a, int b){return b>a ? a=b,1 : 0;}
inline int chmin(int &a, int b){return b<a ? a=b,1 : 0;}
//________

main(){
  FAST;
  int n,k;
  cin >> n >> k;
  int ans = 1;
  while(n--){
    ans = (ans*2 < ans+k)? ans*2 : ans+k;
  }
  outl(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

const int mod = 1e9 + 7;

int add(int a, int b)
{
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b)
{
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mul(int a, int b)
{
    return (LL)a * b % mod;
}

int binpow(int a, int n)
{
    int res = 1;
    while (n)
    {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

const int maxN = 4000;
int c[maxN][maxN];

int CC(int n, int k)
{
    assert(n + k - 1 >= 0);
    assert(n + k - 1 < maxN);
    assert(n >= 0);
    assert(n - 1 <= n + k - 1);
    return c[n + k - 1][n];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    c[0][0] = 1;
    FOR(n, 1, maxN)
    {
        c[n][0] = 1;
        FOR(k, 1, n + 1)
        {
            c[n][k] = add(c[n - 1][k], c[n - 1][k - 1]);
        }
    }
    int s;
    cin >> s;
    int ans = 0;
    int cnt = 1;
    while (s >= cnt * 3)
    {
        ans = add(ans, sub(CC(cnt, s - cnt * 3 + 1), CC(cnt, s - cnt * 3)));
        cnt++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 48664
#include <iostream>
#include<algorithm>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define MOD (int) 1e9+7
#define for0(i, n) for (int i = 0; i < n; i++)
#define ff first
#define ss second
#define endl "\n"
#define bits(n) __builtin_popcount(n)
#define ini(a, i) memset(a, i, sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	// cin >> t;
	t  = 1;
	while (t--)
	{
		ll ans;
		for (ll i = 0; i < 5; i++)
		{
			ll a;
			cin >> a;
			if (a == 0)
				ans = i + 1;
		}
		cout << ans << endl;
	}
	return 0;
}


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

int main() {
  int n, res;
  cin >> n;
  if (0b1000000 <= n) {
    res = 64;
  } else if (0b100000 <= n) {
    res = 32;
  } else if (0b10000 <= n) {
    res = 16;
  } else if (0b1000 <= n) {
    res = 8;
  } else if (0b100 <= n) {
    res = 4;
  } else if (0b10 <= n) {
    res = 2;
  } else if (0b1 <= n) {
    res = 1;
  }
  cout << res << endl;
}


Measured memory_bytes: 3608
$MOD = 1_000_000_007

def mod(n)
  return n % $MOD
end

def modpow(n, x)
  if x == 0
    return 1
  elsif x == 1
    return n % $MOD
  elsif x % 2 == 0
    r = modpow(n, x / 2)
    return r * r % $MOD
  else
    r = modpow(n, (x - 1) / 2)
    # p "#{n} #{x} #{r}"
    return r * r * n % $MOD
  end
end

def modinv(n)
  return modpow(n, $MOD - 2)
end

def modconv(n, k)
  res = 1
  fact = 1
  1.upto(k) do |i|
    res = mod(res * (n - i + 1))
    fact = mod(fact * i)
  end

  return mod(res * modinv(fact))
end

n, a, b = gets.split.map(&:to_i)



pow2 = modpow(2, n)
conva = modconv(n, a)
convb = modconv(n, b)

#p pow2
#p conva
# p convb

res = (pow2 - conva - convb - 1 + 10 * $MOD) % $MOD

p res


# x 4 C 0 = 1
# x 4 C 1 = 4
# 4 C 2 = 6
# x 4 C 3 = 4
# 4 C 4 = 1

# 16 - 1 - 4 - 4 = 7

Measured memory_bytes: 1788
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

psum = [0] + list(accumulate(A))
ans = min(abs(psum[k] - (psum[N] - psum[k])) for k in range(1, N))
print(ans)

Measured memory_bytes: 88528
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){cin>>a[i];}
    ll count[3]={};
    for(int i=0;i<n;i++){
        if(a[i]%4==0){count[2]++;}
        else if(a[i]%2==0){count[1]++;}
        else{count[0]++;}
    }
    bool j=false;
    if(count[0]==0){j=true;}
    if(count[1]==0 && count[2]+1>=count[0]){j=true;}
    n-=count[1];
    count[2]--;
    if(count[2]>=0 && count[2]+1>=count[0]){j=true;}
    cout<<(j?"Yes":"No")<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main(){
  std::string S;
  std::cin >> S;
  
  char hi[] = {'h','i'};
  
  if (S.size() % 2){
    std::cout << "No" << std::endl;
    return 0;
  }
  
  for(auto i=0; i < S.size(); ++i){
    if(S[i] != hi[i%2]){
      std::cout << "No" << std::endl;
      return 0;
    }
  }
 
  std::cout << "Yes" << std::endl;
  return 0;
}

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

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

#define roop(i, n) for(int i = 0;i < n;i++)
#define INF 1000000000

int main(void){

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(26));

    roop(i, n){
        string s;
        cin >> s;
        for(int j = 0;s[j] != '\0';j++){
            a[i][s[j]-'a']++;
        }
    }

    roop(i, 26){
        int value = INF;
        roop(j, n){
            value = min(value, a[j][i]);
        }
        roop(j, value) cout << (char)(i+'a');
    }

    cout << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans=0;
  for (int i=1;i<10;i++) {
    if (n%i==0 && n/i<10) {
      ans=1;
      break;
    }
  }
  if (ans==1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int M,K;
  cin>>M>>K;
  if(M==0){
    if(K==0){
      cout<<"0 0"<<endl;
    }else{
      cout<<-1<<endl;
    }
  }else if(M==1){
    if(K==0){
      cout<<"0 1 1 0"<<endl;
    }else{
      cout<<-1<<endl;
    }
  }else{
    if(K<(1<<M)){
      REP(i,(1<<M)){
        if(i==K)continue;
        cout<<i<<' ';
      }
      cout<<K<<' ';
      REP(i,(1<<M)){
        if((1<<M)-i-1==K)continue;
        cout<<(1<<M)-i-1<<' ';
      }
      cout<<K<<endl;
    }else{
      cout<<-1<<endl;
    }
  }
}


Measured memory_bytes: 1792
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

lint pow(lint n, lint a = 10) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint s;
	cin >> s;

	lint ans = 0, sz = to_string(s).size() - 1;
	for (int bit = 0b0; bit < (1 << sz); bit++) {

		lint tmp = s, div = 10;
		for (int i = 0; i < sz; i++) {
			if (bit & (1 << i)) {
				ans += tmp % div;
				tmp /= div;
				div = 1;
			}
			div *= 10;
		}
		ans += tmp;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = (a + b) % 2;
		int y = (a + b) / 2;
		if(x == 0)
		{
			System.out.println(y);
		}
		else 
		{
			y = y + 1;
			System.out.println(y);
		}
	}

}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N, M;
  cin >> N >> M;
  cout << N*(N-1)/2+M*(M-1)/2 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

char s[30];
int len;
int ans;

int main(){
	scanf("%s",s);
	len=strlen(s);
	ans=s[0]-'0'-1+9*(len-1);
	int sum=0;
	for(int i=0;i<len;i++)
		sum+=s[i]-'0';
	printf("%d\n",max(ans,sum));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<ll,ll> m;
	ll a,b,c;
	ll N,Q;
	ll all = 0;
	cin>>N;

	vector<ll> ans(N);
	for(ll i=0;i<N;i++){
		cin>>a;m[a]++;
		all+=a;
	}
	cin>>Q;
	for(ll i=0;i<Q;i++){
		cin>>b>>c;
		all=(c-b)*m[b]+all;
		m[c]+=m[b];
		m[b]=0;
		cout<<all<<endl;
	}
}

Measured memory_bytes: 9848
// -*- coding:utf-8-unix -*-

use proconio::input;

use num_traits::{pow, One};
use std::ops::{Add, Div, Mul, Sub};

const MODULUS: usize = 1000000007;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        n: usize,
        m: usize,
    }

    let mm = ModP(m);
    let nn = ModP(n);

    // prepare a table of factorials
    let mut fac_vec: Vec<ModP> = Vec::new();
    let mut fac_inv_vec: Vec<ModP> = Vec::new();
    fac_vec.push(ModP(1));
    fac_inv_vec.push(ModP(1));
    for i in 1..=m {
        fac_vec.push(ModP(i) * fac_vec[i - 1]);
        fac_inv_vec.push(ModP(1) / fac_vec[i]);
    }
    let fac_vec = fac_vec;
    let fac_inv_vec = fac_inv_vec;

    let mut result = ModP(0);
    for i in 0..=n {
        if i % 2 == 0 {
            result = result + num_of_pair_of_seq_with_i_same_entries(mm, nn, ModP(i), &fac_vec, &fac_inv_vec);
        } else {
            result = result - num_of_pair_of_seq_with_i_same_entries(mm, nn, ModP(i), &fac_vec, &fac_inv_vec);
        }
    }
    println!("{}", result.0);
}

fn permutation(n: ModP, r: ModP, fac_vec: &Vec<ModP>, fac_inv_vec: &Vec<ModP>) -> ModP {
    return fac_vec[n.0] * fac_inv_vec[(n - r).0];
}

fn combination(n: ModP, r: ModP, fac_vec: &Vec<ModP>, fac_inv_vec: &Vec<ModP>) -> ModP {
    return fac_vec[n.0] * fac_inv_vec[(n - r).0] * fac_inv_vec[r.0];
}

fn num_of_pair_of_seq_with_i_same_entries(
    m: ModP,
    n: ModP,
    i: ModP,
    fac_vec: &Vec<ModP>,
    fac_inv_vec: &Vec<ModP>,
) -> ModP {
    let comb = combination(n, i, fac_vec, fac_inv_vec);
    let perm1 = permutation(m, i, fac_vec, fac_inv_vec);
    let perm2 = permutation(m-i, n-i, fac_vec, fac_inv_vec);
    return comb * perm1 * perm2 * perm2;
}

#[derive(Clone, Copy, PartialEq, Debug)]
struct ModP(usize);

impl One for ModP {
    fn one() -> Self {
        return ModP(1);
    }
}
impl Add for ModP {
    type Output = Self;
    fn add(self, rhs: Self) -> Self {
        return ModP((self.0 + rhs.0) % MODULUS);
    }
}
impl Sub for ModP {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self {
        return ModP((self.0 + MODULUS - rhs.0) % MODULUS);
    }
}
impl Mul for ModP {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {
        return ModP((self.0 * rhs.0) % MODULUS);
    }
}
impl Div for ModP {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {
        if rhs.0 == 0 {
            panic!("Tried to divide by ModP(0)!");
        }
        let rhs_inv = pow(rhs, MODULUS - 2);
        return self * rhs_inv;
    }
}


Measured memory_bytes: 10040
#include <stdio.h>
int main(void){
    int i,j,k,n,x;
    int count=0;
    while(1){
        scanf("%d%d",&n,&x);
        if(n==0&&x==0)break;
        if(n>=3&&n<=100){
        for(i=1;i<=n-2;i++){
             for(j=i+1;j<=n-1;j++){
                  for(k=j+1;k<=n;k++){
                      if(i+j+k==x) count++;}}}}
        printf("%d\n",count);
        count=0;}
    return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
#include <string.h>
int main()
{
  char s[11];
  scanf("%s",s);
  int n=strlen(s),i,k=0;
  char c[11];
  for(i=0; i<n; i++) {
    if(s[i]=='0'){
      c[k]='0';
      k++;
    }
    else if(s[i]=='1'){
      c[k]='1';
      k++;
    }
    else {
      k--;
      if(k<0) k=0;
    }
  }
  for(i=0;i<k;i++) printf("%c",c[i]);
  printf("\n");
  return 0;
}
		  


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


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

    sort(h.begin(),h.end());
    ll ans=100000000000000;

    rep(i,n-k+1){
        // if(ans>x) ans=x;
        ans=min(h[i+k-1]-h[i],ans);
    }

    cout << ans << endl;
}

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

using namespace std;

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

    int sum=0;

    for(int i=0; i<n; i++){
        long x,y;
        cin >> x >> y;

        if(sqrt(x*x+y*y)<=d){
            sum++;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3572
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	preList = []
	preList2 = []
	for i in range(1, N + 1):
		if i ** 2 == N:
			preList.append(1)
			break
		elif i ** 2 > N:
			break
		else:
			if i == int(N // i):
				preList.append(1)
				break
			else:
				preList.append(int(N // i) - int(N // (i + 1)))
				preList2.append(1)

	start = list(reversed(preList + preList2))
	M = len(start)
	DP = [[0] * M for i in range(K)]
	DP[0] = start


	#DP
	for i in range(1, K):
		Csum = [0] * (M + 1)
		for j in range(M):
			Csum[j + 1] += Csum[j] + DP[i - 1][j]

		for j in range(M):
			DP[i][j] = Csum[M - j] * DP[0][j]
			DP[i][j] %= con
	
	# print(start)
	# print(DP)
	print(sum(DP[K - 1]) % con) 
	




if __name__ == '__main__':
	main()

Measured memory_bytes: 118640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s

#define INF 10000000000

int main()
{
    rdi(n);
    rdi(a);
    rdi(b);
    ll result = n / (a + b) * a;
    ll rem = n % (a + b);
    if (rem <= a) {
        result += rem;
    } else {
        result += a;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include <bits/stdc++.h>

// #pragma GCC optimize("O3")
// #pragma GCC target("avx")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define MP make_pair
#define ERR cout << "================================================\n"
#define fi first
#define se second
#define PB push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define print(v)          \
	for (auto x : v)      \
	{                     \
		cout << x << " "; \
	}
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define SP << " " <<
#define W(t)  \
	ll t;     \
	cin >> t; \
	while (t--)
#define FIO                           \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
#define FAST                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1e18;
const ll NEG_INF = -1 * (1e18);
using namespace std;

void usaco(string prob)
{
	freopen((prob + ".in").c_str(), "r", stdin);
	freopen((prob + ".out").c_str(), "w", stdout);
}

/* Function to check primality in O(sqrt(n)) */
bool prime(int n)
{
	if (n < 2)
		return false;
	for (int x = 2; x * x <= n; x++)
	{
		if (n % x == 0)
			return false;
	}
	return true;
}

/* Function to get prime factorization of n */
vector<int> getFactors(int n)
{
	vector<int> f;
	for (int x = 2; x * x <= n; x++)
	{
		while (n % x == 0)
		{
			f.push_back(x);
			n /= x;
		}
	}
	if (n > 1)
		f.push_back(n);
	return f;
}

void solve()
{
	/* Write Solution Here */
	string s, t;
	cin >> s >> t;
	ll ans = t.length();
	ll t1 = t.length();
	ll s1 = s.length();
	forn(i, s1 - t1 + 1)
	{
		ll c = 0;
		ll i1 = i, j = 0;
		for (; j < t1; j++)
		{
			if (t[j] == s[i1])
			{
				c++;
			}
			i1++;
		}
		ans = min(ans, t1 - c);
	}
	cout << ans << "\n";
}

int main()
{
	//FIO
	FAST

		//usaco("cowlands");

		ll TC = 1;
	/*
	Uncomment when multiple test cases
	*/

	// cin>>TC;
	for1(tt, TC)
	{
		solve();
	}
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

int main(){
    int n,T,X,Y;
    cin >> n;
    vector<int> t(n+1),x(n+1),y(n+1);
    t.at(0) = 0;
    x.at(0) = 0;
    y.at(0) = 0;
    for(int i = 1;i < n+1;i ++){
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }

    for(int i = 1;i < n+1;i ++){
        if(x.at(i-1)<x.at(i)){
            X = x.at(i) - x.at(i-1);
        }else{
            X = x.at(i-1) - x.at(i);
        }

        if(y.at(i-1)<y.at(i)){
            Y = y.at(i) - y.at(i-1);
        }else{
            Y = y.at(i-1) - y.at(i);
        }

        T = t.at(i) -t.at(i-1);

        if(T >= X+Y && T%2 == (X+Y)%2){

        }else{
            cout << "No" << endl;
            return 0;
        }

    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
struct edge {
  int from, to, cost;
};
int N, M;
vec< vec< int > > G, Grev;
vec< edge > E;
vec< int > d;
vec< bool > visited[3];
void dfs(int id, int type) {
  visited[type][id] = true;
  FORA(e, type == 0 ? G[id] : Grev[id]) {
    if (!visited[type][e])
      dfs(e, type);
  }
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N >> M;
  G.resize(N, vec< int >());
  Grev.resize(N, vec< int >());
  REP(i, M) {
    int p, q, r;
    cin >> p >> q >> r;
    p--, q--;
    //   r *= -1;
    G[p].pb(q);
    Grev[q].pb(p);
    edge Eele = {p, q, r};
    E.pb(Eele);
  }
  d.resize(N, -INF2);
  d[0] = 0;
  //到達判定を忘れていた。退化している。
  visited[0].assign(N, false);
  dfs(0, 0);
  visited[1].assign(N, false);
  dfs(N - 1, 1);
  visited[2].assign(N, false);
  REP(i, N) { visited[2][i] = visited[0][i] && visited[1][i]; }
  // PRINTALL(visited[2]);
  REP(i, N) {
    FORA(e, E) {
      bool flg = chmax(d[e.to], d[e.from] + e.cost);
      if (flg && i >= N - 1 && visited[2][e.to]) {
        print("inf");

        return 0;
      }
    }
  }
  print(d[N - 1]);
}

/*
http://drken1215.hatenablog.com/entry/2019/02/16/075900
負閉路検出用の配列を用意しておいて、N
回目の更新で更新された箇所にフラグを立てて、そこから到達できるところすべてにフラグを立てることで、負閉路による影響を受けるところをすべて求めることができる
(editorial)

N 回目の更新で更新された箇所に -INF を入れておいて、さらに追加で N 回伝播する
(わかりやすい)

到達用配列を用意して、1から到達できる点の集合とNから到達できる点の集合の積集合を取る。
*/

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k,cnt=0;
  cin>>n>>m>>k;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(n*j+m*i-i*j*2==k){
        cnt++;
        break;
        break;
      }
    }
  }
  if(cnt>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int A,B,C;
    cin >> A >> B >> C;
    if(A%2 == 0 || B%2 == 0 || C%2 == 0) {
        cout << 0 << endl;
    }
    else {
        cout << min({A*B,A*C,B*C}) << endl;
    }
}

Measured memory_bytes: 256