akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
using namespace std;


int main () {
    int N, K;
    cin >> N >> K; 
    multiset<int> H;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        H.insert(temp);
    }

    auto ite = H.end();
    ite--;    
    for (int i = 0; i < K; i++) {
        if (H.size() == 0) {
            break;
        }

        auto temp = ite;
        ite--;
        H.erase(temp);
    }
    
    uint64_t times = 0;
    while (0 < H.size()) {
        times += *ite;
        auto temp = ite;
        ite--;
        H.erase(temp);
    }
    cout << times << endl;
    return 0;

}



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

typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 184467440737095516;

ll dp[1010][1010], h, w;
char str[1010][1010];

void nothing(){
}

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

	cin >> h >> w;
	for (ll i = 1; i <= h; i++){
		for (ll j = 1; j <= w; j++){
			cin >> str[i][j];
		}
	}
	for (ll i = 1; i <= h; i++){
		for (ll j = 1; j <= w; j++){
			if (i == 1 && j == 1){
				if (str[i][j] == '.'){
					dp[i][j] = 1;
				}
			}		
			else if (str[i][j] == '.'){
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod; 
			}
		}
	}
	cout << dp[h][w] % mod << '\n';
}
  

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////
ll H, W;

ll diag[1000][1000];
ll cdiag[1000][1000];
char s[1000][1000];


ll d(ll i, ll j) {
	if (i <= 0 || j <= 0) { return 0; }
	if (i - j<-W || i - j>H) { return 0; }
	if (i > H) { return d(H, j - i + H); }
	if (j > W) { return d(i-j+W,W); }
	return diag[i][j];
}

ll cd(ll i, ll j) {
	if (i <= 0 || j > W) { return 0; }
	if (i + j<=1 || i + j>H + W) { return 0; }
	if (i > H) { return cd(H, i + j - H); }
	if (j <= 0) { return cd(i + j - 1,1); }

	return cdiag[i][j];
}

char ss(ll i, ll j) {
	if (i >= 1 && i <= H && j >= 1 && j <= W) { return s[i][j]; }
	else { return '.'; }
}


int main() {
	
	cin >> H >> W;

	
	repn(i, H)repn(j, W) cin >> s[i][j];

	
	repn(i, H)repn(j, W) {
		diag[i][j] = diag[i - 1][j - 1];
		if (s[i][j] == '#') { diag[i][j]++; }

		cdiag[i][j] = cdiag[i - 1][j + 1];
		if (s[i][j] == '#') { cdiag[i][j]++; }

	}

	ll ans = 0;
	ll ol = 0;

	repn(a, H)repn(b, W) {
		repn(c, min(b - 1, H - a)) {
			if (ss(a,b) == '.' || ss(a+c,b-c) == '.') { continue; }

			ans += cd(a + 2 * c, b) - cd(a + c-1, b + c+1);
			if (ss(a + 2 * c, b) == '#') { ol++; }
			if (ss(a + c, b + c) == '#') { ol++; }

			//cout << a << b << c << " "<<ans <<" "<<ol<< endl;
			
			ans += cd(a, b - 2 * c) - cd(a - c-1, b - c+1);
			if (ss(a, b - 2 * c) == '#') { ol++; }
			if (ss(a - c, b - c) == '#') { ol++; }
			//cout << a << b << c <<" "<< ans <<" "<<ol<< endl;
			

		}
	}

	repn(a, H)repn(b, W) {
		repn(c, max(H - a, W - b)) {
			if (ss(a,b) == '.' || ss(a+c,b+c) == '.') { continue; }

			ans += d(a + 2*c, b) - d(a + c-1, b - c-1);
			if (ss(a + 2 * c, b) == '#') { ol++; }
			if (ss(a + c, b - c) == '#') { ol++; }

			//cout << a << b << c << " " << ans << " " << ol << endl;

			ans += d(a, b + 2 * c) - d(a - c-1, b + c-1);
			if (ss(a, b + 2 * c) == '#') { ol++; }
			if (ss(a - c, b + c) == '#') { ol++; }

			//cout << a << b << c << " " << ans << " " << ol << endl;

		}
	}

	cout << ans - ol/2;

	

	system("PAUSE");
}


Measured memory_bytes: 7800
import math

def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))



N = int(input())

dic = {}

for i in range(N):

    s = input()

    slis = list(s)
    slis.sort()

    strs = "".join(slis)

    if strs not in dic:
        dic[strs] = 1
    else:
        dic[strs] += 1


ans = 0

for i in dic:

    if dic[i] >= 2:
        ans += cc(dic[i],2)

print (ans)



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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;
const long long MOD = 1000000007LL;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    int a;
    string s;
    cin >> a >> s;

    if(a < 3200){
        cout << "red";
    } else {
        cout << s;
    }

    return 0;
}




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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int main(){
	ll a, b, c, k;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
	int sum = 0;
	if(a >= k){
		cout << k << endl;
		return 0;
	} else {
		sum = a;
		k-=a;
	}
	if(b >= k){
		cout << sum << endl;
		return 0;
	} else {
		k-=b;
	}
	sum -= k;
	cout << sum << endl;
	return 0;
}















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

int main() {
  int n,k,r,s,p;
  cin >> n >> k >> r >> s >> p;
  string str;
  char ch[n];
  cin >> str;
  r(i,n){
      if(str[i]=='s')ch[i]='r';
    else if(str[i]=='r')ch[i]='p';
    else ch[i]='s';
    }
  r(i,n-k){
    if(ch[i]==ch[i+k])ch[i+k]='n';
  }
  int sum=0;
  r(i,n){
    if(ch[i]=='r'&&str[i]=='s')sum+=r;
    else if(ch[i]=='s'&&str[i]=='p')sum+=s;
    else if(ch[i]=='p'&&str[i]=='r')sum+=p;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
//#define INF  (1<<30)
#define INFL (1LL<<60)
#define EPS ((ld)(1e-9))
 
#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, e) for (int i = 0, _##i = (e); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i <= _##i; i++)
#define repr(i, s, e) for (int i = (s), _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))
#define ARR(...) vector<int>({__VA_ARGS__})
#define ARS(...) vector<string>({__VA_ARGS__})
 
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> base;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}
 
template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    os << '[';
    for (auto p : v) os << p << ",";
    os << "]";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const set<T, V> v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const multiset<T, V> &v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}
 
template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    os << "{";
    for (auto p : v) os << p << ",";
    os << "}";
    return os;
}
 
ostream& operator<<(ostream &os, tuple<int, int, int> t) {
    os << "<" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ">";
    return os;
}
 
#ifndef ONLINE_JUDGE
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif
 
auto x = []{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return 0;
}();

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}

int N, H;
pll X[1000];

ll dp[10001];

int main(void) {
    cin >> H >> N;
    rep(i, N) cin >> X[i].fi >> X[i].se;

    repp(i, 1, H) {
        dp[i] = 1ll<<50;
        rep(j, N) {
            if (X[j].fi >= i) get_min(dp[i], X[j].se);
            else get_min(dp[i], X[j].se+dp[i-X[j].fi]);
        }
    }

    cout << dp[H] << endl;
}




Measured memory_bytes: 384
MOD = 10**9 + 7
N = int(input())

# 少なくとも0がはいる
in0 = 10**N - 9**N
# 少なくとも0がはいる
in9 = 10**N - 9**N
# 0または9がはいる
not0and9 = 10**N - 8**N

answer = in0 + in9 - not0and9

print(answer%MOD)

Measured memory_bytes: 11300
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long int ll;
typedef double ld;
typedef long double lld;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ONLINE_JUDGE
template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

const ll mod = 1e9+7;

int X[] = {0,1,0,-1,-1,-1,1,1};
int Y[] = {1,0,-1,0,-1,1,-1,1};

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

const int maxn = 1e6+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("planetdistancesmall.in","r",stdin);
    freopen("ans.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    // logic
    int n,k;
    cin >> n >> k;
    int pos = 1;
    int cnt = 0;
    while(1) {
        if(pos >= n) break;
		cnt++;
		pos += k - 1;
	}
    cout << cnt << endl;
#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}



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

int main(void){
    int N,i;
    int A[100001],BOX[100001];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
        BOX[A[i]] = i+1;
    }

    for(i=1;i<=N;i++) printf("%d ",BOX[i]);
    printf("\n");

    return 0;
}

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

using namespace std;

int main() {

    int a, b;
    cin >> a >> b;

    int c = 0;
    int d = b;

    while(d != 0) {
        d = d / 10;
        c++;
    }

    for (int i = 1; i <= c; i++) {
        a = a * 10;
    }

    int number = a + b;

    bool ans = false;

    for (int i = 1 ; i <= 400; i++) {
        if (i * i == number) {
            ans = true;
            break;
        }

        if (i * i >= number) {
            break;
        }
    }

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


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    for(int i=0; i<n; i++) cin>>s[i];
    map<string,int> m;
    for(int i=0; i<n; i++) m[s[i]]++;
    cout<<m.size()<<endl;
}

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

using namespace std;

int p[205];

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	for(int i=0;i<n;i++)
		cin >> p[i];
	sort(p,p+n);
	int ans=0;
	int c1=0,c2=0,c3=0;
	for(int i=0;i<n;i++){
		if(p[i]<=a)
			c1++;
		else if(p[i]>b)
			c3++;
		else
			c2++;
	}
	cout << min(c1,min(c2,c3));

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char s[20];
    scanf("%s",s);
    if(strcmp(s,"Sunny")==0)
    {
        printf("Cloudy");
    }
    else if(strcmp(s,"Cloudy")==0)
    {
        printf("Rainy");
    }
    else if(strcmp(s,"Rainy")==0)
    {
        printf("Sunny");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),k=sc.nextInt(),s=sc.nextInt();
		sc.close();
		for(int i=0;i<k;i++) System.out.print(s+" ");
		if(s<1000000000) for(int i=k;i<n;i++) System.out.print((s+1)+" ");
		else for(int i=k;i<n;i++) System.out.print(1+" ");
	}
}

Measured memory_bytes: 44888
#include <cstdio>

const int maxn=100000;
const int maxm=200000;
long p[maxn+1],c[maxn+1]={0};
int n,m;
int x,y;
int l,r,d;
int ans=1;

int find(int x)
{
    int tem;

    if(p[x]!=x){
        tem=p[x];
        p[x]=find(p[x]);
        c[x]=c[tem]+c[x];    //renew c[tem]+c[x]
    }

    return p[x];
}

void gather()
{
    p[y]=x;
    c[y]=c[l]+d-c[r];
}

int main()
{
    int i;

    scanf("%d%d",&n,&m);

    for(i=0;i<n;i++)
        p[i]=i;

    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&l,&r,&d);
        x=find(l);y=find(r);
        if(x==y){
            if(c[r]-c[l]!=d)
                ans=0;
            else
                continue;
        }else{
            gather();
        }
    }

    if(ans)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 1664
import math
a, b, h, m = map(int, input().split())

arad = (30 * h) + 0.5 * m
brad = 6 * m
rad1 = abs(arad - brad)
if rad1 > 180:
    rad1 = 360 - rad1

cos = math.cos(math.radians(rad1))

ans = a**2 + b**2 - 2*a*b*cos

print(ans**0.5)

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

int main() {
    int n, k;
    cin >> n >> k;

    //int a, b, c;
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
        A.at(i) = 0;
    }

    for (int i = 0; i < k; i++) {
        int a;
        cin >> a;

        for (int j = 0; j < a; j++) {
            int b;
            cin >> b;
            A.at(b - 1)++;
        }

    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        if (A.at(i) == 0) count++;
    }

    cout << count << endl;
}

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

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

    int ans = 0;
    for(int i = 0; i < 4; i++) {
        if(s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=(input.trim()).split("\n");
while(true){
   var str=arr.shift();
   if(str=="#")break;
   str=str.replace(/orth|est/g,"");
   str=str.split("").reverse().join("");
   var sum=0;
   if(str[0]=="n")sum=0;
   if(str[0]=="w")sum=90;
   for(var i=1;i<str.length;i++){
      if(str[i]=="n")sum-=90/Math.pow(2,i);
      if(str[i]=="w")sum+=90/Math.pow(2,i);
   }
   var i=1;
   while(true){
      if((sum*i)%1==0){
         if(i==1)break;
         sum=""+(sum*i)+"/"+i;
         break;
      }
      i++;
   }
   console.log(sum);
}

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

int main() {
  int n;
  cin >> n;
  int p[20];
  for(int i=0;i<n;i++) cin >> p[i];
  int ans = 0;
  for(int i=1;i<n-1;i++){
    if((p[i-1] < p[i]) && (p[i] < p[i+1])) ans++;
    else if((p[i-1] > p[i]) && (p[i] > p[i+1])) ans++;
    }
  cout << ans << endl;
  return 0;
}

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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX],color[MAX];
    
    for(int i=0; i<n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    while (1) {
        minv = INFTY;
        int u = -1;
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u==-1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v]!=BLACK && M[u][v]!=INFTY){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u]+M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(int i=0; i<n; i++){
        cout << i << " " << (d[i]==INFTY ? -1 : d[i]) << endl;
    }
}

int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = INFTY;
        }
    }
    
    int k,c,u,v;
    for(int i=0; i<n; i++){
        cin >> u >> k;
        for(int j=0; j<k; j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    
    dijkstra();
}

Measured memory_bytes: 3132
import sys
input = sys.stdin.buffer.readline

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

K = int(input())
cnt = [0] * (K ** 2 + 1)

for a in range(1, K + 1):
    for b in range(1, K + 1):
        cnt[gcd(a, b)] += 1
#print(cnt)

answer = 0
for ab in range(1, K ** 2 + 1):
    if cnt[ab]:
        for c in range(1, K + 1):
            answer += cnt[ab] * gcd(ab, c)
print(answer)

Measured memory_bytes: 68188
fn main() {
    // input
    let input = read_vec::<i32>();

    // A
    let a = input[0];
    // B
    let b = input[1];
    // C
    let c = input[2];

    let diff = b + c - a;

    let ans = if diff < 0 { 0 }else{diff};

    println!("{}", ans);
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
 
int main(){
    int x, y;
 
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }else if(x <= y){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 1160
#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>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N; cin >> N;
    string S; cin >> S;
    S.erase(unique(S.begin(), S.end()), S.end());
    cout << S.size() << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int n,m,num,rec,ans=0;
    cin>>n>>m;
    vector<int>like(m,1),liketemp(m),zero(m);
    vector<vector<int>>poll(n);
    rep(i,n){
        liketemp=zero;
        cin>>num;
        rep(j,num){
            cin>>rec;
            liketemp[rec-1]++;
        }
        rep(k,m)like[k]*=liketemp[k];
    }
    rep(i,m)ans+=like[i];
    
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, s, cnt;
void comb(int ma, vector<int> v) {
    if(ma == 9) return;
    for(int i=ma+1; i<=9; i++) {
        vector<int> temp = v;
        temp.pb(i);
        if(temp.size() != n) comb(i, temp);
        else {
            do {
                int sum = 0;
                rep(j,0,n) sum += (j+1) * temp[j];
                if(sum == s) cnt++;
            }while(next_permutation(temp.begin(), temp.end()));
        }
    }
}

int main() {
    while(cin >> n >> s) {
        cnt = 0;
        comb(-1, {});
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 2968
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(void){
    int R[MAX], n;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> R[i];
    }

    int maxv = -2000000000;
    int minv = R[0];

    for(int i = 1; i < n; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3876
import java.io.*;
import java.util.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ary = br.readLine().split(" ");
		Arrays.sort(ary);
    	System.out.println(ary[0]+" "+ary[1]+" "+ary[2]);
    }
}

Measured memory_bytes: 24340
#include <stdio.h>
#include <math.h>

double subabs( double x, double q )
{
        double x3 = x*x*x;
        return fabs( x3 - q );
}

int main()
{
        double q, xn;

        while ( scanf( "%lf", &q ) == 1 ) {
                if ( q == -1.0 ) { break; }
                xn = q / 2;

                while ( subabs( xn, q ) > 0.00001*q ) {
                        xn = xn - ( xn*xn*xn - q ) / ( 3*xn*xn );
                }
                printf( "%.6f\n", xn );
        }

        return 0;
}



Measured memory_bytes: 2032
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <atcoder/scc>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
//using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
}

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}
lli m = 1e9 + 7;
int main(void)
{
    int N;
    cin >> N;
    lli cnt = 0;
    for (int i = 1; i < N; i++)
    {
        for (int j = 1; j < N; j++)
        {
            int c = N - i * j;
            if (c > 0)
            {
                cnt++;
            }
            else
            {
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
    int n, i, k;
    int min = 1000000, max = -1000000;
    long long sum = 0;
    cin >> n;
    for( i = 0; i < n; i++) {
        cin >> k;
        if( min > k) min = k;
        if( max < k) max = k;
        sum += k;
    }
    cout << min << " " << max << " " <<sum << endl;
    return 0;
    
}


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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  
  if(t * s >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}



Measured memory_bytes: 3624
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))
import fractions

#n=int(input())
a,b,t=input_list()

c=(t+0.5)//a

print(int(c*b))

Measured memory_bytes: 21912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {


	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int N = in.nextInt();
			int x = in.nextInt();
			int[] an = in.nextIntArray(N);

			long ans = 0;
			if (an[0] > x) {
				ans += an[0] - x;
				an[0] = x;
			}

			for (int i = 1; i < N; i++) {
				int drop = Math.max(an[i] + an[i-1], x) - x;
				ans += drop;
				an[i] -= drop;
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 39892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main  implements Runnable {

    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		//long n = Long.parseLong(sc.next());
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//ar[1]=Integer.parseInt(sc.next());
    	//ar[2]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		int n = Integer.parseInt(sc.next());
		int l = Integer.parseInt(sc.next());
		//long k = Long.parseLong(sc.next());
		//int k = Integer.parseInt(sc.next());
		//String s = sc.next();
		//int k = Integer.parseInt(sc.next());
		//int m = Integer.parseInt(sc.next());
		//int x2000 = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		//ArrayList<Integer> lists = new ArrayList<Integer>();
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		int ans = 0;
		int s = l;
		int e = l+n-1;
		if(e<0)
		{
			ans = -e;
		}
		else if(s>0)
		{
			ans = -s;
		}
		else
		{
			ans=0;
		}

		for(int i = l; i<n+l;i++)
		{
			ans += i;
		}

			out.println(ans);



		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define INF 1 << 30
#define mod 1000000007
#define ll long long
#define pb push_back
#define pp pop_back
#define Loop(i,s,e) for(ll (i) = (s); (i) <= (e); ++(i))
#define dLoop(i,s,e) for(ll (i) = (s); (i) >= (e); --(i))
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

void Swap(ll*a,int x,int y){ll t=a[x];a[x]=a[y];a[y]=t;}
void Qsort(ll*n,int l,int r){if(l>=r)return;int i=l-1,j=r+1;ll m=n[(i+j)/2];
    while(1){while(n[++i]<m);while(n[--j]>m);if(i>=j)break;Swap(n,i,j);}
	Qsort(n,l,i-1);Qsort(n,j+1,r);}
	
	

int main() {

	ACCEL

	int a, b;
	while ( cin >> a >> b ) {
		if ( b % a ) cout << b - a << '\n';
		else cout << b + a << '\n';
	}
	return 0;
}











Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long cnt[2000000];
long long value_cnt[2000000];
long long multiplyer[2000000];
vector<int> divs[1000001];
long long inv(long long now) {
	long long ans = 1;
	long long  b = MOD - 2;
	while (b != 0) {
		if (b % 2) {
			ans *= now;
			ans %= MOD;
		}
		now *= now;
		now %= MOD;
		b /= 2;
	}
	return ans;
}
#define MAX 1000000
int main() {
#define int long long
	int n;
	scanf("%lld", &n);
	REP(i, n) {
		int a;
		scanf("%lld", &a);
		cnt[a]++;
	}
	for(int i = 1;i <= MAX;++i){
		multiplyer[i] += inv(i);
		multiplyer[i] %= MOD;
		for (int q = 2; i * q <= MAX; ++q) {
			multiplyer[i * q] += MOD - multiplyer[i];
		}
		for (int q = 2; i * q <= MAX; ++q) {
			divs[i * q].push_back(i);
		}
	}
	long long ans = 0;
	for (long long i = 1; i <= MAX; ++i) {
		long long hoge = cnt[i] * (cnt[i] - 1LL) / 2LL;
		hoge %= MOD;
		hoge *= i;
		hoge %= MOD;
		ans += hoge;
		value_cnt[i] += cnt[i] * i;
		REP(q, divs[i].size()) {
			int target = divs[i][q];
			ans += (((multiplyer[target] * cnt[i])%MOD * i) % MOD * value_cnt[target])%MOD;
			ans %= MOD;
			value_cnt[target] += cnt[i] * i;
			value_cnt[target] %= MOD;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 145280
#include<iostream>
using namespace std; 
#define LL long long
LL A,B,C;
void getAns(){ 
	LL ta=A%2,tb=B%2,tc=C%2;
	if(ta==0 || tb==0 || tc==0) {
		cout<<"0"; return;
	}
	LL ans1= B*C*ta;
	LL ans2= A*C*tb;
	LL ans3= A*B*tc; 
	if(ans1>ans2) ans1=ans2;
	if(ans1>ans3) ans1=ans3;
	cout<<ans1;
} 
int main(){
	cin >> A >> B >> C;
	getAns();
	return 0;
} 

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

    }
    return 0;
}



Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define fep(i,n) for(i=0;i<(n);i++)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define N 1000000007
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t,r,j,i,n;
    cin>>n;
    vi a(n);
    for(i=0;i<n;i++)
    cin>>a[i];
    int dp[n]={0};
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    int ans=0;
    ans+=dp[1];
    if(n==2)
    {cout<<ans;return 0;}
    for(i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
    
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int h(int d) {
	return d*d;
}

int s(int d) {
	int n = 600/d; bool plus = (600%d==0 ? 0 : 1);
	int ret = 0;
	for (int i=1; i<n; i++) ret += d*h(i*d);
	if (plus) ret += d*h(600-d);
	return ret;
}

int main() {
	int d;
	
	while (cin >> d) {
		cout << s(d) << endl;
	}
		
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

  int ans;
  if(c < a){
    ans = max(0,d-a);
    ans = min(ans,b-a);
  }
  else if(a <= c && c < b){
    ans = min(b-c , d-c);
  }
  else if(b <= c){
    ans = 0;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
"use strict";
function turn(array, human) {
  switch(human) {
    case "a":
      if(array[0].length === 0) console.log("A");
      else {
        const next = array[0].slice(0,1);
        array[0] = array[0].slice(1);
        turn(array, next);
      }
      break;
    case "b":
      if(array[1].length === 0) console.log("B");
      else {
        const next = array[1].slice(0,1);
        array[1] = array[1].slice(1);
        turn(array, next);
      }
      break;
    case "c":
      if(array[2].length === 0) console.log("C");
      else {
        const next = array[2].slice(0,1);
        array[2] = array[2].slice(1);
        turn(array, next);
      }
      break;
  }
}

const input = require("fs").readFileSync("/dev/stdin","UTF-8").trim().split("\n");
turn(input,"a");

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

int main(){
  int l,a,b,c,d;
  while(cin >> l >> a >> b >> c >> d){
    int ans = 0;
    if(a % c != 0) ans = a / c + 1;
    else ans = a / c;
    if(b % d != 0) ans = max(ans,b / d + 1);
    else ans = max(ans,b / d);
    cout << l - ans << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, q;
char s[MAXN], c[MAXN], opt[MAXN];
bool gol(int pos) {
	for (int i = 1; i <= q; i++) {
		if (c[i] == s[pos]) {
			if (opt[i] == 'L') pos--;
			else pos++;
		}
		if (pos > n) return false;
		if (pos < 1) return true;
	}
	return false;
}
bool gor(int pos) {
	for (int i = 1; i <= q; i++) {
		if (c[i] == s[pos]) {
			if (opt[i] == 'L') pos--;
			else pos++;
		}
		if (pos > n) return true;
		if (pos < 1) return false;
	}
	return false;
}
int getl() {
	int l = 0, r = n;
	while (l < r) {
		int mid = (l + r + 1) / 2;
		if (gol(mid)) l = mid;
		else r = mid - 1;
	}
	return l;
}
int getr() {
	int l = 1, r = n + 1;
	while (l < r) {
		int mid = (l + r) / 2;
		if (gor(mid)) r = mid;
		else l = mid + 1;
	}
	return n + 1 - l;
}
int main() {
	read(n), read(q);
	scanf("\n%s", s + 1);
	for (int i = 1; i <= q; i++)
		scanf("\n%c %c", &c[i], &opt[i]);
	writeln(n - getl() - getr());
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

static const double pi = 3.141592653589793;

void koch(double x0, double y0, double x1, double y1, int n)
{
    if (n == 0)
        cout << x0 << " " << y0 << endl;

    else {

        double x = (x1-x0)/3.0, y = (y1-y0)/3.0;

        double s_x = x0 + (x1-x0)/3.0;
        double s_y = y0 + (y1-y0)/3.0;

        double u_x = s_x + (x*cos(pi/3.0) - y*sin(pi/3.0));
        double u_y = s_y + (x*sin(pi/3.0) + y*cos(pi/3.0));

        double t_x = x0 + 2*(x1-x0)/3.0;
        double t_y = y0 + 2*(y1-y0)/3.0;

        koch(x0, y0, s_x, s_y, n-1);
        koch(s_x, s_y, u_x, u_y, n-1);
        koch(u_x, u_y, t_x, t_y, n-1);
        koch(t_x, t_y, x1, y1, n-1);

    }
}

int main()
{
    int n;
    cin >> n;

    koch(0.0, 0.0, 100.0, 0.0, n);
    cout << 100.0 << " " << 0.0 << endl;

}


Measured memory_bytes: 3252
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut cnt = 0;
	for number in 0..(buf.len() - 3) {
		let s = &buf[number..(number+3)];
		if s == "ABC" {
			cnt = cnt + 1;
		}
	}
	println!("{}", cnt);
}

Measured memory_bytes: 4352
<?php
  $stdin = fopen('php://stdin', "r");

  fscanf($stdin, "%d", $n);
  fscanf($stdin, "%s", $s);
  $result = 0;

  for ($i=1; $i<=$n; $i++) {
    // 前半の文字をkeyにする
    $before = substr($s, 0, $i);
    $beforeArr = [];
    for ($j=0; $j<$i; $j++) {
      $beforeArr[$before[$j]] = $before[$j];
    }

    // 後半の文字をkeyにする
    $after = substr($s, $i, $n-$i);
    $afterArr = [];
    for ($j=0; $j<$n-$i; $j++) {
      $afterArr[$after[$j]] = $after[$j];
    }

    // 両方に含まれる文字の数を数える
    $count = 0;
    foreach ($beforeArr as $moji) {
      if (isset($afterArr[$moji])) {
        $count++;
      }
    }

    // 大きい方を保存
    if ($result < $count) {
      $result = $count;
    }
  }

  echo $result.PHP_EOL;


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
using ll = long long;

using namespace std;

int main(){
	/*int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		if(cin.eof())	break;	
		a[i]=x;
	}*/
	
	int x;
	cin >> x;
       	if(x == 3 || x == 5 || x == 7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}	
	
	
	return 0;
}


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

const ll INF = LLONG_MAX;

class LazySegmentTree {
public:
    int n;
    vector<ll> nodes, lazy;
    LazySegmentTree(int n_) {
        n = 1; while (n_ > n) n <<= 1;
        nodes.resize(n*2-1, 0);
        lazy.resize(n*2-1, 0);
    }
    void eval(int k) {
        if ( ! lazy[k]) return;
        nodes[k] += lazy[k];
        if (k < n-1) {
            lazy[k*2+1] += lazy[k];
            lazy[k*2+2] += lazy[k];
        }
        lazy[k] = 0;
    }
    void add(int l, int r, ll x) {
        add(l, r, 0, n, 0, x);
    }
    void add(int l, int r, int tl, int tr, int k, ll x) {
        eval(k);
        if (tr <= l || r <= tl) return;
        else if (l <= tl && tr <= r) {
            nodes[k] += x;
            if (k < n-1) {
                lazy[k*2+1] += x;
                lazy[k*2+2] += x;
            }
            return;
        }
        add(l, r, tl, (tl+tr)/2, k*2+1, x);
        add(l, r, (tl+tr)/2, tr, k*2+2, x);
        nodes[k] = min(nodes[k*2+1], nodes[k*2+2]);
    }
    ll find(int l, int r) {
        return find(l, r, 0, n, 0);
    }
    ll find(int l, int r, int tl, int tr, int k) {
        eval(k);
        if (tr <= l || r <= tl) return INF;
        else if (l <= tl && tr <= r) return nodes[k];
        return min(find(l, r, tl, (tl+tr)/2, k*2+1), find(l, r, (tl+tr)/2, tr, k*2+2));
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    LazySegmentTree seg(n);
    for (int i=0; i<q; ++i) {
        int a, s, t, x;
        cin >> a;
        if (a == 0) {
            cin >> s >> t >> x;
            seg.add(s, t+1, x);
        } else {
            cin >> s >> t;
            cout << seg.find(s, t+1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7076
program c

integer(8) :: n,a(200000),nn,ans=0

read(*,*) n
read(*,*) (a(i),i=1,n)

do i=1,n
	a(i) = a(i) - i
enddo

call heapsort(n,a(1:n))
nn = a((n+1)/2)

do i=1,n
	a(i) = abs(a(i) - nn)
enddo

write(*,*) sum(a(1:n))



contains

subroutine heapsort(n,y1)

	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1
	
	l = n/2+1
	k = n

	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				
		 else
				t1 = y1(k)
				y1(k) = y1(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 exit
				endif
		 endif

		 i = l
		 j = l+l

		 do while(j <= k)
				if(j < k) then
					 if(y1(j) < y1(j+1)) j = j+1
				endif
				
				if (t1 < y1(j)) then
					 y1(i) = y1(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
	
	enddo
	return

end subroutine heapsort

end program

Measured memory_bytes: 2304
cmatrix = []
for i in range(3):
  cmatrix.append(list(map(int, input().split())))
  
if(cmatrix[0][0]+ cmatrix[1][1] == cmatrix[0][1]+ cmatrix[1][0] and \
  cmatrix[0][1]+ cmatrix[1][2] == cmatrix[0][2]+ cmatrix[1][1] and \
  cmatrix[1][0]+ cmatrix[2][1] == cmatrix[1][1]+ cmatrix[2][0] and \
  cmatrix[1][1]+ cmatrix[2][2] == cmatrix[1][2]+ cmatrix[2][1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
//import java.lang.Math;
import java.util.*;
//import java.util.ListIterator;
//import java.util.Iterator;
//import java.util.LinkedList;
 
public class Main{
	
	
	
	@SuppressWarnings({ "rawtypes", "unchecked", "resource" })
	public static void main(String[] arg) {
		
		
		Map map=new HashMap();
		 Scanner sc = new Scanner(System.in);
	        int cnt = sc.nextInt();
	        for (int i = 0; i < cnt; i++) {
	        
	        int cmt=sc.nextInt();
	        
	        switch(cmt){
	        
	        
	        case 0:
	        	  String str=sc.next();
	              int num=sc.nextInt();
	        
	               map.put(str,num);
	            break;
	        case 1:
	        	str=sc.next();
	        	if(map.containsKey(str))System.out.println(map.get(str));
	        	else System.out.println(0);
	        	break;
	        case 2:
	        	str=sc.next();
	        	map.remove(str);
	      
	        }
	        
	        
	        }
		
		
		
		
}
	
	
}


Measured memory_bytes: 192716
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long count=0;
		
		for(int i=0;i<N;i++) {
			long a=sc.nextLong();
			while(a%2==0) {
				count++;
				a/=2;
			}
		}
		System.out.println(count);		
	}
}


Measured memory_bytes: 35252