akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<set>
#include<deque>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){


    int n;
    cin >> n;
    deque<int> q;

    int tmp;
    if(n % 2 == 0){
        REP(i,n){
            cin >> tmp;
            if((i+1)%2 == 1){
                q.push_back(tmp);
            }else{
                q.push_front(tmp);
            }
        }
    }else{
        REP(i,n){
            cin >> tmp;
            if((i+1)%2 == 0){
                q.push_back(tmp);
            }else{
                q.push_front(tmp);
            }
        }
    }


    int count = 1;
    for(auto itr = q.begin(); itr != q.end(); ++itr) {
        if(count < n){
            cout << *itr << " ";
        }else{
            cout << *itr << endl;
        }
        count++;
    }



   
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <fstream>
#include <utility>
#include <queue>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define bs(n) (1ull<<(n))

map<ll, set<ll>> p;

pair<ll, ll> extgcd(ll a, ll b) {
	if (b == 0) return make_pair(a, 0);
	auto t = extgcd(b, a % b);
	return make_pair(t.second, t.first - t.second * (a / b));
}

ll mod = 1000000007;

ll rm(ll n) {
	auto t = extgcd(n, mod);
	return ((t.first % mod) + mod) % mod;
}

ll dm[200000] = { 0 };
ll fm(ll n) {
	if (n == 0) return 1;
	if (dm[n] == 0) dm[n] = (rm(n) * fm(n - 1)) % mod;
	return dm[n];
}

ll df[200000] = { 0 };
ll fc(ll n) {
	if (n == 0) return 1;
	if (df[n] == 0) df[n] = (n * fc(n - 1)) % mod;
	return df[n];
}

ll permutation(ll n, ll k) {
	if (n < k) return 0;
	return (fc(n) * fm(n - k)) % mod;
}

ll rec(ll node, ll anc, ll clr) {
	ll s = clr - 1;
	if (anc > 0) s--;
	ll c = 0;
	ll r = 1;
	for (auto& e : p[node]) {
		if (e == anc) continue;
		c++;
		r = (r * rec(e, node, clr)) % mod;
	}
	r = (r * permutation(s, c)) % mod;
	return r;
}

signed main() {
	ll n, k, a, b;
	cin >> n >> k;
	rep(i, n - 1) {
		cin >> a >> b;
		p[a].insert(b);
		p[b].insert(a);
	}
	cout << (rec(1, -1, k) * k) % mod << endl;
}


Measured memory_bytes: 27136
from sys import stdin
x,y = map(int, stdin.readline().rstrip().split())

if x == 1 and y == 1:
    print(1000000)
    exit()
else:
    pass
ans = 0
if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000
else:
    pass
if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000
else:
    pass

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	long long a,b,c,k;
	cin >> a >> b >> c >> k;
	long long base=max(a,max(b,c));
	for(int i=0; i<k; i++)base*=2;
	cout << a+b+c-max(a,max(b,c))+base << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 int main(){
     int N,Y;
     cin>>N>>Y;
     int a=-1,b=-1,c=-1;
     for(int i=0;i<=N;i++){
         for(int j=0;j<=N-i;j++){
             int l=N-i-j;
             int total = 10000*i+5000*j+1000*l;
             if(total==Y){
                 a=i;
                 b=j;
                 c=l;
             }
         }
     }
     cout<<a<<" "<<b<<" "<<c<<endl;
 }

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

//素因数分解
map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)
        ret[n] = 1;
    return ret;
}

int main() {
    ll N, P;
    cin >> N >> P;
    ll res = 1;
    auto factor = prime_factor(P);
    for(auto x : factor) {
        int a = x.second;
        while(a >= N) {
            res *= x.first;
            a -= N;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input!(
        s: Chars,
        t: Chars,
    );
    let n = s.len();
    for i in 0..n {
        if s[i] != t[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");

}


Measured memory_bytes: 2160
#include<iostream>
using namespace std;//力ずく！！
int main(void)
{
	int i,cnt;
	char s[4],t[4];
	cin>>s>>t;
	for(i=0;i<3;i++){if(s[i]==t[i]) cnt++;}
	cout<<cnt<<endl;
	return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    string s;
    cin >> s;
    for(int i = 0; i < A; i++){
        if(!('0' <= s.at(i) && s.at(i) <= '9')){
            puts("No");
            return 0;
        }
    }
    if(s.at(A) != '-') {
        puts("No");
        return 0;
    }
    for(int i = A + 1; i <= A + B; i++){
        if(!('0' <= s.at(i) && s.at(i) <= '9')) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,l,sum=0,min=10000,r;
	cin>>n>>l;
	long long int a[n+1],b[n+1];
	for(long long int i=1;i<=n;++i)
	{
	    
	    a[i]=l+i-1;
	    b[i]=a[i];
	    sum+=a[i];
	    if(a[i]<0)
	    {
	        a[i]*=-1;
	    }
	    if(a[i]<min)
	    {
	        r=i;
	        min=a[i];
	    }
	    
	}

	cout<<sum-b[r];
	
	
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
  ll n, m;
  cin >> n >> m;
  if( n == m ) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;  
  }
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [["."]+list(input())+["."] for _ in range(h)]
s.insert(0, ["." for _ in range(w+2)])
s.append(["." for _ in range(w+2)])
ans = "Yes"
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j] == "#":
            if not(s[i][j+1]=="#" or s[i][j-1]=="#" or s[i+1][j]=="#" or s[i-1][j]=="#" ):
                ans = "No"
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

vector<int> p[500];

bool done[500];

int n, m;

pair<int, int> count() {
	int cnt[m];
	SET(cnt, 0);
	FOR (i, n) {
		FOR (j, m) {
			int sport = p[i][j];
			if (!done[sport]) {
				cnt[sport]++;
				break;
			}
		}
	}
	int idx = -1, mmin = 0;
	FOR (i, m) {
		if (cnt[i] > mmin) {
			mmin = cnt[i];
			idx = i;
		}
	}
	return make_pair(mmin, idx);
}


int main() {
	cin >> n >> m;
	FOR (i, 500)
		p[i].clear();
	FOR (i, n) {
		int a;
		FOR (j, m) {
			cin >> a;
			a--;
			p[i].pb(a);
		}
	}
	SET(done, 0);
	int ret = n;
	FOR (i, m) {
		pair<int, int> val = count();
		done[val.second] = true;
		ret = min(ret, val.first);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 896
fun ans (i: String, j: String, k: String): String {
  return if ((i + j + k).toInt() % 4 == 0) "YES" else "NO"
}

fun main (args: Array<String>) {
  val col = readLine()!!.split(" ")
  println(ans(col[0], col[1], col[2]))
}


Measured memory_bytes: 36024
N, M = map(int, input().split())

mod = 10**9+7 #出力の制限
P = 10**5
g1 = [1, 1] # 元テーブル 階乗

for i in range( 2, P + 1 ):
    g1.append( ( g1[-1] * i ) % mod )

if abs(N - M) == 0:
    print(g1[N] * g1[M] * 2 % mod)
elif abs(N - M) == 1:
    print(g1[N] * g1[M] % mod)
else:
    print(0)


Measured memory_bytes: 7060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <functional>

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

#define deg_to_rad(deg) (((deg)/360)*2*M_PI)

double continuous_binary_search(
    double lo, // 絶対 OK な値
    double hi, // [lo, hi] の間に最適値があるとする
    function<bool(double)> is_ok, // OK かどうかを判定する
    double eps // 閾値
){
    while(hi - lo > eps){
        const double mid = (hi + lo) / 2.0;
        if(is_ok(mid)){
            lo = mid;
        }else{
            hi = mid;
        }
    }
    return lo;
}

int main(){
    double a, b, x;
    cin >> a >> b >> x;

    double ans = continuous_binary_search(
        0, 90,
        [&](double mid){
            const double rad = deg_to_rad(mid);
            const double rad2 = M_PI / 2 - rad;
            const double aheight = sin(rad) * a;
            const double bheight = sin(rad2) * b;
            double vol = 0;
            if(aheight >= bheight){
                const double aheight2 = bheight / cos(rad2);
                vol = aheight2 * a * b / 2.0;
            }else{
                const double y = aheight / tan(rad2);
                const double z = aheight / sin(rad2);
                vol = (
                    a * a * z / 2.0 + a * (a * cos(rad) + y) * (bheight - aheight)
                );
            }
            return (vol >= x);
        }, 1e-8
    );
    printf("%.8f\n", ans);
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    map<char, char> m;
    m['A'] = 'T';
    m['T'] = 'A';
    m['C'] = 'G';
    m['G'] = 'C';
    string s;
    cin >> s;
    int best = 0;
    int run = 0;
    for (char c : s) {
        if (m.find(c) == m.end()) {
            run = 0;
        } else {
            ++run;
            best = max(best, run);
        }
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 256
def calc_number(number):
    if number % 2 == 0:
        return int(number/2)
    else:
        return 3 * number + 1

def main():
    number = int(input())
    hist = set()
    hist.add(str(number))
    while 1:
        number = calc_number(number)
        # print(number)
        if str(number) in hist:
            # print(hist)
            print(len(hist) + 1)
            break
        else:
            hist.add(str(number))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#!/usr/bin python3
# -*- coding: utf-8 -*-

# ワーシャルフロイド法
# 全頂点間最短路
# d[i][j]は2頂点間i, j間の移動コストを格納, Mは頂点数

from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations


def main():
    N, M, R = map(int,input().split()) #N:頂点数　M:辺の数
    d = [[float("inf")]*N for i in range(N)]
    #d[u][v] : 辺uvのコスト(存在しないときはinf)
    r = list(map(int,input().split()))
    for i in range(M):
        u, v, w = map(int,input().split())
        d[u-1][v-1] = w
        d[v-1][u-1] = w
    for i in range(N):
        d[i][i] = 0 #自身のところに行くコストは０
    cost = floyd_warshall(d)
    L = list(permutations(r, R))
    ret = 10**9
    for rt in L:
        cos = 0
        for i in range(1,R):
            cos += cost[rt[i]-1][rt[i-1]-1]
        ret = min(ret, cos)
    print(int(ret))

if __name__ == '__main__':
    main()

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

int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = n;
    if (n >= b-1) x = b-1;
    ll ans = a*x/b - a*(x/b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
function Main(input) {
	input = input.trim();
  var len = parseInt(input.split("\n")[0]);
  var A = input.split("\n")[1];
  var B = input.split("\n")[2];
  var C = input.split("\n")[3];
  var count = 0;
  if(A == B && B == C){
     console.log(count);
    return;
  }
  for(var i = 0; i < len; i++){
    var tmpA = A.slice(i , i + 1);
    var tmpB = B.slice(i , i + 1);
    var tmpC = C.slice(i , i + 1);
    if(tmpA == tmpB && tmpB == tmpC){
      //console.log("全て同じ(+0)");
      continue;
    }else if(tmpA != tmpB && tmpB != tmpC && tmpA != tmpC){
      //console.log("全て違う(+2)");
       count += 2;
    }else{
      //console.log("その他(+1)");
      count++;
    }
  }
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
I = list(map(int, input().split()))
N = I[0]
K = I[1]
H = list(map(int, input().split()))

dp = [float('inf') for _ in range(N+1)]

dp[N] = 0
for i in range(N-1,N-K-1,-1):
	if i>0:
		dp[i] = abs(H[i-1]-H[N-1])

for i in range(N-K-1,0,-1):
	for k in range(1,K+1):
		if i+k<=N:
			dp[i] = min(abs(H[i+k-1]-H[i-1])+dp[i+k], dp[i])

print(dp[1])

Measured memory_bytes: 88820
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

/*
  階乗計算（MODで割った余りで返す）
*/

class Factorial {
    private:
        vector<ll> fac;
    public:
        Factorial();
        Factorial(ll n_max);
        void initialization(ll n_max);
        ll getFactorial(ll n);
};

Factorial::Factorial() {}
Factorial::Factorial(ll n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (ll i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
void Factorial::initialization(ll n_max) {
    fac.clear();
    fac.push_back(1);
    fac.push_back(1);
    for (ll i = 2; i <= n_max; i++) {
        fac.push_back(fac[i-1] * i % MOD);
    }
}
ll Factorial::getFactorial(ll n) {
    return fac[n];
}

/*
  MOD計算
*/
// 割り算のための逆元を求める（mod m での a の逆元）
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u % m;
}

/*
    順列と組み合わせ (P, C, H)
*/

class PCH {
    private:
        Factorial fact;
    
    public:
        PCH(ll n_max);
        ll P(ll n, ll r);
        ll C(ll n, ll r);
        ll H(ll n, ll r);
};
PCH::PCH(ll n_max) {
    fact.initialization(n_max);
}
ll PCH::P(ll n, ll r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

ll PCH::C(ll n, ll r) {
    return fact.getFactorial(n) % MOD * modinv(fact.getFactorial(r), MOD) % MOD * modinv(fact.getFactorial(n - r), MOD) % MOD;
}

ll PCH::H(ll n, ll r) {
    return C(n - 1 + r, r);
}

int main() {

    ll N, M;
    cin >> N >> M;

    PCH pch(M);
    ll ans = 0;

    for (ll k = 0; k <= N; k++) {
        ll count = pch.C(N, k);
        if (k % 2 == 1) count *= -1;
        count += MOD;
        count %= MOD;
        count *= pch.P(M, k);
        count %= MOD;
        count *= pch.P(M - k, N - k);
        count %= MOD;
        count *= pch.P(M - k, N - k);
        count %= MOD;
        ans += count;
        ans %= MOD;
    }

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


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

int main(void) {
    int N, K, tmp;
    bool ok[10];

    for (int i = 0; i < 10; i++) {
        ok[i] = true;
    }

    cin >> N >> K;

    for (int i = 0; i < K; i++) {
        cin >> tmp;
        ok[tmp] = false;
    }

    int lowest = 9;
    for (int i = 9; i >= 0; i--) {
        if (ok[i]) lowest = i;
    }

    int extra = 0;
    vector<int> result;

    while (N > 0 || extra > 0) {
        int current = N % 10 + extra;
        extra = 0;
        N /= 10;

        for (int i = 0; i < 10; i++) {
            int x = (current + i) % 10;
            if (ok[x]) {
                if (x != current) {
                    for (int j = 0; j < result.size(); j++) {
                        result[j] = lowest;
                    }
                }

                result.push_back(x);
                if (x < current) {
                    extra = 1;
                }
                break;
            }
        }
    }

    for (int i = result.size() - 1; i >= 0; i--) {
        cout << result[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu
)");
#define cin input
#endif

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

	map<char, char> m;
	set<char> u;
	for (size_t i = 0; i < s.size(); ++i)
	{
		if (m.count(t[i]))
		{
			if (m[t[i]] != s[i])
			{
				cout << "No" << endl;

				return 0;
			}
		} else
		{
			if (u.count(s[i]))
			{
				cout << "No" << endl;

				return 0;
			}
			m[t[i]] = s[i];
			u.insert(s[i]);
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 1020
#include<iostream>
using namespace std;
int main()
{
	string s[100];
	bool flag = false, hh = false;
	int n, i, j;
	cin >> n;
	for(i = 0; i < n; i ++)
	{
		cin >> s[i];
	}
	for(i = 1; i < n; i ++)
	{
		if(s[i][0] != s[i - 1][s[i - 1].size() - 1])
		{
			flag = false;
			break;
		}
		else
		flag = true;
	}
	for(i = 1; i < n; i ++)
	{
		for(j = 0; j < i; j ++)
		{
			if(s[i] == s[j])
			{
				hh = false;
			  	break;
		    }
			else
			{
			  	hh = true;
		    } 		
		}
		if(hh == false)
		{
		    break;
		}
	}
	if(flag == true && hh == true)
		cout << "Yes";
	else
    	cout << "No";
}

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

int main() {
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> h(n);
    for (auto& e : h) cin >> e;
    sort(begin(h), end(h));
    cout << (k < n ? accumulate(begin(h), begin(h) + n - k, 0l) : 0) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    int ans=10000;
    rep(i,n){
        int a; cin >> a;
        int cnt=0;
        while(a%2==0){
            a/=2;
            cnt++;
        }
        chmin(ans,cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m;
    cin>>n>>m;
    int x[n+1],y[m+1];
    int ans1=0,ans2=0;
    int prev=0;
    for(int i=1;i<=n;i++)
    {
        cin>>x[i];
        ans1+=((i-1)*x[i])%mod-prev+mod;
        prev+=x[i];
        prev%=mod;
        ans1%=mod;   
    }
    prev=0;
    for(int i=1;i<=m;i++)
    {
        cin>>y[i];
        ans2+=((i-1)*y[i])%mod-prev+mod;
        prev+=y[i];
        prev%=mod;
        ans2%=mod;   
    }
    ans1*=ans2;
    ans1%=mod;
    cout<<ans1;

} 



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

using namespace std;

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

	vector<string> A(H);
	vector<vector<int>> d(H, vector<int>(W, 1e9));
	queue<pair<int,int>> q;
	for (int i = 0; i < H; ++i) {
		cin >> A[i];
		for (int j = 0; j < W; ++j) {
			if (A[i][j] == '#') {
				d[i][j] = 0;
				q.emplace(j, i);
			}
		}
	}

	int dx[]{1, -1, 0, 0}, dy[]{0, 0, 1, -1};
	int ans = 0;
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int x = p.first, y = p.second;
		for (int i = 0; i < 4; ++i) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx < 0 || W <= nx || ny < 0 || H <= ny || A[ny][nx] == '#') {
				continue;
			}
			A[ny][nx] = '#';
			q.emplace(nx, ny);
			ans = max(d[ny][nx] = d[y][x] + 1, ans);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  rep(i,k) ans += a[i];
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
    int n,m;scanf("%d%d",&n,&m);
    int x,y;scanf("%d%d",&x,&y);
    x++;
    int mi,ma;mi=111;ma=-111;
    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        ma=max(ma,x);
    }ma++;
    for(int i=1;i<=m;i++){
        int x;scanf("%d",&x);
        mi=min(mi,x);
    }
    if(mi>=ma&&y>=x&&((mi>=x&&mi<=y)||(ma>=x&&ma<=y)||(y>=ma&&y<=mi)||(x>=ma&&x<=mi)))
        printf("No War\n");
    else printf("War\n");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //map<string,int>mp;
    int tt;
    cin>>tt;
     int a=0,t=0,w=0,r=0;
    while(tt--){
        string s;
        cin>>s;
       if(s[0]=='A'){
        a++;
       }
       if(s[0]=='T'){
        t++;
       }
       if(s[0]=='W'){
        w++;
       }
       if(s[0]=='R'){
        r++;
       }
    }
            cout<<"AC x "<<a<<'\n';
            cout<<"WA x "<<w<<'\n';
            cout<<"TLE x "<<t<<'\n';
            cout<<"RE x "<<r<<'\n';
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	static int[] tmp1,tmp2,a;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		a = new int[2*n];
		tmp1=new int[2*n];
		tmp2=new int[2*n];
		for(int i=0;i<2*n;i++){
			a[i]=i+1;
		}
		for(int i=0;i<m;i++){
			int k = sc.nextInt();
			if(k==0){
				shuffle();
			}
			else{
				shuffle(k);
			}
		}
		for(int i=0;i<2*n;i++){
			System.out.println(a[i]);
		}
	}
	static void shuffle(){
		int cnt1=0,cnt2=0;
		for(int i=0;i<a.length;i++){
			if(i<a.length/2){
				tmp1[cnt1++]=a[i];
			}
			else{
				tmp2[cnt2++]=a[i];
			}
		}
		cnt1=cnt2=0;
		for(int i=0;i<a.length;i++){
			if(i%2==0){
				a[i]=tmp1[cnt1++];
			}
			else{
				a[i]=tmp2[cnt2++];
			}
		}
	}
	static void shuffle(int k){
		for(int i=0;i<k;i++){
			tmp1[i]=a[i];
//			System.out.println(tmp1[i]);
		}
		for(int i=k;i<a.length;i++){
			tmp2[i]=a[i];
//			System.out.println(tmp2[i]);
		}
		for(int i=k;i<a.length;i++){
			a[i-(k)]=tmp2[i];
		}
		for(int i=0;i<k;i++){
			a[i+(a.length-k)]=tmp1[i];
		}

	}
}

Measured memory_bytes: 21892
#include <iostream>

using namespace std;

struct Node{ int p, l, r; };
Node tree[100000];
int depth[100000];

int n;

void print(){
  for(int i = 0; i < n; i++){
    cout << "node " << i << ": ";
    cout << "parent = " << tree[i].p << ", ";
    cout << "depth = " << depth[i] << ", ";
    if(tree[i].p == -1)
      cout << "root, ";
    else if(tree[i].l == -1)
      cout << "leaf, ";
    else
      cout << "internal node, ";
    cout << "[";
    for(int c = tree[i].l; c != -1; c = tree[c].r){
      if(c == tree[i].l)
	cout << c;
      else
	cout << ", " << c;
    }
    cout << "]" << endl;
  }
}

int depthSet(int x, int d){
  depth[x] = d;
  if(tree[x].r != -1)
    depthSet(tree[x].r, d);
  if(tree[x].l != -1)
    depthSet(tree[x].l, d+1);
}

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    tree[i].p = tree[i].l = tree[i].r = -1;
  }
  int lastnodeid;
  for(int i = 0; i < n; i++){
    int pid, num;
    cin >> pid >> num;
    for(int j = 0; j < num; j++){
      int id;
      cin >> id;
      if(j == 0)
	tree[pid].l = id;
      else
	tree[lastnodeid].r = id;
      tree[id].p = pid;
      lastnodeid = id;
    }
  }
  int root;
  for(int i = 0; i < n; i++){
    if(tree[i].p == -1){
      root = i;
    }
  }
  depthSet(root,0);
  print();

}

Measured memory_bytes: 7720
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60]={0};
           signed main(){
        string s;
           	cin>>s;
           	
           int ans=0;
           	for(int i=0;i<3;i++)if(s[i]=='1') ans++;
           	cout<<ans<<endl;
           	
           	return 0;
           	
           	
           }
             

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 650055;
const int K = 700 ;
int a[N], n, x;
int f(int s){
    int res = s * x;
    for (int i = n; i > n - s; i--){
        res += 5 * a[i];
    }
    int cnt = s;
    int val = 5;
    for (int i = n - s; i >= 1; i--){
        if (cnt == 0){
            cnt = s;
            val += 2;
        }
        res += val * a[i];
        cnt--;
    }
    return res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int l = 1;
    int r = n;
    while(r - l > 100){
        int lo = l + (r - l) / 3;
        int hi = r - (r - l) / 3;
        if (f(lo) > f(hi)) l = lo; else r = hi;
    }
    int ans = 1e17;
    for (int i = l; i <= r; i++) ans = min(ans, f(i));
    cout << ans + x * n;
}


Measured memory_bytes: 1792
from itertools import combinations


def valid_tri(l)->bool:
    if l[0] != l[1] and l[1] != l[2] and l[0] != l[2]:
        # print(l)
        if l[0] + l[1] > l[2] and l[1] + l[2] > l[0] and l[0] + l[2] > l[1]:
            return True
        else: return False
    else: return False

def main():
    n = int(input())
    l = list(map(int, input().split()))
    cnt = 0
    for l in combinations(l, 3):
        if valid_tri(l):

            cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    double R;
    cin>>R;
    cout << setprecision(7) <<  R * 2 * 3.14159 << endl;
}

Measured memory_bytes: 3768
i = [int(input()) for i in range(5)]
i2 = [i2 for i2 in i if i2%10 != 0]

if not i2:
    min = i[len(i)-1]

else:
    min = i2[len(i2)-1]

for x in i:
    if 0 < x % 10 < min % 10:
        min = x
i.remove(min)

for x in i:
    if x % 10 != 0:
        index = i.index(x)
        x += 10 - x % 10
        i[index] = x

i.append(min)

print(sum(i))


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


int main()
{
    map<int, int> cnt;
    int n;
    cin >> n;
    for ( int i = 1; i <= n; i++ ) {
        int a;
        cin >> a;
        cnt[a]++;
    }

    int ans = 0;

    for ( auto u : cnt ) {
        if ( u.second >= u.first ) ans += ( u.second - u.first );
        else ans += u.second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 8012
/*
    ZI0N
*/

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

using namespace std;
//using namespace __gnu_pbds;

//VARS
#define int               long long
#define ld                long double
#define mod1              1000000007
#define mod2              998244353
#define pi           `    3.14159265358979323846
#define hs                100006

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define endl              "\n"

//INPUT
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define repe(i,a,b)       for(int i=a;i<=b;i++)
#define bac(i,a,b)        for(int i=a;i>b;i--)
#define bace(i,a,b)       for(int i=a;i>=b;i--)

//FAST
#define ios               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//FUNCTIONS
#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define DSORT(v)          sort(all(v),greater<int>())
#define REVERSE(v)        reverse(ALL(v))
#define GCD(m,n)          __gcd(m,n)
#define LCM(m,n)          m*(n/GCD(m,n))
#define init(x,a)         memset(x,a,sizeof(x))
#define trav(a, x)        for(auto& a : x)
#define display(x)        trav(a,x) cout<<a<<" ";cout<<endl

void solve(){
    int n;
    cin>>n;
    if(n>99999)
        cout<<"90909";
    else if(n>=10000){
        cout<<910+(n-10000);
    }
    else if(n>999)
        cout<<909;
    else if(n>=100)
        cout<<10+(n-100);
    else if(n>9)
        cout<<9;
    else if(n>=1)
        cout<<n;
}


signed main(){
    ios
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }

    return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    
    int ans = 0;
    for(int i = 0; i < 3; i++)
        if(S[i] == T[i]) ans++;
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
H = list(map(int, input().split()))

for i in range(k):
    H.append(0)

cost = [float('INF')]*(n+k)
cost[0] = 0

for i in range(n-1):
    for j in range(1, k+1):
        jump = cost[i] + abs(H[i+j]-H[i])
        if jump < cost[i+j]:
            cost[i+j] = jump

print(cost[n-1])

Measured memory_bytes: 54624
from collections import Counter

N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

ans = 1
cnt = 0
# 最後にバスが出た時間
st = T[0]
for t in T:
    cnt += 1
    # バスが出てからK時間以上たつ or count が　C を越した場合
    if t - st > K or cnt > C:
        ans += 1
        st = t
        cnt = 1

print(ans)

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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  for (size_t i = S.size(); i > 0; --i) {
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
    S = S.back() + S.substr(0, S.size() - 1);
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 10000001
using namespace std;
bool num[N];
int top = N-1;

void Minus(int x){
  num[x] = !num[x];
  while(num[x]) num[++x] = !num[x];
  while(top>=0&&num[top]==0)top--;
}

int main(){
  int n;
  cin>>n;
  num[N-1] = 1;

  while(n--){
    int x;
    scanf("%d",&x);
    x = max(0,N-x-1);
    if(top>=x)printf("Yes\n"),Minus(x);
    else printf("No\n");
  }
  return 0;
}

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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define sort(vec) std::sort(all(vec))
#define rev(vec) std::reverse(all(vec))

void calculate(){

}

int main(int,char**){
    std::string s,t;
    input(s,t);
    sort(s);
    sort(t);
    rev(t);
    if(s < t) std::cout << "Yes\n";
    else std::cout << "No\n";
}


void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

Measured memory_bytes: 256
n, m, c = gets.chomp.split(" ").map(&:to_i)
bs = gets.chomp.split(" ").map(&:to_i)
asArray = []
n.times do |i|
    asArray[i] = gets.chomp.split(" ").map(&:to_i)
end

passed = 0
for as in asArray do
    total = 0
    as.each_with_index do |a, i|
        total += a * bs[i]
    end
    #as.map.with_index {|a, i|total += a * bs[i]}
    val = total + c
    if val > 0
        passed += 1
    end
end

print passed

Measured memory_bytes: 14348
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int D;
vector<int> c(30, 0);
vector<vector<int>> s(400, vector<int>(30, 0));

struct schedule {
	int score = 0;
	vector<int> contest;
	vector<int> last;

	schedule() {
		last.assign(30, 0);
	};

	bool operator<(const schedule& s) const {
		return score > s.score;
	}
};

void input() {
	cin >> D;
	for (int i = 1; i <= 26; ++i) { cin >> c[i]; }
	for (int i = 1; i <= D; ++i) {
		for (int j = 1; j <= 26; ++j) { cin >> s[i][j]; }
	}
}

schedule calc_score(schedule sc, int con) {
	schedule ret = sc;
	int day = sc.contest.size() + 1;
	ret.last[con] = day;
	ret.contest.push_back(con);
	ret.score += s[day][con];
	for (int i = 1; i <= 26; ++i) {
		ret.score -= c[i] * (day - ret.last[i]);
	}

	return ret;
}

int main() {
	constexpr int BEAM = 77;
	input();

	vector<schedule> curr;
	curr.emplace_back(schedule());
	for (int d = 1; d <= D; ++d) {
		vector<schedule> nxt;
		for (auto sc : curr) {
			for (int i = 1; i <= 26; ++i) {
				nxt.push_back(calc_score(sc, i));
			}
		}
		sort(nxt.begin(), nxt.end());
		if (nxt.size() > BEAM) { nxt.resize(BEAM); }
		curr = nxt;
	}
	// cerr << "score = " << curr[0].score << endl;
	for (auto t : curr[0].contest) { cout << t << endl; }

	return 0;
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		FastScanner in;
		PrintWriter out;

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			this.in = in;
			this.out = out;
			long k = in.nextLong();
			solve(k);
//		for (int i = 1; i < 10000; i++) {
//			solve(i);
//		}
		}

		private void solve(long k) {
			long[] a = construct(k);
			if (!check(a.clone(), k)) {
				throw new AssertionError("" + k);
			}
			out.println(a.length);
			for (int i = 0; i < a.length; i++) {
				if (i > 0) {
					out.print(" ");
				}
				out.print(a[i]);
			}
			out.println();
		}

		private long[] construct(long k) {
			int n = 50;
			long[] a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] += k / n + i;
				if (i >= k % n) {
					continue;
				}
				a[i] += n;
				for (int j = 0; j < n; j++) {
					if (j != i) {
						a[j] -= 1;
					}
				}
			}
			return a;
		}

		boolean check(long[] a, long k) {
			int n = a.length;
			long ans = 0;
			while (true) {
				boolean changed = false;
				for (int i = 0; i < n; i++) {
					if (a[i] < n) {
						continue;
					}
					changed = true;
					long x = a[i] / n;
					a[i] -= n * x;
					ans += x;
					for (int j = 0; j < n; j++) {
						if (j != i) {
							a[j] += x;
						}
					}
				}
				if (!changed) {
					break;
				}
			}
			return ans == k;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}



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

void solve(int *a,int n,int k)
{
    int dist[n];
    for(int i=0;i<n;i++)
        dist[i]=INT_MAX;
    dist[0]=0;
    dist[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        for(int j=i-1,p=0;j>=0 && p<k;j--,p++)
        {
            dist[i]=min(dist[i],dist[j]+abs(a[j]-a[i]));
        }
    }
    cout<<dist[n-1];
}

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    solve(a,n,k);

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;

int main()
{
	for(;;){
		int n,m;
		string ss;
		cin >> n ;
		if(n==0)return 0;
		cin >> m >> ss;
		int ans=0;
		for(int i=0;i<=m-(2*n+1);i++){
			//printf("%d\n",i);
			for(int j=i;j<i+2*n+1;j++){
				if(((j-i)%2==0&&ss[j]=='O')||((j-i)%2==1&&ss[j]=='I')){
					goto next;
				}
			}
			ans++;
			i+=(2*n+1);
			while(ss[i]=='O'&&ss[i+1]=='I'){
				i+=2;
				ans++;
				if(i>=m)goto end;
				//printf("%d\n",i);
			}
			i--;
next:;
		}
		end:;
		printf("%d\n",ans);
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int x;
  cin >> x;
  int sum = 0;
  for (int i = 1; i <= x; i++) {
    for (int j = 1; j <= x; j++) {
      for (int k = 1; k <= x; k++) {
        sum += gcd(gcd(i, j), k);
      }
    }
  }
  cout << sum;
}

Measured memory_bytes: 3632
package main

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

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	sc.Text()
	sc.Scan()
	in1strs := strings.Split(sc.Text(), " ")
	sc.Scan()
	sc.Text()
	sc.Scan()
	in2strs := strings.Split(sc.Text(), " ")

	in1 := []int{}
	for _, v := range in1strs {
		num, _ := strconv.Atoi(v)
		in1 = append(in1, num)
	}

	S = in1
	used = make([]bool, 1000)
	results = make([]bool, 5000)
	rec(0, len(in1))

	for _, v := range in2strs {
		target, _ := strconv.Atoi(v)
		if results[target] {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}

}

var used []bool
var S []int

var result int
var exist bool
var results []bool
var max int

func rec(i int, n int) bool {
	if i == n {
		return false
	}

	for j := max; j < n; j++ {
		if used[j] {
			continue
		}
		result += S[j]
		used[j] = true
		max = j
		results[result] = true
		rec(i+1, n)
		result -= S[j]
		used[j] = false
		max--
	}

	return false
}



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

#define  int    long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff         first
#define  ss    second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    int a,aa,b,bb,t;
    cin>>a>>aa>>b>>bb>>t;
    if(aa<bb)
        cout<<"NO";
    else
    {
        if(aa==bb)
        {
            if(a==b)
                cout<<"YES";
            else    
                cout<<"NO";
        }
        else
        {
            int x=abs(a-b);
            x=(x+aa-bb-1)/(aa-bb);
            if(x<=t)
                cout<<"YES";
            else    
                cout<<"NO";
        }
        
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define PR pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define int ll

//ICPC Ranking  AOJ

#define MAX 60
int tt[55];
int pena[55][15];
int point[55];
bool done[MAX];

signed main(){
  int M,T,P,R;
  while(cin>>M>>T>>P>>R&&!(M==0&&T==0&&P==0&&R==0)){
    for(int i=0; i<=55; i++){
      for(int j=0; j<=15; j++){
        pena[i][j]=0;
      }
      tt[i]=0;
      point[i]=0;
      done[i]=false;
    }
    
    for(int i=0; i<R; i++){
      int m,t,p,j;
      cin>>m>>t>>p>>j;
      if(j){
        pena[t][p]++;
      }else{
        tt[t]+=m;
        tt[t]+=pena[t][p]*20;
        point[t]++;
      }
    }
    
    PR pre;
    for(int i=1; i<=T; i++){
      int m=0,t=0;
      int nowt=0;
      for(int j=1; j<=T; j++){
        if(done[j]) continue;
        if(point[j]>m){
          nowt=j;
          m=point[j];
          t=tt[j];
        }else if(point[j]==m){
          if(tt[j]<=t){
            nowt=j;
            m=point[j];
            t=tt[j];
          }
        }
      }
      
      done[nowt]=true;
      if(i==1) cout<<nowt;
      else{
        if(pre.first==m&&pre.second==t){
          cout<<'='<<nowt;
        }else{
          cout<<','<<nowt;
        }
      }
      
      pre.first=m; pre.second=t;
    }
    cout<<en
  }
  RE
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)1000000007
using namespace std;

int main()
{
    double n;
    cin>>n;
    
    for(int i = 1; i <= n; i++){

        int p = i*1.08;
        if(p == n)
        {
            cout<<i<<"\n";
            return 0;
        }
    }

    cout<<":(\n";
    

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int N;
int A[100010];

int main(int argc, const char * argv[]) {
  scanf("%d", &N);
  for(int i=0;i<N;++i) {
    scanf("%d", &A[i]);
  }
  
  long long answer = 0;
  int last = 2;
  for(int i=0;i<N;++i) {
    if (i==0) {
      answer += A[0]-1;
      continue;
    }
    if (A[i]==last) {
      last++;
      continue;
    }
    answer += (A[i]-1) / last;
  }
  
  printf("%lld\n", answer);
return 0;
}

Measured memory_bytes: 512
import sys
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))

    res = 0
    for i in range(n):
        u = bisect_left(A, B[i])
        d = bisect_right(C, B[i])
        res += u * (n - d)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 29212