akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long lli;
lli n;
vector<lli> x;
lli l;
lli q;
vector<lli> a;
vector<lli> b;
lli k;
vector<vector<lli> > r;
lli pow(lli a,lli n,lli mod = 1000000007){
	lli ret = 1;
	for(;n!=0;n=n>>1){
		if(n&1) ret = (ret * a) % mod;
		a = (a * a) % mod;
	}
	return ret;
}
void query(lli a,lli b){
    lli ans = 0;
    if(a > b) swap(a,b);
    for(lli i = k-1,t = 1 << (k-1);i >= 0;i--,t >>= 1){
        if(r[a][i] < b) a = r[a][i],ans += t;
    }
    cout << ans + 1 << endl;
}
int main(int argc, char const *argv[]) {
    cin >> n;
    k = 31;
    //for(lli m = 1;m < n;m <<= 1) k++;
    x = vector<lli> (n+1);
    r = vector<vector<lli> > (n+1,vector<lli>(k));
    for(lli i = 1;i <= n;i++) cin >> x[i];
    cin >> l;
    cin >> q;
    for(lli i = 1;i <= n;i++){
        r[i][0] = upper_bound(x.begin(),x.end(),x[i]+l) - x.begin() - 1;
    }
    for(lli i = 1;i < k;i++){
        for(lli j = 1;j <= n;j++){
            r[j][i] = r[r[j][i-1]][i-1];
        }
    }
    a = vector<lli> (q);
    b = vector<lli> (q);
    for(lli i = 0;i < q;i++) cin >> a[i] >> b[i];
    for(lli i = 0;i < q;i++){
        query(a[i],b[i]);
    }

    return 0;
}


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

int main(){
  int x;
  cin >> x;
  map <int,ll> z5;
  for(int i = -1000; i<1000;i++){
    z5[i]=pow(i,5);
  }
  for(int a = 0;a < 1000; a++){
    for(int b = -1000; b<1000;b++){
      ll z = z5[a]-z5[b];
      if(z==x){
	printf("%d %d\n",a,b);
	return 0;
      }
    }
  }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = Console.ReadLine().Split().Select(s=>long.Parse(s)).ToArray()[0];
            for(long i=-1000;i<1000;i++)
            {
                for(long j=-1000;j<1000;j++)
                {
                    if(Math.Pow(i,5)- Math.Pow(j, 5)==X)
                    {
                        Console.WriteLine($"{i} {j}");
                        return;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 19288
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nk = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nk[0]);
        int k = Integer.parseInt(nk[1]);

        if ((n + 1) / 2 >= k) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

int main()
{
    int a;
    string s, t;
    cin >> s >> t;
    a = stoi(s + t);
    string ans = "No";

    rep(i, 1000)
    {
        if (i * i == a)
            ans = "Yes";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    digits, m = [int(x) for x in input().split()]
    orders = []
    for _ in range(m):
        left_count, numeral = [int(x) for x in input().split()]
        left_count -= 1
        orders.append((left_count, numeral))

    def gen():
        for x in range(10 ** digits):
            if x < 10 ** (digits - 1):
                if not(x == 0 and digits == 1):
                    continue
            ok = True
            s = str(x)
            for left_count, numeral in orders:
                if len(s) <= left_count:
                    ok = False
                    break
                if s[left_count] != str(numeral):
                    ok = False
                    break
            if ok:
                yield x

    candidates = gen()
    try:
        print(min(candidates))
    except ValueError:
        print(-1)
    return


if __name__ == '__main__':
    main()


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

int fac(int N) {
  if(N <= 0) return 0;
  if(N == 1) return 1;
  int n = 1;
  while(N>0) {
    n *= N;
    N--;
  }
  return n;
}

int main() {
  int N; cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X[i];
  
  int ans = pow(10, 9);
  
  rep(i, 100) {
    int a = 0;
    rep(j, N) a += pow((X[j]-(i+1)), 2);
    ans = min(ans,a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import fractions
a,b=map(int,input().split())
g=fractions.gcd(a,b)
ans=1
i=2
while i*i<=g:
    if g%i==0:
        ans+=1
        while g%i==0:
            g//=i
    i+=1
if g>1:
    ans+=1
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define all(X) X.begin(),X.end()
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll n,k,a[2010],be,af,ans,mod=1e9+7;
ll po(ll x,ll y)
{
    if(y==0)
        return 1;
    if(y&1)
        return (x*po(x,y-1))%mod;
    ll t=po(x,y/2)%mod;
    return (t*t)%mod;
}
int main()
{
    go;
    //cout<<po(3,2)<<endl;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[i]>a[j])
            {
                if(i<j)
                    af++;
                else
                    be++;
            }
        }
    }
    //cout<<be<<" "<<af<<endl;
    ll x=(k*(k+1))%mod;
    ll y=po(2,mod-2)%mod;
    y=(y*x)%mod;
    ans=(y*af)%mod;
    x=(k*(k-1))%mod;
    y=po(2,mod-2)%mod;
    y=(y*x)%mod;
    ans=(ans+(be*y)%mod)%mod;
    //ans=(ans+)
    ans=(ans%mod+mod)%mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

long long int beki(int n){
  long long int ret=1;
  while(n!=1){
    ret=(ret*n)%(1000000000+7);
    n--;
  }
  return ret;
}

int main(void){
  int N,M;

  scanf("%d %d", &N, &M);

  long long int num;
  if(N-M>1 && N-M<-1){
    num=0;
  }else if(N==M){
    num=beki(N);
    num=(num*num*2)%(1000000000+7);
  }else if(N==M+1){
    num=(beki(N)*beki(M))%(1000000000+7);
  }else if(M==N+1){
    num=(beki(M)*beki(N))%(1000000000+7);
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <limits.h>
using namespace std;

int main(){

    
    int N;
    int num[1000020];
    num[0]=0;
    long int sum=0;
    cin >> N;
    for(int i=1;i<=N;i++){
        if(i % 3 == 0 && i % 5 ==0){
            num[i] = 0;
        }
        else if(i%3==0){
            num[i]=0;
        }
        else if(i%5==0){
            num[i]=0;
        }
        else{
            num[i]=i;
        }
    } 
    for(int i=1;i<=N;i++){
    
        sum += num[i];
    }
    cout << sum;
    
}

Measured memory_bytes: 7536
#include <iostream>

using namespace std;

int dp[12][1002] = {};

int main(){
  int p_max = 1002;
  int p_min = 1002;
  int d;
  int p[12];
  int c[12];
  int scores[12];
  int g;
  cin >> d >> g;
  for (int i=1;i<=d;i++) {
    int p_tmp, c_tmp;
    cin >> p_tmp >> c_tmp;
    p[i] = p_tmp;
    c[i] = c_tmp;
  }
  for (int i=1;i<=d;i++) {
    for (int j=0;j<=p[i];j++) {
      for (int k=0;k<p_max;k++) {
	int new_value = dp[i-1][k] + j*i*100;
	if (j==p[i]) {
	  new_value += c[i];
	}
	dp[i][k+j] = dp[i-1][k+j] > new_value?dp[i-1][k+j]:new_value;
	if (dp[i][k+j] >= g) {
	  if (k+j < p_min) {
	    p_min = k+j;
	  }
	}
      }
    }
  }
  // for (int k=0;k<p_max;k++) {
  //   for (int i=0;i<=d;i++) {
  //     cout << dp[i][k] << "\t";
  //   }
  //   cout << endl;
  // }
  cout << p_min << endl;
  return(0);
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using lint  = long long;

signed main(){
 string s; cin >> s;
 lint N = s.size();
 lint cs = 0, x = 0;
 for(lint i = 0; i < N; i++){
   if(s[i] == 'S') cs++;
   else{
     if(cs > 0) x++, cs--;
   }
 }
 cout << N - 2*x << endl;
}

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

struct StPoint
{
  StPoint() :
    m_nTime(0), m_nXcrd(0), m_nYcrd(0)
  { }

  int m_nTime;
  int m_nXcrd;
  int m_nYcrd;
};

void input(vector<StPoint>& rvoPoint)
{
  StPoint oPoint;
  int nSize;
  cin >> nSize;

  rvoPoint.resize(nSize + 1, oPoint);
  for (int i = 0; i < nSize; i++)
    cin >> rvoPoint[i + 1].m_nTime >> rvoPoint[i + 1].m_nXcrd >> rvoPoint[i + 1].m_nYcrd;
}

int canTravel(const vector<StPoint>& cnrvoPoint)
{
  for (int i = 0; i < cnrvoPoint.size() - 1; i++)
  {
    int nTime = cnrvoPoint[i + 1].m_nTime - cnrvoPoint[i].m_nTime;
    int nDist = abs(cnrvoPoint[i + 1].m_nXcrd - cnrvoPoint[i].m_nXcrd)
              + abs(cnrvoPoint[i + 1].m_nYcrd - cnrvoPoint[i].m_nYcrd);

    if (nTime < nDist)           return 0;
    if (nTime % 2 != nDist % 2)  return 0;
  }
  return 1;
}

int main()
{
  vector<StPoint> voPoint;

  input(voPoint);
  if (canTravel(voPoint)) cout << "Yes" << endl;
  else                    cout << "No"  << endl;

  return 0;
}

Measured memory_bytes: 4196
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    for i in range(10):
        if n <= i*111:
            print(i*111)
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int k,x;
  cin >> k >> x;
  if(k * 500 >= x)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

int l;
bool f(const char* a,const char* b){
	int s=strlen(b);
	int cnt=0;
	rep(i,s)if(a[0]==b[i]){
		reps(j,1,s){
			rep(k,l){
				if(i+k*j>s)break;
				if(a[k]!=b[i+k*j])break;
				if(k==l-1)return 1;
			}
		}
	}
	return 0;
}

int main(){
	int n,a=0;
	char s[26],t[101];
	scanf("%d",&n);
	scanf("%s",s);
	l = strlen(s);
	rep(i,n){
		scanf("%s",t);
		a += f(s,t);
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
 
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;
using namespace std;

int main(void) {
    int K, T;
    int a[101];
    cin >> K >> T;
    REP(i, T) {
        cin >> a[i];
    }
    int ans = 0;
    int max = 0, max_index=-1;
    REP(j, T) if(a[j] > max) {max = a[j]; max_index = j;}
    int before = max_index;
    a[max_index]--;
    REP(i, K-1) {
        max = 0, max_index=-1;
        REP(j, T) if(a[j] > max && j!=before) {max = a[j]; max_index = j;}
        if(max_index != -1) {
            before = max_index;
            a[max_index]--;
        }
        else {
            a[before]--; ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        

        Scanner sc = new Scanner(System.in);

        String S =sc.next();
        String [] List = S.split("");
        int i=0;
        int[] ans =new int[4];
        int answer=0;
        int tmp =0;
        for(i=0;i<List.length;i++){
            
            ans[i]=Integer.parseInt(List[i]);
            
        }
        
        if(ans[0]+ans[1]+ans[2]+ans[3]==7){
            answer=ans[0]+ans[1]+ans[2]+ans[3];
            System.out.println(ans[0]+"+"+ans[1]+"+"+ans[2]+"+"+ans[3]+"="+answer);
            return;
            
        }else if(ans[0]-ans[1]+ans[2]+ans[3]==7){
            
            answer=ans[0]-ans[1]+ans[2]+ans[3];
            System.out.println(ans[0]+"-"+ans[1]+"+"+ans[2]+"+"+ans[3]+"="+answer);
            return;
            
        }else if(ans[0]+ans[1]-ans[2]+ans[3]==7){
            
            answer=ans[0]+ans[1]-ans[2]+ans[3];
            System.out.println(ans[0]+"+"+ans[1]+"-"+ans[2]+"+"+ans[3]+"="+answer);
            return;
            
        }else if(ans[0]+ans[1]+ans[2]-ans[3]==7){
            
            answer=ans[0]+ans[1]+ans[2]-ans[3];
            System.out.println(ans[0]+"+"+ans[1]+"+"+ans[2]+"-"+ans[3]+"="+answer);
            return;
            
        }else if(ans[0]-ans[1]-ans[2]+ans[3]==7){
            
            answer=ans[0]-ans[1]-ans[2]+ans[3];
            System.out.println(ans[0]+"-"+ans[1]+"-"+ans[2]+"+"+ans[3]+"="+answer);
            return;
            
        }else if(ans[0]-ans[1]+ans[2]-ans[3]==7){
            
            answer=ans[0]-ans[1]+ans[2]-ans[3];
            System.out.println(ans[0]+"-"+ans[1]+"+"+ans[2]+"-"+ans[3]+"="+answer);
            return;
            
        }else if(ans[0]+ans[1]-ans[2]-ans[3]==7){
            
            answer=ans[0]+ans[1]-ans[2]-ans[3];
            System.out.println(ans[0]+"+"+ans[1]+"-"+ans[2]+"-"+ans[3]+"="+answer);
            return;
            
        }else if(ans[0]-ans[1]-ans[2]-ans[3]==7){
            
            answer=ans[0]-ans[1]-ans[2]-ans[3];
            System.out.println(ans[0]+"-"+ans[1]+"-"+ans[2]+"-"+ans[3]+"="+answer);
            return;
            
        }
        
    }
    
} 

Measured memory_bytes: 40372
N = int(input())
A, B, C = list(map(int, input().split()))

for i in range(N - 1):
    a, b, c = list(map(int, input().split()))
    A, B, C = max(B, C) + a, max(C, A) + b, max(A, B) + c
print(max(A, B, C))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 int main(){
   int N;
   cin >>N;
   string s= to_string(N);
   bool ju=0;
   for(int i=0;i<3;i++){
     if(s.at(i)=='7')
       ju=1;
   }
   if(ju)
     cout << "Yes" << endl;
   else
     cout << "No" << endl;
 }

Measured memory_bytes: 3692
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
using namespace std;
int main() {
	int N, X, T;
	cin >> N >> X >> T;
	int suwako = 0;
	while (N > 0) {
		suwako = suwako + T;
		N = N - X;
	}
	cout << suwako;
}



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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,m,a;
	cin>>n>>m;
	map<ll,ll> mp;
	while(m--){
		cin>>a;
		mp[a]++;
	}
	ll dp[n+1];
	dp[0]=1;
	(mp[1]==0)?dp[1]=1:dp[1]=0;
	forni(i,n){
		(mp[i]==0)?dp[i]=(dp[i-1]+dp[i-2])%inf:dp[i]=0;
	}
	cout<<dp[n]<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

ll mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, i;
    cin >> n;
    ll ans = 0, pre = 0;
    for(i=0;i<n;i++){
        ll a; cin >> a;
        ans += (a*pre)%mod;
        ans %= mod;
        pre += a;
        pre %= mod;
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{
  	cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }
    int j = 1;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        j = a.at(j - 1);
        count++;
        if (j == 2)
            break;
    }
    if (count == N)
    {
        cout << -1 << "\n";
    }
    else
    {
        cout << count << "\n";
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

bool pairCompare(pair<int, int> firstElof, pair<int, int> secondElof)
{
    return firstElof.second < secondElof.second;
}

void init() {

}

void input() {

}

vector < pair<int, int> > v[100010];
pair<int, int> res[100010];

void solve() {
  int n, m;
  cin >> n >> m;
  REP(i, m) {
    int p, y;
    cin >> p >> y;
    pair<int, int> pa = make_pair(i, y);
    v[p].push_back(pa);
  }
  FOR(i, 1, n+1) {
    sort(ALL(v[i]), pairCompare);
    REP(j, SZ(v[i])) {
      res[v[i][j].first] = make_pair(i, j+1);
    }
  }
  REP(i, m) {
    printf( "%06d%06d\n", res[i].first, res[i].second);
  }
}

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


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

int func(int n){
    int sum=0;
    while(n){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int N,A,B; cin>>N>>A>>B;

    int ans=0;
    for(int i=1;i<=N;i++){
        int n=func(i);
        if(n>=A&&n<=B) ans+=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int n;
VI t(100);
signed main() {
    cin >> n;
    int res = 1;
    REP(i, n) {
        cin >> t[i];
        res = lcm(res, t[i]);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LS()

  _a=a*int(b)
  _b=b*int(a)

  if _a<_b:
    return _a
  return _b

# main()
print(main())


Measured memory_bytes: 6988
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

ans = a[0]
n -= 1
for i in range(1, n):
    if n > 2:
        ans += a[i] * 2
        n -= 2
    elif n == 2:
        ans += a[i]
        n -= 1
    else:
        break

print(ans)

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

int main() {
	ll n, nn, count, ans;
	cin >> n;
	nn = n;
	count = 1;
	while(nn >= 10) {
		nn /= 10;
		count++;
	}
	ans = count;
	for (ll i = 2 ; i * i <= n; i++) {
		if (n % i == 0) {
			ll x = n / i;
			count = 1;
			while (x >= 10) {
				x /= 10;
				count++;
			}
			ans = count;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		
		int cnt = 0;
		
		for (int i = 0; i <= a; i++) {
			for (int j = 0; j <= b; j++) {
				for (int k = 0; k <= c; k++) {
					if (500 * i + 100 * j + 50 * k == x) cnt++;
				}
			}
		}
		
		System.out.println(cnt);
		
	}

}

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

int main(){
  int a,b,cnt;
  char field[100][100];
  cin >> a >> b;


  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(i < 50) field[i][j] = '.';
      else field[i][j] = '#';
    }
  }

  cnt = 1;
  for(int i = 0; i < 50;){
    for(int j = 0; j < 100;){
      if(cnt == b) break;
      field[i][j] = '#';
      cnt++;
      j += 2;
    }
    if(cnt == b) break;
    i += 2;
  }

  cnt = 1;
  for(int i = 99; i > 49;){
    for(int j = 0; j < 100;){
      if(cnt == a) break;
      field[i][j] = '.';
      cnt++;
      j += 2;
    }
    if(cnt == a) break;
    i -= 2;
  }

  cout << 100 << ' ' << 100 << endl;
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      cout << field[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int N,A=0,B=0;
	std::vector<int> v;
	std::cin >> N;
	v.push_back(0);
	for ( int i = 0 ; i < N ; i++ ) {
		int x;
		std::cin >> x;
		v.push_back(x);
	}
	for ( int i = 0 ; i < ceil(float(N)/2) ; i++ ) {
		std::vector<int>::iterator iter = std::max_element(v.begin(), v.end());
		size_t index = std::distance(v.begin(), iter);
		A += v[index];
		v[index] = -1;
		iter = std::max_element(v.begin(), v.end());
		index = std::distance(v.begin(), iter);
		B += v[index];
		v[index] = -1;
	}
	std::cout << A-B << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
#define prev prev228
#define all(x) (x).begin(), (x).end()

int n, m;
int a, b, v[500000];
int deg[500000];
vector<int> graph[500000];

void dfs(int kek, int p)
{
    v[kek] = 1;
    for (int u : graph[kek])
    {
        if (v[u] == 0)
            dfs(u, kek);
        else if (u == a && p != a) cout << "Yes", exit(0);
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        deg[a]++, deg[b]++;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int t = 0;
    for (int i = 1; i <= n; i++) if (deg[i] % 2 == 1) cout << "No", exit(0);
    for (int i = 1; i <= n; i++) if (deg[i] >= 6) cout << "Yes", exit(0);
    for (int i = 1; i <= n; i++) if (deg[i] >= 4) t++;
    if (t <= 1) cout << "No", exit(0);
    if (t >= 3) cout << "Yes", exit(0);
    for (int i = 1; i <= n; i++) if (deg[i] == 4) {a = i; break;}
    for (int i = n; i >= 1; i--) if (deg[i] == 4) {b = i; break;}
    v[b] = 1;
    dfs(a, -1);
    cout << "No";
}


Measured memory_bytes: 18944
#include <stdio.h>
  
int main()
{
  int W,H,x,y,r;
  scanf("%d %d %d %d %d" ,&W,&H,&x,&y,&r);
    
  if(x > 0 && y > 0 &&  x + r >= 0 && x + r <= W && y + r >= 0 && y + r <= H )
   {
      printf("Yes\n");
   }
  else
   {
      printf("No\n");
   }
    

 return 0;
}
    

Measured memory_bytes: 584
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] st = Console.ReadLine().Split(' ');
        int r = int.Parse(st[0]);
        int d = int.Parse(st[1]);
        int x = int.Parse(st[2]);

        int gram = x;

        for (int i = 1; i <= 10; i++)
        {
            gram = r * gram - d;
            Console.WriteLine(gram);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>


int main(){

  int n = 0, simnao = 0;

  scanf("%d", &n);

  char b[n+1];

  scanf("%s", b);

  if (n % 2 == 0) {

  for (int i = 0; i < n/2; i++){
    if (!(b[i] == b[i+(n/2)])){
      printf("No\n");
      simnao = 1;
      break;
    }
  }

  if (!simnao)
    printf("Yes\n");

  } else {

    printf("No\n");
  }


  return 0;
}


Measured memory_bytes: 128
a,b=map(int,input().split())
num=1
while 1:
    if int(num*0.08)==a and int(num*0.1)==b:
        print(num)
        break
    if int(num*0.08)>a and int(num*0.1)>b:
        print(-1)
        break
    num+=1

Measured memory_bytes: 9180
main :: IO ()
main = do
    [n,y] <- map read . words <$> getLine
    let (c,d,e) = pirupiru 0 0 n y
    putStrLn $ (show c++" "++ show d ++ " " ++ show e)

pirupiru :: Int -> Int -> Int -> Int -> (Int,Int,Int)
pirupiru a b n y =  if (a*10000 + b*5000 + (n-a-b)*1000 == y) then (a,b,n-a-b)
                    else if a == n then (-1,-1,-1)
                    else if a + b == n then pirupiru (a+1) 0 n y
                    else pirupiru a (b+1) n y 

Measured memory_bytes: 508
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	string s;
	int ans=0;
	cin >>n>>s;
	auto itra=s.begin(),itrb=s.begin(),itrc=s.begin();
	for(char a='0';a<='9';a++){
		itra=s.begin();
		while((*itra)!=a and itra!=s.end()){
			itra++;
		}
		if(itra==s.end()){
			continue;
		}
		for (char b = '0'; b <= '9'; b++)
		{
			itrb=itra;
			itrb++;
			while ((*itrb) != b and itrb != s.end())
			{
				itrb++;
			}
			if (itrb == s.end())
			{
				continue;
			}

			for (char c = '0'; c <= '9'; c++)
			{
				itrc=itrb;
				itrc++;
				while ((*itrc) != c and itrc != s.end())
				{
					itrc++;
				}
				if (itrc == s.end())
				{
					continue;
				}else{
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if(a*c<b){
      System.out.println(c);
    }else{
      System.out.println(b/a);
    }
  }
}

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

int main() {
	bool poss[3] = { false };
  	
  	for(int i = 0; i < 2; i++) {
    	int next; cin >> next; next--;
      	poss[next] = true;
    }
  	
  	for(int i = 0; i < 3; i++) {
    	if(!poss[i]) cout << i + 1 << endl;
    }
  
}

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

using namespace std;

int main(int argc, char* argv[]) {
  vector<int> a(5);
  for (int i = 0; i < 5; ++i)
    cin >> a[i];

  int min_index = 0;
  int min_value = 10;
  for (int i = 0; i < 5; ++i) {
    if (a[i] - (10 * (a[i] / 10)) != 0 && a[i] - (10 * (a[i] / 10)) < min_value) {
      min_value = a[i] - (10 * (a[i] / 10));
      min_index = i;
    }
  }

  int res = 0;
  for (int i = 0; i < 5; ++i) {
    if (i != min_index) {
      res += ceil(float(a[i]) / 10) * 10;
    } else {
      res += a[i];
    }
  }

  cout << res << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int r;
  cin >> r;
  if(r<1200) {
    pr("ABC");
    return;
  }
  if(r<2800) {
    pr("ARC");
    return;
  }
  pr("AGC");
}

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


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

#define ll long long
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define see(x) cout<<(#x)<<" -> "<<(x)<<"\n"
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define fr(i,a,b) for(int i=a;i<b;i++)
#define fr1(i,b,a) for(int i=b;i>=a;i--)

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
long double infd=1.0/0.0;
const double pi=2*acos(0.0);
const int MOD=1e9+7;

int main(){
    nimble;
    int tt=1;//cin>>tt;
    while(tt--){
        ll a,b;
        cin>>a>>b;
        ll s=(a/__gcd(a,b))*(b);
        cout<<s;
    }
    return 0;
}



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

int main(){
    double l;
    cin >> l;
    double ans = (l/3)*(l/3)*(l/3);
    cout << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
const int maxn = 2e5 + 10;
const ll inf = 1e18 + 10;
ll ans = inf;
int n, tot;
int xmin = 1e9 + 10, xmax, ymin = 1e9 + 10, ymax;
int a[maxn][2];
pii val[maxn], b[maxn << 1];;
struct cmp
{
	bool operator() (const pii & i, const pii & j)
	{
		if(a[i.first][i.second] != a[j.first][j.second]) return a[i.first][i.second] < a[j.first][j.second];
		return i.first < j.first || (i.first == j.first && i.second < j.second);
	}
};
bool cmpb (const pii & i, const pii & j)
{
	return a[i.first][i.second] < a[j.first][j.second] || (a[i.first][i.second] == a[j.first][j.second] && i.second < j.second);
}
set<pii, cmp> s;
void solve()
{
	if(b[1].first != b[tot].first) s.insert(mp(b[1].first, 1)), s.insert(mp(b[tot].first, 0));
	for(int i = 2; i < tot; ++i)
		if(b[i].second == 0)
			s.insert(b[i]);
	while(true)
	{
		ans = min(ans, 1ll * (a[s.rbegin()->first][s.rbegin()->second] - a[s.begin()->first][s.begin()->second]) * (ymax - xmin));
		auto x = *s.begin();
		if(x.first == tot || x.second == 1)
			break;
		s.erase(x);
		x.second = 1;
		s.insert(x);
	}
	s.clear();
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%d%d", &val[i].first, &val[i].second);
		if(val[i].first > val[i].second) swap(val[i].first, val[i].second);
		xmin = min(xmin, val[i].first);
		xmax = max(xmax, val[i].first);
		ymin = min(ymin, val[i].second);
		ymax = max(ymax, val[i].second);
	}
	ans = min(ans, 1ll * (xmax - xmin) * (ymax - ymin));
	sort(val + 1, val + n + 1);
	for(int i = 1; i <= n; ++i) a[i][0] = val[i].first, a[i][1] = val[i].second;
	for(int i = 1; i <= n; ++i) b[++tot] = mp(i, 0), b[++tot] = mp(i, 1);
	sort(b + 1, b + tot + 1, cmpb);
	solve();
	printf("%lld\n", ans);
	return 0;
}
/*
7
10 4
11 28
24 22
8 6
4 28
8 22
11 11
*/

Measured memory_bytes: 15872
#include<bits/stdc++.h>
//#include<boost\lexical_cast.hpp> 

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int> 
#define vvi vector< vi >
#define vl vector<ll>
#define vpi vector<pi> 
#define vpl vector<pl>

#define PB emplace_back
#define MP make_pair
#define SZ(x) (ll)x.size()
#define SS second
#define FF first


#define DEB(x) cout << #x << "=" << x << endl
#define DEB2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define DEB3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define DEB4(x, y, z, k) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," <<#k << "=" << k<< endl
#define DEBC(a) for(auto x:a) cout<<x<<" ";
#define DEBP(name,a) cout<<name<<endl;for(auto x:a){ cout<<x.first<<"\t"<<x.second<<endl;}

#define INF 0x7fffffff
#define LINF 2000000000000000007
#define endl "\n"
#define MOD 1000000007
#define MAX 100010

#define FILL(a,x) memset(x,a,sizeof x)
#define ALL(x) x.begin(),x.end()
#define REP(i,a,n) for(ll i=a;i<n;++i)
#define REPR(i,n,b) for(ll i=n;i>=b;i--)
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

using namespace std;
//using boost::lexical_cast;
//using boost::bad_lexical_cast;
int main(){
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--){
       ll n, m;
       cin>>n>>m;
       vl v;
       ll sm=0, tmp;
       REP(i,0,n){
        cin>>tmp;
        //sm+=tmp;
        v.PB(tmp);
       }
       if(m>=n){
        cout<<0<<endl;
        continue;
       }
       sort(ALL(v));
       n-=m;
       for(int i=0;i<n;i++){
            sm+=v[i];
       }
       cout<<sm<<endl;
    }
}

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

using IV = std::vector<int>;
IV ToFixedIntArray(std::istream& is, int n) {
	IV ret(n);
	auto* dst = ret.data();
	while(n > 0) {
		--n;
		is >> *dst++;
	}
	return ret;
}

#include <iostream>

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}

int main() {
	DisableIOSync();
	const int N = ToFixedIntArray(std::cin, 1)[0];
	auto input = ToFixedIntArray(std::cin, N);
	input.push_back(-1);
	int count = 0;
	bool holdO = false;
	for(int i=0 ; i<=N ; i++) {
		if(input[i] == i+1) {
			if(!holdO) {
				// X -> O
				holdO = true;
			} else {
				// O -> O
				++count;
				holdO = false;
			}
		} else {
			if(!holdO) {
				// X -> X
			} else {
				// O -> X
				++count;
				holdO = false;
			}
		}
	}
	std::cout << count << std::endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(){
	char a[100];
	long long N, hb, sisa;
	scanf("%lld", &N);
	int j=0;
	while(1){
		hb=N/26;
		sisa=N%26;
		if(sisa==0){
			a[j]='z';
			hb-=1;
		}
		if(sisa!=0){
			a[j]=sisa-1+'a';
		}
		j++;
		if(hb==0){
			break;
		}
		N=hb;
	}
	a[j] = '\0';
	int len = strlen(a);
	for(int i=len-1; i>=0; i--){
		printf("%c", a[i]);
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 3164
from itertools import combinations
def Main(N, X, Y):
    ar = range(N)
    X -= 1
    Y -= 1
    comb = combinations(ar, 2)
    ans = {i:0 for i in range(N-1)}
    for i, j in comb:
        dist = 0
        if i <= X and Y <= j:
            dist = X - i + j - Y + 1
        elif i > X and Y <= j:
            dist = min(i-X + 1 + j-Y, j-i)
        elif i <= X and Y > j:
            dist = min(X-i + 1 + Y-j, j-i)
        else:
            dist = min(i-X + 1 + Y-j, j-i)
        ans[dist-1] += 1
    return ans.values()

def main():
    N, X, Y = map(int, input().split())
    out = Main(N, X, Y)
    for e in out:
        print(e)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    N_MAX = N

    min_factor = list(range(N_MAX + 1))
    min_factor[2::2] = [2] * (N_MAX // 2)
    for i in range(3, int(N_MAX ** 0.5) + 2, 2):
        if min_factor[i] != i:
            continue
        for j in range(i * i, N_MAX + 1, 2 * i):
            if min_factor[j] > i:
                min_factor[j] = i

    def prime_factorize_fast(n):
        a = Counter()
        while n != 1:
            a[min_factor[n]] += 1
            n //= min_factor[n]

        return a

    factors = Counter()

    for n in range(2, N + 1):
        factors += prime_factorize_fast(n)

    ans = 1
    for v in factors.values():
        ans = ans * (v + 1) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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 input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  int n;
  string a,b,c;
  cin >> n >> a >> b >> c;
  int ans = 0;
  for(int i=0;i<n;i++){
    if(a.at(i) == b.at(i) && b.at(i) == c.at(i))continue;
    else if(a.at(i)==b.at(i))ans++;
    else if(a.at(i)==c.at(i))ans++;
    else if(b.at(i)==c.at(i))ans++;
    else ans += 2;
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,q,v[500001],aib[500001],sol[500001];
vector<int> pos[500001];
struct date
{
    ll l,r,poz;
};
date qry[500001];
ll lsb(ll x)
{
    return x&(-x);
}
void update(ll poz, ll val)
{
    for(int i=poz;i<=n;i+=lsb(i))
        aib[i]+=val;
}
ll query(ll poz)
{
    ll rez=0;
    for(int i=poz;i>=1;i-=lsb(i))
        rez+=aib[i];
    return rez;
}
bool comp(date a, date b)
{
    if(a.l!=b.l)
        return a.l<b.l;
    return a.r<b.r;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    for(int i=1;i<=q;i++)
    {
        cin>>qry[i].l>>qry[i].r;
        qry[i].poz=i;
    }
    sort(qry+1,qry+q+1,comp);
    for(int i=n;i>=1;i--)
        pos[v[i]].push_back(i);
    for(int i=1;i<=n;i++)
        if(!pos[i].empty())
            update(pos[i].back(),1);
    ll st=1;
    for(int i=1;i<=q;i++)
    {
        while(st<qry[i].l)
        {
            update(st,-1);
            pos[v[st]].pop_back();
            if(!pos[v[st]].empty())
                update(pos[v[st]].back(),1);
            st++;
        }
        sol[qry[i].poz]=query(qry[i].r);
    }
    for(int i=1;i<=q;i++)
        cout<<sol[i]<<'\n';
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<llP> rob(n);
  rep(i, n) {
    ll x, l; cin >> x >> l;
    rob[i] = make_pair(x-l, x+l);
  }
  auto comp = [&](llP a, llP b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
  };  
  sort(ALL(rob), comp);

  int ans = 0;
  ll cur = -INF64;
  rep(i, n) {
    if(rob[i].first < cur) continue;
    ++ans;
    cur = rob[i].second;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4784
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import static java.util.Comparator.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        ArrayList<ArrayList<Long>> a = new ArrayList<>();
        for(int i = 0; i < N ;i++){
            ArrayList<Long> a2 = new ArrayList<>();
            a2.add(Long.parseLong(sc.next()));
            a2.add(Long.parseLong(sc.next()));
            a.add(a2);
        }
        a.sort(comparing(x->x.get(0)));
        long count = 0l;
        for(ArrayList<Long> ae : a){
            while(M > 0 && ae.get(1) > 0){
                count += ae.get(0);
                ae.set(1, ae.get(1)-1);
                M--;
            }
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 70752
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    itn n,k;
    cin >> n >> k;
    lint sum = 0;
    vector<int> e(n);
    REP(i,n) cin >> e[i];
    sort(ALL(e));
    if(k > n) k = n;
    REP(i,k) e.pop_back();
    REP(i,e.size()){
        sum += e[i];
    }
    println(sum);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    

    string s,t;
    cin >> s >> t;
    ll ans = 0;
    for (ll i=0;i<3;i++){
        if(s[i] == t[i]){
            ans++;
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 256