akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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


    ll n,ans=0;
    cin>>n;
    for(ll i=2; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll cnt=0,prev=0;
            while(n%i==0)
            {
                  cnt++;
                  n/=i;
                  if(cnt>prev)
                  {
                      ans++;
                      prev=cnt;
                      cnt=0;
                  }
            }
        }
    }
    if(n>1)
        ans++;
   cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3692
fun main(args:Array<String>) {
    val (x,a,b) = readLine()!!.split(" ").map { it.toInt() }
    val diffA = Math.abs(x-a)
    val diffB = Math.abs(x-b)

    if(diffA < diffB) {
        println("A")
    } else {
        println("B")
    }

}


Measured memory_bytes: 37920
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	char c; cin>>c;
	if(c!='z') c++;
	else c='a';
	cout<<c<<endl;		
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  double a,b; cin>>a>>b;
  double ans = a/b;
  printf("%.10f\n", ans);
}


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

using namespace std;
using Int = int64_t;

int main() {
  Int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    --a[i];
  }
  
  vector<vector<int>> b(65, vector<int>(N));
  b[0] = a;
  for (int i = 1; i < 65; ++i) {
    for (int j = 0; j < N; ++j) {
      b[i][j] = b[i - 1][b[i - 1][j]];
    }
  }
  
  int ans = 0;
  for (int i = 0; i < 62; ++i) {
    if ((K>>i) & 1) {
      ans = b[i][ans];
      // cerr << "i, ans = " << i << " " << ans << endl;
    }
  }
  cout << ans + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 55768
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

acc = list(accumulate(A))
#sa = acc[-1] -acc[0]

for i in range(N):
    if acc[i] - (acc[-1] - acc[i]) >= 0:
        break

if i == N-1:
    print(abs(A[i] - acc[i-1]))
elif i == 0:
    print(abs(acc[i] - (acc[-1] - acc[i])))
else:
    ans = min(abs(acc[i] - (acc[-1] - acc[i])), abs(acc[i-1] - (acc[-1] - acc[i-1])))
    print(ans)

Measured memory_bytes: 25748
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int m,d;
	cin>>m>>d;
	ll ans = 0;
	reps(i,m){
		reps(j,d){
			if(j%10 < 2) continue;
			if(j/10 < 2) continue;
			if(j%10 * (j/10) == i) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 636
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    ans = 0
    if N < 10:
        ans = N
    elif N < 100:
        ans = 9
    elif N < 1000:
        ans = 9 + N - 99
    elif N < 10000:
        ans = 909
    elif N < 100000:
        ans = 909 + N - 9999
    else:
        ans = 90909
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#define rep(i, n)	for(int i = 0; i < (n); i++)
using namespace std;

int main(){
	/*input*/
	int n, a, b;	cin >> n >> a >> b;
	/*calculation*/
	int sum, tmp, ans = 0;
	for(int i = 1; i <= n; i++){
		sum = 0;
		tmp = i;
		while(tmp){
			sum += tmp%10;
			tmp = (tmp - (tmp%10))/10;
		}
		if(sum >= a && sum <= b)ans += i;
	}
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);


using namespace std;

const int N = 1e4 + 5;
int h;
ll dp[N], INF = 1e15;
vector<ll> damage, cost;

int main()
{
    int n; cin >> h >> n;
    FOR(i, n, 0)
    {
        int x, y; cin >> x >> y;
        damage.pb(x);
        cost.pb(y);
    }
    FOR(i, h + 1, 0)dp[i] = INF;
    dp[h] = 0;
    int ind = 1;
    for(int i = h; i > 0; i--)
    {
        if(dp[i] == INF)continue;
        FOR(j, n, 0)
        {
            ind = max((ll)0, i - damage[j]);
            dp[ind] = min(dp[ind], dp[i] + cost[j]);
        }
    }
    cout << dp[0];
    return 0;
}
/*
-1000000000
1000000000
*/


Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100

int main(){
  int M[MAX][MAX],n,i,j,key,line,brige;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&key,&line);
    key--;//今回は二次配列が０から始まっていて０、１、２、３の４つで１、２、３、４がどの様に繋がっているかを表現するため、−１をして変換する必要がある。
    for(j=0;j<line;j++){
      scanf("%d",&brige);
      brige--;//今回は二次配列が０から始まっていて０、１、２、３の４つで１、２、３、４がどの様に繋がっているかを表現するため、−１をして変換する必要がある。
      M[key][brige]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==n-1){
	printf("%d\n",M[i][j]);
      }
      else{
	printf("%d ",M[i][j]);
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 2112
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
import math

S = int(input())

a = math.ceil(S**0.5)

XY = []
XY.append(a)
XY.append(0)
rest = -S + a**2
if rest > a:
	XY.append(a - 1)
	XY.append(a - 1)
	rest = rest - a
else:
	XY.append(a - 1)
	XY.append(a)

XY.append(0)
XY.append(rest)

for i in range(6):
	print(XY[i], end="")
	print(" ", end="")
print("\n")

Measured memory_bytes: 38512
import java.util.*;
class Main{
  public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();   
    int a = sc.nextInt();
    int t = 0;
    while(h > 0){
    h = h - a;
      t = t + 1;
      }
    System.out.println(t);
 }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long a, b, k;

int main() {
    cin >> a >> b >> k;
    k -= a;
    if(k < 0) {
        cout << (0-k) << " " << b << endl;
    }else {
        k -= b;
        if(k < 0) {
            cout << 0 << " " << (0-k) << endl;
        }else {
            cout << 0 << " " << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    long double sigma = 0;
    long long int ans = 1;

    for(int i=0;i<n;i++){
        long long int tmp;
        cin >> tmp;
        if(tmp == 0){
            cout << 0 << endl;
            return 0;
        }
        sigma = sigma +  log10l(tmp);
        ans *= tmp;
    }

    if(sigma > 18 || ans > 1000000000000000000){
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3676
#include <iostream>

using namespace std;
int main(){
    int A,B,C,X,Y;
    int price = 0;
    cin >> A >> B >> C >> X >> Y;
    while(X > 0 || Y > 0){
        if(A+B > C*2 && X > 0 && Y > 0){
            price += C*2;
            X--;
            Y--;
            continue;
        }
        if(A > C*2 && X >0){
            price += C*2;
            X--;
            Y--;
            continue;
        }
        if(X > 0){
            price += A;
            X--;
            continue;
        }
        if(B > C*2 && Y > 0){
            price += C*2;
            X--;
            Y--;
            continue;
        }
        if(Y > 0){
            price += B;
            Y--;
            continue;
        }
    }
    cout << price << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
int mod=1e9+7;
const int N=1e5+100;


int main()
{
    string s;cin>>s;
    for(int i=0;i<3;i++) cout<<s[i];
    return 0;
}



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

namespace ABC109
{
    class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Dictionary<string, int> dict = new Dictionary<string, int>();
            bool flag = true;
            string s = Console.ReadLine();
            char firstchar = s[0];
            char lastchar = s[s.Length - 1];
            dict[s] = 1;
            for (int i = 1; i < N; i++)
            {
                s = Console.ReadLine();
                if (dict.Keys.Contains(s))
                {
                    flag = false;
                    break;
                }
                dict[s] = 1;
                firstchar = s[0];
                if (firstchar != lastchar)
                {
                    flag = false;
                    break;
                }
                lastchar = s[s.Length - 1];
            }
            Console.WriteLine((flag)? "Yes": "No");
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
bool cmp(pair<int,int>&l,pair<int,int>&r)
{
    if(l.first>r.first)
        return 1;
    if(l.first<r.first)
        return 0;
    if(l.second>r.second)
        return 1;
    return 0;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    vector<pair<int,int> >v;
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(all(v),cmp);
    int day=0;
    priority_queue<pair<int,int> >x,y;
    for(int i=0; i<n; i++)
    {
        if(v[i].first+day<=m)
        {
            day++;
            ans+=v[i].second;
            x.push({v[i].second*-1,v[i].first});
        }
        else
        {
            while(!x.empty())
            {
                int a=x.top().first*-1;
                int b=x.top().second;
                if(v[i].second>a)
                {
                    x.pop();
                    ans-=a;
                    ans+=v[i].second;
                    x.push({v[i].second*-1,v[i].first});
                }
                break;

            }

        }
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    string n;
    cin >> n;
    int sum = 0;
    rep(i,n.size()) {
        int num = n[i]-'0';
        sum += num;
    }
    int nn = stoi(n);
    if (nn%sum==0) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100000001
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[101], dp[101][3][3];
int main(){
	int n, k,t1,t2;
	scanf("%d%d", &n, &k);
	rep(i,k){
		scanf("%d%d", &t1, &t2);
		a[t1] = t2;
	}
	rep(i,3)if(!a[1] || a[1] == i+1)dp[1][i][(i+1)%3] = 1;
	for(int i = 1;i <= n;i++){
		if(a[i] == 0 || a[i] == 1){
			dp[i][0][0] = dp[i-1][0][1]+dp[i-1][0][2];
			rep(j,3)rep(k,2)dp[i][0][k+1] += dp[i-1][k+1][j];
		}
		if(a[i] == 0 || a[i] == 2){
			dp[i][1][1] = dp[i-1][1][0]+dp[i-1][1][2];
			rep(j,3)rep(k,2)dp[i][1][(k+2)%3] += dp[i-1][(k+2)%3][j];
		}
		if(a[i] == 0 || a[i] == 3){
			dp[i][2][2] = dp[i-1][2][0]+dp[i-1][2][1];
			rep(j,3)rep(k,2)dp[i][2][k] += dp[i-1][k][j];
		}
		rep(j,3)rep(k,3)dp[i][j][k] = dp[i][j][k]%10000;
	}
	int ans = 0;
	rep(i,3)rep(j,3)ans += dp[n][i][j];
	printf("%d\n", ans%10000);
	return 0;
}

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

int main() 
{
    lli n,x;
    cin >> n;
    lli mx = -1;
    lli ans = 0;
    
    for(int i=0;i<n;i++){
        cin >> x;
        ans += max(mx-x,1LL*0);
        mx = max(mx,x);
    }
    
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    //1
    if (a == 1 || b == 1) {
        if (a == 1 && b == 1){
            printf("Draw");
        }
        else if (a == 1) {
            printf("Alice");
        }
        else printf("Bob");
    }
    //else
    else if (a > b) {
        printf("Alice");
    }
    else if (a < b) {
        printf("Bob");
    }
    else printf("Draw");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
int const N = 5050;
ll g[2][3];
ll f[3], t[3];
bool v[3];
int main() {
  int n; cin >> n;
  rep(i, 2) {
    rep(j, 3) cin >> g[i][j];
  }
  rep(i, 3) {
    if (g[0][i] < g[1][i]) v[i] = 1, f[i] = g[0][i], t[i] = g[1][i];
    else v[i] = 0, f[i] = g[1][i], t[i] = g[0][i];
  }
  int k = 0;
  rep(i, 3) k += v[i];
  ll ans = 0, m = 5000;
  if (k == 0 || k == 3) {
    rep(i, m + 1) rep(j, m + 1) {
      ll r = n - i * f[0] - j * f[1];
      if (r < 0) continue;
      ll z = (r / f[2]);
      r -= z * f[2];
      r += i * t[0] + j * t[1] + z * t[2];
      ans = max(ans, r);
    }
  } else if (k == 1) {
    rep(e, 3) if (v[e]) {
      ll z = n / f[e];
      ll u = n - z * f[e];
      u += z * t[e];
      ll b[2], cc = 0;
      rep(i, 3) if (!v[i]) b[cc++] = i;
      rep(i, u / f[b[0]] + 1) {
        ll r = u - i * f[b[0]];
        ll z = r / f[b[1]]; r -= z * f[b[1]];
        r += t[b[0]] * i + t[b[1]] * z;
        ans = max(ans, r);
      }
    }
  } else if (k == 2) {
    ll b[2], cc = 0, x;
    rep(i, 3) if (v[i]) b[cc++] = i; else x = i;
    rep(i, m + 1) rep(j, m + 1) {
      ll r = n - i * f[b[0]] - j * f[b[1]];
      if (r < 0) continue;
      r += i * t[b[0]] + j * t[b[1]];
      ll z = r / f[x];
      r -= z * f[x];
      r += z * t[x];
      ans = max(ans, r);
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;

// 問3
int main()
{
	int nCnt;
	long Y = 0;
	cin >> nCnt >> Y;

	// index 0:千円、1:5千円 2:1万円
	int nSatu[3];		// 札の枚数
	int nMax[3];		// 最大値として

	memset(nSatu, 0, sizeof(nSatu));
	memset(nMax, 0, sizeof(nMax));
	nMax[0] = Y / 1000;
	if (nMax[0] > nCnt)
		nMax[0] = nCnt;
	nMax[1] = Y / 5000;
	if (nMax[1] > nCnt)
		nMax[1] = nCnt;
	nMax[2] = Y / 10000;
	if (nMax[2] > nCnt)
		nMax[2] = nCnt;

	int nUseCnt = 0;
	for (nSatu[2] = nMax[2]; nSatu[2] >= 0; nSatu[2]--)
	{
		long Amari = Y;
		Amari = Amari-(nSatu[2]*10000);
		nUseCnt = nSatu[2];

		if (Amari == 0 && nUseCnt == nCnt)
			break;
		else if (Amari < 0)
			continue;

		long lnAmari2 = Amari;
//		for (nSatu[1] = 0; nSatu[1] <= (nMax[1]-nUseCnt); nSatu[1]++)
		for (nSatu[1] = nMax[1]-nUseCnt; nSatu[1] >= 0; nSatu[1]--)
		{
			Amari = lnAmari2;
			Amari = Amari-(nSatu[1]*5000);
			nUseCnt = nSatu[2] + nSatu[1];
			if (Amari == 0 && nUseCnt == nCnt)
				break;
			else if (Amari < 0)
				continue;

			long lnAmari3 = Amari;
//			for (nSatu[0] = 0; nSatu[0] <= (nMax[0] - nUseCnt); nSatu[0]++)
			for (nSatu[0] = nMax[0]-nUseCnt; nSatu[0] >= 0; nSatu[0]--)
			{
				Amari = lnAmari3;
				Amari = Amari-(nSatu[0]*1000);
				nUseCnt = nSatu[2] + nSatu[1] + nSatu[0];
				if (Amari == 0 && nUseCnt == nCnt)
					break;
				else if (Amari < 0)
					continue;
			}
			if (Amari == 0 && nUseCnt == nCnt)
				break;
		}
		if (Amari == 0 && nUseCnt == nCnt)
			break;
	}

	char szRet[100];
	sprintf(szRet, "%d %d %d", nSatu[2], nSatu[1], nSatu[0]);
	cout << szRet;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  int a,b; cin >>a >>b;
  print(a&b&1?"Odd":"Even");
}



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

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n;) {
            a.at(j)++;
            j += i;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += i * a.at(i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+100;


int n,m;

int dk[N];
int vis[N],p[10][10],a[300][300];

void dj(int x)
{
    vis[x]=1;
    for(int i=0;i<=9;i++) dk[i]=p[x][i];

    for(int i=0;i<9;i++){
        int minn=10000,pos;
        for(int j=0;j<=9;j++){
            if(!vis[j] && minn>dk[j]){
                minn=dk[j];
                pos=j;
            }
        }
        vis[pos]=1;
        for(int j=0;j<=9;j++){
            if(dk[pos]+p[pos][j]<dk[j] && !vis[j])
                 dk[j]=dk[pos]+p[pos][j];
        }
    }

}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            cin>>p[i][j];
        }
    }
    for(int i=0;i<=9;i++){
        for(int j=i;j<=9;j++){
            swap(p[i][j],p[j][i]);
        }
    }
    dj(1);
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
            if(a[i][j]!=-1) ans+=dk[a[i][j]];
        }
    }
  //  cout<<vis[1]<<endl;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3868
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var n = ScanInt();
      var a = ScanLongArray();
      var L = new long[n+1];
      var R = new long[n+1];
      L[0] = R[n] = 0;
      for(int i=0; i<n; i++){
        L[i+1] = GCD(L[i], a[i]);
        R[n-i-1] = GCD(R[n-i], a[n-i-1]);
      }
      var res = Enumerable.Range(0,n).Select(_=>GCD(L[_],R[_+1])).Max();
      WriteLine(res);
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 28384
#include <iostream>

using namespace std;

#define rep(i, a, n) for(int i = a; i < (n); ++i)

int main(){
  int n, r;
  cin >> n >> r;
  if (n < 10)
  {
    cout << 100 * (10 - n) + r << endl;
  }
  else
  {
    cout << r << endl;
  }
}

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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);
  
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  int mid = N / 2;
  int ans = d[mid] - d[mid - 1];
  cout << ans << endl;
  return 0;
}

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

int main() {
int a,b,k;
cin>>k;
cin>>a>>b;
string ans="NG";

for(int i=a; i<=b; i++)
{if(i%k==0)ans="OK";
}
cout << ans <<endl;

}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3624
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    _ = _i()
    m = 10**18
    ret = 1
    for ai in sorted(_ia()):
        ret *= ai
        if ret > m:
            return -1
    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 84652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r,D,y;
  cin >> r >> D >> y;
  vector<int> x(10);
  x[0] = r*y-D;
  for(int i=0;i<9;i++){
    x[i+1] = r*x[i] - D;
  }
  for(int i=0;i<10;i++){
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#define ll long long
#define pb push_back
#define rep(i,n) for (int i=0;i<n;i++)
#define INF 1e9+7
#define vec vector<int>

using namespace std;




int main() {
    int n; cin >>n;
    vector<ll> S(n);
    rep(i,n) cin >>S[i];
    sort(S.begin(),S.end());
    int q; cin >>q;
    vector<ll> T(q);
    rep(i,q) cin >>T[i];
    ll ans=0;
    rep(i,q){
        bool itr1=binary_search(S.begin(),S.end(),T[i]);
        if (itr1) ans++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3856
import math

A,B,H,M = map(int, input().split())

h = (H*60 + M)/720*2*math.pi
m = M/60*2*math.pi

d = ((A*math.sin(h) - B*math.sin(m))**2 + 
     (A*math.cos(h) - B*math.cos(m))**2) **.5

print('{:.10f}'.format(d))


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

int main(){
  int N;
  cin >> N;
  if(N <= 9){
    cout << N;
  }else if(10<= N && N<= 99){
    cout << 9;
  }else if(100<= N && N<=999){
    cout << 9+(N-99);
  }else if(1000 <= N && N<= 9999){
    cout << 9+999-99;
  }else if(10000 <= N && N<= 99999){
    cout << 9+999-99+(N-9999);
  }else if(N == 100000){
    cout << 9+999-99+99999-9999;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P 1000000007
using namespace std;
int f[220000],sum[220000];
int a[220000];
int n;
int main(){
	scanf("%d",&n);
	f[0]=1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		f[i]=f[i-1];
		if(a[i]!=a[i-1])(f[i]+=sum[a[i]])%=P;
		if(a[i]!=a[i-1])(sum[a[i]]=f[i])%=P;
	}
	printf("%d\n",f[n]);
}

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


ll mod = 1e9+7;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

int arr[123456];


int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    int n;
    cin >> n;
    while(n--){
          int l, r;
          cin >> l >> r;
          arr[l]++; arr[r+1]--;
    }
    for(int i = 1; i <= 1e5; i++) arr[i] += arr[i-1];
    int ans = 0;
    for(int i = 1; i <= 1e5; i++) if(arr[i]) ans++;
    cout << ans;
}


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

int A, B;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> A >> B;
    rep(i, 10000) {
        if (8*i/100==A && 10*i/100==B) {
            cout << i << endl;
            exit(0);
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
al = list(map(int, [input() for i in range(q)]))

plis = [0] * (n + 1)
for a in al:
    plis[a] += 1

for i in range(1, n+1):
    if k - q + plis[i] > 0:
        print("Yes")
    else:
        print("No")


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N; cin >> N;
    vector<P> xy( N );
    REP( i, N ) cin >> xy[i].first >> xy[i].second;

    sort( ALL( xy ) );

    double ans = 0;
    int cnt = 0;
    do{
        REP( i, N - 1 ){
            ans += sqrt( pow( xy[i].first - xy[i + 1].first, 2 ) + pow( xy[i].second - xy[i + 1].second , 2 ) );
        }
        cnt++;
    }while( next_permutation( xy.begin(), xy.end() ) );

    printf( "%.10f\n", ans / cnt );
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define che
#define debug(...) printf(__VA_ARGS__)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
const int maxn= 100 + 10;
const LL oo = 1ll<<61;
struct Edge{
	int from ,to;LL  flow, cap;
	int nx;
}edg[maxn*100];

int cur[maxn], h[maxn], a[maxn], edgn =0 , G[maxn],N, s,t, fro, rea, que[maxn];
void AddE(int u, int v, LL cap){
	edg[edgn] = (Edge){ u, v, 0, cap, G[u]};
	G[u]= edgn++;
	edg[edgn] = (Edge){ v, u, 0, 0 , G[v]};
	G[v]= edgn++;
}

LL DFS(int u, LL a);
bool BFS();
LL MaxSubGraph();

int main(){
	scanf("%d", &N);
	for (int i=0;i<=N+1; i++) G[i] = -1;
	for (int i=1; i<=N; i++)
		for (int j=i+i; j<=N; j+=i ) AddE( i, j, oo);
	// must be more carefull the negative !!!!
	s= 0, t=N+1;
	LL ans= 0;
	for (int i=1; i<=N; i++) {
		scanf("%d", &a[i]);
		ans += a[i];
		if ( a[i] <0 ) AddE(s, i, -1ll*a[i] );
			else 
		if ( a[i] >0) AddE(i, t, 1ll*a[i]);
	}
	
	ans +=MaxSubGraph();
	printf("%lld\n", ans); 
	return 0;
}

LL DFS(int u, LL a){
	if (u==t || a==0) return a;
	LL flow=0, f;
	for (int &i = cur[u] ; i!= -1; i = edg[i].nx){
		Edge &e= edg[i];
		if ( (h[e.to] ==h[u]+1) && (f=DFS(e.to, min(a, e.cap-e.flow)))>0){
			e.flow += f;
			edg[i^1].flow -= f;
			flow += f;
			a-= f;
			if ( a==0 ) break;
		}
	}
	return flow;
}

bool BFS(){
	fro= rea =0 ;
	for (int i=0; i<=N+1 ; i++) h[i] = -1;
	h[s] = 0;que[ rea++] = s;
	while ( fro < rea){
		int u= que[fro++];
		#ifdef che
		debug("h[%d] = %d\n", u, h[u]);
		#endif
		for (int i=G[u]; i!= -1; i =edg[i].nx){
			if ( h[edg[i].to] != -1 || edg[i].cap == edg[i].flow) continue;
			h[edg[i].to] = h[u]+1;
			que[rea++] = edg[i].to;
		}
	}
	return h[t] != -1;
	 
}


LL MaxSubGraph(){
	LL ans= 0 ;
	for (int i=1; i<= N; i++)
		if ( a[i] <0) ans += -a[i];
	#ifdef che
	debug("ans int flow= %lld\n", ans);

		for (int i=0; i<edgn ;i++) debug("edge : %d---%d, cap= %lld flow = %lld\n", edg[i].from, edg[i].to, edg[i].cap, edg[i].flow);
		debug("\n");
	#endif
	
	
	while ( BFS()){
		
		for (int i=0; i<=N+1; i++) cur[i] = G[i];
		ans -= DFS(s , oo);
	}
	#ifdef che
	debug("ans int flow= %lld\n", ans);
	#endif
	return ans;
	
}
			


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

#define INF (INT32_MAX/2)
#define MOD (1000000000+7)
#define MAX 2999

int N;
double p[MAX];

double dp[MAX + 1][MAX + 1];

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

	dp[0][0] = 1;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < i + 1; j++ ) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1 - p[i]);
		}
	}
	double ans = 0;
	for( int i = N / 2 + 1; i <= N; i++ ) {
		ans += dp[N][i];
	}

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}


Measured memory_bytes: 68864
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException  {
        
        int a,b,x,y;
        int c = 1;
        String term[] = new String[3];
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String st = br.readLine();
        StringTokenizer tokenizer = new StringTokenizer(st, " ");
	while(tokenizer.hasMoreTokens()) {
	    term[c] = tokenizer.nextToken();
	    c++;
	}

        a = Integer.parseInt(term[1]);
        b = Integer.parseInt(term[2]);
        x = a*b;
        y = 2*a + 2*b;
        System.out.println(x+" "+y);        
    
    }
    
}

Measured memory_bytes: 24196
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>

using namespace std;

class Point {
public:
    double _x, _y;
    Point(double x, double y): _x(x), _y(y){}
    Point(const Point& a): _x(a._x), _y(a._y){}

    Point operator+(const Point& a) const{
        return Point(_x + a._x, _y + a._y);
    }
    Point operator-(const Point& a) const{
        return Point(_x - a._x, _y - a._y);
    }
    Point operator*(double& a) const{
        return Point(_x*a, _y*a);
    }
    Point operator/(double& a) const{
        return Point(_x/a, _y/a);
    }
    void operator=(const Point& a){
        _x = a._x;
        _y = a._y;
    }
    double dot(const Point& a) const{
        return (_x*a._x + _y*a._y);
    }
};

Point operator*(double a, const Point& vec){
    return vec*a;
}
Point operator/(double a, const Point& vec){
    return vec/a;
}

typedef Point Vec;

int main(){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    Vec A(x1,y1), B(x2,y2);
    double norm = sqrt(pow(x2-x1,2) + pow(y2-y1,2));
    Vec ABunit( (B-A)/norm );

    int q;
    scanf("%d",&q);
    for(int i=0; i<q; ++i){
        double x,y;
        scanf("%lf %lf",&x,&y);
        Vec AC(Vec(x,y)-A);
        double temp = AC.dot(ABunit);
        Vec AP(temp*ABunit), answer(AP + A);

        cout << std::fixed << std::setprecision(10) << answer._x << " " << answer._y << endl;
    }
    return 0;
}


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

using namespace std;

int count_digits(long n){
  int digits = 1;
  while(n / 10 > 0){
    digits++;
    n /= 10;
  }
  return digits;
}
int max_digits(long a, long b) {
  int digits_1, digits_2;
  
  digits_1 = count_digits(a);
  digits_2 = count_digits(b);
  
  if (digits_1 > digits_2) {
    return digits_1;
  } else {
    return digits_2;
  }
} 

int main() {
  long N;
  cin >> N;
  
  int ans = 11;
  int digits;
  for (int A = 1; A <= sqrt(N); A++) {
    if(N % A != 0) {
      continue;
    } else {
      long B = N / A;
      digits = max_digits(A, B);
      if (digits < ans) {
        ans = digits;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

int main(){
  ll N,ans=0;
  cin>>N;
  
  vector<ll> A,B,C;
  REP(i,N){
    ll a;
    cin>>a;
    A.push_back(a);
  }
  REP(i,N){
    ll a;
    cin>>a;
    B.push_back(a);
  }
  REP(i,N){
    ll a;
    cin>>a;
    C.push_back(a);
  }
  
  SORT(A);
  SORT(B);
  SORT(C);
  
  REP(i,N){
    auto Iter1=lower_bound(ALL(A),B[i]);
    ll Adx=distance(A.begin(),Iter1);
    auto Iter2=upper_bound(ALL(C),B[i]);
    ll Cdx=distance(Iter2,C.end());
    ans+=Adx*Cdx;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3444
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    char str[4];
    int num[4];
    int ans=0;
    cin >> str;
    for(int i=0;i<4;i++){
        if(str[i]=='0')num[i]=0;
        else if(str[i]=='1')num[i]=1;
        else if(str[i]=='2')num[i]=2;
        else if(str[i]=='3')num[i]=3;
        else if(str[i]=='4')num[i]=4;
        else if(str[i]=='5')num[i]=5;
        else if(str[i]=='6')num[i]=6;
        else if(str[i]=='7')num[i]=7;
        else if(str[i]=='8')num[i]=8;
        else if(str[i]=='9')num[i]=9;
    }

    if(num[0]+num[1]+num[2]+num[3]==7){
        cout << num[0] << "+" << num[1] << "+" <<num[2] << "+" << num[3] << "=7" <<endl;
    }else if(num[0]-num[1]-num[2]-num[3]==7){
        cout << num[0] << "-" << num[1] << "-" <<num[2] << "-" << num[3] << "=7" <<endl;
    }else if(num[0]+num[1]+num[2]-num[3]==7){
        cout << num[0] << "+" << num[1] << "+" <<num[2] << "-" << num[3] << "=7" <<endl;
    }else if(num[0]+num[1]-num[2]-num[3]==7){
        cout << num[0] << "+" << num[1] << "-" <<num[2] << "-" << num[3] << "=7" <<endl;
    }else if(num[0]-num[1]-num[2]+num[3]==7){
        cout << num[0] << "-" << num[1] << "-" <<num[2] << "+" << num[3] << "=7" <<endl;
    }else if(num[0]-num[1]+num[2]+num[3]==7){
        cout << num[0] << "-" << num[1] << "+" <<num[2] << "+" << num[3] << "=7" <<endl;
    }else if(num[0]+num[1]-num[2]+num[3]==7){
        cout << num[0] << "+" << num[1] << "-" <<num[2] << "+" << num[3] << "=7" <<endl;
    }else if(num[0]-num[1]+num[2]-num[3]==7){
        cout << num[0] << "-" << num[1] << "+" <<num[2] << "-" << num[3] << "=7" <<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int A, B;
  cin >> A >> B;
  if((A * B) % 2 == 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
flag = 0
count = 0
for i in range(1,N+1):
    if i % 2 != 0:
        for j in range(1, i+1):
            if i % j == 0:
                count+= 1
                
        if count == 8:
            flag += 1
        count = 0


print(flag)

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

int N;
vector<long long> A;
vector<long long> L;
vector<long long> R;

void input(){
  cin >> N;
  A.resize(N);
  L.resize(N);
  R.resize(N);
  for(int i=0;i<N;i++){
    cin >> A[i] ;
    L[i]=i+1+A[i];
    R[i]=i+1-A[i];
  }
}

void solve(){
  map <long long,int> dic;
  for (int i=0;i<N;i++){
    dic[L[i]]+=0;
    dic[R[i]]+=0;
   
  }
  long long ans=0;
  for (int i=0;i<N;i++){
    ans+=dic[R[i]];
    dic[L[i]]++;
  }

  //int ans=0;
  //  map <string,int>::iterator it;
  //  for(it=dic.begin();it!=dic.end();it++){
  //    cout << it->second << endl;
  //    ans += it->second/2;
  //  }
  cout << ans <<endl;
}

int main(){
  //  ifstream in("input.txt");
  //  cin.rdbuf(in.rdbuf());


  input();
  solve();
  return 0;
}

  
 


Measured memory_bytes: 30488
import sys

alpha = [0] * 26
buf = sys.stdin.read()
buf_len = len(buf)

for i in range(buf_len):
    c = buf[i].lower()
    ascii_code = ord(c)

    if ord('a') <= ascii_code <= ord('z'):
        alpha[ascii_code - ord('a')] += 1

for i in range(26):
    ascii_code = ord('a') + i
    print("%s : %d" % (chr(ascii_code), alpha[i]))



Measured memory_bytes: 5560
from collections import Counter,defaultdict,deque
from bisect import bisect_left
import sys,math,itertools,pprint,fractions,time
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = input()
n = len(s)
Q = inp()
q = deque()
for i in s:
    q.append(i)
rev = 0
for _ in range(Q):
    tmp = input().split()
    if tmp[0] == '1':
        rev ^= 1
    else:
        if tmp[1] == '1':
            if rev==0: q.appendleft(tmp[2])
            else: q.append(tmp[2])
        else:
            if rev==0: q.append(tmp[2])
            else: q.appendleft(tmp[2])
    # print(_,q)
# print(q)
res = list(q)
if rev: res = res[::-1]
# print(res)
print(''.join(res))

Measured memory_bytes: 97876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IN(type, n) type n; cin >> n

int main() {
  IN(double, D);
  IN(double, T);
  IN(double, S);

  if (D / S <= T) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3684
#include "bits/stdc++.h"
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define nl '\n'
#define precision(n) setprecision(n)
typedef long double ld;
typedef long long ll;

int main() { _
    int n; cin >> n;
    
    vector<int> nums;
    vector<int> pre;
    int x = 0;
    int sum = 0;
    forn(i, 0, n) {
        int ai; cin >> ai;
        nums.push_back(ai);
        pre.push_back(abs(ai - x));
        sum += abs(pre[i]);
        x = ai;
    }
    pre.push_back(abs(x));
    sum += abs(x);

    x = 0;
    forn(i, 0, n) {
        int cur = nums[i];
        int next = i == n - 1 ? 0 : nums[i + 1];
        int cv = pre[i];
        int nv = pre[i + 1];
        int d;
        if ((cur >= x && cur <= next) || (cur <= x && cur >= next)) {
            d = nv + cv;
        } else {
            d = abs(cv - nv);
        }
//        cout << "d: " << d << nl;
//        cout << cur << " " << next << nl;
//        cout << "cv: " << cv << " nv: " << nv << nl;
        cout << ((sum - cv) - nv) + d << nl;
        x = nums[i];
    }
    
    return 0;
}


Measured memory_bytes: 2292