akhauriyash/Code-Regression huggingface dataset:
from sys import stdin, setrecursionlimit


def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if arr == []:
        arr[n] = 1

    return arr


def main():
    input = stdin.buffer.readline
    n = int(input())

    mods = {}

    for i in range(1, n + 1):
        tmp = factorization(i)
        for j in tmp:
            if j in mods:
                mods[j] += tmp[j]
            else:
                mods[j] = tmp[j]

    c3 = 0
    c5 = 0
    c15 = 0
    c25 = 0
    c75 = 0

    for k in mods:
        if 3 <= mods[k] + 1 < 5:
            c3 += 1
        if 5 <= mods[k] + 1 < 15:
            c5 += 1
        if 15 <= mods[k] + 1 < 25:
            c15 += 1
        if 25 <= mods[k] + 1 < 75:
            c25 += 1
        if mods[k] + 1 >= 75:
            c75 += 1

    ans = 0
    ans += (c5 + c15 + c25 + c75) * (c5 + c15 + c25 + c75 - 1) // 2 * (c3 + c5 + c15 + c25 + c75 - 2)
    ans += (c15 + c25 + c75) * (c5 + c15 + c25 + c75 - 1)
    ans += (c25 + c75) * (c3 + c5 + c15 + c25 + c75 - 1)
    ans += c75

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;
int main() {
    int N;
    cin >> N;
    int ans = -N;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int K = input.nextInt();
        double[] p = new double[N];
        double[] exp = new double[N];
        double ans = 0.0;
        for (int i = 0; i < N; i++) {
            p[i] = input.nextDouble();
            exp[i] = (p[i]+1)*p[i]/2/p[i];
        }
        double StartSum=0;
        for (int i = 0; i < K; i++) {
            StartSum+=exp[i];
        }
        ans=Math.max(ans, StartSum);
        for (int i = 1; i+K<=N; i++) {
            StartSum-=exp[i-1];
            StartSum+=exp[i+K-1];
            ans=Math.max(ans, StartSum);
        }
        System.out.println(ans);
    }
}

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

#define ff first
#define ss second
#define pb push_back

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

const int N = 100005;

int main() {
	ll n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	if(a > b) swap(a, b);
	if((b - a) & 1){
		ll ans = 1e18;
		ll a2, b2;
	   	ll aux = n - b + 1;
		b2 = n;
		a2 = a + aux;
		ans = min(ans, aux + (b2 - a2) / 2);
		aux = a;
		a2 = 1;
		b2 = b - aux;
		ans = min(ans, aux + (b2 - a2) / 2);
		printf("%lld\n", ans);
	}
	else{
		printf("%lld\n", (b - a) / 2);
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int X;
   scanf("%d", &X);
   if ( X % 7 == 0 ) printf("thu\n");
   else if ( X % 7 == 1 ) printf("fri\n");
   else if ( X % 7 == 2 ) printf("sat\n");
   else if ( X % 7 == 3 ) printf("sun\n");
   else if ( X % 7 == 4 ) printf("mon\n");
   else if ( X % 7 == 5 ) printf("tue\n");
   else if ( X % 7 == 6 ) printf("wed\n");
   return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
const long long inf=7+1e9;
int main(){
	long long n; cin >> n; 
    vector<long long> a(n);
    long long mx=0;
    for(int i=0; i<n; ++i){
        cin >> a[i];
        mx = max(mx,a[i]);
    }

    long long ans=0, x=1;
    mx=log2(mx);
    for(int i=0; i<=mx; ++i){
        long long cnt=0;
        for(int j=0; j<n; ++j){
            cnt += 1&a[j];
            a[j] >>= 1;
        }
        ans = (ans+x%inf*cnt%inf*(n-cnt)%inf)%inf;
        x <<= 1;
    }
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/

#define d long double
#define int long long
#define pii pair<int,int>
#define pb push_back
#define endl '\n'
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */

int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}

bool comp(string a,string b)
{
    return a.length()<b.length();
}

signed main()
{
    haha
    int n;
    cin>>n;
    d arr[n+1];
    for(int i=1;i<=n;i++)
    cin>>arr[i];
    d dp[n+1][n+1];
    init(dp,0);
   
    
    dp[0][0]=1;
   
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j-1>=0)
            dp[i][j]=arr[i]*dp[i-1][j-1];
            
                dp[i][j]+=(1-arr[i])*dp[i-1][j];
            
        }
    }
    d s=0;
  
    int x=n/2+1;
    for(int i=x;i<=n;i++)
    {
        s+=dp[n][i];
    }
    cout<<fixed<<setprecision(10);
    cout<<s;

     
}


Measured memory_bytes: 144472
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
#define ALL(o) (o).begin(), (o).end()
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}
template <typename T> ll argmax(const T &xs) {return distance(xs.begin(), max_element(xs.begin(), xs.end()));}
template <typename T> ll argmin(const T &xs) {return distance(xs.begin(), min_element(xs.begin(), xs.end()));}
ll nextLL(){ll x; scanf("%lld", &x); return x;}
int nextInt(){int x; scanf("%d", &x); return x;}
string nextString(){string s; cin >> s; return s;}



ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

int N;
vector<int> a;
bitset<2000001> b;

int main(void){
	cin >> N;
	int sum = 0;
	for(int i=0;i<N;i++){
		a.pb(nextInt());
		sum += a[i];
	}

	int maxi = sum / 2;
	b[0] = 1;
	for(int i=0;i<N;i++){
		b |= (b << a[i]);
	}
	for(int i=maxi;i>=0;i--){
		if (b[i]){
			cout << sum - i << endl;
			return 0;
		}
	}


    return 0;
}




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

int main(){
  int n,k;
  cin>>n>>k;
  int p[200005];
  rep(i,n)
    cin>>p[i];
  int s,ma=0,sum=0;
  for(int i=0;i<n;i++){
    sum+=p[i];
    if(i>=k) sum-=p[i-k];
    if(ma<sum){
      s=i-k+1;
      ma=sum;
    }
  }
  double ans=0;
  for(int i=s;i<=s+k-1;i++){
    for(int j=1;j<=p[i];j++){
      ans+=(double)j/p[i];
    }
  }
  printf("%.10lf\n",ans);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

// a^n modを計算する(二分累乗法)
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n>0) {
    if (n&1) res = res*a%mod;
    a = a*a%mod;
    n >>= 1;
  }
  return res;
}

// mod. m でのaの逆元a^{-1}を計算する
ll modinv(ll a, ll m) {
  ll b = m, u = 1LL, v = 0LL;
  while (b) {
    ll t = a/b;
    a -= t*b;
    swap(a, b);
    u -= t*v;
    swap(u, v);
  }
  u %= m;
  if (u<0) u += m;
  return u;
}

// 二項係数(O(k))
ll comb(ll n, ll k) {
  ll num = 1, den = 1; // 分子と分母
  for (ll i=n; i>=n-k+1; i--) num = num*i%MOD;
  for (ll i=1; i<=k; i++) den = den*i%MOD;
  num %= MOD;
  return num*modinv(den, MOD)%MOD;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll res = modpow(2, n, MOD)-comb(n, a)-comb(n, b)-1;
  res %= MOD;
  if (res<0) res += MOD;
  cout << res << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}


int dy[]={0,1,0,-1};
int dx[]={1,0,-1,0};

signed main()
{
	IOS();
	int N,M;
	vector<int>ans;
	while(1){
		cin>>N>>M;
		if(N==0&&M==0)break;
		vector<int>a(N);
		rep(i,0,N)a[i]=N-i-1;
		rep(i,0,M){
			int P,C;
			cin>>P>>C;
			P--;
			vector<int>tmp;
			rep(j,P,P+C){
				tmp.push_back(a[j]);
			}
			rep(j,0,P){
				tmp.push_back(a[j]);
			}
			rep(j,0,tmp.size())a[j] = tmp[j];
		}
		ans.push_back(a[0]);
	}
	for(auto e:ans)cout<<e+1<<endl;
}



Measured memory_bytes: 3124
#include <stdio.h>

int main(void){
    
    int i,j,n,min;
    char s[51][51];
    int a[51][26]={};
    int b[26]={};
    
    scanf( "%d",&n);
    
    for( i = 0; i < n; i++ ){
        scanf( "%s",s[i] );
    }
    
    for( i = 0; i < n; i++ ){
        for( j = 0; s[i][j] != '\0'; j++ ){
            a[i][s[i][j]-97]++;
        }
    }
    
    for( j = 0; j < 26; j++ ){
        min = 51;
        for( i = 0; i < n; i++ ){
            if(a[i][j] < min ){
                min = a[i][j];
            }
        }
        b[j] = min;
    }
    
    for( i = 0; i < 26; i++ ){
        for( j = 0; j < b[i]; j++ ){
            printf( "%c",97+i );
        }
    }
    printf("\n");
    
    return 0;
}

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

int main() {
  int n, m; cin>>n>>m;
  vector<int> x(m), y(m);
  rep(i, m) cin>>x[i]>>y[i], x[i]--, y[i]--;

  vector<int> ball(n, 1);
  vector<bool> color(n, false);
  color[0]=true;
  rep(i, m) {
    if (ball[x[i]]<=0) continue;
    if (color[x[i]]) color[y[i]]=true;
    ball[x[i]]-=1;
    ball[y[i]]+=1;
    if (ball[x[i]]==0) color[x[i]]=false;
  }
  int sum=0;
  rep(i, n) if (color[i]) sum++;
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1408
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S1 = "";
string S2 = "";
string S3 = "";
ll cases;

int main() {
    go;
    cin >> S1 >> S2 >> S3;
    cout << (char)(toupper(S1[0]))  << (char)(toupper(S2[0])) << (char)(toupper(S3[0])) << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

ans = 100000

def sum_digits(n,m):
    r = 0
    while n:
        r, n = r + n % m, n // m
    return r
 
for i in range(N+1):
    ans = min(ans, sum_digits(i,6)+sum_digits(N-i,9))
 
print(ans)  

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

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(500*500)

graph = []
distance = []

def dfs(G, v, dist = 0):
    #print(v)
    distance[v-1] = dist

    for i in range(0,len(G[v-1]),2):
        #print(i, G[v-1][i])
        if distance[G[v-1][i]-1] != -1:
            continue
        dist += G[v-1][i+1]
        #print(1,1,dist)
        dfs(G, G[v-1][i], dist)
        dist -= G[v-1][i+1]

N = int(input())

for i in range(N):
    graph.append([])
    distance.append(-1)

for i in range(N-1):
    u, v, w = map(int, input().split())
    graph[u-1].append(v)
    graph[u-1].append(w)
    graph[v-1].append(u)
    graph[v-1].append(w)


#print(graph)
#print(distance)

dfs(graph, 1)

for i in range(N):
    if distance[i]%2 == 0:
        print(0)
    else:
        print(1)

#print(graph)
#print(distance)

Measured memory_bytes: 87636
#include<iostream>
#include<string.h>
using namespace std;
int main(){
  string str;
  int N;
  double money,sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
  cin>>money>>str;
 if(str=="BTC")
  money*=380000;
   sum+=money;
  }
   cout<<sum<<endl;
   
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstring>
#include <cctype>
#include <complex>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1<<30;
const int EPS = 1e-15;
#define PB push_back
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int > Pii;
bool PRIME[1000001];
void Prime(){
	PRIME[0] = PRIME[1] = true;
	for(int i = 2; i*i <= 1000000; i++){
		if(!PRIME[i]){
			for(int j = i*i; j <= 1000000; j+=i){
				PRIME[j] = true;
			}
		}
	}
}
int main(){
	Prime();
	int a,d,n;
	while(scanf("%d%d%d",&a,&d,&n),(a|d|n)){
		int cnt = 0;
		while(true){
			if(!PRIME[a])cnt++;
			if(cnt == n){
				printf("%d\n",a);
				break;
			}
			a+=d;
		}
	}
	return 0;
}

Measured memory_bytes: 2164
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a < 10 && b < 10) {
			System.out.println(a*b);
		} else {
			System.out.println(-1);
		}
	
		
	
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int a[2][105];
int visit[2][105];

int main(){
	int n;
	while(cin >> n, n){
		memset( a, 0, sizeof(a) );
		memset( visit, 0, sizeof(visit) );
		rep(k, 2) rep(i, n) cin >> a[k][i];
		rep(k, 2) rep(i, 105) visit[k][i] = 0;


		priority_queue<pair<int, P>, vector<pair<int, P> >, greater<pair<int, P> > > q;
		q.push(MP(0, MP(0, 0)));
		q.push(MP(0, MP(1, 0)));
		int ans = -1;
		while(!q.empty()){
			P p = q.top().second;
			int d = q.top().first;
			q.pop();

			while(a[p.X][p.Y] == 1 && a[p.X][p.Y+1] == 1) p.Y++;
			while(a[p.X][p.Y] == 2) p.Y--;
			if(visit[p.X][p.Y]) continue;
			visit[p.X][p.Y] = 1;
			if(p.Y >= n-1){
				ans = d;
				break;
			}

			rep(i, 3){
				int nx = !p.X;
				int ny = p.Y + i;
				if(ny >= n) ny = n-1;
				q.push(MP(d+1, MP(nx, ny)));
			}
		}
		if(ans != -1) cout << ans << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    stack<int> s;
    int n, ans[100], ct = 0;
    while (cin>>n){
        if (n == 0) {
            ans[ct] = s.top();
            //cout << s.top() << endl;
            s.pop();
            ct++;
        } else {
            s.push(n);
        }
    }
    REP(i, ct){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3008
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int N=1e5+5;
struct eg{int v,nx,w;}e[N<<1];int head[N],tot=1;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int deg[N],st[N],Pre[N],vis[N],top,n,m,S,T,h,t;
bool dfs(int u){
	vis[u]=1;
	go(u)if(!vis[v]&&!e[i].w)Pre[v]=i,dfs(v);
}
bool find(){
	fp(i,1,n)vis[i]=0;
	dfs(S);
	if(!vis[T])return false;
	for(int u=T;u!=S;u=e[Pre[u]^1].v)e[Pre[u]].w=e[Pre[u]^1].w=1;
	return true;
}
bool ck(){
//	printf("%d\n",find());
//	printf("%d\n",find());
//	printf("%d\n",find());
	S=st[1],T=st[2];
	if(find()&&find()&&!find())return true;
	return false;
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(),m=read();
	for(R int i=1,u,v;i<=m;++i)u=read(),v=read(),add(u,v),add(v,u),++deg[u],++deg[v];
	fp(i,1,n)if(deg[i]&1)return puts("No"),0;
	fp(i,1,n)if(deg[i]>=6)return puts("Yes"),0;
	fp(i,1,n)if(deg[i]==4)st[++top]=i;
	if(top>=3)return puts("Yes"),0;
	if(top>=2&&ck())return puts("Yes"),0;
	return puts("No"),0; 
}

Measured memory_bytes: 8832
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;


bool solve(){
	int a,b,x;
	char ch, ch2;
	int ans = 0, ans2 = 0;
	while(cin>>a){
		cin>> ch>> b>> ch2>> x;
		if(a*a + b*b == x*x) ans++;
		if(a == b) ans2++;
	}
	cout<< ans<< endl;
	cout<< ans2<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();
	
	return 0;
}

 

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
# E - Sequence Decomposing
import sys 
from bisect import bisect_left
from collections import deque

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,read().split()))


INF = 10**31
q = deque([])

for a in A:
    idx = bisect_left(q, a)
    if idx == 0:
        q.appendleft(a)
    else:
        q[idx-1] = a
print(len(q))

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

int main() {
    string s;
    cin>>s;
    string ans="";
    rep(i,s.size()) {
        if (i%2==0) ans+=s[i];
    }
    cout<<ans<<endl;
}


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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a,b,k;
    cin>>a>>b>>k;
    if(a+b<=k){
        cout<<0<<" "<<0<<endl;
        return 0;
    }
    else{
        if(a<=k){
            k=k-a;
            a=0;
        }
        else{
            a=a-k;
            k=0;
        }
        if(b<=k) b=0;
        else b=b-k;
        cout<<a<<" "<<b<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes";
    else cout << "No";


    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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;
};

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

  int N, M;
  cin >> N >> M;

  priority_queue<ll> pq;

  ll A;
  rep(i, 0, N) {
    cin >> A;
    pq.push(A);
  }

  rep(i, 0, M) {
    ll cost = pq.top(); pq.pop();
    // cout << cost << endl;
    cost /= 2ll;
    pq.push(cost);
  }

  ll ans = 0ll;
  while (!pq.empty()) {
    ll cost = pq.top(); pq.pop();
    ans += cost;
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 1400
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var a = sc.ArrayInt(N);
        var ans = new int[N];
        var total = 0;
        for (int i = N; i > 0; i--) {
            if (N / i == 1) {
                ans[i - 1] = a[i - 1];
                if (a[i-1] == 1) {
                    total++;
                }
                
            } else {
                // 倍数がある
                var sum = 0;
                var b = false;
                for (int j = i * 2; j <= N; j += i) {
                    if (i == 1) {
                        if (total % 2 != a[i-1]) {
                            ans[i - 1] = 1;
                        }
                        b = true;
                        break;
                    }
                    sum += ans[j-1];
                }
                if (b) break;

                if (a[i-1] != sum % 2) {
                    ans[i-1] = 1;
                    total++;
                }
            }
        }

        var cnt = ans.Where(val => val == 1).Count();
        WriteLine(cnt);
        var tmp = new List<string>();

        for (int i = 0; i < N; i++) {
            if (ans[i] == 1) {
                tmp.Add((i + 1).ToString());
            }
        }

        if (cnt > 0) {
            WriteLine(string.Join(" ", tmp));
        }
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 33884
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string.h>
using namespace std;
const int MAX = 100;
int stack[MAX];
int cnt = 0;
void push(int x) {
	stack[cnt++] = x;
}
int pop() {
	return stack[--cnt];
}
bool isEmpty() {
	return cnt == 0;
}
bool isFull() {
	return cnt == MAX;
}
int main() {
	char input[100];
	while (cin >> input) {
		if (input[0] == '+') {
			int x = pop();
			int y = pop();
			push(x + y);
		}
		else if (input[0] == '-') {
			int x = pop();
			int y = pop();
			push(y - x);
		}
		else if (input[0] == '*') {
			int x = pop();
			int y = pop();
			push(x*y);
		}
		else {
			push(atoi(input));
		}
	}
	cout << stack[0] << endl;
	return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    int n, q;
    cin >> n >> q;
    cin >> s;
    int ac_cnt[100005] = {};
    for( int i = 1; i < s.size(); ++i ) {
        if( s[i - 1] == 'A' && s[i] == 'C' ) ac_cnt[i] = ac_cnt[i - 1] + 1;
        else ac_cnt[i] = ac_cnt[i - 1];
    }

    for( int i = 0; i < q; ++i ) {
        int l, r;
        cin >> l >> r;
        cout << ac_cnt[r - 1] - ac_cnt[l - 1] << endl;

    }


    return 0;
}



Measured memory_bytes: 1488
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int MOD=924844033,N=2*(1e5)+10,NT=N*4,G=5;
struct xxx{
    int y,nxt;
}a[N*2];
int h[N],fac[N],invfac[N],cnt[N],sz[N],ans[N];
int vala[N],valb[N];
int n,m,tot;
int mul(int x,int y){return 1LL*x*y%MOD;}
int add(int x,int y){return (1LL*x+y)%MOD;}
int ksm(int x,int y){
    int ret=1,base=x;
    for (;y;y>>=1,base=mul(base,base))
        if (y&1) ret=mul(ret,base);
    return ret;
}
namespace NTT{/*{{{*/
    int A[NT],B[NT],rev[NT],W[NT][2];
    int len,invlen;
    void init(){
        int invg=ksm(G,MOD-2);
        for (int i=1;i<=19;++i){
            W[1<<i][0]=ksm(G,(MOD-1)/(1<<i));
            W[1<<i][1]=ksm(invg,(MOD-1)/(1<<i));
        }
    }
    void get_len(int n,int m){
        for (int i=0;i<len;++i) A[i]=B[i]=0;
        int bit=0;
        for (len=1;len<=n+m;++bit,len<<=1);
        rev[0]=0;
        for (int i=1;i<len;++i) rev[i]=(rev[i>>1]>>1)|((i&1)<<(bit-1));
        invlen=ksm(len,MOD-2);
    }
    void ntt(int *a,int op){
        int w,w_n,u,v;
        for (int i=0;i<len;++i) if (rev[i]>i) swap(a[i],a[rev[i]]);
        for (int step=2;step<=len;step<<=1){
            w_n=W[step][op==-1];
            for (int st=0;st<len;st+=step){
                w=1;
                for (int i=0;i<(step>>1);++i){
                    v=mul(a[st+i+(step>>1)],w);
                    u=a[st+i];
                    a[st+i]=add(u,v);
                    a[st+i+(step>>1)]=add(u,MOD-v);
                    w=mul(w,w_n);
                }
            }
        }
        if (op==1) return;
        for (int i=0;i<len;++i) a[i]=mul(a[i],invlen);
    }
    void Ntt(int *a,int *b,int n,int m){
        get_len(n,m);
        for (int i=0;i<=n;++i) A[i]=a[i];
        for (int i=0;i<=m;++i) B[i]=b[i];
        ntt(A,1);
        ntt(B,1);
        for (int i=0;i<len;++i) A[i]=mul(A[i],B[i]);
        ntt(A,-1);
    }
}/*}}}*/
void Add(int x,int y){a[++tot].y=y; a[tot].nxt=h[x]; h[x]=tot;}
void prework(int n){
    NTT::init();
    fac[0]=1;
    for (int i=1;i<=n;++i) fac[i]=mul(fac[i-1],i);
    invfac[n]=ksm(fac[n],MOD-2);
    for (int i=n-1;i>=0;--i) invfac[i]=mul(invfac[i+1],i+1);
}
int C(int n,int m){return n<m?0:1LL*fac[n]*invfac[m]%MOD*invfac[n-m]%MOD;}
void dfs(int fa,int x){
    int u;
    sz[x]=1;
    for (int i=h[x];i!=-1;i=a[i].nxt){
        u=a[i].y;
        if (u==fa) continue;
        dfs(x,u);
        sz[x]+=sz[u];
    }
    if (fa) ++cnt[n-sz[x]],++cnt[sz[x]];
}
void solve(){
    for (int i=1;i<=n;++i) vala[i]=mul(cnt[i],fac[i]);
    for (int i=0;i<=n;++i) valb[n-i]=invfac[i];
    //for (int i=0;i<=n;++i) printf("%d ",vala[i]);printf("\n");
    //for (int i=0;i<=n;++i) printf("%d ",valb[i]);printf("\n");
    NTT::Ntt(vala,valb,n+1,n+1);
    for (int i=1;i<=n;++i) ans[i]=mul(NTT::A[n+i],invfac[i]);
    for (int i=1;i<=n;++i)
        printf("%d\n",add(mul(n,C(n,i)),MOD-ans[i]));
}

int main(){
    int x,y;
    scanf("%d",&n);
    memset(h,-1,sizeof(h));
    tot=0;
    for (int i=1;i<n;++i){
        scanf("%d%d",&x,&y);
        Add(x,y); Add(y,x);
    }
    prework(n);
    dfs(0,1);
    solve();
}

Measured memory_bytes: 33152
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e5 + 200;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, k, l = 2, r = 3;
vector<pair<int, int> > v;

int main () {
    ios;
    cin >> n >> k;
    for(int i = 2; i <= n; i++){
        v.pb({1, i});
    }
    llong cur = (n - 1) * (n - 2) / 2;
    if(cur < k) return cout << -1, 0;
    while(cur != k){
        if(l == n + 1) return cout << -1, 0;
        cur--;
        v.pb({l, r});
        r++;
        if(r == n + 1){
            l++;
            r = l + 1;
        }
    }
    cout << v.size() << nl;
    for(int i = 0; i < v.size(); i++){
        cout << v[i].F << ' ' << v[i].S << nl;
    }
    return 0;
}


Measured memory_bytes: 384
import copy

def bubbleSort(C, M, N):
    for i in range(N):
        for j in reversed(range(i+1, N)):
            if C[j] < C[j-1]:
                out1 = C[j]
                C[j] = C[j-1]
                C[j-1] = out1
                out2 = M[j]
                M[j] = M[j-1]
                M[j-1] = out2
    print(' '.join(M))
    print('Stable')
    return M
    
def selectionSort(C, M, N):
    m = copy.deepcopy(M)
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j] < C[minj]:
                minj = j
        out3 = C[i]
        C[i] = C[minj]
        C[minj] = out3
        out4 = M[i]
        M[i] = M[minj]
        M[minj] = out4
    print(' '.join(M))
    return M
    
def isStable(inn, out):
    for a, b in zip(inn, out):
        if a == b: continue
        else : return 'Not stable'
    return 'Stable'
    
if __name__ == '__main__':
    num1 = []
    N = int(input()) #1行目のNを取得する
    M1 = list(input().split())
    for i in range(N):
        s = M1[i]
        num1.append(int(s[-1]))
    M2 = copy.deepcopy(M1)
    num2 = copy.deepcopy(num1)
    out1 = bubbleSort(num1, M1, N)
    out2 = selectionSort(num2, M2, N)
    print(isStable(out1, out2))


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

int main() {
    int n,a;
    cin >> n >> a;
    cout << n*n-a << endl;
}

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

int main(){
	int n;
	cin >> n;
	if(n%1000 == 0){
	cout << "0" << endl;
	}
	else{
	int diff = 1000 - (n%1000);
	cout << diff << endl;
	}
return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a-c)/(b+c)<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $a);
fscanf(STDIN, "%s", $b);
fscanf(STDIN, "%s", $c);

$i = 'a';
$check = '';
while($check != 'A' && $check != 'B' && $check != 'C'){
    if($i == 'a'){
        if($i = $a[0]){
            $a = substr($a, 1);
        }else{
            $check = 'A';
        }
    }elseif($i == 'b'){
        if($i = $b[0]){
            $b = substr($b, 1);
        }else{
            $check = 'B';
        }
    }elseif($i == 'c'){
        if($i = $c[0]){
            $c = substr($c, 1);
        }else{
            $check = 'C';
        }
    }
}
print $check;


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

int main(){
    int N=0,X=0,result=0;

    cin >> N >> X;
    int m[N];
    result = X;
    for(int i = 0;i<N;i++){
        cin >> m[i];
        result = result - m[i];
        if (X>m[i]){
            X = m[i];
        }
    }
    int y;
   y = result / X;
    
cout << N + y << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N, long long D, std::vector<std::vector<long long>> X){
    ll cnt=0;
    rep(i,N){
        repf(j,i+1,N){
            double tmp=0;
            rep(k,D){
                tmp+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            repf(k,1,1000){
                if(tmp==k*k)cnt++;
            }
        }
    }
    op(cnt)
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
    return 0;
}


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

using namespace std;

int main()
{
    int n, type, value;
    string key, upperRange;
    map<string, int> m;
    map<string, int> :: iterator it;

    scanf("%d",&n);

    for(int i = 0; i< n; i++)
    {
        scanf("%d",&type);
        cin>> key;

        if(type == 0)
        {
            scanf("%d",&value);
            m[key] = value;
        }
        else if(type == 1)
        {
            it = m.find(key);
            if(it == m.end())
                printf("0\n");
            else
                printf("%d\n",m[key]);
        }
        else if(type == 2)
            m.erase(key);
        else
        {
            cin>>upperRange;
            it = m.lower_bound(key);
            for(;it!= m.upper_bound(upperRange); it++)
                cout<<(*it).first<<" "<<(*it).second<<endl;
        }
    }

    return 0;
}




Measured memory_bytes: 27848
#include<iostream>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=(int)b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
double dist(double x,double y,double z){
  return sqrt(x*x+y*y+z*z);
}

void solve(double *x,double *y,double *z,int n,double *t){  
  rep(i,n){
    rep(j,n){
      if ( i == j)continue;
      rep(k,n){
	if ( k==j || k == i)continue;
	double r[3]={
	  dist(x[i]-x[j],y[i]-y[j],z[i]-z[j])/t[0],
	  dist(x[k]-x[j],y[k]-y[j],z[k]-z[j])/t[1],
	  dist(x[k]-x[i],y[k]-y[i],z[k]-z[i])/t[2]
	};
	if ( abs(r[0]-r[1])<0.01&&abs(r[1]-r[2])<0.01 && 
	     abs(r[2]-r[0])<0.01){
	  cout << k+1 << " " << i+1 << " " << j+1<<endl;
	  return;
	}
      }
    }
  }
}


main(){
  int te;
  cin>>te;
  while(te--){
    int n;
    double t[3];
    rep(i,3)cin>>t[i];
    cin>>n;
    double x[n],y[n],z[n];
    rep(i,n)cin>>x[i]>>y[i]>>z[i];
    solve(x,y,z,n,t);
  }
  return false;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define inv(x) power(x,Mod-2)
#define upd(a,b) a=add(a,b)
#define rdc(a,b) a=sub(a,b)
using namespace std;
typedef long long ll;
const int Mod=998244353;
int add(int a,const int b){a+=b;if(a>=Mod)a-=Mod;return a;}
int sub(int a,const int b){a-=b;if(a<0)a+=Mod;return a;}
int mul(const int a,const int b){return (ll)a*b%Mod;}
int power(int x,int cs)
{
	int ras=1;
	while(cs)
	{
		if(cs&1) ras=mul(ras,x);
		x=mul(x,x);cs>>=1;
	}
	return ras;
}
const int N=5e5+50,pn=5e5+10;
int n,m,ans=0;
int zp[N],fp[N],cf1[N],cf2[N];
int C(int a,int b){return mul(zp[a],mul(fp[b],fp[a-b]));}
void init()
{
	int i;
	zp[0]=fp[0]=1;
	for(i=1;i<=pn;i++) zp[i]=mul(zp[i-1],i);
	fp[pn]=inv(zp[pn]);
	for(i=pn-1;i>=1;i--) fp[i]=mul(fp[i+1],i+1);
}
int main()
{
	int i,tmp;
	init();
	cin>>n>>m;
	cf1[0]=1;
	for(i=1;i<=n;i++) cf1[i]=mul(cf1[i-1],m+1);
	cf2[0]=1;
	for(i=1;i<=m;i++) cf2[i]=mul(cf2[i-1],n+1);
	for(i=0;i<=min(n,m);i++)
	{
		tmp=mul(mul(cf1[n-i],cf2[m-i]),mul(zp[i],mul(C(n,i),C(m,i))));
		if(i&1) rdc(ans,tmp);
		else upd(ans,tmp);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000003;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[500005],t[500005];
//bool used[500005];
bool flag,dame;


int main(){
	cin >> s;
    n = strlen(s);
    i = 0;
    while(1){
        if(s[i] == 'A'){
            a++;
            i++;
        }else if(s[i] == 'B'){
            if(s[i+1] == 'C'){
                ans += a;
                i += 2;
            }else{
                a = 0;
                i++;
            }
        }else{
            a = 0;
            i ++;
        }
        if(i >= n)break;
    }
    p(ans);
	return 0;
}

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

const int MAXN = 100010;
int N, M;
int cnt[MAXN];

int main() {
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		int x, y; scanf("%d %d", &x, &y);
		cnt[x]++; cnt[y]++;
	}

	for (int i = 1; i <= N; i++) {
		if (cnt[i] % 2 == 1) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");

	return 0;
}


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

  using namespace std;
  using namespace std::chrono; 

  typedef long long int ll;

  #define MOD (ll)(1e9+7)
  #define endl "\n"
  #define pb push_back
  #define TEST_CASES  ll t;cin>>t;while(t--)
  #define forn(i,a,n) for (int i = a; i < n; ++i)
  #define f first
  #define s second
  #define all(x) x.begin(), x.end()

  void __print(int x) {cerr << x;}
  void __print(long x) {cerr << x;}
  void __print(long long x) {cerr << x;}
  void __print(unsigned x) {cerr << x;}
  void __print(unsigned long x) {cerr << x;}
  void __print(unsigned long long x) {cerr << x;}
  void __print(float x) {cerr << x;}
  void __print(double x) {cerr << x;}
  void __print(long double x) {cerr << x;}
  void __print(char x) {cerr << '\'' << x << '\'';}
  void __print(const char *x) {cerr << '\"' << x << '\"';}
  void __print(const string &x) {cerr << '\"' << x << '\"';}
  void __print(bool x) {cerr << (x ? "true" : "false");}

  template<typename T, typename V>
  void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
  template<typename T>
  void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
  void _print() {cerr << "]\n";}
  template <typename T, typename... V>
  void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
  #ifndef ONLINE_JUDGE
  #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
  #else
  #define debug(x...)
  #endif
  
  ll powD(ll x,ll y){
    ll res = 1;
    while(y > 0){
      if(y & 1)
        res = (res*x)%MOD;
      x = (x*x)%MOD;
      y = y>>1;
    }
    return res;
  }
  int MAX = 2e5;
  int n,k;
  vector<int> a(MAX);
  bool check(int val){
    int cnt = 0;
    forn(i,0,n){
      if(a[i] <= val)
        continue;
      cnt += a[i]/val;
    }
    if(cnt <= k)
      return true;
    else
      return false;
  }
  /*CHECK FOR CORNER CASES FOR GOD'S SAKE*/
  int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k;
    forn(i,0,n){
      cin>>a[i];
    }
    int l = 0,r = 1e9;
    while(r-l>1){
      int mid = (l+r)/2;
      if(check(mid))
        r = mid;
      else
        l = mid;
    }
    cout<<r<<endl;
  }
   
  


Measured memory_bytes: 3880