akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int N,M;
string S;
signed main(){
  cin>>N;
  int A,B;cin>>A>>B;
  REP(i,A,B+1){
    if(i%N==0){
      print("OK");
      return 0;
    }
  }
        print("NG");
      return 0;

}


Measured memory_bytes: 3656
#include <cstdio>
long long n, a, b, s, t, x[100005];
int main() {
	scanf("%lld%lld%lld%lld", &n, &a, &b, &x[0]);
	for(int i=1; i<n; i++) {
		scanf("%lld", &x[i]);
		t = (x[i]-x[i-1]) * a;
		s += t<b ? t:b;
	}
	printf("%lld", s);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main()
{
    long long int x,goldenCoin=0,reminder;
    cin>>x;
       if (x/500>=1)
       {
            goldenCoin=(x/500)*1000;
            reminder=x%500;
            if(reminder>=5)
            {
                goldenCoin+=(reminder/5)*5;
            }
       }
       else
       {
         goldenCoin=(x/5)*5;
       }
       cout<<goldenCoin<<endl;
       return 0;
}

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n;
    cin >> n;
    REP(i, -1000, 1000){
        REP(j, -1000, 1000){
            if(pow(i, 5) - pow(j, 5) == n){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4068
N, K  = map(int, input().split())
ps  = list(map(int, input().split()))

values = [(p+1)/2 for p in ps]

ans  = sum(values[:K])
# print(values)
tmp = ans
for i in range(K,N):
    # print(i,tmp)
    tmp = tmp - values[i-K] + values[i]
    ans = max(ans,tmp)

print(ans)



Measured memory_bytes: 24548
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        public struct Restaurant
        {
            public int point;
            public int num;
        }



        

        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());

            Dictionary<string, List<Restaurant>> dic_rest = new Dictionary<string, List<Restaurant>>();

            for(int i = 0; i < N; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                string s = input[0];
                int p = int.Parse(input[1]);

                if (!dic_rest.ContainsKey(s))
                {
                    dic_rest[s] = new List<Restaurant>();
                    dic_rest[s].Add(new Restaurant() {point = p, num = i + 1});
                }
                else
                {
                    dic_rest[s].Add(new Restaurant() { point = p, num = i + 1});
                }


            }

            var sort_dic_rest = dic_rest.OrderBy(x => x.Key);

            
            foreach(var city in sort_dic_rest)
            {            
                var rest_list = city.Value;

                var sort_lsit = rest_list.OrderByDescending(x => x.point);

                foreach(var p in sort_lsit)
                {
                    Console.WriteLine(p.num);
                }

               
            }
            
        }
    }
}

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

using namespace std;

int main()
{
    int a, b;
    while (true)
    {
        cin >> a >> b;
        if (a == 0 && b == 0)
        {
            break;
        }
        cout << min(a, b) << " " << max(a, b) << endl;
    }
}



Measured memory_bytes: 3036
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define VI(v,n) vector<int> v(n)



int main() {
	VI(v, 3);
	cin >> v[0] >> v[1] >> v[2];

	SORT(v);

	long a = v[0];
	long b = v[1];
	long c = v[2];
	


	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0<< endl;
	}
	else {
		cout << a*b<< endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline void checkmin(ll &a, const ll &b) {if(b < a) a = b;}

int L, A[200005];
ll f[200005][5];

int main(){
	getint(L);
	for(register int i = 1; i <= L; i++) getint(A[i]);
	memset(f, 0x3f, sizeof(f));
	f[0][0] = f[0][1] = f[0][2] = f[0][3] = f[0][4] = 0;
	for(register int i = 1; i <= L; i++){
		f[i][0] = f[i - 1][0] + A[i];
		f[i][1] = f[i - 1][1] + (A[i] & 1) + (A[i] == 0) * 2;
		f[i][2] = f[i - 1][2] + !(A[i] & 1);
		f[i][3] = f[i - 1][3] + (A[i] & 1) + (A[i] == 0) * 2;
		f[i][4] = f[i - 1][4] + A[i];
		checkmin(f[i][1], f[i][0]);
		checkmin(f[i][2], f[i][1]);
		checkmin(f[i][3], f[i][2]);
		checkmin(f[i][4], f[i][3]);
	}
	return printf("%lld\n", min(f[L][0], min(f[L][1], min(f[L][2], min(f[L][3], f[L][4]))))), 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s; cin >> s;
  deque<char> dq;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != 'B'){
      dq.push_back(s[i]);
      cnt++;
    }
    else{
      if(!dq.empty()){
        dq.pop_back();
        cnt--;
      }
    }
  }
  for(int i = 0; i < cnt; i++){
    cout << dq.front();
    dq.pop_front();
  }
  cout << endl;
  system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

int gcd(int a, int b){
    if(a * b == 0) return a + b;
    return gcd(b, a % b);
}

void solve(){
    int n;
    cin >> n;
    
    vi pregcd(n), sufgcd(n);
    vi a(n);
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    pregcd[0] = a[0];
    for(int i = 1; i < n; i++){
        pregcd[i] = gcd(a[i], pregcd[i - 1]);
    }
    
    sufgcd[n - 1] = a[n - 1];
    for(int i = n - 2; i >= 0; i--){
        sufgcd[i] = gcd(sufgcd[i + 1], a[i]);
    }
    
    int ans = max({pregcd[n - 1], sufgcd[1], pregcd[n - 2]});
    for(int i = 1; i < n - 1; i++){
        ans = max(ans, gcd(pregcd[i - 1], sufgcd[i + 1]));
    }
    cout << ans;
}

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



Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  char c;
  scanf("%c",&c);
  if(c == 'A') printf("T");
  if(c == 'T') printf("A");
  if(c == 'C') printf("G");
  if(c == 'G') printf("C");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n, cnt = 0;
vector<int> p;

int main(void) {
	cin >> n;
	p = vector<int>(n + 1);
	for (int i = 1; i <= n; i++) {
		int pi;
		cin >> pi;
		p[i] = pi - i;
		if (p[i] != 0)
			cnt++;
	}

	string ret;
	if (cnt > 2)
		ret = "NO";
	else
		ret = "YES";
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
/*
*	User: Isanchez_Aguilar
*	Problem: AtCoder ABC134B - Golden Apple
*/
#include <bits/stdc++.h>

using namespace std;
using Long = long long;

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

	int h, w;
	cin >> h >> w;

	vector< vector<char> > grid(h, vector<char>(w));

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

	const Long MOD = 1000000007ll;

	vector< vector<Long> > dp(h, vector<Long>(w));

	dp[h - 1][w - 1] = 1;

	for (int j = w - 1; j >= 0; --j)
	{
		for (int i = h - 1; i >= 0; --i)
		{
			if (grid[i][j] == '.')
			{
				if (i + 1 < h)
					dp[i][j] = (dp[i][j] + dp[i + 1][j]) % MOD;
			
				if (j + 1 < w)
					dp[i][j] = (dp[i][j] + dp[i][j + 1]) % MOD;	
			}
		}
	}

	cout << dp[0][0];		

	return 0;
}

Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
clr = [2 for _ in range(n)]
seen[0] = 1
clr[0] = 0
now = [0]
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        now.append(y)
        clr[y] = 1 - clr[x]
#print(seen)
#print(clr)
a = n - sum(clr)
b = sum(clr)
z1 = 1
z2 = 2
z3 = 3
g1 = (n+2)//3
g2 = (n+1)//3
g3 = n//3
#print(g1,g2,g3)
ans = [0 for _ in range(n)]
if a > g3 and b > g3:
  for i in range(n):
    if clr[i] == 0:
      if g1:
        ans[i] = z1
        z1 += 3
        g1 -= 1
      else:
        ans[i] = z3
        z3 += 3
    else:
      if g2:
        ans[i] = z2
        z2 += 3
        g2 -= 1
      else:
        ans[i] = z3
        z3 += 3
elif a <= g3:
  g3 -= a
  for i in range(n):
    if clr[i] == 0:
      ans[i] = z3
      z3 += 3
    else:
      if g3:
        ans[i] = z3
        z3 += 3
        g3 -= 1
      elif g1:
        ans[i] = z1
        z1 += 3
        g1 -= 1
      else:
        ans[i] = z2
        z2 += 3
elif b <= g3:
  g3 -= b
  for i in range(n):
    if clr[i] == 1:
      ans[i] = z3
      z3 += 3
    else:
      if g3:
        ans[i] = z3
        z3 += 3
        g3 -= 1
      elif g1:
        ans[i] = z1
        z1 += 3
        g1 -= 1
      else:
        ans[i] = z2
        z2 += 3
else:
  err
print(' '.join(map(str,ans)))

Measured memory_bytes: 128076
#include <iostream>
#include <algorithm>
#include <tuple>
#include <iomanip>
#include <vector>

int main(void)
{
    int N, M;
    std::cin >> N >> M;

    int P[M], Y[M];
    for (int i = 0; i < M; i++)
    {
        std::cin >> P[i] >> Y[i];
    }

    std::vector<std::tuple<int, int, int>> x(M);
    for (int i = 0; i < M; i++)
    {
        x[i] = std::make_tuple(Y[i], P[i], i);
    }

    std::sort(x.begin(), x.end());

    std::pair<int, int> res[M];
    std::vector<int> cnt(N + 1);

    std::fill(cnt.begin(), cnt.end(), 0);

    for (int i = 0; i < M; i++)
    {
        int _y, _p, _i;
        std::tie(_y, _p, _i) = x[i];

        res[_i] = std::make_pair(_p, ++cnt[_p]);
    }

    for (int i = 0; i < M; i++)
    {
        std::cout << std::setw(6) << std::setfill('0') << res[i].first;
        std::cout << std::setw(6) << std::setfill('0') << res[i].second << std::endl;
    }

    return 0;
}

Measured memory_bytes: 4608
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))
h,w = mi()
a = [list(input()) for _ in range(h)]
b = [[-1]*w for i in range(h)]
from collections import deque
l=deque()
l.append((0,0))
b[0][0]=1
y_drct = [-1,0,1,0]
x_drct = [0,1,0,-1]
default_white = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == '.':
            default_white +=1
while len(l)>0:
    cy,cx = l.popleft()
    if cy==h-1 and cx==w-1:
        break
    for i in range(4):
        ny=cy+y_drct[i]
        nx=cx+x_drct[i]
        if 0<=ny<h and 0<=nx<w:
            if a[ny][nx] == '.' and b[ny][nx]==-1:
                l.append((ny,nx))
                b[ny][nx]=b[cy][cx]+1

if b[h-1][w-1] == -1:
    print(-1)
else:
    print(default_white-b[h-1][w-1])
    
    


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  vector<int> l(Q),r(Q);
  for(int i=0;i<Q;++i){
    cin>>l.at(i)>>r.at(i);
  }
 
  vector<int> ac(N);
  int count=0;
  for(int i=0;i<N;++i){
    if(S.at(i)=='A'){
      if(i<N-1 && S.at(i+1)=='C'){
        ac.at(count)=i+1;
        ++count;
      }
    }
  }
  
  sort(ac.begin(),ac.end());
 
  for(int i=0;i<Q;++i){
    int ans=upper_bound(ac.begin(),ac.end(),r.at(i)-1)-lower_bound(ac.begin(),ac.end(),l.at(i));
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
const int BASE = 2002;
const int mod = 1e9+7;
typedef int _int;
#define int long long

int n, a[N], b[N], ans = 0, f[BASE*2+5][BASE*2+5], inv[N], fac[N], pinv[N];

void init(){
	fac[0] = inv[0] = pinv[0] = fac[1] = inv[1] = pinv[1] = 1;
	for(int i = 2; i <= BASE*4; i++){
		fac[i] = 1ll*fac[i-1]*i%mod;
		inv[i] = 1ll*(mod-mod/i)*inv[mod%i]%mod;
		pinv[i] = 1ll*pinv[i-1]*inv[i]%mod;
	}
}

int C(int n, int m){ return 1ll*fac[n]*pinv[m]%mod*pinv[n-m]%mod; }

_int main(){
	//freopen("data.in", "r", stdin);
	ios::sync_with_stdio(false);
	cin >> n, init();
	for(int i = 1; i <= n; i++)
		cin >> a[i] >> b[i], f[BASE-a[i]][BASE-b[i]]++;
	for(int i = 1; i <= BASE*2; i++)
		for(int j = 1; j <= BASE*2; j++)
			(f[i][j] += (f[i-1][j]+f[i][j-1])%mod) %= mod;
	for(int i = 1; i <= n; i++) (ans += f[a[i]+BASE][b[i]+BASE]) %= mod;
	for(int i = 1; i <= n; i++) (ans += mod-C((a[i]+b[i])*2, b[i]*2)) %= mod;
	ans = 1ll*ans*inv[2]%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 131712
s=list(input())
ans=len(s)
for i in range(26):
    c=chr(ord('a')+i)
    if c not in s:
        continue
    tmp=s
    cnt=0
    while any(a!=c for a in tmp):
        cnt+=1
        ss=''
        for a,b in zip(tmp,tmp[1:]):
            if a==c or b==c:
                ss+=c
            else:
                ss+=a
        tmp=ss
    ans=min(ans,cnt)
print(ans)


Measured memory_bytes: 43372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	char s[10001]={};
	cin>>n>>s;
	int m=strlen(s);
	for(int i=0; i<m; i++){
		if(int('Z') < int(s[i])+n){
			cout<<char(int('A')-1+((int(s[i])+n)-int('Z')));
		}else{
			cout<<char(int(s[i])+n);
		}
	}
	cout<<endl;
}
		

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


long long all = 1, bad = 1;
const int N = 15;
int a[N];

int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif


    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i] );

    for (int i = 0; i < n; i++)
    {
        all *= 3;
        if (a[i] % 2)
            bad *= 1;
        else
            bad *= 2;
    }
    printf("%lld\n", all - bad);


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

ll n, a[100009], ans = 1;
ll INF = 1e18;

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

    cin >> n;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    if(a[0] == 0) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, n) {
        if(INF / ans < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << (ans <= INF ? ans : -1) << endl;

    return 0;
}

Measured memory_bytes: 4424
#include<bits/stdc++.h>
#define N 200009
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;

LL a[N];
LL sum, cur;

int main()
{
    int n;
    scanf("%d", &n);
    sum = cur = 0ll;
    for(int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        sum += a[i];
    }

    LL ans = abs(a[1]-(sum-a[1]));

    for(int i = 1; i < n; i++)
    {
        cur += a[i];
        ans = min(ans, abs(cur*2ll-sum));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/24 06:06:29 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void    Main()
{
    ll    l, r;
    cin >> l >> r;
    ll    minv;
    minv = INT_MAX;
    for (ll    i = l; i < r; i++)
    {
        for (ll j = i + 1; j <= r; j++)
        {
            minv = min(minv, i * j % 2019);
            if (minv == 0)
            {
                cout << 0 << endl;
                return ;
            }
        }
    }
    cout << minv << endl;
}
// END

int        main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int k,x;
  int a,b;
  cin >> k >> x;
  a = max(-1000000, x -(k-1));
  b = min(1000000,x + (k-1));
  
  for(int i = a;i<b;i++){
    cout << i << ' ';
  }
  cout << b;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

#define AN 26

int to_number(string s){
    int len = s.size();
    int sum = 0;  
    for(int i = 0; i < s.size() && i < 5; i++){
        sum += (s[i] - 'a' + 1) * pow(AN + 1, 4 - i);
    }
    return sum;
}

string _to_string(int n){
    string s = "";
    for(int i = 0; i < 5; i++){
        if(1 <= n % (AN + 1) && n % (AN + 1) <= 26){
            s.push_back(char(n % (AN + 1) + 'a' - 1));
        }
        n = n / (AN + 1);
    }
    reverse(s.begin(), s.end());
    return s;
}

int main(void){
    string s;
    int K;
    cin >> s;
    scanf("%d", &K);

    vector<int> v;
    for(int i = 0; i < s.size(); i++){
        for(int j = 1; j <= 5; j++){
            if(i + j <= s.size())
                //cout << to_number(s.substr(i, j)) << endl;
                v.push_back(to_number(s.substr(i, j)));
        }
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    /*
    for(int i = 0; i < 5; i++){
        cout << _to_string(v[i]) << endl;
    }
    */

    cout << _to_string(v[K - 1]) << endl;


    return 0;
}


Measured memory_bytes: 512
#include<iostream>
//#include<fstream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<stdlib.h>
using namespace std;
//ifstream cin("d.in");
//ofstream cout("d.out");
int main()
{
	char a[110];
	int sum=0;
	cin>>a;
	for(int i=1;i<strlen(a)-1;i++)
	{
		if(a[i]<='z'&&a[i]>='a')
		{
			sum++;
		}
	}
	cout<<a[0]<<sum<<a[strlen(a)-1];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>

using namespace std;

int main(){
    int n;cin>>n;
    vector<int> a(n);
    int ans=pow(3,n);
    int yo=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            yo *= 2;
        }
    }
    ans -= yo;
    cout<<ans<<endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 a, b, x; cin >> a >> b >> x;
    i64 n = b / x + 1;
    i64 m = (a - 1) / x + 1;
    if (a == 0) m = 0;
    cout << n - m << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

#define ll long long

int a,b,c;
int k;

int main(){
  scanf("%d%d%d",&a,&b,&c);
  scanf("%d",&k);
  int count=0;
  while(b<=a){
    b*=2;
    count++;}
  while(c<=b){
    c*=2;
    count++;}

  if(count<=k){
    puts("Yes");}
  else{
    puts("No");}

  return 0;
}


Measured memory_bytes: 1664
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless, forM_, when)
import Data.Char (isDigit, digitToInt)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

main :: IO ()
main = do
  [w, h] <- map read <$> words <$> getLine
  unless (w == 0 && h == 0) $ do
    solve w h <$> replicateM h getLine >>= print
    main

solve :: Int -> Int -> [String] -> Integer
solve w h css = V.maximum dp
  where toIx (i, j) = i + (w+1) * j
        dp :: Vector Integer
        dp = V.create $ do
          v <- VM.replicate ((w+1)*(h+1)) 0
          forM_ [1..w] $ \i -> do
            forM_ [1..h] $ \j -> do
              let c = css !! (j-1) !! (i-1)
              when (isDigit c) $ do
                x <- VM.read v (toIx (i,j-1))
                y <- VM.read v (toIx (i-1,j))
                VM.write v (toIx (i,j)) (10 * (max x y) + (fromIntegral . digitToInt) c)
          return v



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int r;
    cin >> r;
    printf("%lld\n", r * r);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int i,m,n[100];
scanf("%d",&m);
for(i=0;i<m;i++)
{
	scanf("%d",&n[i]);
}
for(i=m;i>0;i--)
{
	printf("%d",n[i-1]);
	if(i>1)
	{
		printf(" ");
	}
	else
	{}
}
printf("\n");
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
lint mod = 1000000007;
// const int INF=2e9;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

  lint asum=0;
  lint a2sum=0;
  rep(i,n){
    lint a;
    cin>>a;
    asum+=a; asum%=mod;
    a2sum+=a*a; a2sum%=mod;
  }

  lint ans=(asum*asum-a2sum+mod)%mod;
  ans*=(mod+1)/2;
  ans%=mod;

  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3632
n = int(input())
h = list(map(int,input().split()))
 
dp = [None]*n
 
for i in range(n):
  if i == 0:
    dp[0] = 0
    continue
    
  if i == 1:
    dp[1] = abs(h[1] - h[0])
    continue
    
  dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))
  
  
print(dp[n-1])

Measured memory_bytes: 13980
#include<stdio.h>
#define MAX 100

int main(){
    int a[MAX], tmp[MAX], i, n;
    
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &a[i]);

    for(i = 0; i < n; i++){
        tmp[i] = a[i];
    }

    for(i = 0; i < n / 2; i++){
        tmp[i] = a[i];
        a[i] = a[(n - 1) - i];
        a[(n - 1) - i] = tmp[i];
    }

    for(i = 0; i < n; i++){
        printf("%d", a[i]);
        if(i != n - 1)printf(" ");
    }

    printf("\n");
    return 0;
}


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

public class Main {
	private static int nico;
	private static int[] elements;
	
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		try {
			nico = Integer.parseInt(in.readLine());
			
			String[] se = in.readLine().split(" ");
			elements = new int[nico];
			for (int i = 0; i < nico; i++) {
				elements[i] = Integer.parseInt(se[i]);
			}
			
			int lim = Integer.parseInt(in.readLine());
			se = in.readLine().split(" ");
			
			int[] qs = new int[lim];
			for (int i = 0; i < lim; i++) {
				qs[i] = Integer.parseInt(se[i]);
			}
			
			for (int i = 0; i < lim; i++) {
				if (search(qs[i], 0) == true) System.out.println("yes");
				else System.out.println("no");
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static boolean search(int m, int i) {
		if (m == 0) return true;
		if ((m < 0) || i == nico) return false;

		if (search(m - elements[i], i + 1) == false) return search(m, i + 1);
		return true;
	}
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
      cout << "Possible " << endl;
  } else {
      cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import java.util.ArrayList

object AMain{
    fun solve(){
        val k = nextInt()
        for(i in 1..k){
            print("ACL")
        }
        println("")

    }

    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
            if(hasNextByte()) buffer[ptr++]
            else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    AMain.solve()
}



Measured memory_bytes: 33712
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;
using XY = pair<int, int>;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> cache(m);
    int costL = 0, costR = 0;
    forin(i, 0, m) {
        int a;
        cin >> a;
        if (a < x) {
            costL += 1;
        } else {
            costR += 1;
        }
    }
    cout << min(costL, costR);
}





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


void solve(long long N, std::string S){
  vector<int> vW(N + 1, 0), vE(N + 1, 0);

  for (int i = 0; i < N; i++) {
    // takeover of previous state
    vW[i+1] += vW[i];
    vE[i+1] += vE[i];
    // increment by 'W' or 'E'
    if (S[i] == 'W') { vW[i+1]++; } else { vE[i+1]++; }
  }

  int loss = 999999999;
  for (int i = 0; i < N; i++) {
    int n_loss = vW[i] + (vE[N] - vE[i+1]);
    if (loss > n_loss) loss = n_loss;
  }
  cout << loss << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3332
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    ll x,y;
    cin >> x >> y;
    ll ans = LONG_LONG_MAX;
    if(x<=y)ans = min(ans,y-x);
    if(-x<=y)ans = min(ans,y+x+1);
    if(x<=-y)ans = min(ans,-y-x+1);
    if(-x<=-y)ans = min(ans,-y+x+2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int n, i;
    int arr[100];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf(" %d", &arr[i]);
    }
    for (i = 0; i < n; i++)
    {
        if (i)
        {
            printf(" ");
        }
        printf("%d", arr[n - i - 1]);
    }
    printf("\n");
}


Measured memory_bytes: 2740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

int n, a[1010], s=0, ans=0, mn;


int main(){
cin >> n;
rep(i, 1, n){cin >> a[i];s+=a[i];}
s/=n;
s--;
rep(i, 1, n){
ans+=(a[i]-s)*(a[i]-s);
}
mn = ans;

s++;ans=0;
rep(i, 1, n){
ans+=(a[i]-s)*(a[i]-s);
}
mn = min(mn , ans);

ans=0;s++;
rep(i, 1, n){
ans+=(a[i]-s)*(a[i]-s);
}

mn = min(mn, ans);
cout << mn << endl;

return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    while (1) {
        int n, t, l, b; cin >> n >> t >> l >> b;
        if (!n) break;

        vector<int> type(n+1);
        loop (l, i) {
            int j; cin >> j;
            type[j] = 1;
        }
        loop (b, i) {
            int j; cin >> j;
            type[j] = 2;
        }

        vector<vector<double>> prob(t+1, vector<double>(n+1));
        vector<vector<double>> lprob(t+1, vector<double>(n+1));
        prob[0][0] = 1;

        loop (t, i) {
            loop (n, j) {
                if (type[j] == 1) {
                    lprob[i+1][j] += prob[i][j] * 6;
                }
                loop (6, k) {
                    int idx = j+k+1;
                    if (idx > n) idx = n - (idx - n);
                    if (type[idx] == 2) idx = 0;
                    double p = prob[i][j];
                    if (type[j] == 1) p = lprob[i][j];
                    prob[i+1][idx] += p;
                }
            }
            prob[i+1][n] += prob[i][n] * 6;
        }

        double ans = 0;
        double sum = 0;
        loop (n+1, j) sum += prob[t][j] + lprob[t][j];
        ans += prob[t][n] / sum;
        cout << setprecision(9) << fixed;
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  int mod = 1000000007;

  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    sum = sum + a.at(i);
    sum = sum % mod;
  }

  // sum = 正方形の縦軸 または 横軸の長さ
  // sum * sum = 正方形の全体の面積
  // 和・差・積について、最後に mod を取るのと、各演算ごとに mod を取るのとで結果が一致する
  ll ans = (sum * sum) % mod;

  // 中央の正方形を取り除く
  for (int i = 0; i < n; i++) {
    //
    // * Ai <= 10**9 のため Ai * Ai < 2**64 となり、long long 型で保持できる
    // * この時点で mod 同士の引き算となる
    // * A mod M - B mod M = (A-B) mod M より、(sum * sum - a.at[i] * a[i]) mod M と同様である。
    //
    ans = ans - (a.at(i) * a.at(i) % mod);
    //
    // ans が負の数になった場合は、除数 p を加算して正の数にする
    //
    // ### 例
    //
    // n = -1, p = 3 の場合 n mod p = -1 mod 3 = -1 となる。
    // これに除数を複数回、加算する。
    //
    // # 1回
    // (n+p) mod p = (-1 + 3) mod 3 = 2 mod 3 = 2
    // # 2回
    // (n+p+p) mod p = (-1 + 3 + 3) mod 3 = 5 mod 3 = 2
    // # 3回
    // (n+p+p+p) mod p = (-1 + 3 + 3 + 3) mod 3 = 8 mod 3 = 2
    //
    // これらより、被除数が正の数になった後、除数を加算しても余りの数は変わらない。
    // 被除数が負の数から正の数になった場合、余りの数は |除数 - 被除数| の値となる。
    //
    if (ans < 0) { ans += mod; }
  }

  // この時点の ans は、大きい正方形から中央の正方形を取り除いた面積の mod 10**9+7 の剰余の数である。
  // 面積の半分を求めたいので 2 で割りたいが、ans が剰余の数であるため、2で割ることができない（結果がズレる可能性があるため）
  //
  // そのため、逆元を用いる。
  // 一般的な式は以下である。
  //
  //   (a/b) = a * (1/b) (mod 10**9+7)
  //   (a/b) = a * b**-1 (mod 10**9+7)
  //
  // これを今回の変数に当てはめる。
  //
  //   (ans/2) = ans * (2**-1) (mod 10**9+7)
  //
  // (mod 10**9+7) での 2 の逆元を求める。
  // つまり 2 * 2**-1 = 1 となる 2**-1 を求める。
  //
  //       2 * 2**-1
  //   --> 2 * ((10**9+7 + 1) / 2) (mod 10**9+7)
  //   --> (10**9+7 + 1) (mod 10**9+7)
  //   --> 剰余の数は 1 となる
  //
  // つまり、mod P において x の逆元は ((P+1) / x) となる。
  //
  //   x * (((P+1)) / x) (mod P)
  //   = (P+1) (mod P)
  //   = 剰余の数は1となる
  //
  ans = ans * ((mod + 1) / 2);
  ans = ans % mod;

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


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


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  string n;
  cin >> n;
  string ans = "No";
  if(n[0] == n[1]and n[1] == n[2] or n[1] == n[2]and n[2]== n[3])ans = "Yes";
  cout << ans << endl;
}


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

const int N = 2e5 + 10;
int n, mx;
string s[N];
map<string, int>mp;

int main() {
    cin >> n;
    rep(i, 1, n) {
        cin >> s[i];
        mp[s[i]]++;
    }
    sort(s + 1, s + n + 1);
    s[0] = '#';
    rep(i, 1, n) {
        if (s[i] != s[i - 1]) {
            mx = max(mx, mp[s[i]]);
        }
    }
    rep(i, 1, n) {
        if (s[i] != s[i - 1] && mp[s[i]] == mx) {
            cout << s[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 27136
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    if(b >= a) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

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

    int n;
    stack<int> st;
    queue<int> q;
    while (cin >> n)
    {
        if (n != 0)
        {
            st.push(n);
        }
        else
        {
            q.push(st.top());
            st.pop();
        }
    }
    while (q.size())
    {
        cout << q.front() << endl;
        q.pop();
    }
    return 0;
}


Measured memory_bytes: 3088
s = input()
n = len(s)
s0 = 0
s1 = 0
kis=s[1::2].count('0')
gus=s[0::2].count('0')
print(min(abs(kis-len(s[1::2]))+abs(gus),abs(kis)+abs(gus-len(s[0::2]))))

Measured memory_bytes: 3188
n, k= map(int, input().split())
h = list(map(int, input().split()))
h = [0] + h

dp = [10 ** 9] * (n+1)
dp[1] = 0

for i in range(1, n+1):
  for d in range(1, k+1):
    if i > d:
      dp[i] = min(dp[i], dp[i - d] + abs(h[i] - h[i - d]))

print(dp[n])

Measured memory_bytes: 53088
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] map = new int[3];
        int sum = 0;
        for (int i = 0; i < 3; i++) {
        	map[i] = sc.nextInt();
        	sum += map[i];
        }
        
        int min = sum;
        for (int a: map) {
        	min = Math.min(min, sum - a);
        }
        
        System.out.println(min);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,l,i,j,k;
    cin >> n >> m >> l;
    long int vecA[101][101]={{}};
    long int vecB[101][101]={{}};
    long int vecC[101][101]={{}};
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin >> vecA[i][j];
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            cin >> vecB[i][j];
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                vecC[i][j]+=vecA[i][k]*vecB[k][j];
            }
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            cout << vecC[i][j];
            if(j!=l-1)cout << " ";
        }cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
#define mod 1000000007
#define inf 1e18L
using namespace std;
typedef long long int ll ;


ll max(ll a , ll b)
{
  return (a > b) ? a: b;
}
ll min(ll a , ll b)
{
  return (a < b) ? a : b;
}
void memset(int *arr , int n , int value)
{
    for(int i= 0; i<n ; i++)
    {
        arr[i] = value;
    }
}

void knapsack(ll *weight , ll *values , ll n , ll W ,int val_sum ,  ll **dp)
{
    for(int i= 1 ; i<=n ; i++)
    {
        for(int j = 1 ; j<val_sum ; j++)
        {
            dp[i][j] = dp[i-1][j] ;
          if(values[i-1] <= j){
          dp[i][j] = min(dp[i-1][j] ,dp[i -1][j - values[i-1]] + weight[i-1] );
          }
        }
    }
    ll ans = inf;
    for(int i = 0 ; i<val_sum ; i++)
    {
        if(dp[n][i] <= W)
        {
            ans = i;
        }
    }
    /*for(int i= 0 ; i<=n ; i++)
    {
        for(int j = 0; j<=val_sum ; j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<ans<<endl;
}

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

    ll n , W;
    cin>>n>>W;
    ll *weight = new ll[n];
    ll *values = new ll[n];
    for(int i= 0; i<n ; i++)
    {
        cin>>weight[i]>>values[i];
    }
    int val_sum = 0;
    for(int i= 0; i < n ; i++)
    {
        val_sum += values[i] ;
    }
    val_sum+=1;
    ll **dp = new ll*[n+1];
    for(int i=0 ; i<=n ; i++)
    {
        dp[i] = new ll[val_sum];
        for(int k = 0 ; k<val_sum; k++)
        {
            dp[i][k] = inf ;
        }
    }
    dp[0][0] = 0;
    for(int i= 0; i<=n ; i++)
    {
        dp[i][0] = 0;
    }
    for(int i = 1 ; i<val_sum ; i++)
    {
        dp[0][i] = inf ;
    }
  knapsack(weight , values , n ,  W ,val_sum ,  dp) ;
  return 0;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double

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

  ul c[4]={0,0,0,0};

  for (size_t i = 0; i < n; i++)
  {
    string s;
    cin>>s;

    switch (s[0])
    {
    case 'A':
      /* code */
      c[0]++;
      break;
    case 'W':
      /* code */
      c[1]++;
      break;
    case 'T':
      /* code */
      c[2]++;
      break;
    case 'R':
      /* code */
      c[3]++;
      break;

    default:
      break;
    }
  }

  cout << ("AC x "+to_string(c[0])) << endl;
  cout << ("WA x " + to_string(c[1])) << endl;
  cout << ("TLE x " + to_string(c[2])) << endl;
  cout << ("RE x " + to_string(c[3])) << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(){

	int d,t,s;
	
	scanf("%d %d %d",&d,&t,&s);
	float atime=(float)d/(float)s;
	if (atime<=t){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 1644