akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<map<int, int>> edge(N);

    REP(m, M) {
        int l, r, d;
        cin >> l >> r >> d;
        --l; --r;
        edge[l][r] = d;
        edge[r][l] = -d;
    }


    map<int, int> pos;
    // set<int> seen;
    set<int> done;

    bool ok = true;
    REP(n, N) {
        if (done.count(n)) continue;

        pos[n] = 0;
        done.insert(n);

        set<int> bag;
        bag.insert(n);

        while(!bag.empty()) {
            set<int> new_bag;

            for(auto p: bag) {
                // cerr << "p: " << p << endl;
                for(auto nei: edge[p]) {
                    // cerr << "  " << nei.first << endl;
                    auto nei_d = nei.second;
                    auto new_pos = pos[p] + nei_d;
                    if (pos.count(nei.first)) {
                        if (pos[nei.first] != new_pos) {
                            ok = false;
                        }
                    } else {
                        pos[nei.first] = new_pos;
                        // cerr << nei.first << "'s pos: " << new_pos << endl;
                    }
                    if (!done.count(nei.first)) {
                        new_bag.insert(nei.first);
                    }
                }
                done.insert(p);
            }
            bag = new_bag;
        }
    }

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

    return 0;
}


Measured memory_bytes: 40832
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int main(){

	string X;

	char MA[55][55];
	int x,y;

	while(1){
		cin>>x>>y;if(x==0&&y==0)break;

		for(int i=0;i<y;i++)
		{cin>>X;
		for(int j=0;j<X.size();j++)
			MA[i][j]=X[j];}

		int map[55][55]={};
		int G=0;

		for(int i=0;i<y;i++)
		{G++;
		for(int j=0;j<x;j++)
		{if(MA[i][j]=='.'){
			if(j>0&&MA[i][j-1]!='.')G++;
			map[i][j]=G;
		}
		
		if(MA[i][j]=='B'){map[i][j]=7001;}
		if(MA[i][j]=='W'){map[i][j]=7005;}
		}}
		for(int i=0;i<y;i++)
		for(int j=0;j<x;j++)
		{if(map[i][j]<7000){
			if(map[i][j]!=map[i+1][j]&&map[i+1][j]<7000){
				int P=map[i+1][j];
				for(int I=0;I<y;I++)
					for(int J=0;J<x;J++)
						if(map[I][J]==P)map[I][J]=map[i][j];
			}
			
		}
		}

		int F[7000]={};int cnt[7010]={};
		for(int i=0;i<y;i++)
		for(int j=0;j<x;j++)
			{

				cnt[map[i][j]]++;
				if(map[i][j]==7001){
					if(i>0&&map[i-1][j]<7000){if(F[map[i-1][j]]==0||F[map[i-1][j]]==5)F[map[i-1][j]]+=1;}
					if(map[i+1][j]<7000){if(F[map[i+1][j]]==0||F[map[i+1][j]]==5)F[map[i+1][j]]+=1;}
					if(j>0&&map[i][j-1]<7000){if(F[map[i][j-1]]==0||F[map[i][j-1]]==5)F[map[i][j-1]]+=1;}
					if(map[i][j+1]<7000){if(F[map[i][j+1]]==0||F[map[i][j+1]]==5)F[map[i][j+1]]+=1;}
				}

				else if(map[i][j]==7005){
					if(i>0&&map[i-1][j]<7000){if(F[map[i-1][j]]==0||F[map[i-1][j]]==1)F[map[i-1][j]]+=5;}
					if(map[i+1][j]<7000){if(F[map[i+1][j]]==0||F[map[i+1][j]]==1)F[map[i+1][j]]+=5;}
					if(j>0&&map[i][j-1]<7000){if(F[map[i][j-1]]==0||F[map[i][j-1]]==1)F[map[i][j-1]]+=5;}
					if(map[i][j+1]<7000){if(F[map[i][j+1]]==0||F[map[i][j+1]]==1)F[map[i][j+1]]+=5;}
				}

		}
			
		int B=0,W=0;
		for(int i=0;i<7000;i++)
		{if(F[i]==1)B+=cnt[i];
		else if(F[i]==5)W+=cnt[i];
		}
		cout<<B<<" "<<W<<endl;


/*
		
		for(int i=0;i<y;i++)
		{cout<<endl;
		for(int j=0;j<x;j++)
			cout<<map[i][j];}

			*/
			}
	return 0;

}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;cin>>N;
	int V[N],C[N];int sum=0;
	for(int i=0;i<N;i++){
		cin>>V[i];
	}for(int i=0;i<N;i++){
		cin>>C[i];
	}for(int i=0;i<N;i++){
		if(V[i]>C[i]){
			sum+=V[i]-C[i];
		}
	}cout<<sum<<endl;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto&& x:a)cin >> x;
  set<int> b(a.begin(), a.end());
  if(a.size() == b.size())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

using namespace std;

const long long MAX = 1e5 ;
const long long mod = 1e9 + 7ll ;
long long dp[MAX][105][2][2] ;
vector<long long>num ;
long long d ;

long long solve(long long idx , long long rem , bool t , bool t2)
{
    if(idx == num.size())
    {
        if(rem == 0 && t2 == 1)
            return 1ll ;
        return 0ll ;
    }
    long long &ret = dp[idx][rem][t][t2] ;
    if(ret != -1)
        return ret ;
    ret = 0 ;
    long long LMT ;
    if(t == 0)
        LMT = num[idx] ;
    else
        LMT = 9 ;
    for(long long i = 0 ; i <= LMT ; ++i)
    {
        long long nt = t ;
        long long nt2 = t2 ;
        if(t == 0 && i < LMT)
            nt = 1 ;
        if(t2 == 0 && i != 0)
            nt2 = 1ll ;
        ret = (ret + solve(idx+1 , (rem + i) % d , nt , nt2)) % mod;
        ret = (ret % mod) ;
    }
    return (ret % mod) ;
}

long long run(string s)
{
    for(long long i = 0 ; i < s.size() ; ++i)
        num.push_back(s[i] - '0') ;
    memset(dp , -1 , sizeof(dp));
    long long ans = solve(0 , 0 , 0 , 0);
    return ans ;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s ;
    cin>>s ;
    cin>>d ;
    return cout<<run(s)<<"\n" , 0 ;
}


Measured memory_bytes: 329600
import numpy as np
#import functools
#import operator
from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy

#N = int(input())
H,W,K= map(int,input().split())
h=[x for x in range(H)]
w=[x for x in range(W)]
ans=0
#P = list(map(int,input().split()))
#S = str(input())
#T = str(input())
l=[]
for i in range(H):
    S = str(input())
    S=list(S)
    for i in S:
        l.append(i)
l=np.array(l)
l=l.reshape((H,W))
for i in range(H):
    for v in comb(h,i):
        for j in range(W):
            for b in comb(w, j):
                o=0
                #print(v,b)
                L=l.copy()
                for n in v:
                    L[n]=0
                for m in b:
                    L[:,m]=0
                #print(L)
                o=np.count_nonzero(L=='#')
                if o==K:
                    ans+=1
print(ans)


Measured memory_bytes: 27072
#include<stdio.h>

int main(){
        int n,m = 0;
        while( scanf("%d",&n)!=EOF){
                if(n > 50)
                        continue;
                for(int i = 0; i < 10;i++){
                        for(int j = 0; j < 10; j++){
                                for(int k = 0; k < 10;k++){
                                        for(int l = 0; l < 10;l++){
                                                if(i + j + k + l == n){
                                                        m += 1;
                                                }
                                        }
                                }
                        }
                }
                printf("%d\n",m);
                m = 0;
        }
        return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int A,B,T;
    cin >> A >> B >> T;
    int ans=0;
    for(int i=A; i<=T; i+=A){
        ans+=B;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  long long h[N];
  long long max_cont = 0;
  long long pivot = 0;
  long long i;
  cin >> h[0];
  for (i = 1; i < N; ++i) {
    cin >> h[i];
    if (h[i - 1] < h[i]) {
      max_cont = max(max_cont, i - pivot - 1);
      pivot = i;
    }
  }

  max_cont = max(max_cont, i - pivot - 1);

  cout << max_cont << endl;

  return 0;
}

Measured memory_bytes: 1024
s = list(input())
s10 = ['1' if i%2 != 0 else '0' for i in range(len(s))]
s01 = ['0' if i%2 != 0 else '1' for i in range(len(s))]
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
  if s[i] == s10[i]:
    cnt1 += 1
  if s[i] == s01[i]:
    cnt2 += 1
print(min(cnt1,cnt2))

Measured memory_bytes: 5540
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>

using namespace std;
int main(void){
    while(true){
        int tatesen,yokosen,kensa;
        cin>>tatesen>>yokosen>>kensa;
        if(tatesen==0&&yokosen==0&&kensa==0)break;
        int go[yokosen],to[yokosen],level[yokosen],big=0,min=10001;
        for(int s=0;s<yokosen;s++){
            cin>>level[s]>>go[s]>>to[s];
            if(big<level[s])big=level[s];
            if(min>level[s])min=level[s];
        }
        for(int s=0;s<yokosen;s++){
            for(int i=s+1;i<yokosen;i++){
                if(level[s]<level[i]){
                    int work;
                    work=level[s];
                    level[s]=level[i];
                    level[i]=work;
                    
                    work=go[s];
                    go[s]=go[i];
                    go[i]=work;
                    
                    work=to[s];
                    to[s]=to[i];
                    to[i]=work;
                }
            }
        }
        int iti=kensa,memo=0,i;
        for(int s=big;s>=min;s--){//高さを1ランクずつ下げていく
            for(i=memo;i<1001;i++){
                if(level[i]!=s)break;
                if(iti==go[i]){
                    iti=to[i];
                }else if(iti==to[i]){
                    iti=go[i];
                }
                memo=i+1;
            }
        }
        cout<<iti<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	bool can = true;
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	rep(i,0,n-1){
		if(a[i]==a[i+1]){
			can = false;
			break;
		}
	}
	if (can)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

void fetch_card(const int card[][3], int value, bool hit[][3])
{
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      if (card[i][j] == value)
      {
        hit[i][j] = true;
      }
    }
  }
}

bool is_bingo(const bool hit[][3])
{
  for (int i = 0; i < 3; i++)
  {
    if (hit[i][0] && hit[i][1] && hit[i][2])
    {
      return true;
    }
    if (hit[0][i] && hit[1][i] && hit[2][i])
    {
      return true;
    }
  }
  if (hit[0][0] && hit[1][1] && hit[2][2])
  {
    return true;
  }
  if (hit[0][2] && hit[1][1] && hit[2][0])
  {
    return true;
  }
  return false;
}

int main()
{
  int card[3][3] = {{}};
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> card[i][j];
    }
  }
  int n;
  cin >> n;
  bool hit[3][3] = {{}};
  for (int i = 0; i < n; i++)
  {
    int value;
    cin >> value;
    fetch_card(card, value, hit);
  }
  if (is_bingo(hit))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

double getAngle (double H, double M)
{
    double Hangle = H * 30 + M * 0.5;
    double Mangle = M * 6.0;
    double res = max(Hangle,Mangle) - min(Hangle,Mangle);
    res = min(res, 360.0 - res);
    return res / 360.0 * 2.0 * M_PI;
}

int main ()
{   
    double A,B,H,M;
    double res;
    double angle;

    cin >> A >> B >> H >> M;

    angle = getAngle (H,M);
    
    res = pow(A,2) + pow(B,2) - 2.0 * A * B * cos(angle);
    res = sqrt (res);
    printf("%.9lf\n",res);

   return 0;
}

Measured memory_bytes: 4000
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


int main() {
	int N; cin >> N;
	string starts;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		a--;
		starts.push_back(a + '0');
	}
	string goals; 
	for (int i = 0; i < N; ++i) {
		goals.push_back(i + '0');
	}
	vector < vector<string>>fromstarts(5);
	fromstarts[0].emplace_back(starts);
	vector< vector<string>>fromgoals(5);
	fromgoals[0].emplace_back(goals);
	for (int i = 0; i < 4; ++i) {
		vector<string>aset;
		for (auto v : fromstarts[i]) {
			for (int l = 0; l < N; ++l) {
				for (int r = l+2; r <= N; ++r) {
					string rev = v.substr(l, r - l);
					reverse(rev.begin(), rev.end());
					string next = v.substr(0, l) + rev + (v.substr(r, N - r));
					aset.emplace_back(next);
				}
			}
		}
		sort(aset.begin(), aset.end());
		aset.erase(unique(aset.begin(), aset.end()), aset.end());
		fromstarts[i + 1] = aset;
	}
	for (int i = 0; i < 4; ++i) {
		vector<string>aset;
		for (auto v : fromgoals[i]) {
			for (int l = 0; l < N; ++l) {
				for (int r = l + 2; r <= N; ++r) {
					string rev = v.substr(l, r - l);
					reverse(rev.begin(), rev.end());
					string next = v.substr(0, l) + rev + (v.substr(r, N - r));
					aset.emplace_back(next);
				}
			}
		}
		sort(aset.begin(), aset.end());
		aset.erase(unique(aset.begin(), aset.end()), aset.end());
		fromgoals[i + 1] = aset;
	}
	int ans = 9;
	for (int s = 0; s < 4; ++s) {
		for (int t = 0; t < 4; ++t) {
			vector<string>sames;
			set_intersection(fromstarts[s].begin(), fromstarts[s].end(), fromgoals[t].begin(), fromgoals[t].end(), inserter(sames, sames.end()));
			if (!sames.empty()) {
				ans = min(ans, s+t);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 96184
a, b, x = map(int, input().split())

if a == 0:
    pa = 0
else:
    pa = (a - 1) // x + 1

if b == 0:
    pb = 1
else:
    pb = b // x + 1

print(pb - pa)


# 0 1 2 3 4 5
# ^


Measured memory_bytes: 9032
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N,Y;
  cin>>N>>Y;

  rep(i,N+1){
    rep(j,N+1){
      if(i+j>N) continue;
      int k=N-i-j;
      if(i*1000+j*5000+k*10000==Y){
        cout<< k<<" "<<j<<" "<<i<<"\n";
        return;
      }
    }
  }
  cout<< -1<<" "<<-1<<" "<<-1<<"\n";


}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map(&:to_i)

mp = Hash.new(0)
as.each do |a|
    mp[a] += 1
end

ans = 0
mp.keys.sort.reverse.each do |a|
    30.downto(0) do |i|
        break if mp[a] == 0
        b = (1<<i) - a
        next if mp[b] == 0
        if a == b
            add = mp[a]/2
        else
            add = mp[a] < mp[b] ? mp[a] : mp[b]
        end
        ans += add
        mp[a] -= add
        mp[b] -= add
    end
end
puts ans

Measured memory_bytes: 37484
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  lint N;
  cin>>N;
  if(N%2==1){
    cout<<0<<endl;
    return 0;
  }
  lint ans=0;
  lint d=10;
  N/=2;
 for(lint i=5;i<1e18+1;i*=5){
    ans+=N/i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#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 n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  string result(s);
  result[k - 1] = tolower(result[k - 1]);
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools

def rdp_connect() -> bool:
    global h, w, e
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        return False
    e = [list(map(int, input().split())) for _ in range(h)]
    return True

def rdp_scan(x1: int, y1: int, x2: int, y2: int) -> int:
    edges = []
    edges.extend([e[j][x1] for j in range(y1, y2 + 1)])
    edges.extend([e[j][x2] for j in range(y1, y2 + 1)])
    edges.extend([e[y1][i] for i in range(x1 + 1, x2)])
    edges.extend([e[y2][i] for i in range(x1 + 1, x2)])
    inner = [e[j][i] for j, i in itertools.product(range(y1 + 1, y2), range(x1 + 1, x2))]
    edges_min = min(edges)
    if edges_min - max(inner) <= 0:
        return 0
    return sum(map(lambda e: edges_min - e, inner))

if __name__ == '__main__':
    while rdp_connect():
        best = 0
        for y1, x1 in itertools.product(range(h), range(w)):
            for y2, x2 in itertools.product(range(y1 + 2, h), range(x1 + 2, w)):
                best = max(best, rdp_scan(x1, y1, x2, y2))
        print(best)

Measured memory_bytes: 7768
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n;
  cin>>n;
  vector<Int> A(n);
  cin>>A;
  for(int i=0;i<n;i++) A[i] -= (i+1);

  auto calc = [&](Int b){
    Int res = 0;
    for(Int i=0;i<n;i++) {
      res += abs(A[i] - b);
    }
    return res;
  };

  sort(A.begin(), A.end());
  Int ans = calc(A[n/2]);
  cout<<ans<<endl;
  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


void positive(int N) {
    stack<int> st;

    int x = N;
    st.push(x % 2);
    x /= 2;
    while (x) {
        int r = x % 4;
        x /= 4;
        switch (r) {
            case 0: st.push(0); st.push(0); break;
            case 1: st.push(1); st.push(1); break;
            case 2: st.push(0); st.push(1); break;
            case 3: st.push(1); st.push(0); x += 1; break;
        }
    }

    while (st.top() == 0) st.pop();

    while (!st.empty()) {
        cout << st.top(); st.pop();
    }
    cout << endl;
}

void negative(int N) {
    stack<int> st;

    int x = -N;
    while (x) {
        int r = x % 4;
        x /= 4;
        switch (r) {
            case 0: st.push(0); st.push(0); break;
            case 1: st.push(1); st.push(1); break;
            case 2: st.push(0); st.push(1); break;
            case 3: st.push(1); st.push(0); x += 1; break;
        }
    }

    while (st.top() == 0) st.pop();

    while (!st.empty()) {
        cout << st.top(); st.pop();
    }
    cout << endl;
}

int main() {
    int N; cin >> N;
    if (N == 0) {
        cout << '0' << endl;
    } else if (N > 0) {
        positive(N);
    } else {
        negative(N);
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	string s;
	cin >> s;

	if (s[0] == 'A' &&s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
	else if (s[0] == 'B' &&s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;

}

Measured memory_bytes: 256
using System;

namespace B___Strings_with_the_Same_Length
{
    class Program
    {
        static void Main(string[] args)
        {
            var n=int.Parse(Console.ReadLine());
            var input=Console.ReadLine().Split(' ');
            var s=input[0];
            var t=input[1];
            var ans="";
            for(var i=0; i<n; i++)
            {
                ans+=s[i].ToString()+t[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double a, b, c, d, e, f, g, h;
  while (cin >> a >> b >> c >> d >> e >> f >> g >> h) {
    cout << (a <= g && e <= c && b <= h && f <= d ? "YES" : "NO") << endl;
  }
}

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

int main(){
    long long n;
    cin >> n;
    long long c[n-1],s[n-1],f[n-1];
    for(int i=0;i<n-1;i++) cin >> c[i] >> s[i] >> f[i];
    for(int i=0;i<n;i++){
        long long t=0;
        for(int j=i;j<n-1;j++){
            if(t<s[j]) t=s[j];
            else if(t%f[j]==0);
            else t=t+f[j]-t%f[j];
            t+=c[j];
        }
        cout << t << endl;
    }
}


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

int main(void){
while(true){
int n, m, p, ken[110], sum=0, kan;
cin >> n >> m >> p;
if(n==0&&m==0&&p==0) break;
for(int i=0;i<n;++i){
cin >> ken[i+1];
sum += ken[i+1];
}
if(ken[m]==0){
cout << "0" << endl;
continue;
}
kan = sum;
kan *= (100-p);
cout << (kan/ken[m]) << endl;
}
}



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == s[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
#include <queue>
#include <utility>

using namespace std;

int main()
{
    
    int total, m, d;

    cin >> total >> m;
    
    vector<int> denominations(m);
    vector<int> least_coin_num(total+1);

    
    for (int i = 0; i < m; i++)
        cin >> denominations[i];
        
    sort(denominations.begin(), denominations.end());
    // reverse(denominations.begin(), denominations.end());

    least_coin_num[0] = 0;

    for (int i = 1; i <= total; i++)
    {
        int temp = 1<<30;
        
        for (int j = 0; j < m && i >= denominations[j]; j++)
            temp = min(least_coin_num[i-denominations[j]], temp);
        
        least_coin_num[i] = temp + 1;
    }

    cout << least_coin_num[total] << endl;

    
    // for (auto x: denominations)
    //     cout << x << ' ' ;

    // int change_sum = 0;
    // for (int i = 0; i < m; i++)
    // {
    //     change_sum += total / denominations[i];
    //     total %= denominations[i];
    // }

    // cout << change_sum-1 << endl;
}


Measured memory_bytes: 3208
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        
        Queue<long[]> que = new ArrayDeque<long[]>();
        que.add(new long[]{3, 1, 0, 0});
        que.add(new long[]{5, 0, 1, 0});
        que.add(new long[]{7, 0, 0, 1});
        
        int count = 0;
        while (!que.isEmpty()) {
            long[] cur = que.poll();
            long tmp = cur[0];
            long x = cur[1];
            long y = cur[2];
            long z = cur[3];
            
            //if (tmp > 770000000) System.out.println(Arrays.toString(cur));
            
            if (tmp > num) continue;
            if (x * y * z == 1) count++;
            
            
            que.add(new long[]{tmp * 10 + 3, x | 1, y, z});
            que.add(new long[]{tmp * 10 + 5, x, y | 1, z});
            que.add(new long[]{tmp * 10 + 7, x, y, z | 1});
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 27860
#include <cstdio>

const int N = 1000;

char s[N + 1];

int main()
{
    scanf("%s", s);
    int cnt[] = {0, 0, 0, 0};
    for (int i = 0; s[i]; ++ i) {
        if (s[i] == 'N') {
            cnt[0] ++;
        } else if (s[i] == 'S') {
            cnt[1] ++;
        } else if (s[i] == 'E') {
            cnt[2] ++;
        } else {
            cnt[3] ++;
        }
    }
    puts((cnt[0] + cnt[1] == 0 || (cnt[0] > 0 && cnt[1] > 0)) && (cnt[2] + cnt[3] == 0 || (cnt[2] > 0 && cnt[3] > 0)) ? "Yes" : "No");
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define repn(i, m, n) for(int i = m; i < int(n); ++i)

string str;
int n;

int bit[10];

void f(string s, int res[]) {
  //cout << s << endl;
  rep (i, 20) res[i] = 0;
  if (s[0] != '(') {
    res[bit[atoi(s.c_str()) - 1]] = 1;
    //cout << bit[atoi(s.c_str()) - 1] << endl;
    return;
  }
  int count = 0;
  int left[20], right[20];
  repn (i, 1, s.size() - 1) {
    if (s[i] == '(') ++count;
    if (s[i] == ')') --count;
    if (s[i] == ' ' && count == 0) {
      f(s.substr(1, i - 1), left);
      f(s.substr(i + 1, s.size() - i - 2), right);
    }
  }
  rep (i, 20) res[i] = 0;
  rep (i, 16) rep (j, 16) {
    if (left[i] && right[j]) {
      res[i & j] += left[i] * right[j];
      res[i | j] += left[i] * right[j];
      res[i ^ j] += left[i] * right[j];
    }
  }
  //cout << s << endl;
  //rep (i, 16) cout << i << " " << res[i] << endl;
}

int main() {
  for (;;) {
    getline(cin, str);
    if (str == "END") break;
    cin >> n;
    rep (i, n) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      bit[i] = 8 * a + 4 * b + 2 * c + d;
    }
    int res[20];
    f(str, res);
    cout << res[15] << endl;
    getline(cin, str);
  }
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
lst = []


x,i = map(int, input().split())
lst.append(x)
lst.append(i)
y,j = map(int, input().split())
lst.append(y)
lst.append(j)
z,j = map(int, input().split())
lst.append(z)
lst.append(j)


a = (lst.count(1))
b = (lst.count(2))
c = (lst.count(3))
d = (lst.count(4))

if a <3 and b <3 and c <3 and d <3 :
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
import java.util.*;
 
class Main {
  
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        Integer card[] = new Integer[N];
        int Alice = 0;
        int Bob = 0;
      
      for(int i=0;i<N;i++){
        card[i] = Integer.parseInt(sc.next());
      }
		Arrays.sort(card, Collections.reverseOrder());
      
      for(int i = 0;i<N;i++){
        if(i%2==0){Alice +=card[i];}
        else{Bob +=card[i];}
      }

		System.out.print(Alice-Bob);
    }
}

Measured memory_bytes: 21716
import sys

sys.setrecursionlimit(10**7)

N = int(input())
S = []
a = ord('a')
for _ in range(N):
  S.append([ord(c) - a for c in input()][::-1])

_end = -1  #'_'
_count = -2 #'#'
def get_count(root):
  to_visit = [root]
  while to_visit:
    current = to_visit[-1]
    if _count in current:
      to_visit.pop()
      continue
    else:
      done = True
      c = [0] * 26 + [1 if _end in current else 0]
      for k, n in current.items():
        if k in (_end, _count):
          continue
        if _count not in n:
          done = False
          break
        if k not in (_end, _count):
          cc = n[_count]
          #print(k, cc)
          for i, v in enumerate(cc):
            if i == k:
              c[k] += cc[-1]
            else:
              c[i] += v
      if done:
        current[_count] = c
        to_visit.pop()
      else:
        for k, v in current.items():
          if k not in (_end, _count):
            to_visit.append(v)
  return current[_count]
        
  
  
  if _count in root:
    return root[_count]
  else:
    c = [0] * 26 + [1 if _end in root else 0]
    for k, n in root.items():
      if k not in (_end, _count):
        cc = get_count(n)
        #print(k, cc)
        for i, v in enumerate(cc):
          if i == k:
            c[k] += cc[-1]
          else:
            c[i] += v
    root[_count] = c
    return c
    
def make_trie(words):
  root = dict()
  for word in words:
    current_dict = root
    for letter in word:
      #letter = ord(letter)
      current_dict = current_dict.setdefault(letter, {})
    current_dict[_end] = _end
 
  return root

def get_subtree(trie, word):
  current_dict = trie
  for letter in word:
    #letter = ord(letter)
    if letter not in current_dict:
      return {}
    current_dict = current_dict[letter]
  return current_dict
  
def in_trie(trie, word):
  return _end in get_subtree(trie, word)

trie = make_trie(S)
#print(trie)
#print(get_subtree(trie, 'cy'))
#print(in_trie(trie, 'cy'))
#print(in_trie(trie, 'cyx'))

ans = 0
for s in S:
  count = get_count(get_subtree(trie, s[:-1]))
  #print(s, '#', count[s[-1]], count)
  ans += count[s[-1]]

print((ans - N))
                  


Measured memory_bytes: 723852
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> PLL;
#define chmax(x, y) do { x = max(x, y); } while(0)
#define chmin(x, y) do { x = min(x, y); } while(0)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<ll>(a); i < static_cast<ll>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

ll N, Q;
string s;

signed main() {
  cin >> N >> s >> Q;
  while (Q--) {
    ll k;
    cin >> k;
    vector<ll> d(N, 0), m(N, 0), dm(N, 0);
    // d, m, dm の構築
    if (s[0] == 'D') d[0] = 1;
    if (s[0] == 'M') m[0] = 1;
    for (int i = 1; i < N; i++) {
      d[i] = d[i-1];
      m[i] = m[i-1];
      dm[i] = dm[i-1];
      if (s[i] == 'D') {
        d[i] += 1;
      }
      if (s[i] == 'M') {
        m[i] += 1;
        dm[i] += d[i-1];
      }
    }
    ll ans = 0;
    // 集計
    for (int i = 2; i < N; i++) {
      if (s[i] != 'C') continue;
      ans += dm[i-1];
      if (i - k >= 0) {
        ans -= dm[i-k];
        ans -= d[i-k] * (m[i-1] - m[i-k]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 26736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
char s[maxn];
int n;
int a[maxn];
int b[maxn];
int suma[maxn];
int sumb[maxn];
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
    //freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);  
    gbtb;
    cin>>n;
    cin>>s+1;
    repd(i,1,n)
    {
        if(s[i]=='W')
        {
            a[i]=1;
        }else
        {
            a[i]=-1;
        }
    }
    repd(i,1,n)
    {
        suma[i]=suma[i-1];
        // sumb[i]=sumb[i-1];
        if(a[i]==1)
        {
            suma[i]++;
        }

    }
    for(int i=n;i>=1;i--)
    {
        sumb[i]=sumb[i+1];
        if(a[i]==-1)
        {
            sumb[i]++;
        }
    }
    int ans=inf;
    // repd(i,1,n)
    // {
    //     cout<<i<<" "<<suma[i]<<" "<<sumb[i]<<endl;
    // }
    repd(i,1,n)
    {
        // cout<<i<<" "<<sumb[i+1]+suma[i-1]<<endl;
        ans=min(ans,sumb[i+1]+suma[i-1]);
    }
    cout<<ans<<endl;
    
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 11648
N, M = map(int, input().split())
A = list(map(int, input().split()))

sums = []
sums.append(0)

sum = 0
for i in range(len(A)):
    sum += A[i]
    sums.append(sum)

for i in range(len(sums)):
    sums[i] = sums[i] % M

m = {}
cnt = 0

for s in sums:
    if s in m:
        cnt += m[s]
        m[s] += 1
    else:
        m[s] = 1
print(cnt)


Measured memory_bytes: 16556
n = int(input())
def divn(x, i, d, m):
    if x % d == m:
        print("", i, end="")
        return True
    return False

def call(i):
    x = i
    if divn(x, i, 3, 0):return
    if divn(x, i, 10, 3):return
    tmp = 1
    while tmp:
        x = x // 10
        tmp = x
        if not tmp:return
        if divn(x, i, 10, 3):return
    return

for i in range(n):
    call(i+1)
print("")


Measured memory_bytes: 6244
n,k=map(int,input().split())
s=input()
s=list(s)

s_comp = []
cnt = 1

#分解
for i in range(n):
    #最後だけ例外処理
    if i == n-1:
        if s[i-1] != s[i]:
            cnt = 1
            s_comp.append(str(s[i])*cnt)   
        else:
            s_comp.append(str(s[i])*cnt)  
    #同じならカウント
    elif s[i] == s[i+1]:
        cnt+=1
    #違うなら納めてカウント戻す
    else:
        s_comp.append(str(s[i])*cnt)
        cnt = 1

#出力計算
out = 0
cnt = 0

for i in range(1,len(s_comp),2):
    cnt+=1
    #指定回数以上行った場合ブレイク
    if cnt > k:
        break
    if s_comp[i][0] == "R":
        s_comp[i] = "L"*len(s_comp[i])
    elif s_comp[i][0] == "L":
        s_comp[i] = "R"*len(s_comp[i])
    

#合体
s = ""
for i in range(len(s_comp)):
    s += str(s_comp[i])

#数える
cnt = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt += 1

print(cnt)

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



signed main()
{
	int mod = 2019;
	int l,r;cin >> l >> r;
	if(l == 0){
		cout << 0 << endl;
		return 0;
	}
	int a=INF;/*
	if(l <= r/2)
	for(int i = l; i < sqrt(r); ++i){
		for(int j = l+1; j <= sqrt(r)-sqrt(i); ++j){//-sqrt(i)
			a = min(a, i*j%mod);
		}
	}
	else{
		for(int i = l; i < r; ++i){
			for(int j = l+1; j <= r; ++r){
			a = min(a, i*j%mod);
			}
		}
	}*/
	if(r-l >= 2019){
		cout << 0 << endl;
		return 0;
	}
	for(int i = l; i < r; ++i){
		for(int j = i+1; j <= r; ++j){
			a = min(a, i*j%mod);
		}
	}

	cout << a << endl;
    return 0;
}


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

int main(){
  string str;
  int ans = 0;
  while(getline(cin,str)){
    int len = str.size();
    string tmp="";
    for(int i=len-1;i>=0;i--){
      tmp += str[i];
    }
    if(str == tmp) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1192
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            int ret = 0;
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                var inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (inp[0] == inp[1])
                {
                    ++cnt;
                    ret = Math.Max(ret, cnt);
                }
                else
                {
                    cnt = 0;
                }
            }

            Console.WriteLine(ret >= 3 ? "Yes" : "No");
        }
    }
}

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

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

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

  int a, b;

  while (cin >> a >> b) {
    if (a + b == 15) {
      cout << "+\n";
    } else if (a * b == 15) {
      cout << "*\n";
    } else {
      cout << "x\n";
    }
  }
}


Measured memory_bytes: 256
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
s = input()
ind = n
ls = []
while ind > 0:
    flg = False
    for i in range(min(m, ind), 0, -1):
        if s[ind - i] == "0":
            ind -= i
            flg = True
            break
    if not flg:
        ls = []
        i = -1
        ind = 0
    ls.append(str(i))
print(" ".join(ls[::-1]))

Measured memory_bytes: 47856
from collections import Counter
from collections import deque
import math
import bisect
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(n):
    for k in range(n):
        dp[i+1][k]+=dp[i][k]*(1-p[i])
        dp[i+1][k+1]+=dp[i][k]*p[i]
print(sum(dp[n][n//2+1:]))

Measured memory_bytes: 252296
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		double n = sc.nextDouble();

		System.out.println(Math.ceil(n / 2) / n);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
            }

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 23252