akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  ll d = 100*a+10*b+c;
  if(d%4==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}

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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int T = 60, F = 26, Y = 10;
ll ct[T][F][Y];

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

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;

        auto it = find(all(s), '.');

        if (it == s.end()) {
            s += ".";
        }

        ll x = 0, y = -1;

        for (const char &c : s) {
            if (y != -1)
                y++;
            if (c == '.') {
                y = 0;
            }
            else {
                x = x * 10 + c - '0';
            }
        }

        int two = 0, five = 0;

        while (x % 2 == 0) {
            two++;
            x /= 2;
        }

        while (x % 5 == 0) {
            five++;
            x /= 5;
        }

        ct[two][five][y]++;
    }

    ll ans = 0;

    for (int i = 0; i < T; i++) {
        for (int j = 0; j < F; j++) {
            for (int k = 0; k < Y; k++) {
                for (int x = 0; x < T; x++) {
                    for (int y = 0; y < F; y++) {
                        for (int z = 0; z < Y; z++) {
                            if (i + x >= z + k && j + y >= z + k) {
                                if (i == x && j == y && k == z) {
                                    ans += ct[i][j][k] * (ct[i][j][k] - 1);
                                }
                                else {
                                    ans += ct[i][j][k] * ct[x][y][z];
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    ans /= 2;

    cout << ans;

	return 0;
}

Measured memory_bytes: 3668
#include <string>
#include <iostream>
#include <vector>
#include <algorithm> 
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
int main()
{
	int n,c=0,max=0;
	cin>>n;
	int* a =new int[n];
	for(int i=0;i<n;i++)
	{
		cin>>*(a+i);
	}
	
	for(int i=0;i<n-1;i++)
	{
		if(a[i]>=a[i+1])
		{
			c++;
		}
		else
		{
			c=0;
		}
		max=std::max(max,c);
	}
	
	cout<<max;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N, K;

	cin >> N >> K;

	cout << N*K-N-K+1 << endl;


	return 0;
}

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

int mod = 1'000'000'007;

long long getComb(int x, int y){
    //逆元を求める
    vector<long long> rep(x+1, 0);
    rep[1] = 1;
    for (int i = 2; i < x+1; i++){
        rep[i] = (mod - (mod / i)) * rep[mod % i] % mod;
    }
    //nCr
    vector<long long> c(x+1, 0);
    c[0] = 1;
    for (int i = 1; i < x + 1; i++){
        c[i] = c[i - 1] * ((x - i + 1) * rep[i] % mod) % mod;
        c[i] %= mod;
    }
    return c[y];
}

int main(){
    long long n, m, k;
    cin >> n >> m >> k;
    long long ans = 0;
    for (int i = 1; i < m; i++){
        ans += i * ((m - i) * (n * n % mod) % mod) % mod;
        ans %= mod;
    }
    for (int i = 1; i < n; i++){
        ans += i * ((n - i) * (m * m % mod) % mod) % mod;
        ans %= mod;
    }
    ans *= getComb(m * n - 2, k - 2);
    ans %= mod;
    cout << ans << endl;
}



Measured memory_bytes: 3328
#include <cstdio>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int n = 3;
    if(a == b){
        n--;
    }
    if(b == c){
        n--;
    }
    if(c == a){
        n--;
    }
    if(n == 0){
        n = 1;
    }
    printf("%d\n",n);

    return 0;
}

Measured memory_bytes: 256
h,w,K=map(int,input().split())
c=[input() for i in range(h)]
total=0
for i in range(h):
    for j in range(w):
        if c[i][j]=="#":
            total+=1
#print(total)
ans=0
l=[]
for bit in range(1<<h):
    bh=bin(bit)
    bh="0"*(h-len(bh[2:])) +bh[2:]
    gyo=[]
    for i in range(h):
        if bh[-i-1]=="1":
            gyo.append(i)
    for BIT in range(1<<w):
        bw=bin(BIT)
        bw="0"*(w-len(bw[2:]))+bw[2:]
        #print(bh,bw)
        cl=[]
        for j in range(w):
            if bw[-j-1]=="1":
                cl.append(j)
        #print(gyo,cl,bh,bw)
        #ここからようやく#の数数える
        su=0
        for r in range(h):
            if r in gyo:
                continue
            for k in range(w):
                if k in cl:
                    continue
                if c[r][k]=="#":
                    su+=1
        #print(su,gyo,cl,bh,bw)
        if su==K:
            ans+=1
print(ans)

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

string a,b,ans;



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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------


int main(){
  int X;
  cin >> X;
  int ans = 0;
  for(int i=X; ; i++){
    int num = i;
    for(int j=2; j <= num; j++){
      if(num == j) ans = num;
      if(num % j == 0) break;
      
    }
    if(ans) break;
  }
  cout << ans << endl;
  return 0;
}




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

using namespace std;

typedef long long ll;

int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	if(a+b > 2*c){
		int n = min(x, y);
		ans += c*n*2;
		x -= n;
		y -= n;
	}
	if(a > c*2){
		ans += x*c*2;
		x = 0;
	}
	if(b > c*2){
		ans += y*c*2;
		y = 0;
	}
	ans += x*a+y*b;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
t = [0 for i in range(10000)]
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                t[c] = i + j + k + l
                c += 1
for line in sys.stdin:
    print(t.count(int(line)))

Measured memory_bytes: 7744
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
doubling=[[0 for i in range(n)] for j in range(60)]
for i in range(n):
    doubling[0][i]=a[i]
for i in range(59):
    for j in range(n):
        doubling[i+1][j]=doubling[i][doubling[i][j]]
v=0
for d in range(60):
    if(k>>d &1):
        v=doubling[d][v]

print(v+1)

Measured memory_bytes: 225328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool f(ll x) {
    for(ll i = 2; i * i <= x; i++) {
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    for(ll i = X; ; i++) {
        if(f(i)) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N;
    cin >> N;
    if (N<10){
        cout << N << endl;
        return 0;
    }
    if (9 < N && N< 100){
        cout << 9 << endl;
        return 0;
    }
    if (99< N && N< 1000){
        cout << 9+N-99 << endl;
        return 0;
    }
    if (999 < N && N<10000){
        cout << 909 << endl;
        return 0;
    }
    if (9999 < N && N< 100000){
        cout << 909+N-9999 << endl;
        return 0;
    }
    if (N==100000){
        cout << 90909 << endl;
        return 0;
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = long.Parse(Console.ReadLine());
        var flag = false;

        for(long i = -200; i < 201; i++)
        {
            if (!flag)
            {
                for (long j = -200; j < 201; j++)
                {
                    if (!flag)
                    {
                        if (Math.Pow(i, 5) - Math.Pow(j, 5) == input)
                        {
                            Console.WriteLine(i + " " + j);
                            flag = true;
                        }
                    }
                }
            }
        }


        Console.ReadLine();


    }

}



Measured memory_bytes: 18112
n = gets.to_i
d = gets.split(' ').map(&:to_i)

d_sorted = d.sort

d_sorted_lh_max = d_sorted[n / 2 - 1]
d_sorted_rh_min = d_sorted[n / 2 ]

ans = d_sorted_rh_min - d_sorted_lh_max

puts ans


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

int gcd(int a, int b){
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return gcd(a%b, b);
}

int main(){
	int a, b;
	while (cin >> a >> b){
		cout << gcd(a, b) << " " << (a/(gcd(a,b))*b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	int W, H, N;
	cin >> W >> H >> N;
	int x_min = 0;
	int x_max = W;
	int y_min = 0;
	int y_max = H;

	REP(i, N) {
		int x, y, a;
		cin >> x >> y >> a;
		switch (a) {
			case 1:
				x_min = max(x_min, x);
				break;
			case 2:
				x_max = min(x_max, x);
				break;
			case 3:
				y_min = max(y_min, y);
				break;
			case 4:
				y_max = min(y_max, y);
				break;
		}
	}

	cout << max(0, x_max - x_min) * max(0, y_max - y_min) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.size();
    bool ok = true;
    rep (i, n) {
        eprintf("%d %d?\n", i, i_len - i - 1);
        if (s[i] != s[i_len - 1 - i]) ok = false;
    }
    rep (i, (n - 1) / 2) {
        eprintf("%d %d\n", i, i_len - i - 1);
        if (s[i] != s[i_len - 1 - i]) ok = false;
    }
    int k = (n + 3) / 2;
    rep (i, k - 1, n) {
        eprintf("%d %d*\n", i, n - i + k - 2);
        if (s[i] != s[n - (i - k) - 2]) ok = false;
    }
    cout << (ok ? "Yes\n" : "No\n");
    return 0;
}

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

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

typedef long long ll;
using namespace std;

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

  int R, D, X;
  cin >> R >> D >> X;

  int x = X;
  REP(i, 10) {
    cout << R * x - D << endl;
    x = R * x - D;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main (){
int n , x ,y;
cin >> n >> x >> y ;
if (n+x < (x+y) && (n+x < (n+y))){
    cout << n+x ;
}
else if ( x+y <(x+n) && (x+y < (n+y))){
    cout << x+y ;
}
else {
    cout << y+n ;
}


return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
 
constexpr int gcd(int a,int b){return b?gcd(b,a%b):a;}
constexpr int lcm(int a,int b){return a*b/gcd(a,b);}
 
class Eratosthenes{
  public:
    int n, sqlim;
    vector<bool> prime;
    Eratosthenes(int N):n(N+1){
        sqlim=(int)ceil(sqrt(n));
        prime=vector<bool>(n,1); prime[0]=prime[1]=0;
        for(int i=2;i<=sqlim;i++) if(prime[i]) for(int j=i*i;j<=n;j+=i) prime[j]=0;}
    vector<int> primeArray(int s=0, int l=10000){vi ret; for(int i=s;ret.size()!=l;i++) if(prime[i]) ret.push_back(i); return ret;}
};


int main(){
	int p,q;
	cin>>p>>q;
	q/=gcd(p,q);
	vi v;
	for(int i=2;i*i<=q;i++){
	    if(q%i==0){
	        v.pb(i);
	        while(q%i==0)q/=i;
	    }
	}
	v.pb(q);
	cout<<accumulate(all(v),1,[](int a,int b){return a*b;})<<endl;
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long int ll;
using namespace std;


int main()
{
    int n, m; cin >> n >> m;
    vector<ll> dp(n+1);
    vector<int> a(n+1);
    for(int i=0;i<m;i++){
        cin >> a[i];
    }
    dp[0] = 1;
    int j = 0;//next hole
    if(a[0] != 1) {
        dp[1] = 1;
    }
    else {
        dp[1] = 0;
        j++;
    }
    for(int i=2;i<=n;i++){
        if(i != a[j]){
            dp[i] = (dp[i-1] + dp[i-2])%MOD;
        }
        else{
            dp[i] = 0;
            j++;
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main()
{
	long long x1[51],x2[51],y1[51],y2[51];
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>x1[i]>>y1[i];
	}
	for(int j=0;j<m;j++)
	{
		cin>>x2[j]>>y2[j];
	}
	for(int i=0;i<n;i++)
	{
		int dis[51];
		int index[51];
		for(int j=0;j<m;j++)
		{
			dis[j]=abs(x1[i]-x2[j])+abs(y1[i]-y2[j]);
			index[j]=j+1;
		}
		for(int j=0;j<m;j++)
		{
			for(int k=0;k<m-1-j;k++)
			{
				if(dis[k]>dis[k+1])
				{
					swap(dis[k],dis[k+1]);
					swap(index[k],index[k+1]);
				}
			}
		}
		cout<<index[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int main(){
	ll a,b;
	cin>>a>>b;
	if(a==1&&b==1){
		cout<<1;
	}
	else if(a==1||b==1){
		cout<<(a==1?b-2:a-2);
	}
	else{
		cout<<(a-2)*(b-2);
	}
} 

Measured memory_bytes: 256
let cnt = ref 0
let (g : int list ref) = ref []

let insertion_sort (a : int array) n g =
  let rec insert j v =
    if j < 0 || a.(j) <= v then a.(j + g) <- v
    else (a.(j + g) <- a.(j); incr cnt; insert (j - g) v)
  in
  let rec doit i =
    if i < n then (insert (i - g) a.(i); doit (i + 1))
  in
  doit g

let generate_g n =
  let rec doit i g lst =
    if g > n then lst
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: lst)
  in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  let rec doit = function
    | [] -> ()
    | hd :: tl -> (insertion_sort a n hd; doit tl)
  in
  doit !g

let () =
  let n = read_int () in
  let a = Array.make n 0 in
  let rec doit i =
    if i < n then (a.(i) <- read_int (); doit (i + 1))
  in
  doit 0;
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  List.iteri (fun i n -> if i <> 0 then print_string " "; print_int n) !g;
  print_newline ();
  Printf.printf "%d\n" !cnt;
  Array.iter (fun n -> Printf.printf "%d\n" n) a

Measured memory_bytes: 12660
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll N=in<ll>();
	
	REP(n,3500){
		REP(w,3500){
			ll A=N*(n+1LL)*(w+1LL);
			ll B=4LL*(n+1LL)*(w+1LL)-N*(w+1LL)-N*(n+1LL);
			if(B<=0) continue;
			if(!(A%B)){
				out(A/B,n+1LL,w+1LL);
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H , W;
	cin >> H >> W;
	//string vecn;
	/*(for (int i = 0 ; i < H ; i++ ){
	char 	
		vector<int> vecn
	// widthが縦 lengthがよこ
	//
	for (int i=0;i < H; i++){
		cin >>width.at(i)
	}
	for(int i=0 ; i < W ; i++){
		cin >> legnth.at(i) ;
	}
	//まず、一番上の行に、length＋2個の#を付ける
	for (int i=0;i<W+2; i++){
		cout << "#" ;
	}
	//次の行からは、配列とその端っこに#を付ける。
	*/

	//伴さんアドバイス 一行ずつｓｔりんｇでとって 要素数を heigt（縦）文字数をwidthにしてあげるといいんじゃないかな
	//
	//まず ｓ を出力する前に #を付ける
	for (int i = 0 ; i < W+2 ; i++ ){
		cout << "#" ;
		if ( i == W+1 ){
			cout <<endl;
		}

	}
	for (int i = 0 ; i < H ; i ++ ){
		string s ;
		cin >> s ;
		cout <<"#" << s << "#" << endl;
	}
	for (int i = 0 ; i < W+2 ; i ++ ) {
		cout <<"#" ;
	}
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
mo = 1000
now = True  #下がり待つとき #買うとき
have = 0    #持ってるカブの数
price = 0 #持ってるカブの値段
now_max = 0
now_min = 1000000000000
for i in range(n-1):
    if now:
        if a[i]<a[i+1]:
            have = int(mo/a[i])
            price = a[i]
            mo = mo-have*price
            now = not now
    else:
        if a[i]>a[i+1]:
            mo += have*a[i]
            heve = 0
            now = not now
if not now:
    mo += have*a[n-1]

print(mo)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "YES" : "NO") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string S, T;
  cin >> S >> T;
  vector<int> SS(S.size()+1);
  REP(i, S.size()) SS[i+1] = SS[i] + (S[i]=='A' ? 1 : -1);
  vector<int> TT(T.size()+1);
  REP(i, T.size()) TT[i+1] = TT[i] + (T[i]=='A' ? 1 : -1);
  int Q;
  cin >> Q;
  REP(q, Q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    yes((SS[b]-SS[a-1] + 300000)%3 == (TT[d]-TT[c-1] + 300000)%3);
  }
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll k, x;

signed main(){
    cin >> k >> x;
    if(k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}

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

int main() {
    int N ;
    cin >> N ;
    
    vector<long long> A(N) ;
    
    for( int i=0 ; i<N ; i++){
        cin >> A.at(i) ;
    }
    vector<double> B(N) ;
    for( int i=0 ; i<N ; i++){
        B.at(i) = log10( A.at(i) ) ;
    }
    
    long long count=1 ;
    double logcount=0 ;
    
    for( int i=0 ; i<N ; i++){
        if( A.at(i) == 0 ){
            count = 0 ;
            break;
        }
    }
    
    if( count == 0 ){
        cout << 0 << endl;
    }
    else{
        for( int i=0 ; i<N ; i++){
            count *= A.at(i) ;
            logcount += B.at(i) ;
            
            if( count > 1000000000000000000 ){
                count = -1 ;
                break;
            }
            else if( logcount > 18 ){
                count = -1 ;
                break;
            }
        }
        cout << count << endl;
    }
}


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

typedef long long ll;
const int MOD=1e9+7;

struct modint {
    int val;
    modint inv() const{
        int tmp,a=val,b=MOD,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return modint(x);
    }
public:
    modint():val(0){}
    modint(ll x){if((val=x%MOD)<0)val+=MOD;}
    modint pow(ll t){modint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    modint& operator+=(const modint& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
    modint& operator-=(const modint& x){if((val+=MOD-x.val)>=MOD)val-=MOD; return *this;}
    modint& operator*=(const modint& x){val=(ll)val*x.val%MOD; return *this;}
    modint& operator/=(const modint& x){return *this*=x.inv();}
    bool operator==(const modint& x) const{return val==x.val;}
    bool operator!=(const modint& x) const{return val!=x.val;}
    bool operator<(const modint& x) const{return val<x.val;}
    bool operator<=(const modint& x) const{return val<=x.val;}
    bool operator>(const modint& x) const{return val>x.val;}
    bool operator>=(const modint& x) const{return val>=x.val;}
    modint operator+(const modint& x) const{return modint(*this)+=x;}
    modint operator-(const modint& x) const{return modint(*this)-=x;}
    modint operator*(const modint& x) const{return modint(*this)*=x;}
    modint operator/(const modint& x) const{return modint(*this)/=x;}
};

struct factorial {
    vector<modint> Fact, Finv;
public:
    factorial(int _n): Fact(_n+1), Finv(_n+1) {
        Fact[0]=modint(1); for (int i = 0; i < _n; ++i) Fact[i+1]=Fact[i]*(i+1);
        Finv[_n]=modint(1)/Fact[_n]; for (int i = _n; i > 0; --i) Finv[i-1]=Finv[i]*i;
    }
    modint fact(int n,bool inv=0) { if (inv) return Finv[n]; else return Fact[n]; }
    modint nPr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[n-r]; }
    modint nCr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

int main() {
    factorial fact(500010);
    int n,m;
    cin >> n >> m;
    modint res = fact.nPr(m, n);
    for(int k = 1; k <= n; ++k) {
        res -= (modint)(k&1?1:-1) * fact.nCr(n, k) * fact.nPr(m-k, n-k);
    }
    res *= fact.nPr(m, n);
    cout << res.val << endl;
}


Measured memory_bytes: 7012
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(K: int, S: int):
    ret = 0
    for i in range(K + 1):
        for j in range(K + 1):
            if 0 <= S - (i + j) <= K:
                ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<stdio.h>
#define F(i,n) for(int i=0; i<n; i++)
int main(){
    int n;
    scanf("%d",&n);
    long max=0,min=1000000000;
    long a;
    F(i,n){
        scanf("%ld",&a);
        if(max<a) max=a;
        if(min>a) min=a;
    }
    printf("%ld\n",max-min);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>

using namespace std;

int main(void){
	
	string in;
	int cnt=0;

	cin>>in;

	for(int i=0;i<=in.size()/2-1;i++){
		if(!(in[i]=='i'&&in[in.size()-1-i]=='i'||in[i]=='w'&&in[in.size()-1-i]=='w'||in[i]==')'&&in[in.size()-1-i]=='('||in[i]=='('&&in[in.size()-1-i]==')')) cnt++;
	}
	if(in.size()%2==1&&(in[in.size()/2]=='('||in[in.size()/2]==')')) cnt++;

	cout<<cnt<<endl;

	return 0;
}

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

using namespace std;

const int N = 200005;

int n;
int a[N], b[N];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i ++ ) cin >> a[i];
    for (int i = 0; i < n; i ++ ) cin >> b[n - i]; // 读入并将 B 翻转
    
    bool success = true; // 标记是否有合法的 B 的重排
    
    // 找第一个 a[i] == b[i] 的 i
    // 如果找到之后 success 被更新成 false 了，直接跳出
    for (int i = 1; i <= n && success; i ++ )
        if (a[i] == b[i])
        {
            // 这里要试图将 B 和 A 中相等的一段，用 B 的其它元素替换掉
            // 如果 a[i] 和 b[i] 不相等了，说明是 B 中和 A 相等的部分替换完了，直接跳出
            for (int k = 1; k <= n && a[i] == b[i]; k ++ )
            // 如果找到了 B 中的一个元素 b[k], 满足将 b[k] 与 b[i] 交换之后， a[k] != b[k] 且 a[i] != b[i]，
                if (b[k] != b[i] && a[k] != b[i])
                    swap(b[i], b[k]), i ++ ; // 那么将 b[i] 与 b[k] 交换，并让 i 走到下一个要替换的位置

            // 如果试图替换后 b[i] 仍与 a[i] 相同，说明不存在一组合法答案，让 success = false
            if (a[i] == b[i]) success = false;
        }

    puts(success ? "Yes" : "No");
    if (success) for (int i = 1; i <= n; i ++ ) cout << b[i] << ' '; 

    return 0;
}

Measured memory_bytes: 5184
import math
n = int(input())
n_list = []
for i in range(1, int(math.sqrt(n))+1):
    if n % i == 0:
        n_list.append((i, n//i))
sa = n-1
for x, y in n_list:
    if sa >= abs(x-1)+abs(y-1):
        sa = abs(x-1) + abs(y-1)
print(sa)

Measured memory_bytes: 40684
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t K;

    scanf("%"PRId64, &K);

    printf("%"PRId64"\n", (K / 2) * (K / 2 + (K % 2 ? 1 : 0)));

    return 0;
}


Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        l=list(map(int,input().split()))
        ll=l[::-1]
        prev=ll[0]+1
        for i in range(n):
            if prev>=ll[i]:
                prev=ll[i]
            elif prev+1==ll[i]:
                prev=ll[i]-1
            else:
                return 'No'
        return 'Yes'
    print(main())
resolve()

Measured memory_bytes: 14396
import numpy as np
N, K = map(int, input().split())
ans = [0 for _ in range(N)]
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        ans[a - 1] = 1
print(N - np.count_nonzero(np.array(ans)))

Measured memory_bytes: 27172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vector<LL> A(N);
    vector<LL> part(N+1);
    LL pre = 0;
    map<LL,LL> mp;
    mp[pre]++;
    REP(i,N)
    {
        LL tmp;
        cin >> tmp;

        pre += tmp;
        mp[pre]++;
    }
    LL ans = 0;
    for(auto p : mp)
    {
        ans += p.second * (p.second-1) / 2;
    }
    cout << ans << endl;



}

Measured memory_bytes: 15872
#include<stdio.h>

int main()
{
	double vector[2][2];
	double product;
	double xa,ya,xb,yb,xc,yc,xd,yd;

	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF)
	{
		vector[0][0]=xa-xb;
		vector[0][1]=ya-yb;
		vector[1][0]=xc-xd;
		vector[1][1]=yc-yd;
		product=vector[0][0]*vector[1][0]+vector[0][1]*vector[1][1];
		if(product==0){puts("YES");}
		else{puts("NO");}
	}
	return 0;
}

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

int main()
{
    string s;
    cin >> s;

    int a = 0, b = 0, c = 0;

    for (int i = 0; i < 3; i++)
    {
        if (s.at(i) == 'a')
            a = 1;
        else if (s.at(i) == 'b')
            b = 1;
        else
            c = 1;
    }

    if (a == 1 && b == 1 && c == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  string w;
  int count[26] = {};

  cin >> w;

  for(int i = 0;i < w.size();i++){
    count[w[i]-'a']++;
  }

  for(int i = 0;i < 26;i++){
    if(count[i] % 2 != 0){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

int main() {
	const long long INF = 100000000;
	int n, m, r;
	std::cin >> n >> m >> r;

	std::vector<int>town(r);
	for (int i = 0; i < r; ++i) {
		std::cin >> town.at(i);
		town.at(i)--;
	}

	std::vector<std::vector<long long>>road(n, std::vector<long long>(n, INF));
	for (int i = 0; i < n; ++i)
		road.at(i).at(i) = 0;
	for (int i = 0; i < m; ++i) {
		int a, b;
		long long c;
		std::cin >> a >> b >> c;
		road.at(--a).at(--b) = c;
		road.at(b).at(a) = c;
	}

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			for (int k = 0; k < n; ++k)
				if (road.at(j).at(i) != INF && road.at(i).at(k) != INF) {
					road.at(j).at(k) = std::min(road.at(j).at(k), road.at(j).at(i) + road.at(i).at(k));
					road.at(k).at(j) = road.at(j).at(k);
				}

	std::sort(town.begin(), town.end());
	int ans = INF;
	do {
		int dis = 0;
		for (int i = 0; i < r - 1; ++i)
			dis += road.at(town.at(i)).at(town.at(i + 1));
		if (ans > dis)
			ans = dis;
	} while (next_permutation(town.begin(), town.end()));

	std::cout << ans;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long a = 1; a <= n; ++a) {
        long long max_b = (n - 1) / a;
        ans += max_b;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
int N;
double ans = -1e9;
double memo[40010][210];
bool   used[40010][210];
vector <int> t, v;

void rec(int c = 0, int speed = 0, double sum = 0.0) {
    if (c == t.back()) {
        if (speed == 0) ans = max(ans, sum);
        return;
    }

    auto itr = lower_bound(t.begin(), t.end(), c);
    if (speed < 0 || 2 * v[itr - t.begin()] < speed) {
        return;
    }

    if (used[c][speed]) {
        return;
    }
    used[c][speed] = true;

    rec(c + 1, speed + 1, sum + (speed + speed + 1.0) * 1 / 2.0);
    rec(c + 1, speed, sum + speed);
    itr = lower_bound(t.begin(), t.end(), c + 1);
    if (2 * v[itr - t.begin()] >= speed) {
        rec(c + 1, speed - 1, sum + (speed + speed - 1.0) * 1 / 2.0);
    }

    return;
}

int main() {
    cin >> N;
    t = v = vector <int> (N);
    rep (i, N) cin >> t[i], t[i] *= 2;
    rep (i, N - 1) t[i + 1] += t[i];
    rep (i, N) cin >> v[i];

    rec();
    cout << setprecision(10) << ans / 4.0 << endl;

    return 0;
}

Measured memory_bytes: 12288
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  getc solve >>= mapM_ (mapM_ print)

solve :: [String] -> [[Int]]
solve = map (f 0 0)
  where
    f j i ss | length ss < 3 = [j,i]
             | s == "JOI" = f (j+1) i (drop 2 ss)
             | s == "IOI" = f j (i+1) (drop 2 ss)
             | otherwise = f j i (tail ss)
      where
        s = take 3 ss

getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n;
vl a;
ll q;
vl b, c;
/******* define variable end *******/
int solve() {
	cin >> n;
	a.resize(n);
	map<ll, ll> m;
	ll sum = 0;
	REP(i, n){
		cin >> a[i];
		m[a[i]]++;
		sum += a[i];
	}
	sort(ALL(a));
	cin >> q;
	b.resize(q);
	c.resize(q);
	REP(i, q){
		cin >> b[i] >> c[i];
	}
	REP(i, q){
		ll tmp = m[b[i]];
		m[b[i]] = 0;
		m[c[i]] += tmp;
		sum -= b[i] * tmp;
		sum += c[i] * tmp;
		cout << sum << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 11680
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	deque<char> ry;
	for(auto val: s)
		ry.push_back(val);
	int cur = 0;
	int q;
	cin >> q;
	while(q--){
		int t;
		cin >> t;
		if(t == 1){
			cur = 1 - cur;
		}
		else {
			int f; char c;
			cin >> f >> c;
			f--;
			if(cur)f = 1 - f;
			if(!f)
				ry.push_front(c);
			else
				ry.push_back(c);
		}
	}
	if(!cur)
	while(ry.size()){
		cout << ry.front();
		ry.pop_front();
	}
	else{
		while(ry.size()){
			cout << ry.back();
			ry.pop_back();
		}
	}
	cout << '\n';

}

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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
using ll=long long;
using ii=pair<int,int>;

const int mxN = 2e5+5;

int N, P[mxN], Q[mxN], Pi[mxN], Qi[mxN];
vector<int> vals;

ll ans = 0;

struct FenwickTree {
	int ft[4*mxN];
	FenwickTree() { memset(ft,0,sizeof ft); }
	void update(int i, int x) { for (; i <= SZ(vals); i += i&-i) ft[i] += x; }
	int query(int i) { int r = 0; for (; i; i -= i&-i) r += ft[i]; return r; }
} ft;

void cdq(int l, int r) {
	if (l >= r) return;
	
	int m = (l+r)/2;
	//~ int orig = ans;
	cdq(l,m);
	cdq(m+1,r);
	
	vector<ii> upd, que;
	FOR(i,l,m) upd.emplace_back(Pi[i],Qi[i]);
	FOR(i,m+1,r) que.emplace_back(P[i],Q[i]);
	sort(ALL(upd));
	sort(ALL(que));
	
	int i = 0;
	for (auto& x : que) {
		while (i < SZ(upd) && upd[i].first <= x.first) {
			ft.update(upd[i].second+1,1);
			++i;
		}
		//~ TRACE(x.second _ ft.query(x.second+1));
		ans += ft.query(x.second+1);
	}
	
	FOR(j,0,i-1) { ft.update(upd[j].second+1,-1); }
	
	//~ cout << l _ r _ ans-orig << " :: ";
	//~ for (auto x : upd) cout << x.first _ x.second << ", ";
	//~ cout << " | ";
	//~ for (auto x : que) cout << x.first _ x.second << ", ";
	//~ cout << endl;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> N;
    FOR(i,1,N){
		string A; cin >> A;
		int j = A.find('.');
		int p10;
		if (j == -1) p10 = 0;
		else {
			p10 = SZ(A)-1-j;
			A.erase(j,1);
		}
		
		ll val = stoll(A);
		while (val%2 == 0) ++P[i], val /= 2;
		while (val%5 == 0) ++Q[i], val /= 5;
		P[i] -= p10;
		Q[i] -= p10;
		Pi[i] = -P[i];
		Qi[i] = -Q[i];
		//~ TRACE(A _ P[i] _ Q[i]);
		vals.push_back(P[i]);
		vals.push_back(Q[i]);
		vals.push_back(Pi[i]);
		vals.push_back(Qi[i]);
	}
	
	sort(ALL(vals)); vals.resize(unique(ALL(vals))-vals.begin());
	FOR(i,1,N){
		P[i] = lower_bound(ALL(vals),P[i])-vals.begin();
		Q[i] = lower_bound(ALL(vals),Q[i])-vals.begin();
		Pi[i] = lower_bound(ALL(vals),Pi[i])-vals.begin();
		Qi[i] = lower_bound(ALL(vals),Qi[i])-vals.begin();
	}
	cdq(1,N);
	cout << ans << '\n';
	
	//~ FOR(i,1,N){
		//~ FOR(j,i+1,N){
			//~ if (Pi[i] <= P[j] && Qi[i] <= Q[j]) {
				//~ TRACE(i _ j);
			//~ }
		//~ }
	//~ }
}


Measured memory_bytes: 15224
package main

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

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)

    var line string
    var arr []string

    line = readLine(reader)
    arr = strings.Split(line, " ")
    X, _ := strconv.Atoi(arr[1])

    line = readLine(reader)
    arr = strings.Split(line, " ")
    length := len(arr)

    var cnt int = 1
    var pos int = 0
    var num int

    for i := 0; i < length; i++ {
        num, _ = strconv.Atoi(arr[i])
        pos = pos + num

        if pos <= X {
            cnt++
        } else {
            break
        }
    }

    fmt.Println(cnt)
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)

int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int dxx[]={1,1,0,-1,-1,-1,0,1};
int dyy[]={0,-1,-1,-1,0,1,1,1};
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;


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

  cout <<(a/2*(a/2+a%2))<<endl;


  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int ans,a[100001];
int main(void){
    int n;
    cin>>n;
    
 for(int i=0;i<n;i++){
     cin>>a[i];
     a[i]--;
 }
 for(int i=0;i<n;i++){
     if(a[i]==i){
         ans++;
         if(a[i+1]==i+1)i++;
     }
 }
 cout<<ans<<endl;
}


Measured memory_bytes: 640
N=int(input())
S=[]
for _ in range(N):
  s=list(input())
  s.sort()
  S.append("".join(s))
from math import factorial
def C(n, r):
  return factorial(n)//(factorial(r)*factorial(n-r))
S.sort()
tmp=list(set(S))
tmp.sort()
j=0
num=0
ans=0
S.append("123")
for i in range(N+1):
  if tmp[j]==S[i]:
    num+=1
  else:
    if num>1:
      ans+=C(num,2)
    num=1
    j+=1
print(ans)

Measured memory_bytes: 22308
<?php 
  //文字列の切り出し
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}
foreach ($tmp as $key => $value) {
  $array[] = explode(" ", $value);
}
$list = array_count_values($array[0]);
$count = count($list);

if ($count === 2) {
    echo "Yes";
} else {
    echo "No";
}

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

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

	long long min = 1000000000000;
	int flag = 0;

	for (long long i = 1; i <= 100000000; i++)
	{
		if (N % i == 0)
		{
			if (N / i + i - 2 < min)
			{
				min = N / i + i - 2;
				flag = 1;
			}
		}
	}
	if(flag == 1){
		cout << min << endl;
	}else{
		cout << N-1 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define mp make_pair
#define len(s) s.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rocknroll cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0)
#define pq priority_queue
#define pii pair < int, int >
#define pll pair < ll, ll >
#define debug cout << " ---------------------------------------- "
#define kektor vector

typedef long long ll;
typedef long double ld;
typedef double dbl;
typedef unsigned long long ull;

using namespace std;


signed main()
{
    rocknroll;
    vector<int>v(5);
    cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4];
    sort(all(v));
    int ans = 2e9;
    do
    {
        int cnt = 0;
        for(int i = 0; i < 5; ++i)
        {
            if (i < 4)
            {
                cnt += (v[i] + 9) / 10 * 10;
            }
            else
            {
                cnt += v[i];
            }
        }
        ans = min(ans, cnt);
    }   while(next_permutation(all(v)));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

int n, k;
const int N = 55;
int v[N];
int dp[N][N][103];

int solve(int i, int j, int k) {
	if (k<=0 || i>j)
		return 0;
	 //db3(i, j, k);
	if (dp[i][j][k] != -1) return dp[i][j][k];

	// choose from left
	int res = v[i] + solve(i+1, j, k-1);
	// not choose from left
	res = max (res, solve(i+1, j, k-2));
	// choose from right
	res = max(res, v[j] + solve(i, j-1, k-1));
	// not choose from right 
	res = max(res, solve(i, j-1, k-2));
	// db3(i, j, k);
	// db1(res);
	return  dp[i][j][k] = res;
}
void testcase() {
    cin >> n >> k;
    rep (i, 0, n-1) cin >> v[i];
    memset(dp, -1, sizeof(dp));
    cout << solve(0, n-1, k);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 1536
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

int main() {
    int N;
    std::cin >> N;

    std::vector<int> W;
    W.reserve(N);
    {
        int w;
        for(int i = 0; i < N; ++i) {
            std::cin >> w;
            W.push_back(w);
        }
    }

    const int sum = std::accumulate(
        W.cbegin(), W.cend(), 0
    );

    int partial_sum = 0;
    int ret = std::numeric_limits<int>::max();
    for (int i = 0; i < N - 1; ++i) {
        partial_sum += W[i];

        ret = std::min(ret, std::abs(sum - 2*partial_sum));
    }
    
    std::cout << ret << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int allSum = 0;
		for (int i = 1; i <= n; i++) {
			String s = String.valueOf(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				sum += Integer.parseInt(String.valueOf(s.charAt(j)));
			}
			if (sum >= a && sum <= b) {
				allSum += i;
			}
		}
		System.out.println(allSum);
	}
}


Measured memory_bytes: 25300