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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int main()
{
    int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    int w,h;
    while(cin >>w >>h)
    {
        vector<string> s(h);
        rep(i,h) cin >>s[i];
        int n;
        scanf(" %d", &n);
        vector<int> x(n),y(n);
        rep(i,n) scanf(" %d %d", &x[i], &y[i]);

        pi g;
        rep(i,h)rep(j,w) if(s[i][j]=='t') g=pi(i,j);

        int ans=-1;
        #define IN(x,y) (0<=x && x<w && 0<=y && y<h)
        vector<vector<bool>> vis(h,vector<bool>(w,false));
        vis[0][0]=true;
        queue<pi> que;
        que.push(pi(0,0));
        rep(i,n+1)
        {
            while(!que.empty())
            {
                pi now=que.front();
                que.pop();
                if(now==g)
                {
                    ans=i;
                    break;
                }
                rep(j,4)
                {
                    int nx=now.se+dx[j],ny=now.fi+dy[j];
                    if(IN(nx,ny) && s[ny][nx]!='#' && !vis[ny][nx])
                    {
                        vis[ny][nx]=true;
                        que.push(pi(ny,nx));
                    }
                }
            }

            if(i==n || ans>=0) break;

            s[y[i]][x[i]]='.';
            rep(j,4)
            {
                int tx=x[i]+dx[j],ty=y[i]+dy[j];
                if(IN(tx,ty) && vis[ty][tx] && !vis[y[i]][x[i]])
                {
                    vis[y[i]][x[i]]=true;
                    que.push(pi(y[i],x[i]));
                }
            }
        }

        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,m,ans = 0,sum = 0;
	vector<P> vec;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		vec.pb(P(a,b));
	}
	sort(all(vec));
	for(P p : vec){
		if(sum + p.second >= m){
			ans += p.first * (m - sum);
			break;
		}else ans += p.first * p.second;
		sum += p.second;
	}
	cout << ans << endl;
} 

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

 

int main() {
	int N, M, X, Y; cin >> N >> M >> X >> Y;
	int maxX=X, minY=Y;

	for (int i = 0; i < N; i++) {
		int ipts;
		cin >> ipts;
		maxX = max(maxX, ipts);
	}
	for (int i = 0; i < M; i++) {
		int ips;
		cin >> ips;
		minY = min(minY, ips);
	}
	if (maxX < minY)print("No War"); else print("War");


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  int max = a;
  if (b > max) {
    max = b;
  }
  if (c > max) {
    max = c;
  }
  int area = a*b*c/max;
  area /= 2;
  printf("%d\n", area);

  return 0;
}

Measured memory_bytes: 128
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    b = list(map(int, readline().split()))
    a = [0] * n
    for i in range(n):
        if i == 0:
            a[i] = b[i]
        elif i == n - 1:
            a[i] = b[i-1]
        else:
            a[i] = min(b[i], b[i-1])
    print(sum(a))


if __name__ == '__main__':
    solve()


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for (auto& x : m) cin >> x;
  sort(m.begin(), m.end());
  for (int i = 1; i < N; ++i) m[i] += m[i - 1];
  cout << (N + (X - m[N - 1]) / m[0]) << endl;
}


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

int main()
{
    long long p,ft=0,f=0,r=0;
    cin>>p;

    r=p%500;
    ft= p/500;
    f=r/5;

    cout<<ft*1000+f*5<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n, p; string s; 

void solve()
{
    vector <pair<string,int>> v;
    cin >> n; 
    map <int, int> m;
    for (int i=0; i<n; i++) {
        cin >> s >> p;
        v.pb({s,p});
        m.insert({p,i+1});
    }
    sort(v.begin(),v.end());
    string temp;
    priority_queue <int> q;
    temp = v[0].first;
    q.push(v[0].second);
    for (int i=1; i<v.size(); i++) {
        if (v[i].first == temp) {
            q.push(v[i].second);
        }else {
            while (!q.empty()) {
                nout(m.at(q.top()));
                q.pop();
            }
            q.push(v[i].second);
            temp = v[i].first;
        }
    }
    while (!q.empty()) {
                nout(m.at(q.top()));
                q.pop();
            }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i=0, c=T[u].l; c != NIL; i++,c=T[c].r) {
        if(i) cout << ", ";
        cout << c;
    }

    cout << "]" << endl;

}

void rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r, p);
    if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;

    for (i=0; i<n; i++) {
        cin >> v >> d;
        for(j=0; j<d; j++){
            cin >> c;
            if(j==0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(i=0;i<n;i++){
        if(T[i].p == NIL) r = i;
    }
    rec(r, 0);
    for(i=0;i<n;i++) print(i);
    return 0;
}

Measured memory_bytes: 7744
#include<stdio.h>
int main(void)
{

    int   i ,j ,k ,c ;

    int a[100],b[100];

    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);

    }

    for(;;)
    {
        k=1;
    for(i=0;i<9;i++)
    {
        if(a[i] < a[i+1])
        {
            c=a[i];
            a[i]=a[i+1];
            a[i+1]=c;
            k=0;
        }

    }
    if(k==1)
        break;

    }

for(i=0;i<3;i++)
    printf("%d\n",a[i]);
return 0;

}

Measured memory_bytes: 600
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
struct Edge{
  ll to,dist;
};
ll N;
ll d[2000];
vector<Edge> G[2000];

void dijkstra(ll u){
  REP(i,N)d[i]=INF;
  priority_queue<P,vector<P>,greater<P>> que;
  que.push({0,u});
  while(!que.empty()){
    auto r=que.top();que.pop();
    if(r.first>=d[r.second])continue;
    d[r.second]=r.first;
    
    for(Edge& e: G[r.second]){
      ll dist=d[r.second]+e.dist;
      if(dist>=d[e.to])continue;
      que.push({dist,e.to});
    }
  }
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll X,Y;
  cin>>N>>X>>Y;
  X--;Y--;
  REP(i,N-1)G[i].push_back({i+1,1});
  RREPS(i,N-1)G[i].push_back({i-1,1});
  G[X].push_back({Y,1});
  G[Y].push_back({X,1});
  
  ll cnt[N];REP(i,N)cnt[i]=0;
  REP(i,N){
    dijkstra(i);
    REP(j,N){
      //cout<<d[j]<<" ";
      cnt[d[j]]++;
    }//cout<<"\n";
  }
  REPS(i,N-1){
    cout<<cnt[i]/2<<"\n";
  }
  return 0;
}


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

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int maxn = 500005;

char s[maxn];
int mnL[maxn], mnR[maxn];
int n;

int main()
{
	scanf("%s", s);
	n = strlen(s);
	for (int i = 0; i < n; i++)
	{
		if (s[i] == '<') mnL[i + 1] = mnL[i] + 1;
		else mnL[i + 1] = 0;
	}
	for (int i = n - 1; i >= 0; i--)
	{
		if (s[i] == '>') mnR[i] = mnR[i + 1] + 1;
		else mnR[i] = 0;
	}
	ll answer = 0;
	for (int i = 0; i <= n; i++) answer += max(mnL[i], mnR[i]);
	cout << answer << endl;
    return 0;
}


Measured memory_bytes: 4608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String s;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.s = sc.next();
    }
    
    //解答処理
    private String solve() {
        String answer = "";
        for (int i=0; i<s.length(); i++) {
        	if (s.charAt(i) == '0') {
        		answer += "0";
        	} else if (s.charAt(i) == '1') {
        		answer += "1";
        	} else if (s.charAt(i) == 'B' && answer.length() >= 1) {
        		answer = answer.substring(0,answer.length()-1);
        	}
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 38516
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  string T;
  cin >> S;
  cin >> T;
  int count = 0;
  int size = S.size();
  for(int i = 0;i < size;i++){
    if(S.at(i) != T.at(i)){
      count += 1;
    }
  }
  cout << count << endl;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = - K + 1; i < K; i++) {
    if (i == K - 1) {
      cout << X + i <<endl;
    }
    else {
      cout << X + i << " ";
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std;

const int N=1e5+50,oo=1e9; 

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

struct P { int x,y; };
bool operator<(P a,P b){ return a.x==b.x?a.y<b.y:a.x<b.x; }
P mp(int a,int b){ return (P){a,b}; }

P a[N]; 
int n,m,c[N],cov[N],cnt[N]; 
bool fail,sid[N]; 
priority_queue<P> q;
vector<P> rng[N]; 

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin); 
#endif
	read(n);
	m=n+1; 
	rep(i,1,n){
		read(a[i].x);
		read(a[i].y); 
	}
	rep(i,1,m)read(c[i]); 
	sort(c+1,c+m+1); 
	rep(i,1,n){
		a[i].x=lower_bound(c+1,c+m+1,a[i].x)-c; 
		a[i].y=lower_bound(c+1,c+m+1,a[i].y)-c; 
	}
	mem(sid,true); 
	rep(i,1,m)cov[i]=0;
	rep(i,1,n)cov[a[i].x-1]--;
	rep(i,1,n)rng[a[i].x-1].pb(mp(-a[i].y,i));
	int delta=0; 
	cov[m+1]=n;
	dec(i,m,1){
		int len=rng[i].size();
		lop(j,0,len)q.push(rng[i][j]); 
		cov[i]+=cov[i+1];
		cnt[i]=cov[i]-i;
		while(cnt[i]<-1){
			if(q.empty()||-q.top().x>i){
				fail=true;
				break;
			}else{
				P t=q.top(); 
				q.pop(); 
				sid[t.y]=false;
				++delta;
				++cov[i];
				++cnt[i]; 
				--cov[-t.x-1];
			}
		}
	}
	rep(i,0,m)cov[i]=0; 
	rep(i,1,n)++cov[sid[i]?a[i].x:a[i].y];
	rep(i,1,m){
		cov[i]+=cov[i-1];
		cnt[i]=cov[i]-i;
	}
	while(!q.empty())q.pop(); 
	rep(i,1,m)rng[i].clear(); 
	rep(i,1,n)if(sid[i])rng[a[i].y].pb(mp(a[i].x-1,i)); 
	int cur=0; 
	static int f[N]; 
	rep(i,1,m){
		int len=rng[i].size(); 
		lop(j,0,len)q.push(rng[i][j]); 
		f[i]=f[i-1];
		if(cnt[i]==-1){
			if(cur<i){
				if(q.empty()||q.top().x<i)f[i]=oo;
				else{
					P t=q.top(); 
					q.pop(); 
					cur=t.x;
					++f[i]; 
				}
			}
		}
	}
	int q; 
	read(q); 
	while(q--){
		int a,b;
		read(a); 
		read(b); 
		a=lower_bound(c+1,c+(m)+1,a)-c; 
		b=lower_bound(c+1,c+(m)+1,b)-c;
		if(fail)puts("-1"); 
		else{
			int x=f[a-1]+delta,y=f[b-1]+delta;
			int res=min(x,y+1); 
			printf("%d\n",res>m?-1:m-res);	
		}
	}
	return 0; 
}

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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 5;

vector<int> G[N];
ll n, a[N], I[N], ans[N];

void solve(int u, int lis = 0, int p = -1) {
    int idx = lower_bound(I, I + N, a[u]) - I;
    int v = I[idx];
    I[idx] = a[u];
    lis = max(idx, lis);
    ans[u] = lis;
    for (auto to : G[u]) {
        if (to != p) 
            solve(to, lis, u);
    }
    I[idx] = v;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    
    memset(I, 0x3F, sizeof(I));
    I[0] = -INF;

    cin >> n;

    for (int i = 0; i < n; ++i)
        cin >> a[i];

    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    solve(0);
    for (int i = 0; i < n; ++i)
        cout << ans[i] << endl;
}


Measured memory_bytes: 33652
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

const int inf = 1e9;
struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} };

template<class T> bool bellman_ford(int s, const VV<edge>& g, V<T>& d) {
  int n = g.size();
  d.assign(n, inf);
  d[s] = 0;
  for (int i = 0; i < n; i++) {
    bool upd = false;
    for (int v = 0; v < g.size(); v++) if (d[v] != inf) {
      for (auto&& e : g[v]) {
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          upd = true;
        }
      }
    }
    if (!upd) return false;
  }
  return true;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m, p; cin >> n >> m >> p;
  VV<edge> g(n);

  {
    V<> a(m), b(m), c(m); 
    VV<> h(n);
    for (int i = 0; i < m; ++i) {
      cin >> a[i] >> b[i] >> c[i], --a[i], --b[i];
      h[b[i]].push_back(a[i]);
    }

    bitset<2500> bs;
    auto dfs = [&](const auto& dfs, int v) -> void {
      bs[v] = true;
      for (int w : h[v]) if (!bs[w]) {
        dfs(dfs, w);
      }
    };
    dfs(dfs, n - 1);

    for (int i = 0; i < m; ++i) {
      if (!bs[a[i]] or !bs[b[i]]) continue;
      g[a[i]].emplace_back(edge{b[i], p - c[i]});
    }
  }

  V<lint> d;
  if (bellman_ford(0, g, d)) {
    cout << -1 << '\n';
  } else {
    cout << max(-d.back(), 0LL) << '\n';
  }
}

Measured memory_bytes: 640
a = input()

former = a[:2]
latter = a[2:]

months = ["01","02","03","04","05","06","07","08","09","10","11","12"]

if(former in months and latter in months):
	print('AMBIGUOUS')
elif(former in months and latter not in months):
	print('MMYY')
elif(former not in months and latter in months):
	print('YYMM')
elif(former not in months and latter not in months):
	print('NA')

Measured memory_bytes: 3188
#include<stdio.h>
int hanshu(int x,int y)
{
	int t=0,n;
	for(int i=1,n=1;n<=100;i++)
	{
		n=x*i;
		if((n%x==0)&&(n%y!=0))
		{
			printf("%d",n);
			t=t+1;
			break;
		}
		
	}
    if(t==0)
	    return 0;
	else return 1; 
}
int main()
{
	int x,y;
	int m;
	scanf("%d%d",&x,&y);
	m=hanshu(x,y);
	if(m==0)
	printf("-1");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/**
void comb(vector<vector <ll> > &v) {
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

int main(){
	ll l,r;
	cin>>l>>r;
	ll ans=11000;
	ll stock =0;
	bool p =true;
	if(r-l>=2019)p=false;

	if(p){
		rep(i,l,r){
			rep(j,i+1,r+1){
				ans = min(ans, ((i%2019)*(j%2019))%2019);
				if(ans==0) break;
			}
		}
	}
	if(p)cout<<ans;
	else cout<<"0";
}




Measured memory_bytes: 256
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    ret=0
    k,s = map(int,input().split())
    for x in range(k+1):
        for y in range(k+1):
            if 0 <= s-x-y <= k:
                ret+=1
    print(ret)
 
if __name__=='__main__':
    main()

Measured memory_bytes: 3316
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 1e2 + 10;
const ll inf = (1ll << 62) + ((1ll << 62) - 1);

vector<int> g[N];
ll height[N], branch[N];
pii edge[N];

void dfs(int u, int p);

int main() {
	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);
		edge[i] = {u, v};
	}
	height[0] = 0;
	ll min_height = inf, min_leaves = inf;
	for (int i = 1; i <= n; ++i) {
		memset(branch, 0, sizeof(branch));
		dfs(i, 0);
		ll leaves = 1, cur_height = 0;
		for (int j = 1; j <= n; ++j) {
			cur_height = max(cur_height, height[j]);
		}
		for (int j = 1; j < cur_height; ++j) {
			leaves *= branch[j];
		}
		if (branch[1] == 1) {
			++leaves;
		}
		// cout << i << ' ' << cur_height << ' ' << leaves << endl;
		if (cur_height < min_height) {
			min_height = cur_height;
			min_leaves = leaves;
		} else if (cur_height == min_height and leaves < min_leaves) {
			min_leaves = leaves;
		}
	}
	for (int i = 1; i < n; ++i) {
		memset(branch, 0, sizeof(branch));
		int u, v;
		tie(u, v) = edge[i];
		height[v] = 0;
		dfs(u, v);
		height[u] = 0;
		dfs(v, u);
		height[u] = 1;
		ll leaves = 2, cur_height = 0;
		for (int j = 1; j <= n; ++j) {
			cur_height = max(cur_height, height[j]);
		}
		for (int j = 1; j < cur_height; ++j) {
			leaves *= branch[j];
		}
		// cout << i << ' ' << cur_height << ' ' << leaves << endl;
		if (cur_height < min_height) {
			min_height = cur_height;
			min_leaves = leaves;
		} else if (cur_height == min_height and leaves < min_leaves) {
			min_leaves = leaves;
		}
	}
	cout << min_height << ' ' << min_leaves << endl;
}

void dfs(int u, int p) {
	height[u] = 1 + height[p];
	ll children = 0;
	for (auto &v : g[u]) {
		if (v != p) {
			++children;
			dfs(v, u);
		}
	}
	branch[height[u]] = max(branch[height[u]], children);
}

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

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;
 

   int a[3];

   for(int i = 0 ; i < 3 ; ++i)
   	cin >> a[i];

   sort(a,a+3);


   if(a[0] == 5 && a[1] == 5 && a[2] == 7)
   	cout << "YES";
   else
   	cout << "NO";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int arr[n - 1];
    for (int i = 0; i < n - 1; i++) cin >> arr[i];
    int res = arr[0] + arr[n - 2];
    for (int i = 1; i < n - 1; i++) res += min(arr[i], arr[i - 1]);
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll x,y,z,n,m=0,k,h,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n >> k;
    if(k%2==0){
        for(ll i=1; i<=n;i++){
            if(i%k==0){
                ans++;
            }
            if(i%k==k/2){
                sum++;
            }
        }
        cout << ll(pow(ans,3)+pow(sum,3)) << endl;
        return 0;
    }
    else {
        for(ll i=1; i<=n;i++){
            if(i%k==0){
                ans++;
            }
        }
        cout << ll(pow(ans,3) )<< endl;
        return 0;
    }
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
v1 = [v[i] for i in range(n) if i % 2 == 0]
v2 = [v[i] for i in range(n) if i % 2 != 0]

c1 = Counter(v1)
c2 = Counter(v2)

c1 = sorted(c1.items(), key=lambda x:(x[1], -x[0]), reverse=True)
c2 = sorted(c2.items(), key=lambda x:(x[1], -x[0]), reverse=True)
ans = 0
if c1[0][0] != c2[0][0]:
    if len(c1) != 1:
        for k, v in c1[1:]:
            ans += v
    if len(c2) != 1:
        for k, v in c2[1:]:
            ans += v
    print(ans)
else:
    if len(c1) == 1 and len(c2) == 1:
        ans += n // 2
    elif len(c1) == 1 and len(c2) > 1:
        ans += len(v2) - c2[1][1]
    elif len(c1) > 1 and len(c2) == 1:
        ans += len(v1) - c1[1][1]
    else:
        if c1[1][1] < c2[1][1]:
            ans += len(v1) - c1[0][1]
            ans += len(v2) - c2[1][1]
        else:
            ans += len(v1) - c1[1][1]
            ans += len(v2) - c2[0][1]
    print(ans)


Measured memory_bytes: 67820
import java.util.ArrayDeque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        ArrayDeque<Integer> l = new ArrayDeque<>();
        for (int i = 0; i < c; i++) {
            String op = sc.next();
            switch (op) {
                case "insert":
                    l.push(sc.nextInt());
                    break;
                case "delete":
                    l.remove(sc.nextInt());
                    break;
                case "deleteFirst":
                    l.removeFirst();
                    break;
                case "deleteLast":
                    l.removeLast();
                    break;
            }
        }
        StringBuilder sb = new StringBuilder();
        sb.append(l.poll());
        for (int n : l) {
            sb.append(" ").append(n);
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 485028
N = int(input())
point = [0, 0]
t_list = []
ans = "Yes"
t = list(map(int, input().split()))
dis = abs(point[0]-t[1])+abs(point[1]-t[2])
t_list.append(t)
if t[0] < dis or t[0]%2!=dis%2:
    ans = "No"
point = [t[1], t[2]]
for i in range(N-1):
    t = list(map(int, input().split()))
    dis = abs(point[0]-t[1])+abs(point[1]-t[2])
    if t[0]-t_list[-1][0] < dis or (t[0]-t_list[-1][0])%2!=dis%2:
        ans = "No"
    point = [t[1], t[2]]
    t_list.append(t)
print(ans)

Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  ll n,d,c=0;
  cin>>n>>d;
  d=d*d;
  while(n--) {
  	ll x,y;
  	cin>>x>>y;
  	x=x*x;
  	y=y*y;
  	if(x+y<=d) { c++; }
  }
  cout<<c;
  //} 
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
  string line;
  getline(cin, line);
  const int N = stoi(line);
  getline(cin, line);

  vector<char> cands = {'S', 'W'};
  for(char first : cands)
  {
	for(char second : cands)
	{
	  vector<char> ans(N);
	  ans[0] = first;
	  ans[1] = second;
	  ans[N - 1] = ((ans[0] == 'S') ^ (line[0] == 'o') ^ (ans[1] == 'S') == true) ? 'S' : 'W';
	  
	  for(int i = 2; i < N - 1; i++)
	  {
		ans[i] = ((ans[i - 1] == 'S') ^ (line[i - 1] == 'o') ^ (ans[i - 2] == 'S') == true) ? 'S' : 'W';
	  }

	  // for(auto v : ans) cout << v << ", ";
	  // cout << endl;

	  if((((ans[N - 1] == 'S') ^ (line[N - 1] == 'o') ^ (ans[N - 2] == 'S') ^ (ans[0] == 'S')) == false) &&
		 (((ans[N - 2] == 'S') ^ (line[N - 2] == 'o') ^ (ans[N - 3] == 'S') ^ (ans[N - 1] == 'S')) == false))
	  {
		for(auto ch : ans) cout << ch;
		cout << endl;
		return 0;
	  }
	}
  }
  cout << -1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i=0;i<N;i++) {
        cin >> X[i];
    }
    
    ll ans=10000000000;
    for (int i=1;i<101;i++) {
        ll sum=0;
        for (int j=0;j<N;j++) {
            sum+=pow((X[j]-i),2);
        }
        ans=min(ans,sum);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3616
N,M = map(int,input().split())
S = input()

c = 0
flag = 0
for i in S:
    if i == '0':
        if c >= M:
            flag = 1
            break
        c = 0
    else:
        c += 1
        
if flag == 1:
    print(-1)
else:
    T = S[::-1]
    now = 0
    ans = []
    while now != N:
        delta = 0
        for i in range(1,M+1):
            if now + i == N:
                delta = i
                break
            if T[now+i] == '0':
                delta = i
        ans.append(delta)
        now += delta
    Answer = ans[::-1]
    print(*Answer)

Measured memory_bytes: 51184
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int D = scn.nextInt();
		int shou = N / ( 2 * D + 1);
		int amari = N % ( 2 * D + 1);

		if (amari != 0) {
			shou++;
		}

		System.out.println(shou);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end();
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
int main(){
  int a,b,c;
  cin >>a>>b>>c;
  bool f = false;
  if(a==b&&a!=c)f=true;
  if(a==c&&a!=b)f=true;
  if(b==c&&b!=a)f=true;
  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            long[] L = { 2, 1 };

            long next = 0;
            if(n == 1) {
                Console.WriteLine(1);
                return;
            }

            for (int i = 2; i<=n; ++i) {
                next = L[0] + L[1];
                L[0] = L[1];
                L[1] = next;
            }

            Console.WriteLine(next);

        }
    }
}

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

if n < 10:
    if n == 3:
        print("bon")
    elif n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        print("hon")
    else:
        print("pon")
elif n >= 10:
    if n%10 == 3:
        print("bon")
    elif n%10 == 2 or n%10 == 4 or n%10 == 5 or n%10 == 7 or n%10 == 9:
        print("hon")
    else:
        print("pon")    

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

#define ll long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define int long long
#define INF 1e9
#define pt(xx) cout << "\n" \
                    << xx << "\n"
#define debugv(x, n)               \
    cout << "\n"                   \
         << #x << ": ";            \
    rep(i, n) cout << x[i] << " "; \
    cout << endl
#define debug2d(x, m, n)            \
    cout << "\n"                    \
         << #x << " is: \n";        \
    for (int i = 0; i < m; ++i)     \
    {                               \
        for (int j = 0; j < n; ++j) \
        {                           \
            cout << x[i][j] << " "; \
        }                           \
        cout << endl;               \
    }
#define nl cout << endl

#define MOD 1000000007
int i, j, k, l, m;
int N, M, K, X;
int W, H, x, y;
int ans;


const int  GOLD=0;
const int  SILVER=1;
const int  BRONS=2;

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

    cin >> N;
    int s[2][3];
    cin >> s[0][0] >> s[0][1] >> s[0][2];
    cin >> s[1][0] >> s[1][1] >> s[1][2];

    //debug(N);
    //debug2d(s, 2, 3);

    /* 
    int dp_g[5001][5001] = {};
    int dp_s[5001][5001] = {};
    int dp_b[5001][5001] = {};
*/

    /*
    N 個のドングリでの最大利益?
    dp[N] = ?

 */

    // count?
    int dp[N + 2] = {}; // zeros
    rep(i,N+1) dp[i] = i;//initialize

    //pt("\ni)Aで金属を買い，Bで売る");
    // s[0][x] -> s[1][x] : profit
    FOR(i, 1, N + 1)
    {
        rep(gsb, 3)
        {
            if ((i-s[0][gsb]) >= 0){
                dp[i] = max(dp[i],dp[i-s[0][gsb]]+s[1][gsb]);
            }
        }
    }
    //debugv(dp,N);
    int res = dp[N];
    //debug(res);


    //pt("\nii) Bで金属を買い，Aで売る");

    int dp2[res+2];
    rep(i,res+2)dp2[i] = i;
    
    FOR(i,1,res+1)
    {
        rep(gsb,3)
        {
            if ((i-s[1][gsb]) >= 0){
                dp2[i] = max(dp2[i],dp2[i-s[1][gsb]] + s[0][gsb]);
            }
        }
    }
    ans = dp2[res];
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 195584
#include <iostream>
#include <climits>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0;i<int(n);i++)

int main()
{
  int N, M;
  cin >> N >> M;
  int a[N], b[N], c[M], d[M];
  REP(i,N) cin >> a[i] >> b[i];
  REP(i,M) cin >> c[i] >> d[i];
  REP(i,N){
    int md = INT_MAX, ans;
    REP(j,M){
      if(abs(a[i]-c[j])+abs(b[i]-d[j]) < md){
        ans = j+1;
        md = abs(a[i]-c[j])+abs(b[i]-d[j]);
      }
    }
    cout << ans << endl;
  }
}

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

int main() {
  string S;
  cin >> S;
  vector<string> cut={"maerd","remaerd","esare","resare"};
  reverse(S.begin(),S.end());
  bool all_cut=false;
  for(int i=0;;){
    if(i==S.size()){
      all_cut=true;
      break;
    }
    bool exist_cut=false;
    for(int j=0;j<4;j++){
      if(S.substr(i,cut.at(j).size())==cut.at(j)){
        exist_cut=true;
        i+=cut.at(j).size();
        break;
      }
    }
    if(!exist_cut){
      break;
    }
  }
  if(all_cut){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}    

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int cand = 0;
    int total = 0;
    vector<int> votes(n);
    for (int i = 0; i < n; i++) {
        cin >> votes[i];
        total += votes[i];
    }
    for (int i = 0; i < n; i++) {
        if (votes[i] > (total - 1) / (4 * m)) {
            cand++;
        }
    }
    cout << (cand >= m ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

arr = [[0 for i in range(w)] for j in range(h)]

now_x=0
now_y=0
move_r=True
for num in range(len(a)):
    for i in range(a[num]):
        arr[now_y][now_x] = num+1
        if move_r:
            if now_x == w-1:
                now_y+=1
                move_r=False
            else:
                now_x+=1
        else:
            if now_x == 0:
                now_y+=1
                move_r=True
            else:
                now_x-=1

for tmp in arr:
    print(' '.join(map(str, tmp)))

Measured memory_bytes: 40816
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0); 
      string s;
       cin>>s;
      for(int i=0; i<s.length(); i++)
         cout<<"x";
    
    }



Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[200005];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	int cnt = 0;
	ll ans = 0;
	for(int i = 0; i < N; i++) {
		if(arr[i] == cnt + 1) {
			ans++;
			cnt += 1;
		} 
	}
	if(ans == 0) {
		printf("-1\n");
		return 0;
	}
	ans = N - ans;
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 1792
from collections import deque

*S, = input().split()
operater = '+-*'

stack = deque()

for s in S:
    if s in '+-*':
        b = stack.pop()
        a = stack.pop()

        if s == '+':
            stack.append(a+b)
        elif s == '-':
            stack.append(a-b)
        elif s == '*':
            stack.append(a*b)
    else:
        stack.append(int(s))

print(stack.pop())



Measured memory_bytes: 6000
import sys
input = sys.stdin.readline

R,C,K=map(int,input().split())
J=[tuple(map(int,input().split())) for i in range(K)]

#DP0=[[0]*(C+2) for i in range(R+2)]
DP1=[[0]*(C+2) for i in range(R+2)]
DP2=[[0]*(C+2) for i in range(R+2)]
DP3=[[0]*(C+2) for i in range(R+2)]

MAP=[[0]*C for i in range(R)]

for x,y,v in J:
    MAP[x-1][y-1]=v

for i in range(R):
    for j in range(C):
        DP1[i][j]=max(DP1[i][j-1],DP1[i-1][j]+MAP[i][j],DP2[i-1][j]+MAP[i][j],DP3[i-1][j]+MAP[i][j])
        DP2[i][j]=max(DP2[i][j-1],DP1[i][j-1]+MAP[i][j])
        DP3[i][j]=max(DP3[i][j-1],DP2[i][j-1]+MAP[i][j])

ANS=0
for i in range(R):
    for j in range(C):
        ANS=max(ANS,DP1[i][j],DP2[i][j],DP3[i][j])
print(ANS)



Measured memory_bytes: 377220
# ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)
def main():
    S = {s: list(input().rstrip())[::-1] for s in ("a", "b", "c")}
    cur = "a"
    while S[cur]:  # search greedily
        cur = S[cur].pop()
    print(cur.upper())


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  a=list(map(int,input().split()))
  jdg=0
  for i in range(m):
    jdg+=a[i]*b[i]
  if jdg+c>0:
    ans+=1
print(ans)
    

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int n;
  cin >> n;

  vi sieve(n + 1, 2);
  sieve[1] = 1;
  for (int i = 2; i <= n; i++) {
    for (int j = i + i; j <= n; j += i) {
      sieve[j]++;
    }
  }

  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += 1ll * i * sieve[i];
  }

  cout << sum;

  return 0;
}


Measured memory_bytes: 42264
#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 A[2][105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, 2) {
        REP(j, N) {
            cin >> A[i][j];
        }
    }
    ll s = 0;
    ll ans = 0;
    REP(i, N) {
        s += A[0][i];
        ll t = s;
        FOR(j, N, i) {
            t += A[1][j];
        }
        ans = std::max(t, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

const ll mod=1000000007;

char s[maxn];
ll n,h[maxn],b[maxn];

inline ll gh(int l,int r)
{
	return (h[r]-(h[l-1]*b[r-l+1]%mod)+mod)%mod;
}

inline bool jud(int x)
{
	map <ll,int> mp; mp.clear();
	for(int i=1;i<=n-x+1;i++)
	{
		ll p=gh(i,i+x-1);
		if(mp[p])
		{
			if(i-mp[p]>=x) return true;
			continue;
		}
		else mp[p]=i;
	}
	return false;
}

int main()
{
	cin>>n; scanf("%s",s+1); b[0]=1; h[0]=0;
	for(int i=1;i<=n;i++) b[i]=(b[i-1]*233)%mod;
	for(int i=1;i<=n;i++) h[i]=(h[i-1]*233+s[i])%mod;
	int l=0,r=n,ans=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(jud(mid)) l=mid+1,ans=mid;
		else r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4736
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];
    sort(L);
    //
    ll ans = 0;
    for(int i=0;i<N;++i)
    {
        for (int j = i+1; j < N; ++j)
        {
            for (int k = j+1; k < N; ++k)
            {
                //
                auto arr = std::array<ll,3>({ L[i],L[j] ,L[k] });
                bool valid = arr[0] != arr[1] && arr[0] != arr[2] && arr[1] != arr[2];
                if (valid && (arr[2] < arr[0] + arr[1]))
                {
                    ++ans;
                }
            }
        }
    }
    cout << ans;
    //

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    A = fetch_vec<int>(N);
}

int color(int x){
    if(x<400) return 1;
    else if(x<800) return 2;
    else if(x<1200) return 3;
    else if(x<1600) return 4;
    else if(x<2000) return 5;
    else if(x<2400) return 6;
    else if(x<2800) return 7;
    else if(x<3200) return 8;
    return 9;
}

int solve(){
    int cnt9 = 0;
    set<int> se;
    for(auto a:A){
        int c = color(a);
        if(c!=9) se.insert(c);
        else cnt9++;
    }
    if(se.size()!=0){
        cout << se.size() << " " << se.size()+cnt9 << endl;
    }
    else{
        cout << 1 << " " << cnt9 << endl;
    }
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
XY = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
indeg = [0] * N
for x,y in XY:
    x,y = x-1,y-1
    es[x].append(y)
    indeg[y] += 1

from collections import deque
q = deque()
for i in range(N):
    if indeg[i] == 0:
        q.append(i)

dp = [0] * N
while q:
    v = q.popleft()
    for to in es[v]:
        indeg[to] -= 1
        if indeg[to] == 0: q.append(to)
        dp[to] = max(dp[to], dp[v] + 1)

print(max(dp))

Measured memory_bytes: 40764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int l = Integer.parseInt(str);
		str = br.readLine();
		String[] a = str.split(" ");
		int odd = 0, e_4 = 0;
		for (String ai_s : a) {
			int ai = Integer.parseInt(ai_s);
			if (ai % 4 == 0)
				e_4++;
			else if (ai % 2 != 0)
				odd++;
		}
		if (e_4 >= odd)
			System.out.println("Yes");
		else if (e_4 + 1 == odd && e_4 + odd == l)
			System.out.println("Yes");
		else
			System.out.println("No");

	}
}


Measured memory_bytes: 37588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int n = Integer.parseInt(br.readLine());
		String[] x = br.readLine().split(" ");
		String[] y = br.readLine().split(" ");

		double ans = 0;
		int i = 0;

		for( i=0 ; i<n ; i++ ){
			ans = ans+Math.abs(Double.parseDouble(x[i])-Double.parseDouble(y[i]));
		}

		sb.append(String.format("%.6f", ans)).append("\n");
		ans = 0;

		for( i=0 ; i<n ; i++ ){
			ans = ans+Math.pow(Math.abs(Double.parseDouble(x[i])-Double.parseDouble(y[i])), 2);
		}

		sb.append(String.format("%.6f", Math.sqrt(ans))).append("\n");
		ans = 0;

		for( i=0 ; i<n ; i++ ){
			ans = ans+Math.pow(Math.abs(Double.parseDouble(x[i])-Double.parseDouble(y[i])), 3);
		}

		sb.append(String.format("%.6f", Math.cbrt(ans))).append("\n");
		ans = 0;

		for( i=0 ; i<n ; i++ ){
			ans = Math.max(Math.abs(Double.parseDouble(x[i])-Double.parseDouble(y[i])), ans);
		}

		sb.append(String.format("%.6f", ans)).append("\n");
		ans = 0;

		System.out.print(sb);
	}
}

Measured memory_bytes: 25496