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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

struct max_flow{
   struct Edge { int to,cap,rev; };
   int V; vector<vector<Edge>> G; vector<int> itr,level;
public:
   max_flow(int V):V(V){G.assign(V,vector<Edge>()); }
   void add_edge(int from,int to,int cap){
      G[from].push_back({to,cap,(int)G[to].size()});
      G[to].push_back({from,0,(int)G[from].size()-1});
   }
   void bfs(int s){
      level.assign(V,-1); queue<int> q;
      level[s]=0; q.push(s);
      while(!q.empty()){
         int v=q.front(); q.pop();
         for(auto& e:G[v]){
            if(e.cap>0&&level[e.to]<0) {
               level[e.to]=level[v]+1;
               q.push(e.to);
            }
         }
      }
   }
   ll dfs(int v,int t,int f){
      if(v==t)return f;
      for(int& i=itr[v];i<(int)G[v].size();i++){
         Edge& e=G[v][i];
         if(e.cap>0&&level[v]<level[e.to]){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
               e.cap-=d,G[e.to][e.rev].cap+=d;
               return d;
            }
         }
      } return 0;
   }
   ll run(int s,int t){
      ll ret=0,f;
      while(bfs(s),level[t]>=0){
         itr.assign(V,0);
         while((f=dfs(s,t,inf))>0)ret+=f;
      } return ret;
   }
};

int main(){
   int h,w; scanf("%d%d",&h,&w);
   max_flow g(h+w+2); int s=h+w,t=h+w+1;
   rep(i,0,h)rep(j,0,w){
      char c; cin>>c;
      if(c=='S'){
         g.add_edge(s,i,inf);
         g.add_edge(s,j+h,inf);
      }
      if(c=='T'){
         g.add_edge(i,t,inf);
         g.add_edge(j+h,t,inf);
      }
      if(c=='o'){
         g.add_edge(i,j+h,1);
         g.add_edge(j+h,i,1);
      }
   }
   ll res=g.run(s,t);
   if(res>h*w)printf("-1\n");
   else printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll BIG=1e9;

ll d[201][201];

int main(){
    int N,M,R; cin>>N>>M>>R;
    for(int i=0;i<201;i++){
        for(int j=0;j<201;j++) if(i!=j) d[i][j]=BIG;
    }
    vector<int> v(R);
    for(int i=0;i<R;i++) cin>>v.at(i);

    for(int i=0;i<M;i++){
        int A,B; cin>>A>>B;
        ll C; cin>>C;
        d[A][B]=C;
        d[B][A]=C;
    }
    for(int k=1;k<201;k++){
        for(int i=1;i<201;i++){
            for(int j=1;j<201;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    ll ans=BIG;
    sort(v.begin(),v.end());
    do{
        ll kari=0;
        for(int i=0;i<R-1;i++) kari+=d[v.at(i)][v.at(i+1)];
        ans=min(kari,ans);
    }while(next_permutation(v.begin(),v.end()));
    cout<<ans<<endl;

}

Measured memory_bytes: 512
//
//  main.cpp
//  ABC160C
//
#include <iostream>
#include <vector>
#include <numeric> // accumulate
#include <algorithm> // max_element
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    int K,N;
    cin>>K>>N;
    vector<int>A(N+1);
    vector<int>B(N+1);
    int rst=0;
    for (int i=1; i<=N; i++) {
        cin>>A.at(i);
        B.at(i)=A.at(i)-A.at(i-1);
        if(i==N) rst=K-A.at(i);
    }
    B.at(1)+=rst;
    int mx= *max_element(B.begin(), B.end());
    int sum=accumulate(B.begin(),B.end(),0);
    cout<<sum-mx<<endl;
    return 0;
}


Measured memory_bytes: 1920
using System;

public class Hello
{
    public static void Main()
    {
        var a = new int[4];
        for (int i = 0; i < 3; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < 2; j++)
            {
                var w = int.Parse(line[j]);
                a[w - 1]++;
            }
        }
        Array.Sort(a);
        Console.WriteLine(a[0] == 1 && a[1] == 1 && a[2] == 2 && a[3] == 2 ? "YES" : "NO");
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=2e5+5;

int n,m;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;
	if(n<m){
		for(int i=0;i<m;i++){
			cout<<n;
		}
	}
	else {
		for(int i=0;i<n;i++){
			cout<<m;
		}
	}

return 0;
}

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

int main(){
	int h,w ;
	cin >> h >> w ;
	for(int i=0;i<w+2;i++) cout << '#' ;
	cout << endl ;
	for(int i=0;i<h;i++){
		cout << '#' ;
		for(int j=0;j<w;j++){
			char c ; cin >> c ; cout << c ;
		}
		cout << '#' << endl ;
	}
	for(int i=0;i<w+2;i++) cout << '#' ;
	cout << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 15
 
bool isTri(double a,double b,double c){
  if(c < a+b && a < b+c && b < c+a){
    return true;
  }
  return false;
}
 
double getArea(double a,double b,double c){
  double s = (a+b+c)/2.0;
  return sqrt(s*(s-a)*(s-b)*(s-c));  
}
 
double S(double x){
  return x*x;
}
 
double calc(vector<double> &v){
  double a = S(v[0])*S(v[4])*(S(v[1])+S(v[2])+S(v[3])+S(v[5])-S(v[0])-S(v[4]));
  double b = S(v[1])*S(v[5])*(S(v[0])+S(v[2])+S(v[3])+S(v[4])-S(v[1])-S(v[5]));
  double c = S(v[2])*S(v[3])*(S(v[0])+S(v[1])+S(v[4])+S(v[5])-S(v[2])-S(v[3]));
  double d = -S(v[0])*S(v[1])*S(v[3])-(S(v[1])*S(v[2]))*S(v[4])-
    S(v[0])*S(v[2])*S(v[5])-S(v[3])*S(v[4])*S(v[5]);
  return sqrt((a+b+c+d)/144.0);
}
 
double getVolume(vector<double> &v){
  if(!isTri(v[0],v[1],v[3])){ return 0.0; }
  if(!isTri(v[0],v[2],v[5])){ return 0.0; }
  if(!isTri(v[1],v[2],v[4])){ return 0.0; }
  if(!isTri(v[3],v[4],v[5])){ return 0.0; }
  return calc(v);
}
 
double solve(int S,vector<double> &v,vector<double> &a){
  if(__builtin_popcount(S) == 6){
    return getVolume(v);
  }
  double res = 0;
  for(int i = 0 ; i < (int)a.size() ; i++){
    if((S >> i) & 1){ continue; }
    v.push_back(a[i]);
    res = max(res,solve(S|(1<<i),v,a));
    v.pop_back();
  }
  return res;
}
 
int main(){
  int N;
  while(cin >> N,N){
    vector<double> a(N),v;
    for(int i = 0 ; i < N ; i++){
      cin >> a[i];
    }
    printf("%.10f\n",solve(0,v,a));
  }
  return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] t = new int[n];
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0 ; i < n ; i++) {
			t[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		int T = 0;
		int X = 0;
		int Y = 0;
		for(int i = 0 ; i < n ; i++) {
			int tt = t[i] - T;
			int dd = Math.abs(X - x[i]) + Math.abs(Y - y[i]);
			if(tt >= dd && tt % 2 == dd % 2) {
				T = t[i];
				X = x[i];
				Y = y[i];
			} else {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 93200
from collections import Counter


n = int(input())
A = list(map(int, input().split()))

ok = [False] * (10**6 + 1)
for a in A:
    ok[a] = True

for i in range(10**6 + 1):
    if ok[i]:
        j = 2
        while i * j <= 10**6:
            ok[i * j] = False
            j += 1

for a, cnt in Counter(A).items():
    if cnt >= 2:
        ok[a] = False

print(sum(ok))


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

int main(){
    int n,m,x;
    cin >>n>>m>>x;
    int c[n],a[n][m];
    rep(i,n){
        cin >>c[i];
        rep(j,m) cin >>a[i][j];
    }
    int state[m],ans=INT_MAX,nck[n]={0};
    nck[0]=1;
    rep(i,pow(2,n)-1){
        int pre[m]={0};
        int kak=0;
        rep(j,n){
            if(nck[j]){
                rep(k,m){
                    pre[k]+=a[j][k];
                }
                kak+=c[j];
            }
        }
        int flag=1;
        rep(j,m){
            if(pre[j]<x) {
                flag=0;
                break;
            }
        }
        if(flag) ans=min(ans,kak); 
        int cou=0;
        while(true){
            if(nck[cou]==1){
                nck[cou]=0;
                cou++;
            }else{
                nck[cou]=1;
                break;
            }
        }
    }
    if(ans==INT_MAX){
        cout << "-1" <<endl;
        return 0;
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 4032
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n, m;
    cin >> n >> m;
    i64 l = 1;
    akari<i64> as(n);
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
        as[i] >>= 1;
        l = as[i] * l / __gcd(as[i], l);
        if (l > m)
        {
            cout << 0 << endl;
            return;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if ((l / as[i]) & 1)
        {
            continue;
        }
        cout << 0 << endl;
        return;
    }
    i64 ans = m / l;
    ans = (ans + 1) / 2;
    cout << ans << endl;
}

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


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

int main(){
  int n;
  ll m;
  cin>>n>>m;
  vector<pair<ll,ll>> vec(n);;
  for(int i=0;i<n;i++){
    cin>>vec[i].first>>vec[i].second;
  }
  sort(vec.begin(),vec.end());
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=vec[i].first*min(vec[i].second,m);
    m-=min(vec[i].second,m);
    if(m==0){
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 109;
int a,b,c;
int main()
{
   std::ios_base::sync_with_stdio(false); cin.tie(NULL);
   cin>>a>>b>>c;
   if(a == b) cout<<c;
   else{
      if(a == c) cout<<b;
      else
       cout<<a;
   }
   return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int n = 0;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;

  vector<vi> groups;
  int m = n;
  if (n % 2 == 1) {
    groups.push_back(vi{n});
    m--;
  }

  for (int i = 1; i <= m && i < m-(i-1); i++) {
    groups.push_back(vi{i,m-(i-1)});
  }

  vector<pii> ans;
  forn (i,groups.size()) {
    vi g = groups[i];
    for (int j = i+1; j < (int)groups.size(); j++) {
      for(int v1 : g)
        for(int v2 : groups[j])
          ans.push_back(mp(v1,v2));
    }
  }

  cout << ans.size() << "\n";
  for (auto p : ans)
    cout << p.fst << " " << p.snd << "\n";

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long ll;
ll n,s[50],ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=s[i]*s[j];
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)

#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


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

    int N, M;
    int P[100000],Y[100000];
    vector<int> yd[100001];

    scanf("%d%d",&N,&M);
    rep(i, M) scanf("%d%d", &P[i], &Y[i]),yd[P[i]].push_back(Y[i]);
    rep(i ,N) sort (yd[i+1].begin() , yd[i+1].end() );
    rep(i ,M) printf ("%012lld\n" , ll (P[i]) * 1000000 + int ( lower_bound ( yd[P[i]].begin() , yd [P[i]].end() ,Y[i]) - yd[P[i]].begin()) + 1);


    /* 以下、TLE出まくったうんこ回答 */
//    int N,M;
//    cin >> N >> M;
//
//    int P, Y;
//
////    vector<pair<int, int> > pairs(M+1);
//    vector<pair<int, int> > original_pairs(M+1);
//
//    for(int i=1; i<M+1; i++){
//        cin >> P >> Y;
//        original_pairs[i] = make_pair(P, Y);
//    }
//
////    sort(pairs.begin(), pairs.end());
//
//    for(int i=1; i<M+1; i++){
//        //　何番か求める
//        int num = 0;
////        for(int tmp=1; tmp<M+1; tmp++){
////            if(pairs[tmp].first == original_pairs[i].first && pairs[tmp].second == original_pairs[i].second){
////                j=tmp;
////                break;
////            }
////        }
//
////        for(int k=1; k<=j; k++){
////            if(pairs[k].first == pairs[j].first){
////                num++;
////            }
////        }
//        for(int j=1; j<M+1; j++){
//            if(original_pairs[i].first == original_pairs[j].first && original_pairs[i].second > original_pairs[j].second){
//                num++;
//            }
//        }
//
//        cout  << setfill('0') << setw(6) << original_pairs[i].first << setfill('0') << setw(6) << num << '\n';
//    }






}

Measured memory_bytes: 7808
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

int main() {
    long long n;
    cin >> n;
    long long a[n + 1];
    long long b[n + 1];
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= n - 1; i++) {
        cin >> b[i];
    }
    b[n] = 0;
    long long count = 0;
    for (int i = 0; i < n; i++) {
        long long x = a[i], y = b[i];

        count += min(x, y);
        b[i] -= min(x, y);
        a[i] -= min(x, y);
        count += min(a[i + 1], b[i]);
        a[i + 1] -= min(a[i + 1], b[i]);
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 1792
n, m = list(map(int, input().split()))
maxl = 0
minr = 1000000
for i in range(m):
    l, r = list(map(int, input().split()))
    maxl = max(maxl, l)
    minr = min(minr, r)
if minr < maxl:
    print(0)
else:
    print(minr - maxl + 1)

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

int main()
{
	int mt[10];
	for(int i=0;i<10;i++){
		cin >> mt[i];
	}
	sort(mt,mt+10,greater<int>());
	for(int i=0;i<3;i++){
		cout << mt[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
package main

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

var sc *bufio.Scanner

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	m, d := nextInt(), nextInt()

	ans := 0
	for mth := 1; mth <= m; mth++ {
		for dth := 1; dth <= d; dth++ {
			switch {
			case dth/10 <= 1:
				continue
			case dth%10 <= 1:
				continue
			case (dth/10)*(dth%10) == mth:
				ans++
			default:
				continue
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PP = pair<int, P>;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    map<char, int> score;
    score['r'] = r;
    score['s'] = s;
    score['p'] = p;
    string t; cin >> t;
    string used;
    for(int i = 0; i < n; i++)
    {
        if(t[i] == 'r')
        {
            used += 'p';
        }
        if(t[i] == 's')
        {
            used += 'r';
        }
        if(t[i] == 'p')
        {
            used += 's';
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(i - k >= 0 && used[i - k] != 'x' && used[i] == used[i - k])
        {
            used[i] = 'x';
        }
        else
        {
            ans += score[used[i]];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    copy_n(istream_iterator<int>(cin), n, A.begin());
    vector<int64_t> C(n + 1);
    for (const auto &a: A)
        C[a]++;
    int64_t S = 0;
    for (const auto &c: C){
        S += c * (c - 1) / 2;
    }

    for (const auto &a: A){
        if (C[a] == 0)
            cout << S << endl;
        else
            cout << S - (C[a] * (C[a] - 1) / 2) + (C[a] - 1) * (C[a] - 2) / 2 << endl;
    }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

template<class T> struct SegTree{
  int n;
  vector<T> node;
  T initv;
  
  SegTree(int n_, T initv_){
    n = 1;
    while(n < n_) n *= 2;
    node.resize(n*2-1);
    initv = initv_;
    rep(i, n*2-1) node[i] = initv;
  }
  
  void update(int i, T val){
    i += n - 1;
    node[i] += val;
    while(i > 0) i = (i-1) / 2, node[i] = node[i*2+1] + node[i*2+2];
  }
  
  T getsum(int a, int b, int i, int l, int r){
    if(r<=a || b<=l) return initv;
    if(a<=l && r<=b) return node[i];
    T vl = getsum(a, b, i*2+1, l, (l+r)/2);
    T vr = getsum(a, b, i*2+2, (l+r)/2, r);
    return vl + vr;
  }
};

int main(){
    int n, q; cin >> n >> q;
    SegTree<int> st(n, 0);
    rep(i, q){
        int c, x, y; cin >> c >> x >> y;
        if(c) cout << st.getsum(x-1, y, 0, 0, st.n) << endl;
        else st.update(x-1, y);
    }
}


Measured memory_bytes: 3896
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n, m , ans , sum , a , b ,arr[mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin >> n >> m;
		for(int i = 0 ; i<m ; i++) {
			cin >> a;
			sum += a;
		}
		if(n < sum) {
			cout << "-1";
		}else {
			cout << n-sum ;
		}
	}
	return 0;
}


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

  int time,hour,minute,second;

  scanf("%d",&time);

    hour   = time / (60*60);
    minute = (time - hour*60*60) / 60;
    second = time % 60;

  printf("%d:%d:%d\n",hour,minute,second);

  return 0;
}

Measured memory_bytes: 1804
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC124A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = ReadInt;
            int B = ReadInt;

            if (A > B)
            {
                Console.WriteLine(2 * A - 1);
            }
          else if(A==B)Console.WriteLine(2*A);
            else
            {
                Console.WriteLine(2 * B - 1);
            }


        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

using namespace std;


void solve(){
    int a, l;
    cin>>a>>l;
    if(l&1) cout<<"No";
    else{
        if(a==l/4 && l%4==0) cout<<"Yes";
        else{
            while(a!=l/2){
                --a, l-=4;
                if(a==0){
                    cout<<"No";
                    return;
                }
            }
            cout<<"Yes";
        }
    }
}


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

    // int T; cin>>T; while(T--)
        solve();
}

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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	int ans = 1;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			ans = K;
		}
		else {
			ans *= (K - 1);
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
  ll N, M;
  pair<ll, ll> p[110000];
  ll res=0;
  cin >> N>> M;

  rep(i,N) {
    ll a, b;
    cin >> a >> b;
    p[i] = make_pair(a,b);
  }

  sort(p,p+N);

  ll cnt=0;
  rep(i,M){
    ll num=min(p[i].second, M-cnt);
    res += num*p[i].first;
    cnt += num;
  }
  cout << res << endl;
}


Measured memory_bytes: 2048
l, r = map(int, input().split())
d = r - l
d = min(d, 2019)
l %= 2019
r = l + d
ans = float('inf')
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        ans = min(ans, (i * j) % 2019)
print(ans)

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	FastReader sc = new FastReader();
	int n = sc.nextInt();
	int k = sc.nextInt();
	int[] p = new int[n];
	
	for (int i = 0; i < n; i++) {
		p[i] = sc.nextInt();
	}
	
	System.out.println((int)Math.ceil((double)(n-1)/(double)(k-1)));
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 33896
# coding: utf-8


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    H = list(map(int, args[1].split()))
    AB = [tuple(map(int, ab.split())) for ab in args[2:]]

    R = [set() for _ in range(n)]
    for a, b in AB:
        R[a-1].add(b-1)
        R[b-1].add(a-1)

    ret = 0
    for i, D in enumerate(R):
        if len(D) == 0 or max([H[d] for d in D]) < H[i]:
            ret += 1

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

typedef long long ll;

ll n, cnt;

ll dfs(ll x, int cnt3, int cnt5, int cnt7) {
    if(x > n)
        return 0;
    if(cnt3 && cnt5 && cnt7) {
        cnt ++;
    }
    dfs(x * 10 + 3, 1, cnt5, cnt7);
    dfs(x * 10 + 5, cnt3, 1, cnt7);
    dfs(x * 10 + 7, cnt3, cnt5, 1);
}

int main() {
    scanf("%lld", &n);
    dfs(0, 0, 0, 0);
    printf("%lld", cnt);
    return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x, y;
    x = c / b;
    if(c % b != 0){
        x++;
    }
    y = a / d;
    if(a % d != 0) {
        y++;
    }
    // cout << x << "  "<< y << endl;  
    if(x > y){
        cout << "No";
    } else {
        cout << "Yes";
    }
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

/* 
	add utility Algorithm
*/

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int A, B;
    cin >> A >> B;

    if(A == 2 || B == 2) {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
    }

    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//

ll dp[105][100005];

int main() {
  int n, k;
  cin >> n >> k;
  vi w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  rep(i, n) rep(j, k+1) {
    if (j - w[i] >= 0) {
      chmax(dp[i+1][j], dp[i][j - w[i]] + v[i]);
    }
    chmax(dp[i+1][j], dp[i][j]);
  }
  cout << dp[n][k] << endl;
}

Measured memory_bytes: 81588
import sys, heapq

def calccontestnumbers(D, complaints, satisfications):
    ContestDays = [1] * 26
    HoldedContests = [-1] * D
    for i in range(D-1):
        Demands = []
        for j in range(26):
            Demand_j = ContestDays[j] * complaints[j] + satisfications[i][j]
            heapq.heappush(Demands, (-Demand_j, j) )
            ContestDays[j] += 1
        Demand_Contest = heapq.heappop(Demands)
        Contest = Demand_Contest[1]
        ContestDays[Contest] =1
        HoldedContests[i] = Contest+1

    Demands = []
    for j in range(26):
        Demand_j = -ContestDays[j] * complaints[j] + satisfications[D-1][j]
        heapq.heappush(Demands, (-Demand_j, j) )
        ContestDays[j] += 1
    Demand_Contest = heapq.heappop(Demands)
    Contest = Demand_Contest[1]
    HoldedContests[D-1] = Contest+1

    return HoldedContests



"""
13: 19922, 89
20: 19830, 80
20: 19830 - 80 * 5 = 19430
13: 19922 - 89 * 2 = 19744
毎日1つのコンテスト
満足度をあげるようにコンテスト
ci * (最後にコンテストを行ってからの経過日数)満足度低下
上昇値はs_d_i

"""
if(__name__ == "__main__"):
    D = int(input().strip())
    complaints = list(map(int, input().split() ) )

    satisfications = []
    for i in range(D):
        satisfication = list(map(int, input().split() ) )
        satisfications.append(satisfication)
    HoldedContests = calccontestnumbers(D, complaints, satisfications)
    for i in range(D):
        print(HoldedContests[i])


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

int a[100001] = {0};

int main(void) {
	int N, x;
	cin >> N >> x;

	long long ans = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		if ((a[i-1] + a[i]) > x) {
			long long eat = (a[i] +a[i-1]) - x;
			a[i] -= eat;
			ans += eat;
		}
	}
	cout << ans << endl;

	return 0;
}


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

ll solve() {
    ll N, A, B;
    cin >> N >> A >> B;
    return (abs(A-B) % 2 == 0);
}

int main() {
    string ans = solve() ? "Alice" : "Borys";
    cout << ans << "\n";
    return 0;
}

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

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

int main(void){
    // Your code here!
    int N;
    string S;
    set<string> st;
    cin >> N >> S;
    auto calc = calcNext(S);
    for(int i = 0; i <= N-3; i++){
        for(int j = 0; j <= 9; j++){
            if(calc[i+1][j] >= N) continue;
            int order1 = calc[i+1][j];
            for(int k = 0; k <= 9; k++){
                if(calc[order1+1][k] >= N) continue;
                int order2 = calc[order1 + 1][k];
                string tmp = "";
                tmp += S[i];
                tmp += S[order1];
                tmp += S[order2];
                st.insert(tmp);
            }
        }

    }
    
    cout << st.size() << endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

/*#ifndef __LOCAL__ 
#pragma comment(linker,"/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif*/ 

using namespace std;
using namespace __gnu_pbds;
 
//#define int int64_t

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ost;

typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<set<int>> vsi;

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define F first
#define S second
#define fore(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define debug(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0)


const int N1=100*1000;
const int N2=1000*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T>
istream& operator >> (istream& is,vector<T>& vec){
  for(T &x:vec)is>>x;
  //for(int i=0;i<vec.size();++i)is>>x[i];
  return is;
}

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

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

const ll FIXED_RANDOM=chrono::steady_clock::now().time_since_epoch().count();

struct chash {
    static unsigned long long hash_f(unsigned long long x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    static unsigned hash_combine(unsigned a, unsigned b) { return a * 31 + b; }
    int operator()(int x) const { return hash_f(x); }
};
//unordered_map <int, int, chash> m; way to use this 
//the way you're supposed to do is it by initializing FIXED_RANDOM with something like chrono::steady_clock::now().time_since_epoch().count()(current time in microseconds or something like that) and instead of hash_f(x) do hash_f(FIXED_RANDOM^x) 

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

ll mpow(ll a, ll b){
  ll ret=1;
  while(b>0){
    if(b&1LL)(ret*=a)%=mod;
    (a*=a)%=mod;
    b>>=1LL;
  }
  return ret;
}

void solve(){
  int n;cin>>n;
  int ans=n/2;
  if(n%2==0)ans--;
  cout<<ans<<endl;
  
}
int32_t  main(){
  IOS;
  cout<<(fixed)<<setprecision(6);
  solve();
  return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    if a % b == 0:
        return b
    return gcd(b, a%b)

L = [0]; R = [0]
for i in range(N-1):
    L.append(gcd(L[i], A[i]))
    R.append(gcd(R[i], A[N-1-i]))

maxGCD = 1
for j in range(N):
    maxGCD = max(maxGCD, gcd(L[j], R[N-j-1]))
print(maxGCD)


Measured memory_bytes: 14400
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	map<int, int> cards;
	int a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		++cards[a];
	}

	int b, c;
	while (m--) {
		cin >> b >> c;
		cards[c] += b;
	}

	long long ans = 0;
	int left = n;
	for (auto it = cards.rbegin(); it != cards.rend(); ++it) {
		int curr = min(left, it->second);
		ans += (long long) curr * (it->first);
		left -= curr;
		if (!curr) {
			break;
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 9600
k=int(input())
m = input()
codes = 65                    # 文字 a の文字コード
kosu = 26                      # 英字アルファベットの数
leng = len(m)                  # 文字列の長さ
c = ""

for i in range(leng):
    code = ord(m[i])           # i 文字目のコードを得る
    
    sa = code - codes
        #
    if sa>=0 and sa<kosu:
    	sa=(sa+k)%kosu
        #
    c = c + chr(sa + codes)    # 暗号文用のコードの格納
print(c)


Measured memory_bytes: 3060
#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(){
    string s;
    cin >> s;
    if(s.at(0) == s.at(1) && s.at(1) == s.at(2) && s.at(0) == s.at(2)) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int n;
  scanf("%d",&n);

  char W[n][11];
  for(int i = 0; i < n; ++i){
    scanf("%s",&W[i]);
  }

  /*しりとり2重チェック*/
  for(int i = 0; i < n; ++i){
    for(int j = i+1; j < n; ++j){
      if( strcmp(W[i], W[j]) == 0 ){
      printf("No");
      return 0;
      }
    }
  }

  /*しりとり接続チェック*/
  for(int i = 1; i < n; ++i){
    int len = strlen(W[i-1]);
    if( W[i-1][len-1] != W[i][0] ){
      printf("No");
      return 0;
    }
  }

  printf("Yes");

  return 0;
}


Measured memory_bytes: 1704
N = int(input())

def get_divs(n):
    divs = []
    for i in range(1, int(n**0.5)+1):
        if n%i==0:
            divs.append(i)
            if n//i!=i:
                divs.append(n//i)
    return divs

divs = get_divs(N)

ans = 0
for d in divs:
    l = d - 1
    if 0 < l > N//d:
        ans += (d-1)

print(ans)




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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 400*1000+10, maxl = 18;
int n, k, c, mx[maxn][maxl], tmp = 1, l[maxn], r[maxn];
string s;
vector<int> ja;

int g(int *arr, int x)
{
	if (x < 0 || x >= maxn)
		return 0;
	return arr[x];
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k >> c >> s;
	if (c == 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (s[i] == 'o')
				ja.push_back(i + 1);
		}
		if (SZ(ja) == k)
		{
			for (auto &w : ja)
				cout << w << endl;
		}
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		l[i + 1] = l[i];
		if (s[i] == 'o')
			l[i + 1] = max(l[i + 1], 1 + g(l, i - c));
	}
	for (int i = n - 1; i >= 0; i--)
	{
		r[i] = r[i + 1];
		if (s[i] == 'o')
			r[i] = max(r[i], 1 + g(r, i + c + 1));
	}
	for (int i = 0; i < 2 * n; i++)
	{
		r[i] += g(l, i - c);
		mx[i][0] = r[i];
	}
	for (int i = 1; i < maxl; i++)
	{
		tmp *= 2;
		for (int j = 0; j + tmp <= 2 * n; j++)
			mx[j][i] = max(mx[j][i - 1], mx[j + tmp / 2][i - 1]);
	}
	tmp = 0;
	while ((1 << tmp) <= c)
		tmp++;
	tmp--;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'x')
			continue;
		if (max(mx[i + 1][tmp], mx[i + 1 + c - (1 << tmp)][tmp]) < k)
			cout << i + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 31892
#include <stdio.h>
int n,i,A[2000];
int solve(int,int);
int main(){
  int m[2000],q;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&m[i]);
  for(i=0;i<q;i++){
    if(solve(0,m[i])==1)
      printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  int res;
  if(m==0)
    return 1;//真                                                               
  if(i>=n)
    return 0;//負                                                               
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}




Measured memory_bytes: 2100
n,m,l = map(int,input().split())
matrixA = [list(map(int,input().split())) for i in range(n)]
matrixB = [list(map(int,input().split())) for i in range(m)]
 
matrixAxB = [list(sum([matrixA[i][k] * matrixB[k][j] for k in range(m)]) for j in range(l)) for i in range(n)]
 
for row in matrixAxB:
    print(*row)

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

int main() {
    int N; cin>>N;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        cin>>h[i];
        
    }
    int max=h[0];
    int ans=0;
    int cnt=0;
    for(int i=0;i<N;i++){
        if(max<=h[i]) {
            cnt++;
            max=h[i];
        }
        else{
            continue;
        }
        
    }
    
    cout<<cnt<<endl;
    
}
    


Measured memory_bytes: 384
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan =new Scanner(System.in);
    		String c=scan.next();
    		if (c.equals("a")||c.equals("i")||c.equals("u")||c.equals("e")||c.equals("o")) {
    			System.out.print("vowel");
    		}else {
    			System.out.print("consonant");
    		}
    		
    		
    }
     
    }

Measured memory_bytes: 20820
from collections import Counter
input()
A=list(map(int,input().split()))
A.sort(reverse=True)
C=Counter(A)
ans=0
for a in A:
    if C[a]==0:
        continue
    C[a]-=1
    t=2**a.bit_length()-a
    if C[t]:
        C[t]-=1
        ans+=1
print(ans)

Measured memory_bytes: 33296
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}

int main () {
	SpeedForce;
	
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	while(a >= b) {
		--k;
		b *= 2;
		
	}
	while(b >= c) {
		--k;
		c *= 2;
	}
	cout << (k >= 0 ? "Yes\n" : "No\n");

	return Accepted;
}

// B...a

Measured memory_bytes: 3628
def resolve():
    '''
    code here
    '''
    N = int(input())
    S = input()

    cnt = 0
    for i in range(1000):
        words = '{:0>3}'.format(i)
        k = 0
        for item in S:
            if item == words[k]:
                # print(item, words[k])
                k += 1

            if k == 3:
                cnt +=1
                break

    print(cnt)



if __name__ == "__main__":
    resolve()


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

using namespace std;

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, ok = 1;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        if (x % 2 == 0) {
            if (x % 3 != 0 && x % 5 != 0) ok = 0;
        }
    }
    if (ok) cout << "APPROVED";
    else cout << "DENIED";
    return 0;
}



Measured memory_bytes: 256