akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define LN 18

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
vii adj[upperlimit+1];
bool visited[upperlimit+1];
int sparse[upperlimit+1][LN+1];
ll weight[upperlimit+1][LN+1];
int level[upperlimit+1];
int parent[upperlimit+1];
int parent_edge[upperlimit+1];
int q,n;
void dfs(int node,int lv,int pa,int pa_edge){
    visited[node]=true;
    level[node]=lv;
    parent[node]=pa;
    parent_edge[node]=pa_edge;
    for(int i=0;i<adj[node].size();i++)if(!visited[adj[node][i].F])dfs(adj[node][i].F,lv+1,node,adj[node][i].S);
}
void compute(){
    int i,j,k;
    dfs(1,1,1,0);
    for(i=1;i<=n;i++){
        sparse[i][0]=parent[i];
        weight[i][0]=parent_edge[i];
    }
    for(j=1;j<=LN;j++)for(i=1;i<=n;i++){
        sparse[i][j]=sparse[sparse[i][j-1]][j-1];
        weight[i][j]=weight[i][j-1]+weight[sparse[i][j-1]][j-1];
    }
}
int lca(int a,int b){
    if(level[a]>level[b])swap(a,b);
    int temp=level[b]-level[a];
    for(int j=LN;j>=0;j--)if((temp>>j)&1)b=sparse[b][j];
    if(a==b)return a;
    for(int j=LN;j>=0;j--)if(sparse[a][j]!=sparse[b][j]){
        a=sparse[a][j];
        b=sparse[b][j];
    }
    return parent[a];
}
ll queryup(int a,int b){
    int temp=level[a]-level[b];
    ll ret=0;
    for(int j=LN;j>=0;j--)if((temp>>j)&1){
        ret+=weight[a][j];
        a=sparse[a][j];
    }
    return ret;
}
ll dist(int a,int b){
    int l=lca(a,b);
    return (queryup(a,l)+queryup(b,l));
}
int main()
{
    int i,j,k,a,b,c;
    sd(n);
    for(i=1;i<n;i++){
        sd(a);sd(b);sd(c);
        adj[a].pb(mp(b,c));
        adj[b].pb(mp(a,c));
    }
    compute();
    sd(q);sd(k);
    while(q--){
        sd(a);sd(b);
        ll answer=dist(a,k)+dist(b,k);
        plldn(answer);
    }
    return 0;
}

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

#define int long long
#define ld long double

#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()

#define debug1(a) cerr<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cerr<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
 
#define INF (int)100000000000000000
#define PI (double)3.14159265358979
#define MOD 1000000007

struct Node 
{
    //Lazy Propagation
    //Node N(vector , v.begin(), v.end());
    //N.query(v.begin(), v.end());
    //N.add(v.begin(), v.end());
    Node *l = 0, *r = 0;
    int lo, hi ;
    int madd = 0, val = -INF;
    Node(vector <int>& v, int lo, int hi) : lo(lo), hi(hi) {
        if (lo + 1 < hi) {
            int mid = lo + (hi - lo)/2;
            l = new Node(v, lo, mid); r = new Node(v, mid, hi);
            val = max(l->val, r->val);
        }
        else val = v[lo];
    }
    int query(int L, int R) {
        if (R <= lo || hi <= L) return -INF;
        if (L <= lo && hi <= R) return val;
        push();
        return max(l->query(L, R), r->query(L, R));
    }
    void add(int L, int R, int x) {
        if (R <= lo || hi <= L) return;
        if (L <= lo && hi <= R) {
            madd += x;
            val += x;
        }
        else {
            push(), l->add(L, R, x), r->add(L, R, x);
            val = max(l->val, r->val);
        }
    }
    void push() {
        if (madd)
            l->add(lo,hi,madd), r->add(lo,hi,madd), madd = 0;
    }
};

vector <vector <int32_t>> r;
vector <int> c;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
    int h, w, m;

    cin >> h >> w >> m;

    r.resize(h+5);
    c.resize(w+5, 0);

    for (int i=0;i<m;++i)
    {
        int x, y;
        cin >> x >> y;
        r[x].pb(y);
        c[y]++;
    }
    // for (auto j:c)
    //     debug1(j);
    int res = 0;
    Node N(c, 0, w+1);
    for (int i=1;i<=h;++i)
    {
        int cur = 0;
        cur += sz(r[i]);
        for (auto j:r[i])
            N.add(j, j+1, -1);
        cur += N.query(1, w+1);
        // debug3(i, sz(r[i]), N.query(1, w+1));
        res = max(res, cur);
        for (auto j:r[i])
            N.add(j, j+1, 1);
    }
    cout << res << "\n";
    

    return 0;
}

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

public class Main{

	public static void main(String[] args) throws IOException {
		println(readInt()/3);
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBoolean() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


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

int d[200][200],s[200],n,m,r,M=INT_MAX,c;
int main() {
	cin>>n>>m>>r;
	memset(d,0x3f,sizeof(d));
	rep(i,r)scanf("%d",&s[i]),s[i]--;sort(s,s+r);
	rep(i,m){int a,b,c;cin>>a>>b>>c;d[--a][--b]=d[b][a]=c;}
	rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	do{int c=0;rep(i,r-1)c+=d[s[i]][s[i+1]];M=min(M,c);}while(next_permutation(s,s+r));
	printf("%d",M);
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle {
	int f[N2];
	int space;
	string path;

	bool operator < ( const Puzzle &p ) const {
		for ( int i = 0; i < N2; i++ ) {
			if ( f[i] == p.f[i] ) continue;
			return f[i] > p.f[i];
		}
	return false;
	}
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget(Puzzle p) {
	for ( int i = 0; i < N2; i++ )
		if (p.f[i] != (i + 1)) return false;
	return true;
}

string bfs(Puzzle s) {
	queue<Puzzle> Q;
	map<Puzzle, bool> V;
	Puzzle u, v;
	s.path = "";
	Q.push(s);
	V[s] = true;

while ( !Q.empty()) {
	u = Q.front(); Q.pop();
	if ( isTarget(u) ) return u.path;
	int sx = u.space / N;
	int sy = u.space % N;
	for ( int r = 0; r < 4; r++ ) {
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
		v = u;
		swap(v.f[u.space], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if ( !V[v] ) {
				V[v] = true;
				v.path += dir[r];
				Q.push(v);
			}
		}
	}

	return "unsolvable";
}

int main() {
	Puzzle in;

	for (int i = 0; i < N2; i++ ) {
		cin >> in.f[i];
		if ( in.f[i] == 0 ) {
			in.f[i] = N2;
			in.space = i;
		}
	}
	string ans = bfs(in);
	cout << ans.size() << endl;

	return 0;
}


Measured memory_bytes: 30660
<?php
 fscanf(STDIN,"%d",$n) ;

for($i=1;$i<10;$i++){
 if($n%$i==0){
  $a=$n/$i;
  if($a>=1&&$a<=9){
  	echo "Yes" ;
    exit ;
  }
 }
}
echo "No" ;

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

int main() {
	int N;
	cin >> N;
  vector<int> A(N);
	rep(i,N) cin >> A[i];
	bool ans = true;
	rep(i,N){
		if(A[i]%2 == 0){
			if(!(A[i]%3 == 0 || A[i]%5==0)){
				ans = false;
			}
		}
	}
	if(ans){
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
        }
}

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

int n, m;
int cnt[26];

int d2, d1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> m;
	for (int i=1; i<=n; i++) {
		string s;
		cin >> s;
		for (char x : s) {
			cnt[x - 'a']++;
		}
	}

	for (int i=0; i<26; i++) {
		switch (cnt[i] % 4) {
			case 0: break;
			case 1: d1++; break;
			case 2: d2++; break;
			case 3: d1++; d2++; break;
		}
	}

	if (n%2 == 0 && m%2 == 0) {
		// svi mora budu deljivi sa 4
		if (d2 > 0 || d1 > 0) {
			cout << "No\n";
		} else {
			cout << "Yes\n";
		}
		return 0;
	}

	if (n%2 == 1 && m%2 == 0) {
		if (d2 > m/2 || d1 > 0) {
			cout << "No\n";
		} else {
			cout << "Yes\n";
		}
		return 0;
	}

	if (n%2 == 0 && m%2 == 1) {
		if (d2 > n/2 || d1 > 0) {
			cout << "No\n";
		} else {
			cout << "Yes\n";
		}
		return 0;
	}

	if (d2 > (m+n-2)/2 || d1 > 1) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3152
N = int(input())
A = list(map(int,input().split()))
from fractions import gcd
mod = 10**9+7
g = A[0]
for a in A[1::]:
  g = g*a//gcd(g,a)
  
ans = 0
b = g%mod
for a in A:
  ans += g%mod*pow(a,mod-2,mod)
  ans %= mod
  
print(ans%mod)

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

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

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

typedef pair<int,int> P;

int bit[200010];

void add(int i,int x){
	while(i<200010){
		bit[i]+=x;
		i+=i&-i;
	}
}

int sum(int i){
	int s=0;
	while(i){
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}
signed main(){
	int n,c,t[100000],p[100000],pt[100000]={},typ[100000],m[100000];
	queue<int> ind[100000];
	vector<P> vec;
	cin>>n>>c;
	for(int i=0;i<n;i++)vec.push_back(P(0,-i));
	for(int i=0;i<c;i++){
		cin>>typ[i];
		if(!typ[i]){
			cin>>t[i]>>p[i];t[i]--;
			pt[t[i]]+=p[i];
			vec.push_back(P(pt[t[i]],-t[i]));
		}else cin>>m[i];
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<vec.size();i++){
		if(!vec[i].first)add(i+1,1);
		ind[-vec[i].second].push(i+1);
	}
	for(int i=0;i<c;i++){
		if(!typ[i]){
			add(ind[t[i]].front(),-1);
			ind[t[i]].pop();
			add(ind[t[i]].front(),1);
		}else{
			int low=0,up=n+c+1;
			while(up-low>1){
				int mid=(low+up)/2;
				if(sum(mid)>=n-m[i]+1)up=mid;
				else low=mid;
			}
			cout<<1-vec[up-1].second<<" "<<vec[up-1].first<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 78528
#include<cstdio>
int n,m;
inline bool legal(const int &x,const int &y){
    return 1<=x&&x<=n&&1<=y&&y<=m;    
}
int d[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
char g[1005][1005];
int dis[1005][1005];
int qx[1000005],qy[1000005];
int hd=0,tl=0;//head,tail
void push(int x,int y){
    qx[tl]=x;qy[tl]=y;++tl;
}
void bfs(){
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(g[i][j]=='#')push(i,j),dis[i][j]=0;
        }
    }
    int xx,yy,xxx,yyy;
    while(hd!=tl){
        xx=qx[hd];yy=qy[hd];++hd;
        for(int i=0;i<4;++i){
            xxx=xx+d[i][0];yyy=yy+d[i][1];
            if(legal(xxx,yyy)&&g[xxx][yyy]!='#'){
                dis[xxx][yyy]=dis[xx][yy]+1;
                g[xxx][yyy]='#';
                push(xxx,yyy);
            }
        }
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)scanf("%s",g[i]+1);
    bfs();
    int ans=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            if(dis[i][j]>ans)ans=dis[i][j];
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 12928
package main

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

func main() {
	S := ReadString()
	for {
		S = S[:len(S)-2]
		i := 0
		j := len(S) / 2
		ok := true
		for j < len(S) {
			if S[i] != S[j] {
				ok = false
				break
			}
			i++
			j++
		}
		if ok {
			fmt.Println(len(S))
			return
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

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


Measured memory_bytes: 1848
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int a, b, c; cin>>a>>b>>c;
  int e = a-b;
  int ans = max(c-e,0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto tmp = readln.split.to!(int[]);
    auto x1 = tmp[0], y1 = tmp[1], x2 = tmp[2], y2 = tmp[3];
    auto dx = x2 - x1, dy = y2 - y1;
    auto x3 = x2 - dy, y3 = y2 + dx;
    auto x4 = x3 - dx, y4 = y3 - dy;
    writefln("%d %d %d %d", x3, y3, x4, y4);
}



Measured memory_bytes: 256
import numpy as np

def f(a, b, c): 
    return a*a + b*b + c*c + a*b + b*c + c*a

def tansaku(N, A):
    for i in range(1, 101):
        for j in range(i, 101):
            for k in range(j, 101):
                n = f(i, j, k)
                if(n>N):
                    break;
                if((i==j) and (j==k)):
                    A[n] += 1
                if((i==j) and (j!=k)):
                    A[n] += 3
                if((i!=j) and (j==k)):
                    A[n] += 3
                if((i!=j) and (j!=k)):
                    A[n] += 6
    return A

def main():
    N = int(input())
    A = np.zeros(N+1)
    A = tansaku(N, A)
    for i in range(1,N+1):
        print('{:d}'.format(int(A[i])))


main()


Measured memory_bytes: 26908
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    int n,h;
    scanf("%d",&n);
    int now=0,ans=0;
    for(int i=0;i<n;i++){
         scanf("%d",&h);
         if(now<=h)
            ans++;
         now=max(h,now);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef pair<int, int> pa;
typedef vector<pair<int,int> > vepa;
typedef map<int, int> mp;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
ll cnt[N]={};
bool f;
int main()
{

  int n,m;
  cin>>n>>m;
  ve v(m);
  if(n>=m)
  {
      puts("0");
      go;
  }
  for(int i=0;i<m;i++)
    cin>>v[i];
  sort(all(v));
  ve def(m-1);
  for(int i=0;i<m-1;i++)
  {
      def[i]=(v[i+1]-v[i]);
  }
  sort(all(def));
  int ans=0;
  for(int i=0;i<(m-n);i++)
  {
      ans+=def[i];
 // cout<<def[i]<<" ";
  }
  cout<<ans;

go;
}


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

int main(){
  int A, B, C; cin >> A >> B >> C;
  int a=A;
  int b=B;
  int c=C;
  int ans=0;
  while(true){
    if(a%2==1 || b%2==1 || c%2==1){
      break;
    }
    if(a==b && b==c){
      cout << -1 << endl;
      return 0;
    }
    a=(B+C)/2;
    b=(A+C)/2;
    c=(A+B)/2;
    A=a;
    B=b;
    C=c;
    ans++;
  }
  cout << ans << endl;
}

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

int main(){
    vector<int> x(5);
    int idx;
    int min = 10;
    int ans = 0;
    for(int i = 0; i < 5; i++){
        cin >> x.at(i);
        if (min > x.at(i) % 10 && x.at(i) % 10 != 0) {
            idx = i;
            min = x.at(i) % 10;
        }
    }
    for(int i = 0; i < 5; i++){
        if(i != idx && x.at(i) % 10 != 0){
            ans += x.at(i) + (10 - (x.at(i) % 10));
        }
        else{
            ans += x.at(i);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
I = input().split()
a = [int(x) for x in I]
ans = 10**20
for i in range(0, 2):
    for j in range(i+1, 3):
        s = a[i]*a[j]
        k = 3-(i+j)
        A = s*((a[k]+1)//2)
        B = s*((a[k])//2)
        ans = min(ans, A-B)
print(ans)


Measured memory_bytes: 3060
n = int(input())
s = str(input())
def sc(n,l):
  al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  for i in range(26):
    if l == al[i]:
      return al[(i+n)%26]
for i in range(len(s)):
  print(sc(n,s[i]),end="")
  
 
  
  

Measured memory_bytes: 4468
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	ll n;cin>>n;
 	if(n<=9) cout<<n;
 	else if(n>9 &&n<=99) cout<<9;
 	else if(n>=100 &&n<=999) cout<<(n-100+1+9);
 	else if(n>999 &&n<=9999) cout<<909;
 	else if(n>=10000 &&n<=99999) cout<<(909+n-10000+1);
 	else cout<<(909+90000);
	
	
	
	
 return 0;
}

Measured memory_bytes: 256
from collections import deque

N, Q = map(int, input().split())

# ノードaがノードbの親とは限らない点に注意
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[b-1].append(a-1)
    tree[a-1].append(b-1)

counter = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

# BFSで親ノードの値を子ノードに足していく
# ノードのインデックスが0以外不規則であるかもしれないので、隣接ノードのうち親ノードでないノードを子ノードと考える
point = deque()
for child in tree[0]:
    point.append([0,child])

while point:
    parent, current = point.popleft()
    counter[current] += counter[parent]
    for child in [x for x in tree[current] if x != parent]:
        point.append([current, child])

print(*counter)

Measured memory_bytes: 63248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct qeu{
  int n;
  char name[10];
}Qeu;
void init();
void enque(Qeu);
Qeu deque();

int head,tail;
Qeu Qo[100000];

void init(){
  head = 0;
  tail = 0;
}

void enque(Qeu Q){
  Qo[tail++] = Q;
  tail = tail % 100000;
}

Qeu deque(){
  Qeu x;
  x = Qo[head];
  head++;
  head = head %100000;
  return x;
}

int mini(int a,int b){
  if(a<b) return a;
  else return b;
}
  
int main(){
  Qeu Q,Qt[1000],Qnow;
  int i,n,time;
  int total,tt;
  total = 0;
  scanf("%d %d",&n,&time);

  for(i=0;i<n;i++){
    scanf("%s %d",Q.name,&Q.n);
    enque(Q);
  }
  while(1){
    if(head == tail) break;
    Qnow = deque();
    tt = mini(Qnow.n,time);
    Qnow.n -= tt;
    total += tt;
    if(Qnow.n == 0){
      printf("%s %d\n",Qnow.name,total);
    }
    else{
      enque(Qnow);
    }
  }
  return 0;
}

Measured memory_bytes: 4128
#include<stdio.h>

#define N 25
#define Gard -1

typedef struct{
  int parent;
  int leftch;
  int rightch;
}Tree;

Tree PreT[N];
Tree InT[N];
Tree PostT[N];

void Pre(int );
void In(int );
void Post(int );

int main(){
  int loop,freq,leftnum,rightnum;
  int i;
  int cheker1=0;
  int cheker2=0;
  int cheker3=0;

  scanf("%d",&loop);
  for(i=0;i<loop;i++){
    PreT[i].parent=Gard;
    InT[i].parent=Gard;
    PostT[i].parent=Gard;
  }

  for(i=0;i<loop;i++){
    scanf("%d %d %d",&freq,&leftnum,&rightnum);

    PreT[freq].leftch=leftnum;
    PreT[freq].rightch=rightnum;
    
    InT[freq].leftch=leftnum;
    InT[freq].rightch=rightnum;

    PostT[freq].leftch=leftnum;
    PostT[freq].rightch=rightnum;

    if(leftnum!=Gard){
      PreT[leftnum].parent=freq;
      InT[leftnum].parent=freq;
      PostT[leftnum].parent=freq;
    }

    if(rightnum!=Gard){
      PreT[rightnum].parent=freq;
      InT[rightnum].parent=freq;
      PostT[rightnum].parent=freq;
    }
  }

  for(i=0;i<loop;i++){

    if(PreT[i].parent==Gard){
      cheker1=i;
    }

    if(InT[i].parent==Gard){
      cheker2=i;
    }

    if(PostT[i].parent==Gard){
      cheker3=i;
    }
    
  }

  printf("Preorder\n");

  Pre(cheker1);

  printf("\n");

  printf("Inorder\n");

  In(cheker2);

  printf("\n");

  printf("Postorder\n");

  Post(cheker3);

  printf("\n");
  
  return 0;
}

void Pre(int judge){

  if(judge==Gard){
    return;
  }

  printf(" %d",judge);

  Pre(PreT[judge].leftch);

  Pre(PreT[judge].rightch);
  
}

void In(int judge){

  if(judge==Gard){
    return;
  }

  In(InT[judge].leftch);

  printf(" %d",judge);

  In(InT[judge].rightch);
   
}

void Post(int judge){

  if(judge==Gard){
    return;
  }

  Post(PostT[judge].leftch);

  Post(PostT[judge].rightch);

  printf(" %d",judge);
  
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll  long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define all(a) a.begin(),a.end()
//#define int ll
#define vvi vector<vector<int>>
using namespace std;
using namespace __gnu_pbds;
typedef tree <pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll const mod=1e9+7;
int powi(int i,int b){
    int res=1;
    while(b){
        if(b&1)res*=i,res%=mod;
        b>>=1;
        i*=i;
        i%=mod;
    }
    return res;
}
// map<int,int> m;
// ll fact(int n){
// 	//if(n==0)return 0;
// 	if(n<=1)return 1;
// 	if(m[n]!=0)return m[n];
// 	return (n*fact(n-1))%mod;
// }
// int ncr(int n,int r){
//     int h=fact(n);
//     int v=fact(r);
//     int j=fact(n-r);
//     v*=j;
//     v%=mod;
//     v=powi(v,mod-2);
//     return (h*v)%mod;
// }
// vi ar(2000000);
// vi sz(2000000);
// int root(int a){
//     if(ar[a]==a)return a;
//     return ar[a]=root(ar[a]);
// }
// int merge(int a,int b){
//     int h=root(a),j=root(b);
//     int ans=sz[h]*sz[j];
//     sz[j]+=sz[h];
//     if(h!=j){
//         ar[h]=j;
//     }
//     return ans;
// }
void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int g=ceil((double)c/b),h=ceil((double)a/d);
    if(g<=h){
        cout<<"Yes";
    }else {
        cout<<"No";
    }

}
signed main(){
    boost;
    int t=1;
    //cin>>t;
    for(int _=1;_<=t;_++){
        //cout<<"Case #"<<_<<": ";
        solve();
        cout<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 3652
n = int(input())

a = [] #monster
a_li = input().split()

b = []
b_li = input().split()

for i in range(n):
    a.append(int(a_li[i]))
    b.append(int(b_li[i]))
a.append(int(a_li[n]))

ans = 0

sub = [0 for i in range(n)]
for i in range(n):
    if a[i] >= b[i]:
        ans += b[i]
    else:
        ans += a[i]
        sub[i] = b[i] -a[i]
        
    if sub[i] != 0:
        if sub[i] >= a[i+1]:
            ans += a[i+1]
            a[i+1] = 0
        else:
            ans += sub[i]
            a[i+1] = a[i+1] - sub[i]
            

print(ans)
        
    

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

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

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

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

	if (s[0] == s[1] && s[0] == s[2] && s[1] == s[2])
		cout << "No" << endl;
	else
		cout << "Yes" << endl;



	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int student[5], total;

	total = 0;
	for (int i = 0; i < 5; i++){
		cin >> student[i];
		if (student[i] < 40){
			student[i] = 40;
		}
		total += student[i];
	}

	cout << total / 5 << endl;

	return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>



using namespace std;

bool hebi_a(string hebi){
    if(!(hebi[0]=='>' && hebi[1]=='\''))return false;
    if(hebi[2]!='=')return false;
    
    int now=3;
    int count=1;
    
    while(1){
        if(hebi[now]=='#'){
            now++;
            break;
        }else if(hebi[now]=='='){
            now++;
            count++;
        }else{
            return false;
        }
    }
    
    while(now!=hebi.length()){
        if(hebi[now]=='='){
            now++;
            count--;
        }else if(hebi[now]=='~'){
            now++;
            break;
        }else{
            return false;
        }
    }
    if(now==hebi.length()&& count==0)return true;
    else return false;
}


bool hebi_b(string hebi){
    if(!(hebi[0]=='>' && hebi[1]=='^'))return false;
    if(hebi[2]!='Q')return false;
    if(hebi[3]!='=')return false;
    int now=4;
    while(1){
        if(hebi[now]!='Q'){
            break;
        }else{
            now++;
        }
        
        if(now==hebi.length())return false;
        
        if(hebi[now]!='='){
            return false;
        }else{
            now++;
        }
        
        if(now==hebi.length())return false;
    }
    if(now==hebi.length())return false;
    
    if(hebi[now]!='~')return false;
    now++;
    if(now==hebi.length())return false;
    if(hebi[now]!='~')return false;
    now++;
    if(now==hebi.length())return true;
    else return false;

}


int main(){
    int n;
    cin>>n;
    for(int roop=0; roop<n; roop++){
        string hebi;
        cin>>hebi;
        if(hebi_a(hebi))cout<<"A"<<endl;
        else if(hebi_b(hebi))cout<<"B"<<endl;
        else cout<<"NA"<<endl;
        
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <set>
#include <queue>
#include <unordered_map>

#define X first
#define Y second
#define mp std::make_pair
#define MAX_N 100010
typedef std::pair <int, int> pii;

int n, sz[MAX_N], fa[MAX_N];
std::set <int> S[MAX_N];
std::unordered_map <int, std::unordered_map<int, int> > cnt;
std::queue <pii> q;

int getfa(int x){
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		sz[i] = 1, fa[i] = i;
	for(int i = 1, x, y; i <= 2 * n - 2; i++){
		scanf("%d%d", &x, &y);
		S[x].insert(y); S[y].insert(x);
		cnt[x][y]++, cnt[y][x]++;
		if(cnt[x][y] == 2) q.push(mp(x, y));
	}
	while(!q.empty()){
		int x = q.front().X, y = q.front().Y;
		q.pop();
		x = getfa(x), y = getfa(y);
		if(x == y) continue;
		S[x].erase(y), S[y].erase(x);
		if(sz[x] < sz[y]) std::swap(x, y);
		for(auto i: S[y]){
			S[i].erase(y); S[i].insert(x);
			S[x].insert(i);
			cnt[i][x]++, cnt[x][i]++;
			cnt[i][y] = cnt[y][i] = 0;
			if(cnt[i][x] == 2) 
				q.push(mp(i, x));
		}
		sz[x] += sz[y], fa[y] = x; 
		S[y].clear();
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) 
		cnt += fa[i] == i;
	puts(cnt > 1 ? "NO" : "YES");
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll M = 1000000007;

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

	ll n;
	cin >> n;

	string s1;
	cin >> s1;

	string s2;
	cin >> s2;

	if(n == 1) {
		cout << 3 << endl;
		return 0;
	}

	ll ans = 1;
	ll p = 0;

	bool befhori = false;

	if(s1[p] == s1[p+1]) {
		ans *= 6;
		ans %= M;
		p += 2;
		befhori = true;
	}else{
		ans *= 3;
		ans %= M;
		p++;
		befhori = false;
	}

	while(p<n){
		if(p+1<n && s1[p] == s1[p+1]){
			if(befhori) ans *= 3;
			else ans *= 2;
			ans %= M;
			p += 2;
			befhori = true;
		}else{
			if(befhori) ans *= 1;
			else ans *= 2;
			ans %= M;
			p++;
			befhori = false;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int s;
    scanf("%d",&s);
    int tmp = s%10;
    s /= 10;
    for(int i = 0;i < 3;i++){
        if(tmp == s % 10){
            printf("Bad");
            return 0;
        }
        tmp = s%10;
        s /= 10;
    }
    printf("Good");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,a,i,s,ans=0;
  cin >> n;
  for (i=1;i<=n;i++){
    s=0;
    a=i;
    while (a){
      a/=10;
      s++;
    }
    if (s%2) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    vector<int> A(n);
    for(int i=0;i<n;i++) cin>>A[i];
    
    int num=0;
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(A[j]<A[minj]){
                minj=j;
            }
        }
        swap(A[i],A[minj]);
        if(i!=minj) num++;
    }
    
    for(int i=0;i<n-1;i++) cout<<A[i]<<" ";
    cout<<A[n-1]<<endl<<num<<endl;
    
    return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
    char ch;

    while(1){
        scanf("%c", &ch);
        
        if ( ch == '\n' ) break;
        
        if(isalpha(ch)){
            if(islower(ch)){
                printf("%c", toupper(ch));
            }
            
            else if(isupper(ch)){
                printf("%c", tolower(ch));
            }
        }
        
        else{
            cout << ch;
        }
    }
    cout << endl;
}


Measured memory_bytes: 3140
s=int(input())
if s<3:
    print(0)
else:
    f=[0]*4001
    f[0]=1
    f[1]=1
    for i in range(2,4001,1):
        f[i]=f[i-1]*i
    t=0
    w=s
    for i in range(1,s//3+1,1):
        w-=3
        t+=f[w+i-1]//(f[w]*f[i-1])%(10**9+7)
        t%=10**9+7
    print(t)

Measured memory_bytes: 19556
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#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 int long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9;
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, s;
    cin >> n >> k >> s;
    vector <int> a(n);
    for (int i = 0; i < k; i++) a[i] = s;
    int val = INF;
    if (INF == s) val = INF - 1;
    for (int i = k; i < n; i++) {
        a[i] = val;
    }
    for (auto &i : a) cout << i << ' ';
    cout << '\n';
}


Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n >> s;
    
    int count, mincount;
    int i;
    count = 0;
    mincount = 0;
    
    // 1人目がリーダーの場合
    for(i = 1; i < n; i++){
        if(s[i] == 'E'){
            count++;
        }
    }
    mincount = count;
    
    // 2人目以降がリーダーの場合の人数を直前のケースから求める
    for(i = 1; i < n; i++){
        if(s[i - 1] == 'W'){
            count++;
        }
        if(s[i] == 'E'){
            count--;
        }
        
        if(count < mincount){
            mincount = count;
        }
    }
    
    cout << mincount << endl;
    return 0;
}

Measured memory_bytes: 900
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
using namespace std;

long long int N, M;


int main(){

    int res = 1;

    cin >> N;
	vector<string> S(N);

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

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

    string tmp = S[0];
    for(int i=1;i<N;i++){
        if(tmp != S[i]){
            res++;
        }
        tmp = S[i];
    }

    cout << res;
}   

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

int main(){
    int N;
    int a[110];
    cin>>N;
    for(int i=0; i<N; ++i) cin>>a[i];

    sort(a,a+N,greater<int>());

    int Alice=0;
    int Bob=0;

    for(int i=0; i<N; ++i){
        if (i%2==0){
            Alice += a[i];
        }
        else {
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        ll n;
        string s ;
        cin >> n >> s;
        ll ans = 0;
        REP(i,0,SIZE(s)-2){
                if(s[i] != s[i+1]){
                        ans ++;
                }
        }
        cout << ans  + 1 << endl;
}

Measured memory_bytes: 512
def binary(n):
    return bin(n)[2:]


# バイナリ法
def pow_by_binary_exponentiation(a, x, n):  # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


# nCr mod m
# modinvが必要
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9 + 7):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i + 1, mod) % mod
    return res


n, a, b = map(int, input().split())

mod = 10**9 + 7
S = pow_by_binary_exponentiation(2, n, mod) - 1
A = combination(n, a, mod)
B = combination(n, b, mod)

ans = (S - A - B) % mod
if ans < 0:
    ans += mod
print(ans % mod)


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

#define int int_least64_t

int sum_modeq(int l, int r, int n, int rem) {
  int d = n%l;
  l += max((int)0, d/rem-1);
  if (l<r && n%l == rem)
    return l;
  else
    return 0;
}

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int n; cin >> n;
  int m=1;
  int ans=0;
  while (m < n) {
    int rr=n/(n/m), ll=n/(n/m+1)+1;
    ans += sum_modeq(ll, rr+1, n, n/ll);
    m = rr+1;
  }
  cout << ans << '\n';
}



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

int main()
{
    int N, tmp;
    int d = 0;
    map<long, int> m;
    int ans = 0;

    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> tmp;
        m[tmp]++;
    }

    for(auto itr = m.rbegin(); itr != m.rend(); itr++) {
        /*
        cout << "---" << endl;
        for(auto itr2 = m.begin(); itr2 != m.end(); itr2++) {
            cout << itr2->first << " ";
        }
        cout << endl;
        cout << "---" << endl;
        */
        long v = itr->first;
label:
        //cout << "v: " << v << endl;
        for(int t = 1; t <= 32; t++) {
            long val = pow(2, t);
            if(v <= val && val <= v * 2) {
                //cout << "val = " << val << endl;
                if(m.find(v) != m.end() && m[v] > 0 && m.find(val - v) != m.end() && m[val - v] > 0) {
                    if(val - v == v) {
                        if(m[v] < 2) {
                            continue;
                        }
                    }
                    //cout << "hit = " << v << ", " << val - v << endl;
                    m[val - v]--;
                    m[v]--;
                    ans++;
                    if(m[v] > 0) {
                        goto label;
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12800
#include <iostream>

using namespace std;

int main(){
  int a, b, c;
  std::cin >> a >> b >> c;
  if(a <= c && b <= c){
    std::cout << c*10 + a + b << '\n';
  }else if(a <= b && c <= b){
    std::cout << b*10 + a + c << '\n';
  }else{
    std::cout << a*10 + c + b << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mo = 1e9 + 7;
const int MAXN = 2e3 + 10;
typedef long long ll;
int n, m, cnt, flag1, flag2, s1, s2;
ll k;
char s[MAXN][MAXN];
template <class T>
inline void _read(T &x)
{
	x = 0;
	char t = getchar();
	while (!isdigit(t) && t != '-') t = getchar();
	if (t == '-')
	{
		_read(x);
		x *= -1;
		return ;
	}
	while (isdigit(t))
		x = x * 10 + t - '0', t = getchar();
}
ll fpm(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1) res = res * a % mo;
		a = a * a % mo;
		b >>= 1;
	}
	return res;
}
struct mat
{
	ll a[3][3];
	mat()
	{
		memset(a, 0, sizeof(a));
	}
	mat operator *(mat &m)
	{
		mat ans;
		for(int i = 1; i <= 2; ++i)
			for(int j = 1; j <= 2; ++j)
				for(int k = 1; k <= 2; ++k)
					ans.a[i][j] = (ans.a[i][j] + a[i][k] * m.a[k][j] % mo) % mo;
		return ans;
	}
};

int main()
{
	_read(n), _read(m), _read(k);
	for(int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j <= m; ++j)
			if(s[i][j] == '#')
			{
				++cnt;
				s1 += s[i][j - 1] == '#';
				s2 += s[i - 1][j] == '#';
			}
		if(s[i][1] == '#' && s[i][m] == '#')++flag1;
	}
	for(int i = 1; i <= m; ++i)if(s[1][i] == '#' && s[n][i] == '#')++flag2;
	if(flag1 && flag2)
	{
		puts("1");
		return 0;
	}
	if(!flag1 && !flag2)
	{
		printf("%lld\n", fpm(cnt, k - 1));
		return 0;
	}
	if(!flag1)swap(flag1, flag2), swap(s1, s2);
	mat A;
	A.a[1][1] = cnt;
	A.a[2][1] = s1;
	A.a[2][2] = flag1;
	--k;
	mat res;
	res.a[1][1] = res.a[2][2] = 1;
	while(k)
	{
		if(k & 1)res = res * A;
		A = A * A;
		k >>= 1;
	}
	printf("%lld\n", (res.a[1][1] - res.a[2][1] + mo) % mo);
	return 0;
}

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

using namespace std;

int main(){

  double l;
  double r;

  int l_a=0;
  int l_b=0;
  int l_c=0;
  int l_d=0;
  int r_a=0;
  int r_b=0;
  int r_c=0;
  int r_d=0;
  
  while(cin>>l>>r){

	if(l>=1.1)
	  l_a++;
	else if(l>=0.6 && l<1.1)
	  l_b++;
	else if(l>=0.2 && l<0.6)
	  l_c++;
	else if(l<0.2)
	  l_d++;

	if(r>=1.1)
	  r_a++;
	else if(r>=0.6 && r<1.1)
	  r_b++;
	else if(r>=0.2 && r<0.6)
	  r_c++;
	else if(r<0.2)
	  r_d++;
	
  }

  cout<<l_a<<" "<<r_a<<endl;
  cout<<l_b<<" "<<r_b<<endl;
  cout<<l_c<<" "<<r_c<<endl;
  cout<<l_d<<" "<<r_d<<endl;
  
}



Measured memory_bytes: 3152
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var s = Console.ReadLine();
            string ans = "";
            foreach (char c in s)
            {
                if (c == '1')
                {
                    ans += "9";
                }
                else
                {
                    ans += "1";
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>


int main()
{
	int sum;
	char str[1000];

	while (true)
	{
		scanf("%s", str);

		if (str[0] == '0') {
			break;
		}

		sum = 0;
		for (int i = 0;i < strlen(str);i++) {
			sum += str[i] - '0';
		}

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

	}

    return 0;
}



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

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc=new Scanner(System.in);
		Reader reader=new Reader();
		int t=1;//sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			long mod=(long)1e9+7;
			//System.out.println(mod);
			long[] arr=new long[n];
			long[] suff=new long[n];
			for(int i=0;i<n;i++) {
				arr[i]=sc.nextLong();
			}
			suff[n-1]=arr[n-1];
			for(int i=n-2;i>=0;i--) {
				suff[i]=suff[i+1]+arr[i];
				suff[i]%=mod;
			}
			long ans=0;
			for(int i=0;i<n-1;i++) {
				ans=(ans+arr[i]*1l*(suff[i+1]))%mod;
				//ans%=mod;
			}
			System.out.println(ans);
		}
	}
}
class Reader{
	BufferedReader reader;
	Reader(){
		reader=new BufferedReader(new InputStreamReader(System.in));
	}
	int nextInt() throws IOException{
		String in=reader.readLine().trim();
		return Integer.parseInt(in);
	}
	long nextLong() throws IOException{
		String in=reader.readLine().trim();
		return Long.parseLong(in);
	}
	String next() throws IOException{
		return reader.readLine().trim();
	}
	String[] stringArray() throws IOException{
		return reader.readLine().trim().split("\\s+");
	}
	int[] intArray() throws IOException{
		String[] inp=this.stringArray();
		int[] arr=new int[inp.length];
		int i=0;
		for(String s:inp) {
			arr[i++]=Integer.parseInt(s);
		}
		return arr;
	}
}


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

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int cnt = 0;
    while(true){
        if(cnt%2 == 0) {
            c -= b;
            if(c <= 0){
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            a -= d;
            if(a <= 0){
                cout << "No" << endl;
                return 0;
            }
        }
        cnt++;
    }

    return 0;
}

Measured memory_bytes: 3616
sx, sy, tx, ty = map(int, input().split())
h = tx - sx # 横
v = ty - sy # 縦

ans = 'R' * h + 'U' * v + 'L' * h + 'D' * v + 'D' * 1 + 'R' * (h + 1) + 'U' * (v + 1) + 'L' * 1 + 'U' * 1 + 'L' * (h + 1) + 'D' * (v + 1) + 'R' * 1
print(ans)

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


void solve(std::vector<long long> A){
    cout << ((A[0] + A[1] + A[2] >= 22) ? "bust" : "win");
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;
	string s,t;
	cin >> s >> t;

	int p;
	for(int i=N; i<=2*N; i++){
		for(p=0; p<2*N-i; p++){
			if(s.at(p+i-N)!=t.at(p)){
				break;
			}
		}
		if(p==2*N-i){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256