akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<pair<__int128_t, __int128_t>> ab;
    int64_t c = 0;
    for (auto i : irange(0L, n)) {
        int64_t a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            ++c;
        } else {
            if (b < 0 || (b == 0 && a < 0)) {
                a = -a;
                b = -b;
            }
            ab.emplace_back(a, b);
        }
    }

    sort(ab.begin(), ab.end(), [](const auto& lhs, const auto& rhs) {
        return lhs.first * rhs.second - lhs.second * rhs.first > 0;
    });

    constexpr auto M = 1000000007L;

    int64_t m = ab.size();

    vector<int64_t> p2(m + 1, 1L), ip2(m + 1, 1L);
    for (auto i : irange(1L, m + 1)) {
        p2[i] = p2[i - 1] * 2;
        p2[i] %= M;
        ip2[i] = ip2[i - 1] * 500000004L;
        ip2[i] %= M;
    }

    int64_t ans = 1L;
    for (int64_t i = 0, j = 0; i < m;) {
        int64_t i0 = i;
        while (i < m &&
               ab[i0].first * ab[i].second - ab[i0].second * ab[i].first == 0) {
            ++i;
        }
        while (j < m &&
               ab[i0].first * ab[j].first + ab[i0].second * ab[j].second < 0) {
            ++j;
        }
        int64_t j0 = j;
        while (j < m &&
               ab[i0].first * ab[j].first + ab[i0].second * ab[j].second == 0) {
            ++j;
        }

        ans += ans * ip2[j - j0] % M * (p2[i - i0] - 1) % M;
        ans %= M;
    }

    ans = (ans + c + M - 1) % M;

    cout << ans << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll dist(ll x1, ll y1, ll x2, ll y2){
	return abs(x1 - x2) + abs(y1 - y2);
}

pll mid(ll x1, ll y1, ll x2, ll y2, ll K){
    ll x = x2 - x1;
    ll y = y2 - y1;
    ll z = x + y;
    ll w = x - y;
    int zneg = (z < 0 ? -1 : 1);
    int wneg = (w < 0 ? -1 : 1);
    z *= zneg;
    w *= wneg;
    ll mz, mw;
    if(z < K && w > K) mz = z - K, mw = K;
    else mz = K, mw = w - K;
    mz *= zneg;
    mw *= wneg;
    ll mx = (mz+mw)/2;
    ll my = (mz-mw)/2;
    return {x1 + mx, y1 + my};
}

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

    ll K;
    ll X, Y;
    cin >> K >> X >> Y;

    ll x = abs(X), y = abs(Y);
    int xneg = (X<0 ? -1 : 1);
    int yneg = (Y<0 ? -1 : 1);

    if(K%2==0 && (x+y)%2==1){
    	cout << -1 << endl;
    	return 0;
    }

    vector<pll> res;
    res.push_back({0, 0});

    ll z = 0, w = 0;
    while(dist(z, w, x, y)>=2*K){
    	ll x_susumu = min(x-z, K);
    	z += x_susumu;
    	ll y_susumu = K - x_susumu;
    	w += y_susumu;
    	res.push_back({z, w});
    }

    if(dist(z, w, x, y) == K){
    	res.push_back({x, y});
    }else{
    	if(K%2 == 1 && (z+w)%2 != (x+y)%2){
	    	ll x_susumu = min(x-z, K);
	    	z += x_susumu;
	    	ll y_susumu = K - x_susumu;
	    	w += y_susumu;
	    	res.push_back({z, w});
	    }
        assert(dist(x, y, z, w) <= 2*K);
	    pll mi = mid(z, w, x, y, K);
	    res.push_back({mi.first, mi.second});
	    res.push_back({x, y});
    }


    // output
    cout << res.size()-1 << endl;
    REP(i, res.size()){
        if(i == 0) continue;
        cout << xneg*res[i].first << " " << yneg*res[i].second << endl;
    }

    REP(i, res.size()-1){
        //dump(dist(xneg*res[i].first, yneg*res[i].second, xneg*res[i+1].first, yneg*res[i+1].second))
        //assert(dist(xneg*res[i].first, yneg*res[i].second, xneg*res[i+1].first, yneg*res[i+1].second) == K);
    }
    return 0;
}


Measured memory_bytes: 5484
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	vll a(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) ;
	vll sum(n+1,0) ;
	for(int i=0;i<n;i++) sum.at(i+1) = sum.at(i)+a.at(i) ;
	vll sub = sum ;
	ll cnt1 = 0 ;
	ll d = 0 ;
	for(int i=1;i<=n;i++){
		ll num ;
		sum.at(i) += d ;
		if(i&1){
			num = max(0LL,1-sum.at(i)) ;
			cnt1 += num ;
			d += num ;
		}else{
			num = max(0LL,sum.at(i)+1) ;
			cnt1 += num ;
			d -= num ;
		}
//		cout << cnt1 << (i==n?'\n':' ') ;
	}
	ll cnt2 = 0 ;
	d = 0 ;
	for(int i=1;i<=n;i++){
		ll num ;
		sub.at(i) += d ;
		if((i+1)&1){
			num = max(0LL,1-sub.at(i)) ;
			cnt2 += num ;
			d += num ;
		}else{
			num = max(0LL,sub.at(i)+1) ;
			cnt2 += num ;
			d -= num ;
		}
//		cout << cnt2 << (i==n?'\n':' ') ;
	}
	cout << min(cnt1,cnt2) << endl ;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

long long cnt;
int A[1000000];
int n;
int l;

vector<int> G;

void insertionSort(int A[], int n, int g){
  for( int i=g; i<n; i++){
    int v = A[i];
    int j = i-g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n){
  for(int h =1; ; ){
    if( h>n ) break;
    G.push_back(h);
    h = 3*h +1;
  }
  for(int i=G.size()-1; i>=0; i--){
    insertionSort(A, n, G[i]);
  }
}

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

  for(int i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  cnt=0;

  shellSort(A, n);

  std::cout << G.size() << std::endl;
  for(int i = G.size()-1; i>=0; i--){
    printf("%d", G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n", (int)cnt);
  for(int i=0; i<n; i++){
    printf("%d\n", A[i]);
  }
  return 0;
}



Measured memory_bytes: 7136
def main():
    S = input()
    count = 0
    max_count = 0
    for i in range(len(S)):
        if S[i] in "ATCG":
            count += 1
            max_count = max(max_count, count)
        else:
            count = 0
    return max_count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9

int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<int> x(n);
        vector<int> y(n);
        vector<int> r(n);
        vector<int> c(n);        

        for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i] >> c[i];

        vector<vector<bool> > canTake(n, vector<bool> (n, false));
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                int d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
                if(d < (r[i] + r[j]) * (r[i] + r[j])) canTake[j][i] = true;
            }
        }

        /*for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cout << canTake[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;*/

        //ワーシャルフロイド
        for(int k = 0; k < n; k++){
            for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                    canTake[i][j] = canTake[i][j] || canTake[i][k] && canTake[k][j];
                }
            }
        }

        /*for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                cout << canTake[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
        */
        //幅優先探索
        vector<bool> visited((1<<n), false);
        queue<pair<int, int> > q;
        q.push({0, (1<<n) - 1});
        visited[(1<<n) - 1] = true;

        int ans = 0;

        while(!q.empty()){

            int now_bit = q.front().second;
            int now_cost = q.front().first;
            ans = max(ans, now_cost);
            q.pop();

            for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){

                    //i番目 と j番目が取り出せるか
                    if(!((1<<i) & now_bit)) continue;
                    if(!((1<<j) & now_bit)) continue;                    
                    //色が違うならダメ
                    if(c[i] != c[j]) continue;
                
                    //iの上に何かあればダメ
                    bool flagi = true;
                    for(int k = 0; k < n; k++){
                        if(canTake[i][k] && (now_bit & (1<<k))){
                            flagi = false;
                            break;
                        }
                    }


                    if(!flagi) continue;
                
                    bool flagj = true;
                    for(int k = 0; k < n; k++){
                        if(canTake[j][k] && (now_bit & (1<<k))){
                            flagj = false;
                            break;
                        }
                    }

                    if(!flagj) continue;

                    int next_bit = now_bit & (~((1<<i) | (1<<j)));
                    if(!visited[next_bit]){
                        visited[next_bit] = true;
                        q.push({now_cost + 1, next_bit});
                    }
                }
            }
        }

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

}


Measured memory_bytes: 7944
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

const int MAX = 2000100;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k)
{
	if (n < k)
		return 0;
	if (n < 0 || k < 0)
		return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	// 前処理
	COMinit();

	ll x, y;
	cin >> x >> y;
	ll over = 2 * x - y;
	//a->1,2  b->2,1
	if (over % 3 != 0)
	{
		cout << 0 << endl;
		return 0;
	}
	ll a, b;
	b = over / 3;
	a = x - b*2;
	ll ans = COM(a + b, a);
	
	cout << ans << endl;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int a, b, c, d, k;
  cin >> a >> b >> c >> d >>k;
  int ans = c*60+d-a*60-b-k;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#define TEST_SNO	1
#define TEST_ENO	3
#define ll			long long

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

FILE *in, *ans;
int t;
ll n;
ll v[5];

int
out(const char *s)
{
#ifdef TEST
	char buf[8192];
	fgets(buf, sizeof(buf), ans);
	if (strcmp(buf, s)) {
		printf("err\n");
	}
#else
	printf(s);
#endif
	return 0;
}

int
outll(ll l)
{
	char s[128];
	sprintf(s, "%lld\n", l);
	out(s);
	return 0;
}

ll
getll()
{
	ll l;
	fscanf(in, "%lld", &l);
	return l;
}

int
getstr(char *s)
{
	fscanf(in, "%s", s);
	return 0;
}

int
sortfnc(const void *v1, const void *v2)
{
	int *i1 = (int *)v1;
	int *i2 = (int *)v2;

	if (*i1 > *i2) {
		return 1;
	}
	else if (*i1 < *i2) {
		return -1;
	}

	return 0;
}

ll
chk()
{
	ll time = (n + v[0] - 1) / v[0];
	for (int i = 1; i < 5; i++) {
		time++;
		ll time2 = (n + v[i] - 1) / v[i] + i;
		if (time < time2) {
			time = time2;
		}
	}

	return time;
}

int
fnc()
{
	n = getll();
	for (int i = 0; i < 5; i++) {
		v[i] = getll();
	}

	ll r = chk();
	outll(r);

	return 0;
}

int
main()
{
#ifdef TEST
	for (t = TEST_SNO; t <= TEST_ENO; t++) {
		char str[128];
		sprintf(str, "test%d.txt", t);
		in = fopen(str, "r");
		sprintf(str, "ans%d.txt", t);
		ans = fopen(str, "r");
		fnc();
		fclose(in);
		fclose(ans);
	}
	printf("end\n");
#else
	in = stdin;
	fnc();
#endif

	return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.conv;
import std.string;
import std.range;
import std.algorithm;

void main(){
    int n = readln().chomp().to!int();
    int[] data = iota(1, n + 1).array();
    foreach(i; 0..readln().chomp().to!int){
        auto input = readln().chomp().split(",");
        swap(data[to!int(input[0]) - 1], data[to!int(input[1]) - 1]);
    }
    data.map!(to!string).join("\n").writeln();
}

Measured memory_bytes: 1008
#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() {
  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}



Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007LL;
int cntS[100000], cntT[100000];
int main() {
	string S, T;
	cin >> S;
	cin >> T;
	for (int i = 0; i < S.size(); i++) {
		cntS[i] = (S[i] == 'A');
		if (i > 0) cntS[i] += cntS[i - 1];
	}
	for (int i = 0; i < T.size(); i++) {
		cntT[i] = (T[i] == 'A');
		if (i > 0) cntT[i] += cntT[i - 1];
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d; a--; b--; c--; d--;
		int A = cntS[b];
		if (a > 0) A -= cntS[a - 1];
		int lenS = A + (b - a + 1 - A) * 2;
		A = cntT[d];
		if (c > 0) A -= cntT[c - 1];
		int lenT = A + (d - c + 1 - A) * 2;
		if (abs(lenS - lenT) % 3 == 0) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

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

int n,p[100010],cnt,vis[100010];
long long a[100010],l[100010],r[100010],ans;//lÎªÔ­Êý£¬rÎªÓël³Ë»ýÎªÍêÈ«Á¢·½ÊýµÄÊý 
map<long long,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%lld",&a[i]);
	vis[1]=1;
	for(int i=2;i<=2200;++i)
	{
		if(!vis[i])
		p[++cnt]=i;
		for(int j=1;j<=cnt&&p[j]*i<=2200;++j)
		{
			vis[p[j]*i]=1;
			if(i%p[j]==0)
			break;
		}
	}
	for(int i=1;i<=n;++i)
	{
		long long ji=a[i],qwq=1,ovo=1;
		for(int j=1;j<=cnt;++j)
		{
			int gg=0;
			while(ji%p[j]==0)
			{
				++gg;
				ji/=p[j];
			}
			gg%=3;
			if(gg)
			{
				for(int k=gg;k<3;++k)
				{
					qwq*=p[j];
					if(qwq>1e10)
					qwq=0;
				}
				while(gg)
				{
					ovo*=p[j];
					--gg;
				}
			}
		}
		l[i]=ovo*ji;
		mp[l[i]]++;
		r[i]=qwq;
		long long qaq=(long long)sqrt(ji);
		if(qaq*qaq!=ji)
		{
			if(ji*r[i]<=1e10)
			r[i]*=ji;
			else
			r[i]=0;
			if(ji*r[i]<=1e10)
			r[i]*=ji;
			else
			r[i]=0;
		}
		else
		{
			if(qaq*r[i]<=1e10)
			r[i]*=qaq;
			else
			r[i]=0;
		}
	}
	for(int i=1;i<=n;++i)
	{
		if(l[i]==1)
		continue;
		ans+=max(mp[l[i]],mp[r[i]]);
		mp[l[i]]=0;
		mp[r[i]]=0;
	}
	if(mp[1])
	ans++;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12928
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    idx_start = 0
    sum_a = 0
    ans = 0
    cnt = 0
    len_a = len(a)

    for i in range(1, len_a):
        if a[idx_start] < a[i]:
            ans += (cnt * a[idx_start]) - sum_a
            idx_start = i
            sum_a = 0
            cnt = 0
        else:
            sum_a += a[i]
            cnt += 1
            if i == len_a - 1:
                ans += (cnt * a[idx_start]) - sum_a
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 104252
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)

int main() {
    int N; cin >> N;
    vector<int> A(N), B;
    map<int, int> mp;
    rep(i, N) cin >> A[i];
    B = A;
    sort(B.begin(), B.end());
    rep(i, N) mp[B[i]] = i;
    
    int cnt = 0;
    rep(i, N) if(i % 2 == 0) {        
        cnt += mp[A[i]] % 2;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " "<< a<<  " " << b <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

bool isOK(int index, int key, vector<ll>& a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    int a, b , c; cin >> a >> b >> c;
    if (b -a == c - b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


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

int main(void)
{
    string s;
    string res="Yes";
    int l;
    cin >> l;
    cin >> s;
    l = s.size();
    if(l%2 ==1){
        res = "No";
    }else{
        for(int i=0 ; i< (int)l/2; i++){
            if(s[i] != s[(int)l/2+i]){
                res = "No";
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3612
s = input()
t = input()

s_len =len(s)
t_len =len(t)
count = 0
ans = []



for i in range(s_len - t_len + 1):
    for j in range(t_len):
        if s[i:t_len + i][j] != t[j]:
            count += 1
    ans.append(count)
    count = 0

min_ans = min(ans)
print(min_ans)



Measured memory_bytes: 9004
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
typedef long long ll;

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

    if(a%x==0){
        cout << b/x - a/x + 1 << endl;
        return 0;
    }
    cout << b/x - a/x << endl;
}

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

typedef long long ll;

const int Maxn = 1005;
const int Maxm = Maxn * Maxn / 2;
const int Maxb = 50;

int n, k;
int a[Maxn];
ll mask[Maxm];
int mlen;
bool tk[Maxm];
ll res;

int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        ll sum = 0;
        for (int j = i; j >= 0; j--) {
            sum += a[j];
            mask[mlen++] = sum;
        }
    }
    for (int i = Maxb - 1; i >= 0; i--) {
        int has = 0;
        for (int j = 0; j < mlen; j++) if (!tk[j])
            if (mask[j] & 1ll << ll(i)) has++;
        if (has >= k) {
            res |= 1ll << ll(i);
            for (int j = 0; j < mlen; j++) if (!tk[j])
                if (!(mask[j] & 1ll << ll(i))) tk[j] = true;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 4608
#atcoder2
N = int(input())
Z = list(map(int,input().split()))
#S=input()

total = 0
subtotal = 0
slist = []

for i in range(N):
    total = Z[i] + total

for i in range(N):
    subtotal = Z[i] + subtotal
    s = total - subtotal
    slist.append(abs(s-subtotal))

slist.sort()

print(slist[0])

Measured memory_bytes: 3064
import math

a, b, theta_deg = map(int, input().split())
theta_rad = math.radians(theta_deg)

h = b * math.sin(theta_rad)
s = a * h / 2
c = (a ** 2 + b ** 2 - 2 * a * b * math.cos(theta_rad)) ** 0.5
l = a + b + c

print(s)
print(l)
print(h)


Measured memory_bytes: 5724
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

string s;

int main() {
    cin >> s;
    int slen = s.length();
    vector<string> nsvec;
    string ns = "";
    s = s + "#";
    int ch = 0;
    for(int i = 0; i < slen; ) {
        if(s[i] == 'B') {
            if(s[i+1] == 'C') {
                ns.push_back('D');
                i += 2;
            }else {
                ns.push_back(s[i]);
                i++;
            }
        }else {
            ns.push_back(s[i]);
            i++;
        }
    }

    ns = ns + "#";

    int nslen = ns.size();
    nsvec.push_back("");
    for(int i = 0; i < nslen; ++i) {
        if(ns[i] == 'A') nsvec[ch].push_back('A');
        else if(ns[i] == 'D') nsvec[ch].push_back('D');
        else {
            if((int)nsvec[ch].size() != 0) {
                ch++;
                nsvec.push_back("");
            }
        }
    }

    ll cnt = 0;
    for(int i = 0; i < ch; ++i) {
        string cns = nsvec[i];
        reverse(cns.begin(), cns.end());
        int clen = cns.length();
        ll cc = 0;
        // cout << cns << endl;
        for(int j = 0; j < clen; ++j) {
            if(cns[j] == 'D') cc++;
            else cnt += cc;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 5856
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int ans=0;
  rep(i, n-2){
  	if(s.substr(i, 3)=="ABC")ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        String[] a = new String[N];

        for(int i=0; i<N; i++){
            a[i] = sc.next();
        }
        if(N==1){
            System.out.println(a[0]);
            return;
        }
        String[] ans = new String[N];
        for(int i=0; i<N/2; i++){
            if(N%2==0){
                ans[N / 2 + i] = a[2 * i];
                ans[N / 2 - i - 1] = a[2 * i + 1];
            }
            else{
                ans[N / 2 - i] = a[2 * i];
                ans[N / 2 + 1 + i] = a[2 * i + 1];
                if(i==N/2-1){
                    ans[0] = a[N - 1];
                }
            }
        }
        for(int i=0; i<N; i++){
            if(i==0){
                System.out.print(ans[i]);
            }
            else{
                System.out.print(" " + ans[i]);
            }
        }
    }
}

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

int main()
{
    string s; cin>>s;
    int k; cin>>k;
    int n=s.size();

    set<string, greater<string>> q;
    for(int i=0; i<n; ++i) {
        string t=string(1, s[i]);
        for(int j=1; j<=n-i; ++j) {
            q.insert(t);
            if (q.size()>k) q.erase(begin(q));
            t+=s[i+j];
        }
    }
    cout<<*begin(q)<<endl;
}


Measured memory_bytes: 256
// I think of what the world could be, A vision of the one I see, A million dreams is all it's gonna take

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 2e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10;

int a[maxn], b[maxn], arr[maxn];
vector<ll> vec;
ll dp[40];

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

    int n, t;
    cin >> n >> t;
    for(int i = 0; i < n; i++){
	cin >> a[i] >> b[i];
	a[i]++;
	b[i]+= a[i];	
    }
    for(int i = 0; i < n; i++){
	if(a[i] == 1){
	    vec.PB(b[i]);
	    swap(a[i], a[n-1]);
	    swap(b[i], b[n-1]);
	    --n;
	    --i;
	}
    }
    sort(vec.begin(), vec.end());
    for(int i = 1; i < sz(vec); i++)
	vec[i]+= vec[i-1];
    iota(arr, arr+n, 0);
    sort(arr, arr+n, [&](int i, int j){ return 1ll * b[j] * (a[i]-1) > 1ll * b[i] * (a[j]-1); });

    fill(dp, dp+40, inf);
    dp[0] = 0;    
    for(int i = 0; i < n; i++){
	for(int j = 39; j > 0; j--){
	    dp[j] = min(dp[j], 1ll * a[ arr[i] ] * dp[j-1] + b[ arr[i] ]);	    
	}
    }
    int ans = 0;
    for(int i = 0; i < 40; i++){
	int pt = 0;
	while(pt < sz(vec) && dp[i] + vec[pt] <= t)
	    pt++;
	if(dp[i] <= t)
	    ans = max(ans, i+pt);
    }
    return cout << ans << endl, 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871;
const int N = 2e5 + 10;
lli nums[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> nums[i];

    sort(nums + 1, nums + n + 1);
    reverse(nums + 1, nums + n + 1);

    lli ans = 0;
    multiset<pair<lli, lli>> pars;
    pars.insert({nums[1], nums[1]});
    for(int i = 2; i <= n; i++) {
        auto j = *pars.rbegin();
        ans += j.first;
        pars.erase(pars.find(j));
        pars.insert({nums[i], j.first});
        pars.insert({nums[i], j.second});
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 17708
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] a = {sc.nextInt(), sc.nextInt(), sc.nextInt()};
        Arrays.sort(a);
        if (a[0] + a[1] == a[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

const int INF = 1e9 + 7;

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

    int west = 0, east = 0;
    std::vector<int> westgazers(n, 0), eastgazers(n, 0);
    for(int i = 1; i < n; ++i){
        if('W' == s.at(i - 1)){
            ++west;
        }
        westgazers.at(i) = west;

        if('E' == s.at(n - i)){
            ++east;
        }
        eastgazers.at(n - 1 - i) = east;
    }

    int min = INF;
    for(int i = 0; i < n; ++i){
        min = std::min(min, westgazers.at(i) + eastgazers.at(i));
    }

    std::cout << min << std::endl;

    return 0;
}

Measured memory_bytes: 3068
N=int(input())
sdic={}

for s in range(N):
  s=input()
  if s in sdic:
    sdic[s]+=1
  else:
    sdic[s]=1

max_s=0
for s in sdic:
  if sdic[s]>max_s:
    max_s=sdic[s]
    
#print(max_s)
slist=[]
for s in sdic:
  if sdic[s]==max_s:
    slist.append(s)
    
slist.sort()
#print(slist)
for s in slist:
  print(s)

Measured memory_bytes: 32096
n = int(input())
dat = map(int, input().split())
dat = list(dat)
buf = [0] * 100100
buf[0] = 3
res = 1
M = (10**9 + 7)
for i in range(n):
    x = dat[i]
    res *= buf[x]
    res %= M
    buf[x] -= 1
    buf[x+1] += 1
print(res)



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

Int MOD = 1e9+7;

int main(){
    int H, W;
    vector<string> A(1010);

    cin >> H >> W;
    rep(i,H) cin >> A[i];

    // dp[i][j]: マス(i,j)への経路の総数
    vector<vector<Int>> dp(1010, vector<Int>(1010, 0));
    dp[0][0] = 1;

    rep(i,H) rep(j,W){
        if(A[i][j] == '#') continue;

        if(i != 0) dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
        if(j != 0) dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
    }

    cout << dp[H-1][W-1] << endl;
    
}

Measured memory_bytes: 9344
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n = Scanf.sscanf (read_line ()) "%d" (
        fun n -> 
                n
)

let sorted = Str.split (Str.regexp " ") (read_line ())
             |> List.map float_of_string
             |> List.fast_sort compare

let rec f lst =
        match lst with
                  [] -> 0.0
                | first :: [] -> 
                        first
                | first :: second :: rest -> 
                        let v = (first +. second) /. 2.0 in
                        let rlst = List.fast_sort compare ([v] @ rest) in
                                f rlst


let () = 
        f sorted
        |> Printf.printf "%f\n"


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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int ret = 0;

    char array[6][6];

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> array[i][j];
        }
    }

    int n = h;

    vector< vector<int> > SC(64);
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                SC[bit].push_back(i);
            }
        }

        //cout << bit << ": {";
        for (int i = 0; i < (int)SC[bit].size(); ++i) {
            //cout << SC[bit][i] << " ";
        }
        //cout << "}" << endl;
    }


    n = w;

    vector< vector<int> > SR(64);
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                SR[bit].push_back(i);
            }
        }

        //cout << bit << ": {";
        for (int i = 0; i < (int)SR[bit].size(); ++i) {
            //cout << SR[bit][i] << " ";
        }
        //cout << "}" << endl;
    }

    for(int i = 0; i < 1<<h; i++) {
        for(int j = 0; j < 1<<w; j++) {

            char array_tmp[6][6];
            for(int x = 0; x < h; x++) {
                for(int y = 0; y < w; y++) {
                    array_tmp[x][y] = array[x][y];
                }
            }

            for(int x = 0; x < h; x++) {
                for(int y = 0; y < w; y++) {
                    //cout << array_tmp[x][y];
                }
                //cout << endl;
            }
            //cout << endl;
            

            for (int x = 0; x < (int)SC[i].size(); ++x) {
                for(int a = 0; a < w; a++) {
                    array_tmp[SC[i][x]][a] = 'r';
                }
            }

            for (int y = 0; y < (int)SR[j].size(); ++y) {
                for(int b = 0; b < h; b++) {
                    array_tmp[b][SR[j][y]] = 'b';
                }
            }

            int count = 0;
            for(int x = 0; x < h; x++) {
                for(int y = 0; y < w; y++) {
                    //cout << array_tmp[x][y];
                    if(array_tmp[x][y] == '#') {
                        count++;
                    }
                }
                //cout << endl;

            }
            //cout << endl;
            if(count == k) {
                ret++;
                //cout << "UP" << endl;
            }

        }
    }

    cout << ret << endl;

    

}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int ans=0;
			int b=in.nextInt();
			int r=in.nextInt();
			int g=in.nextInt();
			int c=in.nextInt();
			int s=in.nextInt();
			int total=in.nextInt();
			if((b|r|g|c|s|total)==0)
				return;
			int my=100;
			my+=b*15+r*15+b*65+r*39+g*4+c*(-1);
			total=total-s-b*5-r*3-g-c;
			ans=my-total*3;
			System.out.println(ans);
		}
	}
}

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

int main(){
 long long n, z, cnt=0, p, q;
 cin >> n;
 z=n%100;
 while(1){
  if(z>4){
    cnt=cnt+z/5;
    z=z%5;
  }
  else if(z>3){
    cnt=cnt+z/4;
    z=z%4;
  }
  else if(z>2){
    cnt=cnt+z/3;
    z=z%3;
  }
  else if(z>1){
    cnt=cnt+z/2;
    z=z%2;
  }
  else if(z>0){
    cnt+=z;
    break;
  }
  else break;
 }
 p=n/100;
 if(cnt==0){
  printf("1");
  return 0;
 }
 q=p/cnt;
 //printf("%d %d\n", p, cnt);
 if(q==0) printf("0");
 else printf("1");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
typedef long long LL;
int A[20],n;
LL f(int l,int r,int x,int y){
    if(r-l<=1)return 0;
    LL p=1e18;
    for(int i=l+1;i<r;++i)
    p=std::min(p,f(l,i,x,x+y)+f(i,r,x+y,y)+(LL)(x+y)*A[i]);
    return p;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",A+i);
    printf("%lld",f(0,n-1,1,1)+*A+A[n-1]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int b=0;
  string s;
  cin>>s;
  if(s.size()%2==0){
    s.pop_back();
    s.pop_back();
  }else{
    s.pop_back();
  }
  while(s.size()>0){
    for(int i=0;i<s.size()/2;i++){
      if(s[i]==s[i+s.size()/2]){
        b++;
      }
    }
    if(b==s.size()/2){
      cout<<s.size()<<endl;
      return 0;
    }else{
      b=0;
      s.pop_back();
      s.pop_back();
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int A, B;
	scanf("%d %d", &A, &B);
	int res = 0;
	int t = 1;
	for (int i = 0; i < B; i++) {
		if (t >= B) {
			res = i;
			break;
		}
		t += A - 1;
	}
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)
prefs = Array.new(n+1).map{{}}
codes = Array.new(m)
m.times do |i|
  p, y = gets.split.map(&:to_i)
  prefs[p][i] = y
end
prefs.each_with_index do |pref, pref_no|
  city_no = 1
  pref.sort{|a,b| a[1]<=>b[1]}.each do |i, y|
    codes[i] = sprintf("%06d%06d", pref_no, city_no)
    city_no += 1
  end
end

codes.each{puts _1}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int H,W,K;
char mp[6][6];
int res;

void input() {
	cin>>H>>W>>K;
	for(int i=0; i<H; i++) for(int j=0; j<W; j++) {
		cin>>mp[i][j];
	}
}

void solve() {
	for(int hbit=0; hbit<(1<<H); hbit++) for(int wbit=0; wbit<(1<<W); wbit++) {
		int k=0;
		for(int h=0; h<H; h++) {
			if((hbit>>h) & 1) continue;
			for(int w=0; w<W; w++) {
				if((wbit>>w) & 1) continue;
				if(mp[h][w]=='#') k++;
			}
		}
		if(k==K) res++;
	}
	cout<<res<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll ind[200100];

int main() {
    ll N;
    cin >> N;
    rep(i, N) {
        ll a;
        cin >> a;
        ind[a] = i;
    }
    set<ll> st;
    st.insert(-1);
    st.insert(N);
    ll ans = 0;
    for (ll i=1; i<=N; ++i) {
        st.insert(ind[i]);
        ll l = *(--st.find(ind[i]));
        ll r = *(++st.find(ind[i]));
        //cout << ind[i] << " " << l << ", " << ind[r] << " " << r << endl;
        ans += i * (ind[i]-l) * (r-ind[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n;
    int cnt=0;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    for(int i=1; i<=n; i++){
        if(i%2 == 1){
            if(a[i-1]%2 == 1) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    init_comb();

    int n, m, k;
    std::cin >> n >> m >> k;

    long long comb_value = comb(n * m - 2, k - 2);

    long long ans = 0;
    for (int x_distance = 1; x_distance < m; x_distance++) {
        ans += (m - x_distance) * n * n % mod * comb_value % mod * x_distance % mod;
        ans %= mod;
    }

    for (int y_distance = 1; y_distance < n; y_distance++) {
        ans += (n - y_distance) * m * m % mod * comb_value % mod * y_distance % mod;
        ans %= mod;
    }

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


Measured memory_bytes: 12160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<int> P(N), partial;
    REP(i, N) {
        cin >> P[i];
        P[i]--;
    }

    vector<int> Q(N);
    REP(i, N) Q[P[i]] = i;

    int ans = 0, length = 0;
    length = 1;
    FOR(i, 1, N-1)
        if(Q[i] > Q[i-1]) length++;
        else {
            if(length > ans) ans = length;
            length = 1;
        }
    
    if(length > ans) ans = length;
    ans = N - ans;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
 
#include <iostream>
 
static void print_ints(const int as[], const unsigned int n) {
  const char* sep = "";
  for (unsigned int i = 0; i < n; ++i) {
    std::cout << sep << as[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static void insert(int as[], const unsigned int i) {
  // as[0..i-1] is sorted
  const int asi = as[i];
  unsigned int j = i;
  while (j > 0 && asi < as[j-1]) {
    as[j] = as[j-1];
    --j;
  }
  as[j] = asi;
}

void insertion_sort(int as[], const unsigned int n) {
  for (unsigned int i = 1; i < n; ++i) {
    print_ints(as, n);
    insert(as, i);
  }
}
 
int main(void) {
  unsigned int n;
  std::cin >> n;
  int as[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> as[i];
  }

  insertion_sort(as, n);
  print_ints(as, n);
  return 0;
}
// end

Measured memory_bytes: 1168
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N;cin>>N;
    vector<ll> a(N);
    REP(i,N)cin>>a[i];
    ll sm=0;REP(i,N)sm^=a[i];
    vi b(N);REP(i,N)b[i]=0;
    REP(i,N){
        b[i]=sm^a[i];
    }
    REP(i,N){
        cout<<(b[i])<<" ";
    }cout<<"\n";
}

Measured memory_bytes: 6408
import java.util.BitSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t;
		BitSet time = new BitSet();
		while ((t = in.nextInt()) > 0) {
			int n = in.nextInt();
			time.clear();
			while (n-- > 0) {
				time.set(in.nextInt(), in.nextInt());
			}
			int size = time.cardinality();
			if (size >= t) {
				System.out.println("OK");
			} else {
				System.out.println(t - size);
			}
		}
	}
}

Measured memory_bytes: 23256
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int a,b,c;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();

		int count = 0;
		for ( int div = a; div <= b; div++) {
			if ( c % div == 0 )
				count++;
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 26324
package main

import "fmt"

func main() {
	var n, a, b, tmp int
	output := 0
	fmt.Scanf("%d %d %d", &n, &a, &b)
	for i := 1; i <= n; i++ {
		tmp = someSum(i)
		if (tmp >= a) && (tmp <= b) {
			output += i
		}
	}
	fmt.Println(output)
}

// 各桁の合計値を求める。
func someSum(d int) int {
	out := 0
	for d >= 1 {
		out += d % 10
		d /= 10
	}
	return out
}


Measured memory_bytes: 512
k = int(input())

if k%2 == 0 or k%5 == 0:
    print(-1)
else:
    n = 0
    cnt = 0
    while 1:
        n *= 10
        n += 7
        cnt += 1
        n %= k
        if n == 0:
            break
    print(cnt)

Measured memory_bytes: 62980