akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var d = int.Parse(list[1]);

        var xss = new int[n][];
        for (int i = 0; i < xss.Length; ++i)
        {
            var xs = new int[d];
            xss[i] = xs;
            var list2 = Console.ReadLine().Split(' ');
            for (int j = 0; j < xs.Length; ++j)
                xs[j] = int.Parse(list2[j]);
        }

        int count = 0;

        for (int i = 0; i < xss.Length; ++i)
        {
            var xs_l = xss[i];
            for (int j = i + 1; j < xss.Length; ++j)
            {
                var xs_r = xss[j];
                long dis = 0;
                for (int k = 0; k < xs_l.Length; ++k)
                {
                    var t = xs_l[k] - xs_r[k];
                    dis += t * t;
                }
                var a = (long)Math.Sqrt(dis);
                if (a * a == dis)
                    ++count;
            }
        }

        Console.WriteLine(count);
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 13268
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, Y;
        cin >> N >> Y;
        int mi = Y / 10000, hi = Y / 5000;

        rep(i, mi + 1)
        {
                rep(j, hi + 1)
                {
                        if (N == Y / 1000 - 10 * i - 5 * j + i + j && Y / 1000 - 10 * i - 5 * j >= 0)
                        {
                                cout << i << ' ' << j << ' ' << Y / 1000 - 10 * i - 5 * j << endl;
                                return 0;
                        }
                }
        }

        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
        return 0;
}


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

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

    for (int i = 0; i < N; i++) {
        if (S[i] != S[K - 1]) S[i] = '*';
    }

    cout << S << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

import java.math.BigDecimal;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while( (line = br.readLine()) != null ){
            String[] input = line.split(" ");
            double[] data = new double[6];

            for(int i = 0; i < 6; i++){
                data[i] = Double.parseDouble(input[i]);
            }

            double x = (data[2]*data[4] - data[1]*data[5]) /
                       (data[4]*data[0] - data[1]*data[3]);
            double y = (data[0]*data[5] - data[3]*data[2]) /
                       (data[4]*data[0] - data[1]*data[3]);
            
            BigDecimal a = new BigDecimal(x);
            BigDecimal b = new BigDecimal(y);

            a = a.setScale(3 , BigDecimal.ROUND_HALF_UP);
            b = b.setScale(3 , BigDecimal.ROUND_HALF_UP);
            System.out.println(a + " " + b);

        }
    }
}

Measured memory_bytes: 24512
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,a,b;cin >> n >> a >> b;
    vector<int> h(n);
    rep(i,n)cin >> h[i];
    auto ok = [&](int x){
        //x回ですべての体力を０いかにできるか
        int ret = 0;
        rep(i,n){
            int tmp = max(0ll,h[i] - x*b);
            ret += (tmp + (a-b)-1)/(a-b);
        }
        return ret <= x;
    };
    int top = 1001001001,bot = 0;
    while(top - bot > 1){
        int mid = (top + bot)/2;
        if(ok(mid))top = mid;
        else bot = mid;
    }
    cout << top << endl;
    return 0;
}

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

int main(){
	int N;
  	cin >> N;
  	int c0 = N/100;
  	int c1 =N-c0*100;
  	int f0 =0;
    int f1 =0;
	if(c0 >0 &&c0 <13) f0 =1;
	if(c1 >0 &&c1 <13) f1 =1;
	string ans ="NA";
  	if(f0 ==1&&f1==1){
    	ans = "AMBIGUOUS";
    }else if(f0 ==1&&f1==0){
    	ans = "MMYY";
    }else if(f0 ==0&&f1==1){
    	ans = "YYMM";
    }
  	cout << ans << endl;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)   for(ll i=0;i<(b);i++)
#define f1(i,b)   for(ll i=1;i<=(b);i++)
#define f2(i,a,b) for(ll i=(a);i<=(b);i++)
#define f3(i,b,a) for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld\n",a)

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

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

    //scan(n);
    cin>>n;
    ll A[n+1], B[n];

    f0(i,n+1)
    {
        cin>>A[i];
    }
    f0(i,n)
    {
        cin>>B[i];
        if(A[i]>=B[i])
        {
            A[i]-=B[i];
            cnt+=B[i];
        }
        else
        {
            B[i]-=A[i];
            cnt+=A[i];
            A[i]=0;
            if(A[i+1]>=B[i])
            {
                A[i+1]-=B[i];
                cnt+=B[i];
            }
            else
            {
                cnt+=A[i+1];
                A[i+1]-=B[i];
                A[i+1]=0;
            }
        }
    }

    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int ans = a;
	if (a > b) ans--;
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String line = reader.readLine();           
            double r = Double.parseDouble(line);
            double area = r*r*Math.PI;
            double circumference = 2*r*Math.PI; 
            System.out.printf("%f %f\n",area,circumference);

    }
}


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

using namespace std;

int main()
{
	int i,j;
	char array[1000010];
	
	for(i=0;i<1000001;i++)
		array[i]='1';
	
	array[0]=array[1]='0';
	
	for(i=0;i<1000001;i++)
	{
		if(array[i]=='1')
		{
			for(j=2;i*j<1000001;j++)
				array[i*j]='0';
		}
	}
	
	vector<int> ans;
	
	for(i=0;i<1000001;i++)
	{
		ans.push_back(0);
	}
	for(i=1;i<1000001;i++)
	{
		ans[i]+=ans[i-1];
		ans[i]+=(int)array[i]-48;
	}
	
	int inp;
	for(;cin >> inp;)
	{
		cout << ans[inp] << endl;
	}
}

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

int main() {
	int n, m;
	std::cin >> n >> m;

	int cnt[100010];


	int min = 1e6;
	int max = 0;
	for (int i = 0; i < m; ++i) {
		int l, r;
		std::cin >> l >> r;
		min = std::min(min, r);
		max = std::max(max, l);
	}

	std::cout << std::max(0, min - max + 1);
}

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

int recur(int st,int k,vector<int>& dp,vector<int> &vec){
    if(!st) return 0;
    if(st<0) return 1e7;
    int &ret=dp[st];
    if(ret!=-1) return ret;
    ret=abs(vec[st]-vec[st-1])+recur(st-1,k,dp,vec);
    for(int i=2;i<=k;++i)
        ret=min(ret,abs(vec[st]-vec[st-i])+recur(st-i,k,dp,vec));
    return ret;
}

signed main(){
    int i,n,k; scanf("%d%d",&n,&k);
    vector<int> vec(n),dp(n,-1);
    for(i=0;i<n;++i) scanf("%d",&vec[i]);
    cout<<recur(n-1,k,dp,vec);
    return 0;
}

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

int main() {
  int N,Y;
  cin >> N >> Y;
  int yen;
  int dai = -1 , tyu = -1 ,syo = -1;
  for(int i=0; i<=N; i++){
      for(int jj=0; i+jj<=N; jj++){
      yen = i*10000 +jj*5000 +(N-i-jj)*1000;
      if(yen == Y){dai =i;tyu =jj;syo = N-i-jj;break;}
      }
  }

  cout << dai << ' ' <<  tyu << ' ' << syo << endl;
}


Measured memory_bytes: 256
// @Problem https://atcoder.jp/contests/abc139/tasks/abc139_b
use proconio::input;

fn main() {
    input! {
        unit_socket: f32,
        required_socket: f32,
    }
    let r = ((required_socket - 1.0) / (unit_socket - 1.0)).ceil() as i32;
    println!("{}", r);

}

Measured memory_bytes: 2632
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int n;
  cin>>n;

  vector <double> a(n);
  cin>>a;

  sort(ALL(a));

  REP(i,n-1) a[i+1]=(a[i]+a[i+1])/2;

  cout<<a[n-1]<<endl;

  return 0;

}


Measured memory_bytes: 256
from math import sin, cos, radians, sqrt
a, b, C = map(float, input().split())
rad = radians(C)
h = b * sin(rad)
print(a * h / 2)
print(a + b + sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(rad)))
print(h)


Measured memory_bytes: 5684
N, x = map(int,input().split())
a = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    if a[i] + a[i+1] > x:
        temp = a[i] + a[i+1] - x 
        if a[i+1] - temp >= 0:
            ans += temp
            a[i+1] -= temp
        else:
            ans += temp
            a[i+1] = 0
            a[i] -= temp - a[i+1]
     
print(ans)

Measured memory_bytes: 19880
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int,int>>>g(n);
	for (int i = 0; i < m;i++) {
		int l, r, d;
		cin >> l >> r >> d;
		l--;
		r--;
		g[l].emplace_back(make_pair(r, d));
		g[r].emplace_back(make_pair(l, -d));
	}

	queue<int> que;
	vector<ll> x(n, BIG_NUM);
	bool canConsist = true;
	for (int i = 0; i < n;i++) {
		if (x[i] == BIG_NUM) {
			x[i] = 0;
			que.push(i);
		}

		
		while (!que.empty()) {
			int v = que.front();
			que.pop();
			for (auto it = g[v].begin();it != g[v].end(); it++) {
				int p = it->first;
				if (x[p] == BIG_NUM) {
					x[p] = x[v] + it->second;
					que.push(p);
				}
				else {
					if (x[p] != x[v] + it->second) {
						canConsist = false;
						break;
					}
				}
			}
			if (!canConsist) {
				break;
			}



		}
	}

	cout << (canConsist ? "Yes" : "No") << endl;

}


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

using namespace std;

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

    long max = 0;
    long test;
    for (int i = 1; i < N; i++)
    {
        max += i;
    }

    int index = N / 2;
    test = max - index + (N % (index + 1));

    while (test > max)
    {
        max = test;
        N = index;
        index = N / 2;
        test = max - index + (N % (index + 1));
    }

    //cout << "Max : " << max << endl;
    //cout << "Test : " << test << endl;

    if (test > max)
    {
        max = test;
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 100000, MAX_M = 100000;
    int N, M, a, b;
    vector<pair<int, int> > vp;
    cin >> N >> M;
    REP(i, M) {
        cin >> a >> b;
        vp.push_back(make_pair(a, b));
    }
    SORT(vp);
    int r = N, res = 1;
    REP(i, M) {
        if (vp[i].first < r) {
            amin(r, vp[i].second);
        } else {
            res++;
            r = vp[i].second;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}

int main(){
  vector<vector<ll>> g(4, vector<ll>(4,0));
  REP(i,3){
    ll a,b; cin >> a >> b;
    a--; b--;
    g[a][b] = 1;
    g[b][a] = 1;
  }

  vector<ll> p = {0,1,2,3};
  do{
    REP(i,3){
      if(!g[p[i]][p[i+1]]) break;
      if(i==2) yes();
    }
  }while(next_permutation(ALL(p)));
  no();
}

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


int main(){
  int n,c=0;
  cin >> n;
  vector<int> a(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]){
      //cout << i <<"\n";
      i++;c++;
    }
  }
  cout << c;
}


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

#define N 100005

typedef struct {
	int parent;
	int appaer;
	int member;
	int root;
	int visit;
}node_t;

node_t node[N] = { 0 };

void joint(int a, int b) {
	int a_root = root(a), b_root = root(b);

	if (a_root != b_root) {
		if (node[a_root].member >= node[b_root].member){
			node[b_root].parent = a_root;
			node[a_root].member += node[b_root].member;
			node[b_root].member = 0;
		}
		else {
			node[a_root].parent = b_root;
			node[b_root].member += node[a_root].member;
			node[a_root].member = 0;
		}
	}

}

int root(int node_n) {
	if (node[node_n].parent == 0)return node_n;
	else return root(node[node_n].parent);
}
int main(void) {
	int n, m, k;
	int a, b;
	int c, d;

	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= n; i++)node[i].member = 1;
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a, &b);
		node[a].appaer++, node[b].appaer++;
			joint(a, b);
	}
	for (int i = 1; i <= n; i++)
		node[i].root = root(i);
	for (int i = 0; i < k; i++) {
		scanf("%d %d", &c, &d);
		if (node[c].root == node[d].root) {
			node[c].appaer++, node[d].appaer++;
		}
	}

	/*
	for (int i = 1; i <= n; i++) {
		printf("node[%d].root=%d\n", i, node[i].root);
	}
	for (int i = 1; i <= n; i++) {
		printf("node[%d].member=%d\n", i, node[i].member);
	}
	*/
	for (int i = 1; i <= n; i++) {
		if (node[node[i].root].member > 1)
			printf("%d ", node[node[i].root].member - node[i].appaer - 1);
		else printf("0 ");
	}
	return 0;
}


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

int main(void){
    long long n, k, sum = 0;
    cin >> n >> k;
    
    vector<int> h(n);
    rep(i, n){
        cin >> h.at(i);
    }
    
    sort(h.begin(), h.end());

    if(n-k >= 0){
        rep(i, n-k){
            sum += h.at(i);
        }
    }
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	ll A,B,N;

	cin >> A >> B >> N;

	ll c = 0;

	if (B<=N) {
		c = (A*(B - 1)) / B -  A * ((B - 1) / B);
	}
	else {
		c = (A*N) / B - A *( N / B);
	}

	
	cout << c;
	return 0;
}

Measured memory_bytes: 3664
#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

ll d[200200];
ll dd[200200];
ll ddd[200200];

int main() {
	ll n, m;
	cin>>n>>m;
	clr(d,0);
	vector<pair<ll,ll> > vp;
	ll a;
	cin>>a;
	a--;
	ll total = 0;
	rep(i,1,n){
		ll b;
		cin>>b;
		b--;
		if(a<b){
			vp.pb(mp(a,b));
			total += b-a;
		}
		else{
			vp.pb(mp(a,m+b));
			total += m+b-a;
		}
		a=b;
	}
	clr(d,0);
	clr(dd,0);
	rep(i,0,vp.sz){
		d[vp[i].fi+1]++;
		d[vp[i].se]--;
		dd[vp[i].se]-=vp[i].se-vp[i].fi-1;
	}
	clr(ddd,0);
	ll c = 0;
	ll e = 0;
	rep(i,0,200100){
		e += c;
		ddd[i]+=e;
		e += dd[i];
		c += d[i];
	}
	ll mn = 1000000000000LL;
	rep(i,0,m){
		mn = min(mn,total-ddd[i]-ddd[i+m]);
	}
	printf("%lld\n", mn);
	return 0;
}

Measured memory_bytes: 6640
package main

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

const MaxBuf = 200100

var buf = make([]byte, MaxBuf)
var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, MaxBuf)
}

func main() {
	n := scanInt()
	s := scanString()
	var wcnt, rcnt int
	for i := 0; i < n; i++ {
		if s[i] == 'W' {
			wcnt++
		} else {
			rcnt++
		}
	}
	var wwcnt, rrcnt int
	for i := 0; i < rcnt; i++ {
		if s[i] == 'W' {
			wwcnt++
		}
	}
	for i := 0; i < wcnt; i++ {
		if s[n-1-i] == 'R' {
			rrcnt++
		}
	}
	fmt.Println(min(wwcnt, rrcnt))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 2180
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstring>
#include <set>
#include <map>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define rep(i, a, b) for (int i=(a);i<=(b);i++)
#define dd(x) cout << #x << " = " << x << endl;
typedef pair<int, int> pii;
typedef long long LL;

const LL MOD = 1000000007;
const int N = 500000+10;

int n, c[N];
int main() {
    cin >> n;
    rep(i, 1, n) {
        int x; cin >> x;
        c[x] ++;
    }
    int ans = 0;
    rep(i, 1, 100) {
        if (c[i]) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, u: Usize1, v: Usize1,
        ab: [(Usize1, Usize1); n-1]
    }
    let mut graph = vec![Vec::new(); n];
    for (a, b) in ab {
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut udist = vec![0; n];
    let mut stack = Vec::new();
    stack.push((u, u, 0));
    while let Some((node, prev, dist)) = stack.pop() {
        udist[node] = dist;
        for &next in &graph[node] {
            if next != prev {
                stack.push((next, node, dist+1));
            }
        }
    }

    let mut vdist = vec![0; n];
    let mut stack = Vec::new();
    stack.push((v, v, 0));
    while let Some((node, prev, dist)) = stack.pop() {
        vdist[node] = dist;
        for &next in &graph[node] {
            if next != prev {
                stack.push((next, node, dist+1));
            }
        }
    }
    
    let mut dist = 0;
    for i in 0..n {
        let d = vdist[i];
        if udist[i] < d {
            dist = max(dist, d);
        }        
    }
    println!("{}", dist - 1);
}


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

const int MOD = 998244353;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a) {
    return modpow(a, MOD - 2);
}


int main() {
    int N, S; cin >> N >> S;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<vector<ll>> memo(N, vector<ll>(S+1, 0));

    memo[0][0] = modpow(2, N);
    ll modinv2 = modinv(2);
    if (A[0] <= S) memo[0][A[0]] = (memo[0][0] * modinv2) % MOD;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= S; j++) {
            memo[i][j] = memo[i-1][j];
            if (j - A[i] >= 0) {
                memo[i][j] += (memo[i-1][j-A[i]] * modinv2) % MOD;
                memo[i][j] %= MOD;
            }
        }
    }
    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j <= S; j++) {
    //         cout << memo[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    cout << memo[N-1][S] << endl;
}

Measured memory_bytes: 73656
import java.util.Scanner;

/**
 * https://abc052.contest.atcoder.jp/tasks/arc067_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		long[] x = new long[N];
		for(int i=0; i<N; i++){
			x[i] = Long.parseLong(sc.next());
		}
		sc.close();

		long ans = 0;
		for(int i=1; i<N; i++){
			ans += Math.min((x[i]-x[i-1])*A, B);
		}
		
		System.out.println(ans);
		
	}

}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

const int MAXan=100001;

int main(){

    int n;
    cin>>n;
    vi a(n),num(MAXan,0);
    ll ans=0;
    rep(i,n){
        cin>>a[i];
        num[a[i]]++;
        ans+=a[i];
    }
    int q;
    cin>>q;
    vi b(q),c(q);
    rep(i,q)cin>>b[i]>>c[i];


    rep(i,q){
        ans+=(c[i]-b[i])*num[b[i]];
        num[c[i]]+=num[b[i]];
        num[b[i]]=0;
        cout<<ans<<"\n";
    }

    return 0;

}

Measured memory_bytes: 4836
from sys import stdin

n = int(stdin.readline().rstrip())

mi = 10**10

for i in range(1,n):
    a = str(i)
    b = str(n-i)
    point = 0
    for i in a:
        point += int(i)
    for j in b:
        point += int(j)
    mi = min(point,mi)
print(mi)


Measured memory_bytes: 3060
//C - Multiple Clocks: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll mmc(ll x, ll y) {
    ll aux = __gcd(x, y), a;
    a = (x / aux) * y;
    return a;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    ll ans;

    cin >> n;
    vector<ll> times(n);
    loop(i, 0, n) cin >> times[i];
    if(n == 1) ans = times[0];
    else {
        ans = mmc(times[0], times[1]);
        loop(i, 2, n) {
            ans = mmc(ans, times[i]);
            //cout << ans << "\n";
        }
    }
    cout << ans << "\n";
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) REP(i,0,n)

class Point {
public:
  Point(){}
  Point(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
  double x, y, z;
};

class Vector : public Point {  
public:
  void make(Point p1, Point p2) { x = p2.x-p1.x; y = p2.y-p1.y; z = p2.z-p1.z; }
  
  double l() {
    return sqrt(x*x+y*y+z*z);
  }
};

double dot(Vector v1, Vector v2) {
  return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
}

int main() {
  int n;
  Point ZeroPoint(0,0,0);
  
  while(cin>>n,n) {
    vector<Vector> s(n);
    rep(i,n) {
      Point p;
      cin>>p.x>>p.y>>p.z;
      s[i].make(ZeroPoint, p);
    }

    int m; cin>>m;
    vector<Vector> t(m);
    vector<double> phi(m);
    rep(i,m) {
      Point p;
      cin>>p.x>>p.y>>p.z>>phi[i];
      t[i].make(ZeroPoint, p);
    }
    
    vector<bool> seen(n, false);
    rep(i,n) rep(j,m) {
	double d = dot(s[i],t[j]);
	double th = acos( d/(s[i].l()*t[j].l()) );
	if(th < phi[j]) seen[i] = true;
    }

    int ret = 0;
    rep(i,n) if(seen[i]) ret++;
    cout << ret << endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n){
		int sum=1;
		rep(i,n)sum+=i+1;
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N, M;
char chairs[100];

int main(){
    while(std::cin >> N >> M, N){
        REP(i, N){chairs[i] = '#';}

        REP(i, M){
            char c;
            std::cin >> c;

            if(c == 'A'){
                REP(j, N){
                    if(chairs[j] == '#'){chairs[j] = 'A'; break;}
                }
            }else if(c == 'B'){
                bool can = false;
                for(int j=N-1;j>=0;j--){
                    if(chairs[j] != '#'){continue;}
                    if(j-1 >= 0 && chairs[j-1] == 'A'){continue;}
                    if(j+1 < N && chairs[j+1] == 'A'){continue;}
                    chairs[j] = 'B';
                    can = true;
                    break;
                }
                if(can){continue;}
                REP(j, N){
                    if(chairs[j] == '#'){chairs[j] = 'B'; break;}
                }
            }else if(c == 'C'){
                if(i == 0){chairs[N/2] = 'C'; continue;}

                REP(j, N){
                    if(chairs[j] == '#'){continue;}
                    if(j+1 < N && chairs[j+1] == '#'){chairs[j+1] = 'C'; break;}
                    if(j-1 >= 0 && chairs[j-1] == '#'){chairs[j-1] = 'C'; break;}
                }
            }else if(c == 'D'){
                int pos = -1, max_l = 0;
                REP(j, N){
                    if(chairs[j] != '#'){continue;}

                    int l1 = INF, l2 = INF;
                    for(int k=j-1;k>=0;k--){
                        if(chairs[k] != '#'){l1 = j-k; break;}
                    }
                    for(int k=j+1;k<N;k++){
                        if(chairs[k] != '#'){l2 = k-j; break;}
                    }

                    if(std::min(l1, l2) > max_l){pos = j; max_l = std::min(l1, l2);}
                }

                chairs[pos] = 'D';
            }
        }

        REP(i, N){
            putchar(chairs[i]);
        }
        puts("");
    }
}

Measured memory_bytes: 1112
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", long, "z");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto h = lread();
    auto w = lread();
    auto n = lread();
    if(h < w)
        swap(h, w);
    // 必ずh >= w
    writeln((n + h - 1) / h);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];

using namespace std;

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-2){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(abs(s)>abs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1||b==N-1)continue;
            if(abs(t)>abs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840
module mod_tree
  implicit none
  type arraylist
    integer :: num = 0
    integer, pointer :: arr(:) => null()
  end type
  type tree
    type(arraylist), pointer :: egs(:) => null()
    integer, pointer :: cnt(:) => null()
  contains
    procedure :: add => add
    procedure :: dfs => dfs
  end type
  interface tree
    module procedure :: newt
  end interface tree
contains
  subroutine appende(a)
    integer, pointer, intent(inout) :: a(:)
    integer :: n
    integer, allocatable :: tmp(:)
    n = size(a)
    allocate(tmp(n))
    tmp = a
    deallocate(a)
    allocate(a(2*n))
    a(1:n) = tmp
    deallocate(tmp)
  end
  subroutine adde(list,e)
    class(arraylist), intent(inout) :: list
    integer, intent(in) :: e
    if (.not.associated(list%arr)) allocate(list%arr(1))
    if (list%num == size(list%arr)) call appende(list%arr)
    list%num = list%num+1
    list%arr(list%num) = e
  end
  function gete(list,i) result(ret)
    class(arraylist), intent(inout) :: list
    integer, intent(in) :: i
    integer :: ret
    ret = list%arr(i)
  end
  function newt(n) result(ret)
    integer, intent(in) :: n
    type(tree) :: ret
    allocate(ret%egs(n))
    allocate(ret%cnt(n))
    ret%cnt = 0
  end
  subroutine add(this,fm,to)
    class(tree), intent(inout) :: this
    integer, intent(in) :: fm, to
    call adde(this%egs(fm),to)
  end
  recursive subroutine dfs(this,v,p,d)
    class(tree), intent(inout) :: this
    integer, intent(in) :: v, p, d
    integer :: n, i, u
    this%cnt(v) = this%cnt(v)+d
    n = this%egs(v)%num
    do i = 1, n
      u = gete(this%egs(v),i)
      if (u == p) cycle
      call dfs(this,u,v,this%cnt(v))
    end do
  end
end module mod_tree
program ki
  use mod_tree
  implicit none
  integer :: n, q, a, b, p, x, i
  type(tree) :: t
  read(*,*) n, q
  t = tree(n)
  do i = 1, n-1
    read(*,*) a, b
    call t%add(a,b)
    call t%add(b,a)
  end do
  do i = 1, q
    read(*,*) p, x
    t%cnt(p) = t%cnt(p)+x
  end do
  call t%dfs(1,-1,0)
  write(*,'(i0)',advance='no') t%cnt(1)
  do i = 2, n
    write(*,'(x,i0)',advance='no') t%cnt(i)
  end do
  write(*,*)
end program ki

Measured memory_bytes: 32896
#include<bits/stdc++.h>
using namespace std;
int cnt;
long long n;
bool f(long long ans)
{
    int x=0,xx=0,xxx=0;
    while(ans)
    {
        int k=ans%10;
        if(k==3) x++;
        else if(k==5) xx++;
        else if(k==7) xxx++;
        else
        {
            return false;
        }
        ans/=10;
    }
    if(x*xx*xxx>0) return true;
    return false;
}
void dfs(long long ans)
{
    if(ans>n||ans<3) return;
    if(ans<=n&&ans>=1)
    {
        if(f(ans)) cnt++;
    }
    dfs(ans*10+3);
    dfs(ans*10+5);
    dfs(ans*10+7);
}
int main()
{
    cnt=0;
    scanf("%lld",&n);
    dfs(3);
    dfs(5);
    dfs(7);
    printf("%d\n",cnt);
}


Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		int a,b,c;
		cin>>a>>b>>c;
		if(2*b==a+c)
		{
			cout<<"YES"<<endl;
			return 0;
		}
		cout<<"NO"<<endl;
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


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

using namespace std;

int main() {
	int n, q;
	while(cin >> n >> q, n) {
		vector<string> name(n);
		vector<pair<int, int> > years(n);
		for (int i = 0; i < n; ++i) {
			cin >> name[i];
			int ey, wy; cin >> ey >> wy;
			years[i] = make_pair(wy - ey + 1, wy);
		}
		while(q--) {
			int a; cin >> a;
			bool flag = true;
			for (int j = 0; j < n; ++j) {
				if(years[j].first <= a && a<= years[j].second) {
					flag = false;
					cout << name[j] << " " << a - years[j].first + 1 << endl;
					break;
				}
			}
			if (flag) cout << "Unknown" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3172
$prime = {}
def is_prime(n)
  unless $prime[n]
    if n < 2
      $prime[n] = false
    elsif n < 4
      $prime[n] = true
    elsif n % 2 == 0
      $prime[n] = false
    else
      i = 3
      flag = true
      while i <= Math.sqrt(n)
        if n % i == 0 then
          flag = false
          break
        end
        i += 2
      end
      $prime[n] = flag
    end
  end
  return $prime[n]
end

while n = gets
  m = n.to_i - 1
  m -= 1 if m % 2 == 0
  if m > 1
    while not is_prime(m)
      m -= 2
    end
    print m
  else
    print 2
  end

    m = n.to_i + 1
  m += 1 if m % 2 == 0
  while not is_prime(m)
    m += 2
  end
  puts " #{m}"
end

Measured memory_bytes: 8684
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long N = scanner.nextLong();
    long ans = 0;
    for (long a = 1; a * a < N; a++) {
      if (N % a == 0) {
        long b = N / a;
        if (b - 1 > a) ans += b - 1;
      }
    }
    System.out.println(ans);
  }
}


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

int main(void)
{
	int  get,n, k;
	int ruiseki[200001] = { 0 }, wa = 0,max = 0,maxnum;
	double ans = 0;
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &get);
		wa += get;
		ruiseki[i] += wa;
	}

	for (int l = 0; l <= n - k + 1; l++) {
		if (ruiseki[l + k] - ruiseki[l] > max) {
			max = ruiseki[l + k] - ruiseki[l];
			maxnum = l + 1;
		}
	}

	for (int m = maxnum; m < maxnum + k; m++) {
			ans += (((ruiseki[m] - ruiseki[m - 1]) * ((ruiseki[m] - ruiseki[m - 1]) + 1)) / 2.0) / (ruiseki[m] - ruiseki[m - 1]);
	}
	printf("%.10lf\n", ans);
	return 0;
}


Measured memory_bytes: 896
import math
N, M, K = map(int,input().split())
MOD = 10**9+7

def nCr(n,r):
    return (math.factorial(n)//(math.factorial(r)*math.factorial(n-r)))%MOD

ans = 0
t = nCr(N*M-2,K-2)
for d in range(1,M):
    ans += d*(M-d)*(N*N)*t
    ans %= MOD

for d in range(1,N):
    ans += d*(N-d)*(M*M)*t
    ans %= MOD

print(ans)

Measured memory_bytes: 74588
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
  
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  
  public static void main(String args[]) 
{
FastReader in= new FastReader();
int N=in.nextInt();
int M=in.nextInt();
int p[]=new int[M];
String S[]=new String[M];
for(int i=0;i<M;i++)
{
p[i]=in.nextInt();
S[i]=in.next();
}
int solve[]=new int[N];
int wa[]=new int[N];
int cor=0,pen=0;
for(int i=0;i<M;i++)
{
if((S[i].equals("WA"))&&(solve[p[i]-1]==0))
wa[p[i]-1]++;

else if((S[i].equals("AC"))&&(solve[p[i]-1]==0))
{
cor++;
solve[p[i]-1]++;
pen+=wa[p[i]-1];
}

}
System.out.println(cor+" "+pen);
}

}




Measured memory_bytes: 45788
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    if(a>=c) cout << 0 << endl;
    else {
        if(b+a>=c) cout << c-a << endl;
        else cout << "NA" << endl;
    }
    return 0;
}


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

int main() {
  int N , a, b, c ;
  cin >> N ;
  a = N / 100 ;
  b = (N - 100 * a)/ 10;
  c = (N - 100 * a - 10 * b);
  cout << a + b + c << endl ;
}


Measured memory_bytes: 256