akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int a, b, c;
  readf("%s %s %s\n", &a, &b, &c);
  min(b/a, c).writeln;
}


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

int main()
{
    long long N;
    cin >> N;

    vector<pair<long long, pair<long long, long long>>> point(N);
    long long A, B;
    for (int i = 0; i < N; i++)
    {
        cin >> A >> B;
        point[i] = make_pair(A + B, make_pair(A, B));
    }
    sort(point.rbegin(), point.rend());

    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            ans += point[i].second.first;
        }
        else
        {
            ans -= point[i].second.second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  for(a;a<b+1;a++)
    {
      if(c%a==0)d++;
    }
  printf("%d\n",d);
  return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b <= 2 * c) {
        cout << a * x + b * y << '\n';
    }
    else {
        int ans = 2 * c * min(x, y);
        if (x <= y) {
            if (b > 2 * c) ans += (y - x) * 2 * c;
            else ans += (y - x) * b;
        }
        else {
            if (a > 2 * c) ans += (x - y) * 2 * c;
            else ans += (x - y) * a;
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(){
	int i,x,z;
	char y;
	string str;
	while(cin>>str){
		string ans;
		for(i=0;i<str.size();i++){
			if(str[i]=='@'){
				int x;
				char y;
				x=str[i+1]-'0';
				y=str[i+2];
				for(z=1;z<=x;z++){
					ans+=y;
				}
				i=i+2;
			}else{
				ans+=str[i];
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){

	int N;
	cin >> N;
	
	long long power = 1;
	
	for(int i=1;i<=N;i++){
		power = power*i%(int(pow(10.0,9.0))+7);
	
	}
	
	cout << power << endl;
	
	
	return 0;

}

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

int main(){
    int coin;

    cin >> coin;

    int fHoundred=0,five=0;
    fHoundred = coin / 500;
    coin -= 500*fHoundred;
    five = coin / 5 ;
    cout << fHoundred * 1000 + five * 5 << endl;

    return 0;
}

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

ll GCD(ll c, ll d){
  if(c<d)swap(c,d);
  if(c%d==0)return d;
  else{return GCD(c%d,d);}
}

int main() {
  ll a,b,c,d; cin>>a>>b>>c>>d;
  ll g=GCD(c,d);
  ll l=c*d/g;
  a--;
  ll a_=a/c+a/d-a/l;
  ll b_=b/c+b/d-b/l;

  ll ans=(b-b_)-(a-a_);
  cout<<ans;
}
      



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int>> vs(26);
  rep(i, n){
    char now = s[i] - 'a';
    vs.at(now).insert(i);
  }
  int q;
  cin >> q;
  rep(i, q){
    int qq;
    cin >> qq;
    if(qq == 1){
      int j;
      cin >> j;
      j--;
      char c;
      cin >> c;
      rep(k, 26){
        if(vs.at(k).count(j) == 1) vs.at(k).erase(j);
      }
      vs.at(c-'a').insert(j);
    }else{
      int l, r;
      cin >> l >> r;
      l--; r--;
      int ans = 0;
      rep(j, 26){
        auto itr = vs.at(j).lower_bound(l);
        if(itr == vs.at(j).end() || r < *itr) continue;
        ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24196
import Data.List

main :: IO ()
main = do
  [k, t] <- getInts
  ns <- zip [1..] <$> getInts
  print $ solve k t ns

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Int -> Int -> [(Int, Int)] -> Int
solve k t ns = max (mx - 1 - (k - mx)) 0
  where
    (ma, mx) = maximumBy (\(_, a) (_, b) -> compare a b) ns


Measured memory_bytes: 892
#include <stdio.h>
#include <iostream>

int main() {
    int cnt;
    int value;
    
    value = 1;
    cnt = 0;
    
    while(1) {
        cnt++;
        scanf("%d", &value);
        if (!value) break;
        printf("Case %d: %d\n", cnt, value);
    }
    
    return 0;
}

Measured memory_bytes: 3132
mod = 10**9+7
import math
N, K = map(int, input().split())
fac = [0]*2010
for i in range(2010):
    fac[i] = math.factorial(i)

def C(n, k):
    return fac[n]//fac[k]//fac[n-k]
def f(k, m, i):
    if m<i+1:
        C1 = 0
    else:
        C1 = C(m-1, i)
    if m<i:
        C2 = 0
    else:
        C2 = C(m-1, i-1)
    if (i<=1) or (m<i-1):
        C3 = 0
    else:
        C3 = C(m-1, i-2)
    if i==1 and m==0:
        C3 = 1
    return C(k-1, i-1)*(C1+C2*2+C3)
M = N-K
for i in range(1, K+1):
    print(f(K, M, i)%mod)



Measured memory_bytes: 5876
#define _USE_NATH_DEFINES
#include<iostream>
#include<string>
using namespace std;

int main() {
	string s;
	cin >> s;
	if(s[5] == '0'){
	 if (s[6] <= '4') cout << "Heisei" << endl;
	 else cout << "TBD" << endl;
	}
	else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int A, B, C, D;

int main() {
	int ans = 0;
	cin >> A >> B >> C >> D;
	if (B < C || D < A) {
		ans = 0;
	}
	else if (C <= A && B <= D) {
		ans = B - A;
	}
	else if (A <= C && D <= B) {
		ans = D - C;
	}
	else if (A <= B && B <= D) {
		ans = B - C;
	}
	else if (C <= A && D <= B) {
		ans = D - A;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
    input = input.split('\n');
  	let textlen = parseInt(input[0].split(' ')[0]);
  	let target = parseInt(input[0].split(' ')[1]);
	let text = input[1].split("");
  	text[target-1] = text[target-1].toLowerCase();
    console.log('%s',text.join(''));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  string S;
  cin >> S;
  string t = "AKIHABARA";
  set<string> vs;
  for (int i = 0; i < 1 << 9; i++) {
    string x;
    for (int j = 0; j < 9; j++) {
      if (t[j] == 'A' && (i >> j) & 1) {
      } else {
        x += t[j];
      }
    }
    vs.insert(x);
  }
  string ans = "NO";
  if (vs.count(S) > 0) ans = "YES";
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


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

using namespace std;

struct S
{
    long long x, y, z;
    long long sum(int n) const 
    {
        return 
        ((n == 3 || n == 5 || n == 6 || n == 7) ? ( x * -1 ) : x )+
        ((n == 2 || n == 4 || n == 6 || n == 7) ? ( y * -1 ) : y )+
        ((n == 1 || n == 4 || n == 5 || n == 7) ? ( z * -1 ) : z );
    }
};

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

    vector<S>v(N);

    for(auto& it: v)
    {    
        cin >> it.x >> it.y >> it.z;
    }

    long long maxn = 0;

    for(int i = 0; i < 8; ++i)
    {
        std::sort(v.begin(), v.end(),
            [&](const S& lh,const S& rh){
                return lh.sum(i) > rh.sum(i);
            }    
        );

        long long sumx = 0, sumy = 0, sumz = 0;
        for (int i = 0; i < M; ++i)
        {
            sumx += v.at(i).x;
            sumy += v.at(i).y;
            sumz += v.at(i).z;
        }

        long long sums = abs(sumx) + abs(sumy) + abs(sumz);

        maxn = std::max(maxn,sums);
    }


    cout << maxn;

}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n; cin >> n;
  vector<ll> v(n); cin >> v;
  vector<map<ll, ll>> cnt0(2);
  rep(i, n) {
    cnt0[i%2][v[i]]++;
  }
  vector<vector<P>> cnt(2);
  rep(i, 2) each(p, cnt0[i]) {
    cnt[i].pb(P(p.second, p.first));
  }
  rep(i, 2) sort(all(cnt[i]));
  ll ans = 0;
  {
    auto it1 = prev(cnt[0].end(), 1);
    auto it2 = prev(cnt[1].end(), 1);
    if (it1->second == it2->second) {
      if (it2 != cnt[1].begin()) {
        --it2;
        chmax(ans, it1->first + it2->first);
      }
      else {
        chmax(ans, it1->first);
      }
    }
    else {
      chmax(ans, it1->first + it2->first);
    }
  }
  {
    auto it1 = prev(cnt[0].end(), 1);
    auto it2 = prev(cnt[1].end(), 1);
    if (it1->second == it2->second) {
      if (it1 != cnt[0].begin()) {
        --it1;
        chmax(ans, it1->first + it2->first);
      }
      else {
        chmax(ans, it2->first);
      }
    }
    else {
      chmax(ans, it1->first + it2->first);
    }
  }
  ans = n - ans;
  cout << ans << endl;
}


Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

const int maxN = 100005;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

class TaskB {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int ha, sa, hb, sb;
		cin >> ha >> sa;
		cin >> hb >> sb;
		for(int i = 0; ha > 0 and hb > 0 ; i++){
			if(i % 2 == 0){
				hb -= sa;
			}else{
				ha -= sb;
			}
		}
		cout << (ha > 0 ?"Yes":"No" ) << endl;

	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskB solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3636
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int[] x = new int[N];
            int[] y = new int[N];
            double[,] Road = new double[N, N];
            for (int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                x[i] = int.Parse(str[0]);
                y[i] = int.Parse(str[1]);
            }
            //int M = int.Parse(str[1]);
            for (int i = 0; i < N; i++)
            {
                for (int j = i; j < N; j++)
                {
                    Road[i, j] = Math.Sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
                    Road[j, i] = Road[i, j];
                }
            }

            int kaizyou = 1;
            for (int i = 1; i < N + 1; i++)
            {
                kaizyou = kaizyou * i;
            }
            int tmp = kaizyou * 2 / N;
            double ans = 0;
            for (int i = 0; i < N; i++)
            {
                for (int j = i; j < N; j++)
                {
                    ans += tmp * Road[i, j];
                }
            }
            ans = ans / kaizyou;
            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
const int maxn = 1e2 + 5;
using namespace std;

int main()
{
	int m, n;
	while (cin >> n) {
		m = n;
		int sum = 0;
		while (m) {
			sum += m % 10;
			m /= 10;
		}
		if (n % sum)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
	return 0;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
ll N[maxn];
int main()
{
	int n,k;string s;cin>>n;cin>>s;cin>>k;
	char c=s[k-1];
	for(int i=0;i<s.length();i++)
	{
		if(c==s[i]) printf("%c",s[i]);
		else printf("*");
	}
	
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

int main()
{
    ll i,j,n;
    cin>>n;
    vector<int> a,b;
    for(i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        a.push_back(x-y);
        b.push_back(x+y);
    }
    ll mna = *min_element(all(a));
    ll mxa = *max_element(all(a));
    ll mnb = *min_element(all(b));
    ll mxb = *max_element(all(b));
    ll ans = max(mxa - mna, mxb - mnb);
    cout<<ans<<"\n";
}

Measured memory_bytes: 4996
#ABC127-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n,m=IL()
l,r=IL()
for i in range(m-1):
    nl,nr=IL()
    l=max(nl,l)
    r=min(nr,r)
print(max(r-l+1,0))

Measured memory_bytes: 47592
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,np,ns;
    cin>>n;
    ns = n%100;
    np = n/100;
    if((np>12 ||np==0) && (ns<13&&ns>0))
        cout<<"YYMM"<<endl;
    else if((np<13&&np>0)&&(ns>12||ns==0))
        cout<<"MMYY"<<endl;
    else if(np<13 &&(ns<13&&ns>0))
        cout<<"AMBIGUOUS"<<endl;
    else
        cout<<"NA";
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    ll a[n],ans=0,count=1;
    for (ll i=0;i<n;i++)cin >> a[i];
    for (ll i=0;i<n;i++){
        if (a[i]==count){
            count++;
            continue;
        }
        ans++;
    }
    if (ans==n){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	string s;
	char ans='1';
	int n;
	cin>>s>>n;
	for(int i=0;i<n;i++){
		if(s[i]=='1'){
			
		}
		else{
			ans=s[i];
			break;
		}
	}
	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
ll pre[2001][2001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    return(b%a,a);
}

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
ll fib(ll n)
{
    if(n<=1)
    {
        return n;
    }
    return fib(n-1)+fib(n-2);
}
void ncr()
{
    pre[0][0]=1;
    go(i,1,2001)
    {
        pre[i][0] = 1;
        go(j,1,2001)
        {
            pre[i][j] = pre[i-1][j] + pre[i-1][j-1];
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll ans = (a+b);
    if(ans&1) show("IMPOSSIBLE");
    else show((ans>>1));
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
X = open(0).readlines()
n = int(X[0])
*A, = map(int, X[1].split())
counter = Counter(A)
q = int(X[2])
s = sum(A)
for x in X[3:]:
    b, c = map(int, x.split())
    if b in counter:
        t = counter.pop(b)
        s += c*t - b*t
        counter[c] = counter.get(c, 0) + t
    print(s)

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

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector< int > r_arr(r);
    const int INF = 1000000000;
    int w[n][n];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) {
                w[i][j] = 0;
            } else {
                w[i][j] = INF;
            }
        }
    }
    for (int i = 0; i < r; i++) {
        cin >> r_arr[i];
    }
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        w[a - 1][b - 1] = min(w[a - 1][b - 1], c);
        w[b - 1][a - 1] = min(w[b - 1][a - 1], c);
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
            }
        }
    }

    int min_res = INF;
    sort(r_arr.begin(), r_arr.end());
    do {
        int res = 0;
        for (int i = 0; i < r - 1; i++) {
            res += w[r_arr[i] - 1][r_arr[i + 1] - 1];
        }
        min_res = min(min_res, res);
    } while (next_permutation(r_arr.begin(), r_arr.end()));
    cout << min_res;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);

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

    vector<int> a(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> b(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    
    int cnt = 1;
    int bef = 0;
    int aft = 0;
    do {
        if (a == v) {
            bef = cnt;
        }
        if (b == v) {
            aft = cnt;
        }
        cnt++;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(bef - aft) << endl;    
}

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

using namespace std;

const int maxn = 100010;

vector<int> g[maxn];

int c[maxn];

typedef long long ll;
vector<ll> vec;
bool dfs(int u,int par) {
	if(par) g[u].erase(find(begin(g[u]), end(g[u]), par));
	for(auto v: g[u]) if(!dfs(v, u)) return false;
	if(g[u].size() == 0) return true;
	vec.clear();
	for(auto v: g[u]) vec.push_back((ll)c[v]);
	auto mx = *max_element(begin(vec), end(vec));
	auto sum = accumulate(begin(vec), end(vec), 0ll);
	if(sum > 2 * c[u] || sum < c[u]) return false;
	if(sum - mx < sum - c[u]) return false;
	c[u] = 2 * c[u] - sum;
	return true;
}

int main() {
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &c[i]);
	for(int i = 1; i < n; ++i) { int u, v; scanf("%d%d", &u, &v); g[u].push_back(v); g[v].push_back(u); }
	if(!dfs(1, 0)) puts("NO");
	else if(g[1].size() > 1 && c[1]) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 11392
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	nn := pow(2, n)
	s := scanInts(nn)
	sort.Ints(s)

	pq := &priorityQueue{nn}
	heap.Init(pq)
	for i := len(s) - 1; i >= 0; {
		num := s[i]
		c := 1
		for i-c >= 0 && num == s[i-c] {
			c++
		}
		// debug(*pq, num, c)
		if len(*pq) < c {
			fmt.Fprintln(wr, "No")
			return
		}
		arr := make([]int, c)
		for j := 0; j < c; j++ {
			arr[j] = heap.Pop(pq).(int)
		}
		for j := 0; j < c; j++ {
			for arr[j] > 1 {
				arr[j] /= 2
				heap.Push(pq, arr[j])
			}
		}
		i -= c
	}
	fmt.Fprintln(wr, "Yes")

}

type priorityQueue []int

func (pq priorityQueue) Len() int            { return len(pq) }
func (pq priorityQueue) Swap(i, j int)       { pq[i], pq[j] = pq[j], pq[i] }
func (pq priorityQueue) Less(i, j int) bool  { return pq[i] > pq[j] }
func (pq *priorityQueue) Push(x interface{}) { *pq = append(*pq, x.(int)) }
func (pq *priorityQueue) Pop() interface{} {
	x := (*pq)[len(*pq)-1]
	*pq = (*pq)[0 : len(*pq)-1]
	return x
}

func pow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res *= a
		}
		a *= a
		n >>= 1
	}
	return res
}


Measured memory_bytes: 8832
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val b = readLine()!!.split(" ").map{it.toInt()}
    var sum = b[0] + b[n - 2]
    for(i in 1 until n - 1){
        sum += Math.min(b[i], b[i - 1])
    }
    println(sum)
}

Measured memory_bytes: 35952
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1000000007;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int M;
    cin >> M;
    lint ans = 0, sum = 0;
    for(int i = 0; i < M; i++){
        int d;
        lint c;
        cin >> d >> c;
        ans += c, sum += c * d;
    }
    cout << ans + (sum - 1) / 9 - 1 << endl;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))

c = 0
for i in range(1,n-1):
  if p[i-1] < p[i] and p[i] < p[i+1]:
  	c += 1
  elif p[i+1] < p[i] and p[i] < p[i-1]:
    c += 1
  else:
    pass

print(c)
  

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

#define  Infile			freopen("input.txt", "r", stdin)
#define  Outfile		freopen("output.txt", "w", stdout)
#define  lowb(a,x) 		lower_bound(a.begin(),a.end(),x)-a.begin();
#define  upb(a,x) 		upper_bound(a.begin(),a.end(),x)-a.begin();
#define  fu(i,a,b)		for(long long i=(a); i<=(b); ++i)
#define  fd(i,a,b)		for(long long i=(a); i>=(b); --i)
#define  fo(i,n)		for(long long i=0; i<(n); ++i)
#define  show(a) 		cout<<"\n-> "<<#a<<" = "<<(a)<<endl;
#define  fix_set(x)		fixed<<setprecision(x)
#define  ms(a)			memset(a, 0, sizeof(a))
#define  all(x)			(x).begin(), (x).end()
#define  pb(x)			push_back(x)
#define  ar(x, n)		(x),(x)+(n)
#define  mp(a,b)		make_pair(a, b)
#define	 fst			first
#define	 snd			second

typedef long long ll;
typedef vector <ll> vtll;

clock_t TimeBegin, TimeEnd;
ll LX[] = {-1,0,0,1,-1,-1,1,1}; // 8 - 4
ll LY[] = {0,-1,1,0,-1,1,-1,1}; 
ll const INF = LLONG_MAX;


inline ll mod(string num, ll Base);
inline ll diMod(ll A, ll B, ll Base);
inline ll fpow(ll a, ll x, ll Base);
inline string toString(ll n);
inline void Tstart();
inline void Tstop();


//Declare Here
ll n, a[100005];
ll x = INF, cm = 0, s = 0;

//============//

void Solve()
{
	cin >> n;
	fo(i, n)
	{
		cin >> a[i];
		if (a[i] < 0)
			cm++;
		x = min(x, abs(a[i]));
		s += abs(a[i]);
	}
	if (cm&1)
	{
		s -= x*2;
	}
	cout << s;
	
}


//=============================================================================//

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

	#ifdef RAVENCLAW
		Infile;
		//Outfile;
	#endif
		Solve();

	return 0;
}

//=============================================================================//
//=============================================================================//

inline ll mod(string num, ll Base) 
{ 
    ll res = 0; 
    fo(i, num.length()) 
        res = (res*10 + (ll)num[i] - '0') % Base;
    return res; 
} 

inline ll fpow(ll a, ll x, ll Base)
{
	if(x==0)return 1;	
	if(x&1) 
	{
		return a*fpow(a, x-1, Base)%Base;
	} 
	else
	{
		ll t=fpow(a, x/2, Base);
		return t*t%Base;
	}
}

inline ll diMod(ll A, ll B, ll Base)
{
	//(A/B)%Base
	ll result = (A * fpow(B, Base-2, Base)) % Base; 
	return result;
}

inline string toString(ll n) 
{
	stringstream ss; ss << n;
	return ss.str();
}	

inline void Tstart()
{
	TimeBegin = clock();
}

inline void Tstop()
{
	TimeEnd = clock();
	cout << "\nTime elapsed: " << 1000 * (TimeEnd - TimeBegin) / CLOCKS_PER_SEC << " ms\n";
}

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

#define int long long 
#define dou  double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,m,i,j,cnt,maxi=INT_MIN;
	string str1,str2;
	cin >> str1 >>str2;
	n = str1.size();
	m = str2.size();
	for(i=0;i<=n-m;i++)
	{
		cnt =0;
		for(j=0;j<m;j++)
		{
			if(str1[i+j] == str2[j])
				cnt++;
		}
		if(cnt>maxi)
			maxi = cnt;
	}
	cout << m-maxi << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

Measured memory_bytes: 3652
N,M = [int(i.strip()) for i in input().split(' ')]
A = [int(i.strip()) for i in input().split(' ')]

S = sum(A)

c = 0
for i in A:
    if i >= S/(4*M):
        c += 1

if c >= M:
    print('Yes')
else:
    print('No')

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

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

    cout << max({a * c, a * d, b * c, b * d}) << endl;

    return 0;
}

Measured memory_bytes: 3692
#include <cstdio>
#include <map>
using namespace std;

int main() {
    int N; scanf("%d", &N);
    map<int, int> mp;
    for(int i=0; i<N; i++) {
        int A; scanf("%d", &A);
        mp[A] ^= 1;
    }

    int ans = 0;
    for(auto x : mp) {
        ans += x.second;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>
int main() {
char c[11];
scanf("%s", c);
int left = 0;
int best = 753;
for (left=0; c[left+2]!=0; left++) {
int num = (c[left] - 0x30) * 100 + (c[left+1] - 0x30) * 10 + (c[left+2] - 0x30);
int diff = num - 753;
if (diff < 0) diff *= -1;
if (best > diff) best = diff;
}
printf("%d\n", best);
return 0;
}

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

d = {'gry':0,'brw':0,'grn':0,'miz':0,'blu':0,'yel':0,'dai':0,'red':0,'any':0}
for i in a:
    if 1 <= i <= 399:
        d['gry'] += 1
    elif 400 <= i <= 799:
        d['brw'] += 1
    elif 800 <= i <= 1199:
        d['grn'] += 1
    elif 1200 <= i <= 1599:
        d['miz'] += 1
    elif 1600 <= i <= 1999:
        d['blu'] += 1
    elif 2000 <= i <= 2399:
        d['yel'] += 1
    elif 2400 <= i <= 2799:
        d['dai'] += 1
    elif 2800 <= i <= 3199:
        d['red'] += 1
    else: #any
        d['any'] += 1

ans = 0
zero = 0
for k,v in d.items():
    if k == 'any':
        pass
    else:
        if v != 0:
            ans += 1

print (max(1,ans),ans+d['any'])


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

int main()
{
  string s,t;
  
 cin>>s>>t;
  
  int l=s.length();
  int count=0;
  for(int i=0;i<l;i++)
  {
    if(s[i]!=t[i])
      count++;
  }
  
  cout<<count<<endl;
}
  
  

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  int n = 0;
  int max = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'I') n++;
    else n--;

    if (n > max) max = n;
  }

  cout << max << endl;
}


Measured memory_bytes: 256
import math

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for num in range(1, 4):
    z = []
    for X, Y in zip(x, y):
        z.append(abs((X - Y))**num)
    print((sum(z))**(1 / num))
print(max(abs(X - Y) for X, Y in zip(x, y)))
        


Measured memory_bytes: 5700
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

ll pref1[100050];
ll pref2[100050];
int niz[100050];

int n,k;

void input(){
	cin>>n>>k;
	int br;
	
	for(int i=1;i<=n;i++){
		cin>>br;
		niz[i]=br;
		if(i==0){
			pref1[i]=br;
			if(br>=0)pref2[i]=br;
		}
		else{
			pref1[i]=pref1[i-1]+br;
			pref2[i]=pref2[i-1];
			if(br>=0)pref2[i]+=br;
		}
		
	}
}

int main(){
	input();
	
	ll maxx1=-1000000000000000000;
	ll maxx2=-1000000000000000000;
	for(int i=1;i<=n-k+1;i++){
		ll raz1=pref1[i+k-1]-pref1[i-1];
		ll raz2=pref2[i+k-1]-pref2[i-1];
		
		ll raz3=0-raz2;
		ll raz4=raz1-raz2;
		
		maxx1=max(maxx1,raz3);
		maxx2=max(maxx2,raz4);
	}
	
	cout<<max(maxx1,maxx2)+pref2[n];
	
	
	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

string state;

void query(int i)
{
    cout << i << endl;
    cin >> state;
}

int main() {
    cin >> n;

    query(0);
    string state0 = state;

    if (state0[0] == 'V')
    {
        return 0;
    }

    int lo = 1;
    int hi = n - 1;

    while (hi - lo > 1)
    {
        if ((hi - lo + 2) % 4 == 1)
        {
            int mid = (lo + hi) / 2;
            query(mid);

            if (state[0] == 'V')
            {
                return 0;
            }
            else if (state[0] == state0[0])
            {
                lo = mid + 1;
            }
            else
            {
                hi = mid;
            }
        }
        else  // == 3
        {
            int mid = (lo + hi) / 2 - 1;
            query(mid);

            if (state[0] == 'V')
            {
                return 0;
            }
            else if (state[0] == state0[0])
            {
                lo = mid + 1;
            }
            else
            {
                hi = mid;
            }
        }
    }

    for (int i = lo; i <= hi; i++)
    {
        query(i);

        if (state[0] == 'V')
        {
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 852
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
monster_count = 0

for i in range(N):
    a_1, a_2 = A_list[i], A_list[i+1]
    b = B_list[i]
    if b>=a_1:
        monster_count = monster_count + a_1
        b = b - a_1
    elif b<a_1:
        monster_count = monster_count + b
        continue

    if b>=a_2:
        monster_count = monster_count + a_2
        A_list[i+1] = 0
    elif b<a_2:
        monster_count = monster_count + b
        a_2 = a_2 - b
        A_list[i+1] = a_2

print(monster_count)


Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int a,b;
    int *dif;
    cin >> N;
    dif = new int[N];
    for (int i=0;i<N;i++){
        cin >> dif[i];
    }

    sort(dif,dif+N);
    a = N / 2 - 1;
    b = N / 2;

    cout << dif[b] - dif[a] << endl;



    delete[] dif;
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
using namespace std;
int n,t;
long long m;
long long f[N],x[N]; 
int main()
{
	scanf("%d%lld%d",&n,&m,&t);
	for(int i=1;i<=n;i++) scanf("%lld",&x[i]),f[i]=100000000000;
	long long minn=100000000000;
	int r=0;
	for(int i=1;i<=n;i++)
	{
		while(r<i && (x[i]-x[r+1])*2>=t)
		{
			minn=min(minn,f[r]-2*x[r+1]);
			r++;
		}
		f[i]=min(f[r]+t,minn+2*x[i]);
	}
	printf("%lld",f[n]+m);
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>



int array[512345];

int a[212345];



int main(){

	int n;

	scanf("%d", &n);

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

	int left=212345, right=left+1;

	for(int i=0; i<n; ++i){

		if(i%2 == (n-1)%2){

			array[left--]=a[i];

		}else{

			array[right++]=a[i];

		}

	}

	for(int i=left+1; i<right; ++i){

		printf("%d ",array[i]);

	}

	return 0;

}



Measured memory_bytes: 3712
#include <stdio.h>

int main(void)
{
  int am, pm, i;
  char cl[20];

  for(i=0;i<9;i++)
    {
      scanf("%s %d %d", &cl, &am, &pm);
      printf("%s %d %d\n", cl, am+pm, am*200+pm*300);
    }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = 0 ;
	for(ll i=1;i*i<n;i++){
		if(i*i+1+i>n) break ;
		if((n-i)%i==0) ans += (n-i)/i ;
	}
	cout << ans << endl ;
}


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

money=1000
kabu=0

uru_t=[0]*n
kai_t=[0]*n

kai_flag=False
uri_flag=True

for i in range(n-1):
    tmp_v=a[i]
    for j in range(i+1,n):
        if tmp_v<a[j]:
            kai_flag=True
            break
    if a[i]<=a[i+1]:
        uri_flag=False

    if kai_flag:
        num_kabu=money//a[i]
        kabu+=num_kabu
        money-=num_kabu*a[i]

    if uri_flag:
        money+=kabu*a[i]
        kabu=0

    # print(money, kabu, kai_flag, uri_flag)
    kai_flag=False
    uri_flag=True

money+=kabu*a[-1]
print(money)


Measured memory_bytes: 9212
#include <iostream>
//#include <vector>

using namespace std;

int main () {
    int A,B,C,D,E;
    cin >> A >> B>>C>>D>>E;
    int k;
    cin >> k;
    
    if(B-A >k) cout << ":(" << endl;
    else if(C-A > k) cout << ":(" << endl;
    else if(D-A > k) cout << ":(" << endl;
    else if(E-A > k) cout << ":(" << endl;
    
    else if(C-B > k) cout << ":(" << endl;
    else if(D-B > k) cout << ":(" << endl;
    else if(E-B > k) cout << ":(" << endl;
    
    else if(D-C > k) cout << ":(" << endl;
    else if(E-C > k) cout << ":(" << endl;
    
    else if(E-D > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;    
}




Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}
  
int main(){
  ll n,k;cin >> n >> k;
  ll t=k;
  vector<ll> tele(n);
  rep(i,n){cin >> tele[i];tele[i]--;}
  if(k==1){cout << tele[0]+1 << endl;return 0;}

  ll syuuki=0;
  ll now=0;
  map<ll,ll> first;
  first[now]=0;
  rep(i,n+100){
    now=tele[now];
    if(first.count(now)){syuuki=i+1-first[now];break;}
    first[now]=i+1;
  }
  if(k<=first[now]){
    now=0;
    rep(i,k)now=tele[now];
    cout << now+1 << endl;
    return 0;
  }
  k-=first[now];
  k%=syuuki;
  rep(i,k){
    now=tele[now];
  }
  cout << now+1 << endl;
}

Measured memory_bytes: 17120
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int a;scanf("%d",&a);
int L=a/100;
int R=a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)printf("AMBIGUOUS\n");
else printf("MMYY\n");
}else{
if(1<=R&&R<=12)printf("YYMM\n");
else printf("NA\n");
}

    }

Measured memory_bytes: 256
def calculate(n,m,arr):

    if n >= m:
        print(0)
        return

    arr.sort()
    drr = list([])
    for index in range(1,len(arr)):
        drr.append(arr[index] - arr[index-1])
    drr.sort()
    drr = drr[:(m-n)]
    print(sum(drr))



S = input().split(" ")
n = int(S[0])
m = int(S[1])

S = input().split(" ")

arr = list([int(s) for s in S])


calculate(n,m,arr)


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  if (n == 3 || n == 5 || n == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var q = new Queue<int>();
        var z = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
        foreach (var x in z) q.Enqueue(x);
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var st = int.Parse(line[0]);
            var ar = int.Parse(line[1]);
            var bs = -1;
            while (bs != st) { bs = q.Dequeue(); q.Enqueue(bs); }
            var bslist = new List<int>();
            while (true)
            {
                bs = q.Dequeue(); q.Enqueue(bs);
                if (bs == ar) { display(bslist, st, ar); break; }
                else if (bs == st) bslist.RemoveAll(x => x >= 0);
                else bslist.Add(bs);
            }
        }
    }  
    public static void display (List<int> b,int st,  int ar)
    {
        Console.Write("{0} ", st);
        foreach (var x in b) Console.Write("{0} ", x);
        Console.WriteLine(ar);
    }
}

Measured memory_bytes: 10084