akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 300000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int cnt[1000010];
int arr[MAX];
int n;

int32_t main()
{
	scanf(" %lld", &n);
	for(int i = 0; i < n; i++)
	{
		scanf(" %lld", &arr[i]);
		cnt[arr[i]]++;
	}
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		int x = arr[i];
		
		cnt[x]--;
		
		bool fl = true;
		
		for(int d = 1; d * d <= x; d++)
		{
			if(x % d == 0)
			{
				int d2 = x / d;
				if(cnt[d] or cnt[d2]) fl = false;
			}
			if(!fl) break;
		}
		
		cnt[x]++;
		if(fl) ans++;
	}
	cout << ans << '\n';


	return 0;
}

Measured memory_bytes: 13024
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pi ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<pip> v(n);
for(int i = 0 ;i <n ;i++){
  cin>>v[i].f.f>>v[i].f.s>>v[i].s;
}
int dp[n+1][4];
dp[0][1] = 0;
dp[0][2] = 0;
dp[0][3] = 0;
for(int i = 1 ; i<= n;i++){
   dp[i][1] = v[i-1].f.f + max(dp[i-1][2] , dp[i-1][3]);
   dp[i][2] = v[i-1].f.s + max(dp[i-1][1] , dp[i-1][3]);
   dp[i][3] = v[i-1].s + max(dp[i-1][1] , dp[i-1][2]);
}
cout<<max(dp[n][1] , max(dp[n][2] , dp[n][3]))<<endl;
}



Measured memory_bytes: 5760
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 200000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int n;
int a[MAX_N + 1];

vector<int> evenArr(int n)
{
  vector<int> result;
  for (int i = 2; i <= n; i += 2) {
    result.push_back(a[i]);
  }
  return result;
}

vector<int> oddArr(int n)
{
  vector<int> result;
  for (int i = 1; i <= n; i += 2) {
    result.push_back(a[i]);
  }
  return result;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  // 1-indexed
  REP(i, n) cin >> a[i + 1];

  vector<int> odd = oddArr(n);
  vector<int> even = evenArr(n);

  // for (auto o : odd) cout << o << endl;
  // for (auto o : even) cout << o << endl;

  // return 0;
  // cout << "----" << endl;

  // Even
  if (n % 2 == 0) {
    if (even.size() > 1) reverse(even.begin(), even.end());
    REP(i, odd.size()) even.push_back(odd[i]);
    REP(i, even.size()) cout << even[i] << SLN(i, even.size());
  }
  else {
    if (odd.size() > 1) reverse(odd.begin(), odd.end());
    REP(i, even.size()) odd.push_back(even[i]);
    REP(i, odd.size()) cout << odd[i] << SLN(i, odd.size());
  }

  return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main() {
  int s, w;
  cin >> s >> w;
  if (s > w) {
    cout << "safe" << endl;
  } else {
    cout << "unsafe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3608
from itertools import combinations
import numpy as np

N,M,X=map(int, input().split())
list_=[list(map(int, input().split())) for _ in range(N)]
cost=100000001
list_C=[]

for i in range(N):
	list_C=np.array(list(combinations(list_,N-i)))
	count=0
	#print(list_C)
	for h in range(len(list_C)):
		if all(np.sum(list_C[h], axis=0)[1:]>=X):
			if np.sum(list_C[h], axis=0)[0]<cost:
				cost=np.sum(list_C[h], axis=0)[0]
			#print(np.sum(list_C[h], axis=0),cost)
			count+=1
	if count==0:
		break

print(cost if cost<100000001 else "-1")

Measured memory_bytes: 28288
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    string S;
    int K;
    cin >> S >> K;

    vector<string> v;

    for(int i=0; i<K;i++){
        for(int j=0; j<S.length()-i; j++){
            v.push_back(S.substr(j,i+1));
        }
    }

    sort(v.begin(),v.end());
    int change=1;
    string ans = v[0];
    int i=1;
    while(change != K){
        if(v[i] != ans){
            change++;
            ans = v[i];
        }
        i++;
    }

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



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll big = 1000000007;
const ll mod = 998244353;

ll n,m,k,T;

vl A;

ll getv(ll i){
    if(i == -1)return 0;
    if(i == n)return 0;
    assert(i >= 0 && i < n);
    return A[i];
}

ll upp(ll i, ll j){
    if(j == 0)return 1;
    ll h = upp(i,j/2);
    if(j%2 == 0)return (h*h)%big;
    return (((h*h)%big)*i)%big;
}

vl heights;
set<ll> S;

ll upto(ll i, ll j){
    if(j == 0){
        return (upp(2,A[i])-2+big)%big;
    }
    return (upp(2,A[i]-heights[j]+1)-2+big)%big;
}

ll horisontal(ll i, ll j){
    if(heights[j] >= A[i])return 0;
    ll d1 = A[i]-heights[j];
    ll d2 = A[i]-heights[j+1];
    return (upto(i,j)-upto(i,j+1)+big)%big;
}


unordered_map<ll,ll> M;

ll dp(ll i, ll horisont, bool vertical){
    if(i == n)return 1;
    ll h = 2ll*(i*ll(12345678911)+horisont) + vertical;
    if(M.find(h) != M.end())return M[h];

    ll ans = 0;
    if(A[i] == 0){
        return dp(i+1,0,1);
    }
    if(vertical){
        ans += 2*dp(i+1,A[i],1);
        if(A[i] > horisont){
            for(int c1 = 0; c1 < sz(heights); c1++){
                if(heights[c1] < horisont)continue;
                ans += horisontal(i,c1)*dp(i+1,heights[c1],0);
                ans %= big;
            }
        }
    }
    if(!vertical){
        if(horisont >= A[i]){
            ans = 2*dp(i+1,A[i],1);
        }
        else{
            ll d = max(A[i]-getv(i-1),0ll);
            ans = upp(2,d)*dp(i+1,horisont,0);
        }
    }

    ans %= big;
    M[h] = ans;
    return ans;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,d;
    cin >> n;
    ll ans = 1;
    for(int c1 = 0; c1 < n; c1++){
        cin >> a;
        if(a == 1){
            a = 0;
            ans *= 2;
            ans %= big;
        }
        A.push_back(a);
    }

    for(int c1 = 0; c1 < n; c1++){
        d = max(A[c1] - max(getv(c1-1),getv(c1+1)),0ll);
        ans *= upp(2,d);
        ans %= big;
        A[c1] -= d;
    }
    heights.push_back(0);
    S.insert(0);
    for(int c1 = 0; c1 < n; c1++){
        if(S.find(A[c1]) == S.end()){
            S.insert(A[c1]);
            heights.push_back(A[c1]);
        }
    }
    sort(all(heights));
/*
    cerr << "h: " << horisontal(1,0) << " " << horisontal(1,1) << "\n";

    cout << ans << "\n";
    for(int c1 = 0; c1 < n; c1++){
        cout << A[c1] << " ";
    }cout << "\n";
    cerr << dp(5,0,1) << "  jk\n";
    */
    ans *= dp(0,0,1);
    cout << ans%big << "\n";


    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<queue>

typedef long long ll;
using namespace std;

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

const int max_n = 1e5+5;
const ll mod = 1e9 + 7;


int n;
int d[51];
int main()
{
	IOS;
 
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> d[i];
	ll ans = 0;
	for(int i=0; i<n; i++)
		for (int j = i + 1; j < n; j++)
			ans += d[i] * d[j];
	cout << ans;
}

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

int main(){
  
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a>b){
    int wk=b;
    b=a;
    a=wk;
  }
  
  if(b>c){
    int wk=c;
    c=b;
    b=wk;
  }
  
   if(a>b){
    int wk=b;
    b=a;
    a=wk;
  }
  
  if(b>c){
    int wk=c;
    c=b;
    b=wk;
  } 
  cout << a <<" " <<b << " " <<c << endl;
  
  return 0;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int a[20];
int b,c;
int main(){
    int ti;
    cin>>ti;
    while(ti--){
        b=c=0;
        bool flag=1;
        for(int i=1;i<=10;i++){
            cin>>a[i];
        }
        for(int i=1;i<=10;i++){
            if(b>a[i]&&c>a[i]){
                cout<<"NO"<<endl;
                flag=0;
                break;
            }
            if(a[i]>b){
                b=a[i];
                continue;
            }
            if(a[i]>c){
                c=a[i];
                continue;
            }
        }
        if(flag){
            cout<<"YES"<<endl;
        }
    }
}


Measured memory_bytes: 2972
#!/usr/bin/env python
# coding: utf-8

a,b = map(int,input().split())
pub = 0.0

for i in range(a):
    k = i + 1
    s = 1.0/ a
    while k <= b -1:
        k = k * 2
        s = s * 0.5
    pub += s

print('{:.12g}'.format(pub))


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,K;
string S;

int main(){
  cin>>N>>K;
  cin>>S;

  ll ans=0;
  for(int i=0;i<N;i++){
    if(S[i]=='L'&&i-1>=0&&S[i-1]=='L') ans++;
    else if(S[i]=='R'&&i+1<N&&S[i+1]=='R') ans++;
  }

  ll res=min((ll)N-1,ans+2*K);
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
    return (x * y) // gcd(x, y)

num = int(input())

print(lcm(2, num))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  bool f=false;
  for(int i=0;i<=n;i++){
     for(int j=0;j<=n;j++){
        int k=n-i-j;
        if(k<0) continue;
        if(i+j+k>n) continue;
        if(10000*i+5000*j+1000*k==y){
            cout<<i<<" "<<j<<" "<<k<<endl;
            f=true;
            return 0;
        }
     }
  }
  if(f==false) cout<<"-1 -1 -1"<<endl;

return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
D = [int(d) for d in input().split()]
# N = 5
# D = [3, 5, 7, 9, 12]
counts = [0] * 13

if 0 in D or D.count(12) > 1:
    print(0)
    sys.exit()

for i in range(N):
    if D[i] > 12:
        D[i] = 24 - D[i]
D.append(0)

for d in D:
    counts[d] += 1

E = []
F = []
for idx, count in enumerate(counts):
    if count > 2:
        print(0)
        sys.exit()
    elif count == 2:
        E.append(idx)
        E.append(24 - idx)
    elif idx == 0 or (idx == 12 and count > 0):
        E.append(idx)
    elif count == 1:
        F.append(idx)

max_val = 0


def update(arr):
    global max_val
    min_val = 24
    arr.sort()
    for i in range(1, len(arr)):
        if arr[i] - arr[i - 1] < min_val:
            min_val = arr[i] - arr[i - 1]
    if 24 - arr[-1] < min_val:
        min_val = 24 - arr[-1]
    if min_val > max_val:
        max_val = min_val

for i in range(2 ** len(F)):
    G = [0] * len(F)
    for j in range(len(F)):
        if i & (2 ** j):
            G[j] = 24 - F[j]
        else:
            G[j] = F[j]
    update(E + G)

print(max_val)


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,1,n)cin>>a[i];
    map<int,int> mp;
    rep(i,1,n)mp[a[i]]++;
    rep(i,1,n+1){
        cout<<mp[i]<<nl;
    }
    return 0;
}


Measured memory_bytes: 13556
<?php
$str = "0".str();
$l = strlen($str);
$dp0 = array_fill(0, $l+1, 0);//超えてないやつ
$dp1 = array_fill(0, $l+1, 0);//超えたやつ
for($i = 0; $i < $l; $i++){
    $dp0[$i+1] = min($dp0[$i]+$str[$i], $dp1[$i]+10-$str[$i]);
    $dp1[$i+1] = min($dp0[$i]+$str[$i]+1, $dp1[$i] + 9 -  $str[$i]);
}
echo min($dp0[$i],$dp1[$l]+1),"\n";
//o($str);
//o($dp0);
//o($dp1);

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}

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


int main(void){
    long long int *alturas, result = 0; // o ponteiro que vai guardar as alturas
    int n; //numero de componentes e o resultado
    scanf("%d", &n);

    alturas = (long long int *) malloc(n * sizeof(long long int)); //o ponteiro aponta para um espaço de memoria do tamanho definido pelo usuario

    for(int i = 0; i < n; i++){ //loop pra preencher com todas as alturas
        scanf("%lld", &alturas[i]);
    }

    for(int i = 0; i < n-1; i++){
        if(alturas[i] > alturas[i+1]){
            result += alturas[i] - alturas[i+1];
            alturas[i+1] = alturas[i];
        }
    }
    printf("%lld", result);

    free(alturas);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    long long sum = 0;
    vector<long long> A(N); for (auto &a : A) { cin >> a; }
    vector<long long> B(N); for (auto &b : B) { cin >> b; }
    for (int i = 0; i < N; i++) {
        if (A[i] == B[i]) continue;
        if (A[i] > B[i]) {
            sum += (A[i] - B[i]) * 2;
        } else {
            sum -= (((B[i] - A[i]) / 2) * 2);
        }
    }
    cout << ((sum <= 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0430_atcoder問題_10
{
    class Program
    {
        static void Main(string[] args)
        {
            int hoge = int.Parse(Console.ReadLine());
            if (hoge == 1)
            {
                Console.WriteLine("Hello World");
            }
            else
            {
                int a = int.Parse(Console.ReadLine());
                int b = int.Parse(Console.ReadLine());
                int c = a + b;
                Console.WriteLine(c);
            }
        }
    }
}


Measured memory_bytes: 13140
//abc063_d.cpp
//Sun May 24 18:07:33 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

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

	vector<ll> h;
	ll hptotal = 0;
	for (int i=0;i<n;i++){
		ll x;
		cin >> x;
		h.push_back(x);
		hptotal += x;
	}

	sort(h.begin(),h.end());

	ll ans = -1;
	ll high = h[n-1]/b+1;
	ll low = -1;
	while (abs(high-low)>1){
		ll tmp = (high+low)/2;
		auto itr = upper_bound(h.begin(),h.end(),tmp*b);
		ll count = 0;
		for (int i=itr-h.begin();i<n;i++){
			count += (h[i]-tmp*b)/(a-b);
			if ((h[i]-tmp*b)%(a-b)!=0){
				count++;
			}
		}
		if (count > tmp){
			low = tmp;
			ans = high;
		}else if (count < tmp) {
			high = tmp;
			ans = high;
		}else {
			ans = tmp;
			break;
		}
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1400
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = i / 60 - h * 60;
   s = i % 60;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3088
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
import std.math;
void main()
{
    auto buf = readln.chomp.split.to!(int[]);
    immutable
        theta0 = 2 * PI * (buf[2] / 12.0L + buf[3] / 720.0L),
        theta1 = 2 * PI * (buf[3] / 60.0L),
        x0 = buf[0] * cos(theta0),
        y0 = buf[0] * sin(theta0),
        x1 = buf[1] * cos(theta1),
        y1 = buf[1] * sin(theta1);
        stderr.writefln("%f %f %f %f %f %f", theta0, theta1, x0, y0, x1, y1);
    "%.15f".writefln(sqrt((x0-x1) ^^ 2 + (y0-y1) ^^ 2));
}


Measured memory_bytes: 3012
#include <stdio.h>

typedef struct {
	int id;
	long sum;
} MEMBER;

int main(void)
{
	MEMBER member[4000];
	int i, j, n, f, id;
	long unit, num;
	
	while (scanf("%d", &n), n != 0){
		for (i = 0; i < 4000; i++){
			member[i].id = 0;
			member[i].sum = 0;
		}
		
		for (i = 0, j = 0; i < n; i++){
			scanf("%d %ld %ld", &id, &unit, &num);
			
			for (i = 0; i < j; i++){
				if (member[i].id == id){
					member[i].sum += unit * num;
				}
			}
			if (i == j){
				member[j].id = id;
				member[j].sum = unit * num;
				j++;
			}
		}
		
		for (i = 0, f = 0; i < j; i++){
			if (member[i].sum >= 1000000){
				printf("%d\n", member[i].id);
				f = 1;
			}
		}
		if (f == 0){
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 672
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let mut a:usize=read!();
    let mut ans:f64=0.0;
    for i in 0..a {
        let mut b:f64=read!();
        let mut c:String=read!();
        if c=="JPY" {
            ans+=b;
        }
        else {
            ans+=b*380000.0;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 2168
from sys import stdin
def main():
  from builtins import int, list, map, min
  readline = stdin.readline
  n, m = map(int, readline().split())
  data = [list(map(int, readline().split())) for _ in range(n)]
  data.sort(key = lambda x: x[0])
  purchased = 0
  amount = 0
  for v in data:
    t = min(m - purchased, v[1])
    amount += t * v[0]
    purchased += t
    if purchased == m:
      break
  print(amount)
main()

Measured memory_bytes: 28952
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    ss=set(s)
    if len(s)==len(ss):
        print('yes')
    else:
        print('no')
if __name__ == '__main__':
    do()

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

template <class Abel>
class UnionFind{
    vector<int> par_, weight_;
public:
    UnionFind(size_t n){
        par_.assign(n, -1);
        weight_.assign(n, 0);
    }

    int root(int x){
        if (par_[x] < 0) {
            return x;
        }else{
            int res = root(par_[x]);
            weight_[x] += weight_[par_[x]];
            return par_[x] = res;
        }
    }

    int weight(int x){
        root(x);
        return weight_[x];
    }

    int weight(int x, int y){
        return weight(y) - weight(x);
    }

    int size(int x){
        return -par_[root(x)];
    }

    bool IsSame(int x, int y){
        return root(x) == root(y);
    }

    void Merge(int x, int y, Abel w){
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (IsSame(x, y))
            return;
        if (size(x) < size(y)) {
            w = -w;
            swap(x, y);
        }
        par_[x] += par_[y];
        par_[y] = x;
        weight_[y] = w;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind<int> uf(n);
    for (int i = 0; i < m; i++) {
        int q, l, r, d;
        cin >> q;
        if (q == 0) {
            cin >> l >> r >> d;
            uf.Merge(l, r, d);
        }else{
            cin >> l >> r;
            cout << ((uf.IsSame(l, r)) ? to_string(uf.weight(l, r)) : "?") << endl;
        }
    }

    return 0;
}


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;
typedef vector<int> IntVector;
typedef list<int> IntList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll H, N;
  cin >> H >> N;
  ll A[N], B[N];
  for(int i=0;i<N;i++){
    cin >> A[i] >> B[i];
  }
  
  ll dp[H+1];
  for(int i=0;i<H;i++){
    dp[i] = MAX;
  }
  dp[H] = 0;
  for(int i=H;i>0;i--){
    if(dp[i] == MAX) continue;
    for(int j=0;j<N;j++){
      if(i-A[j] < 0){
        dp[0] = min(dp[0], dp[i]+B[j]);
      }else{
        dp[i-A[j]] = min(dp[i-A[j]], dp[i]+B[j]);
      }
    }
  }
  ll ans = dp[0];
  
  cout << ans << endl;
}

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

int main() {
  ll x;
  cin >> x;
  ll c = 0;
  ll g = 100;
  while (g < x) {
    g *= 1.01;
    c += 1;
  }
  cout << c << endl;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,b;

  cin>>a>>b;

  cout<<(a+b)/2<<endl;


  return 0;

}



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

int main(){
	ll N;
	cin >> N;
	vector<string> s(N);
	for(int i=0;i<N;i++)
	{
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(),s.end());

	/*
	for(int i=0;i<N;i++)
		cout << s[i] << endl;
		*/
	string key = s[0];
	ll ans = 0;
	ll tmp = 1;
	for(int i=1;i<N;i++)
	{
		if(key==s[i]) {
			tmp++;
		}else {
			ans += tmp*(tmp-1)/2;
			key = s[i];
			tmp = 1;
		}
	}
	ans += tmp*(tmp-1)/2;
	cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n ;
    int v[n];
    int i;
    for(i=0;i<n;i++)
    {
        cin >> v[i] ;
    }
    int q ;
    cin >> q ;
    while(q--)
    {
        int a,b,c;
        cin >> a >>b>>c;
        rotate(v+a,v+b,v+c);
    }
    for(i=0;i<n;i++)
    {
        if(i) cout << ' ' ;
        cout << v[i] ;
    }
    cout << endl ;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define LL long long
using namespace std;


void solve(long long N, std::vector<long long> d){
    sort(d.begin(), d.end());
    LL curr=1, ans=0, seek=0, acc=0;
    while(curr <= d[N-1]){
        if(acc==N/2)ans++;
        if(acc>N/2)break;
        while(seek<N && curr==d[seek]){
            acc++;
            seek++;
        }
        curr++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1000005,INF=1<<30;

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

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}


int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;cin>>N;
    make();
    
    ll sum=0;
    ll pas=0;
    
    for(ll i=1;i<=N-1;i++){
        sum+=(fac[i]*fac[N-1-i]%mod*comb(i-1,N-1-i)%mod-pas+mod)%mod*i%mod;
        sum%=mod;
        
        pas=fac[i]*fac[N-1-i]%mod*comb(i-1,N-1-i)%mod;
        
        //cout<<pas<<endl;
    }
    
    cout<<sum<<endl;
}






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

int main() {
	string s;
	cin >> s;
	int i;
	for (i = 1; i < s.size(); ++i) {
		if (s[i - 1] == s[i]) break;
	}
	if (i == s.size()) {
		for (i = 2; i < s.size(); ++i) {
			if (s[i - 2] == s[i]) break;
		}
		if (i == s.size()) cout << "-1 -1";
		else cout << i - 1 << ' ' << 1 + i;
	}
	else cout << i << ' ' << 1 + i;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MAX 100900000005

using namespace std;

int main() {
    long A,B,Q,t,i;
    cin>>A>>B>>Q;
    vector<long> a,b;

    for(i=0;i<A;i++){
        cin>>t;
        a.push_back(t);
    }
    for(i=0;i<B;i++){
        cin>>t;
        b.push_back(t);
    }
    vector<long> q;
    for(i=0;i<Q;i++){
        cin>>t;
        q.push_back(t);
    }
    for(i=0;i<Q;i++){
        t = q[i];
        auto aIdx = lower_bound(a.begin(), a.end(), t);
        auto bIdx = lower_bound(b.begin(), b.end(), t);

        long aRight = aIdx == a.end() ? MAX : *aIdx;
        long bRight = bIdx == b.end() ? MAX : *bIdx;
        long aLeft = aIdx != a.begin() ? *(aIdx - 1) : 0;
        long bLeft = bIdx != b.begin() ? *(bIdx - 1) : 0;
        // cout << aLeft << " " << aRight << " " << bLeft << " " << bRight << endl;
        long res = MAX;

        if(bLeft != 0)res = min(res, (aRight - t) + aRight - bLeft);
        if(bLeft != 0)res = min(res, abs(t - bLeft) + (aRight - bLeft));
        if(aLeft != 0)res = min(res, (bRight - t) + bRight - aLeft);
        if(aLeft != 0)res = min(res, abs(t - aLeft) + bRight - aLeft);
        // cout << "res4 = " << res << endl;
        if(aRight!=MAX&&bRight!=MAX)res = min(res, max(aRight, bRight) - t);
        // cout << "res5 = " << res << endl;
        if(aLeft!=0&&bLeft!=0)res = min(res, abs(t - min(aLeft, bLeft)));
        // cout << "res6 = " << res << endl;
        cout << res << endl;
    }
    return 0;
}

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

int main() {
  string S;
  cin>>S;
  int len=(int)(S.size());
  bool ans=false;
  
  if(S.substr(0,7)=="keyence"||S.substr(len-7)=="keyence")
    ans=true;
  for(int i=1;i<7;i++){
    string a=S.substr(0,i);
    string b=S.substr(len-7+i);
    if(a+b=="keyence")
      ans=true;
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 3568
#include<cstdio>
#include<functional>
#include<algorithm>
#include<string.h>
using namespace std;


int main(){
	int a,b,h;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&h);
	int ans = (a+b)*h/2;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#coding:utf-8
import sys

BAMB_NUM = 0
BAMB_A = 0
BAMB_B = 0
BAMB_C = 0
BAMB_LIST = []

def calcMP(idx, lenA, lenB, lenC):
    """
    calculate MP.
    """
    # when classified all bamboos
    if (idx == BAMB_NUM):
        return abs(lenA - BAMB_A) + abs(lenB - BAMB_B) + abs(lenC - BAMB_C) - 30 if min(lenA, lenB, lenC) > 0 else sys.maxsize
    
    # don't use idx-th bamboo
    mp1 = calcMP(idx + 1, lenA, lenB, lenC)
    # use idx-th bamboo
    mp2 = calcMP(idx + 1, lenA + BAMB_LIST[idx], lenB, lenC) + 10
    mp3 = calcMP(idx + 1, lenA, lenB + BAMB_LIST[idx], lenC) + 10
    mp4 = calcMP(idx + 1, lenA, lenB, lenC + BAMB_LIST[idx]) + 10

    return min(mp1, mp2, mp3, mp4)

if __name__ == "__main__":
    """
    http://drken1215.hatenablog.com/entry/2019/02/24/224100
    """
    # requested bamboo lengths
    BAMB_NUM, BAMB_A, BAMB_B, BAMB_C = map(lambda x: int(x), input().split())
    # available bamboo lengths
    for bamb in range(BAMB_NUM):
        BAMB_LIST.append(int(input()))

    mp = calcMP(0, 0, 0, 0)
    print(mp)

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

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

    long long ans = 0;
    vector<vector<long long>> c(10, vector<long long>(10, 0));
    for(int i = 1; i <= n; i++){
        int iTop, iBottom, iKeta = 0;
        int tmp = i;
        while(tmp){
            tmp /= 10;
            iKeta++;
        }
        iTop = i / pow(10, iKeta - 1);
        iBottom = i % 10;
        c[iTop][iBottom]++;
    }

    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += c[i][j] * c[j][i];
        }
    }

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    ans=-1
    
    A,B=MI()
    for i in range(10000):
        a=int(i*0.08)
        b=int(i*0.1)
        
        if a==A and b==B:
            ans=i
            break
        
    print(ans)


main()


Measured memory_bytes: 63976
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
typedef long long ll;
using namespace std;
ll a[200005];
ll n,k;
int main(void)
{
	cin>>n>>k;
	memset(a,0,sizeof(a));
	while(k--)
	{
		ll d;
		cin>>d;
		while(d--)
		{
			ll b;
			cin>>b;
			a[b]=1;
		}
	}
	ll sum=n;
	for(ll i=1;i<=n;i++)
	{
		sum-=a[i];
	}
	cout<<sum;
}

Measured memory_bytes: 5140
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int n,m,i,j,a,b,x[101][101],y[101],z[101];
	cin>>m>>n;
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			cin>>x[i][j];
		}
	}
	for(i=0;i<m;i++) z[i]=0;
	for(i=0;i<n;i++) cin>>y[i];
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			z[i]=z[i]+x[i][j]*y[j];
		}
	}
	for(i=0;i<m;i++){
		cout<<z[i]<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int a[25], b[25];
void solve() {	
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	int ans = 1e18;
	int inf = ans;
	for (int mask = 0; mask < (1 << n); ++mask) {
		if (__builtin_popcount(mask) % 2)
			continue;
		vector<pair<int, int>> arr;
		for (int i = 0; i < n; ++i) {
			if ((1 << i) & mask) {
				arr.push_back({b[i], 1 - (i % 2)});
			}
			else {
				arr.push_back({a[i], i % 2});
			}
		}
		bool can = true;
		int ops = 0;
		for (int i = 0; i < n; ++i) {
			int smallest = 1e18, where = -1;
			for (int j = i; j < n; ++j) {
				if (arr[j].first < smallest and (i % 2) == arr[j].second) {
					smallest = arr[j].first;
					where = j;
				}
			}
			if (where == -1) {
				can = false;
				break;	
			} 
			for (int j = where; j > i; --j) {
				++ops;
				swap(arr[j], arr[j - 1]);
			}
		}
		for (int j = 1; j < n; ++j) {
			if (arr[j].second != j % 2)
				can = false;
			if (arr[j].first < arr[j - 1].first)
				can = false;
		}
		if (can) {
			ans = min(ans, ops);
		}
	}
	if (ans < inf) 
		cout << ans;
	else
		cout << -1;
}

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

using namespace std;
typedef long long ll;

int main() {
    int a;
    string s;

    cin >> a;
    cin >> s;

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

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vvi vector<vector<int>>
using namespace std;

int main() {
    string input;
    stack<int> st;

    while (cin >> input) {
        if (input == "+") {
            int x = st.top(); st.pop();
            int y = st.top(); st.pop();
            st.push(x + y);
        }
        else if (input == "-") {
            int x = st.top(); st.pop();
            int y = st.top(); st.pop();
            st.push(y - x);
        }
        else if (input == "*") {
            int x = st.top(); st.pop();
            int y = st.top(); st.pop();
            st.push(x * y);
        }
        else {
            int x = stoi(input);
            st.push(x);
        }
    }

    cout << st.top() << endl;
}


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

int main() {
  int N;

  int index = 1;
  while (true) {
    cin >> N;
    if (N == 0) break;
    cout << "Case"
         << " " << index << ":"
         << " " << N << endl;
    index++;
  }
}


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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int d, t, s;
	cin >> d >> t >> s;

	if (d <= t * s)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

Measured memory_bytes: 3604
// https://atcoder.jp/contests/dwacon5th-prelims/tasks/dwacon5th_prelims_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn solve(width: usize, s: &Vec<char>, sum_m: &Vec<i64>) -> i64 {
    let n = s.len();
    let mut from = 0;
    let mut to = 0;
    let mut total = 0;

    let mut ds = 0;
    let mut dms = 0;
    while from < n {
        while to < n && to - from < width {
            // add to
            match s[to] {
                'D' => {
                    ds += 1;
                },
                'M' => {
                    dms += ds;
                },
                'C' => {
                    total += dms;
                },
                _ => {},
            };
            to += 1;
        }
        // remove from
        if s[from] == 'D' {
            ds -= 1;
            dms -= sum_m[to] - sum_m[from];
        }
        from += 1;
    }
    total
}

fn main() {
    input! {
        n: usize, s: chars,
        q: usize,
        queries: [usize; q],
    };

    let mut sum_m = vec![0; n+1];
    for i in 0..n {
        let w = sum_m[i];
        if s[i] == 'M' {
            sum_m[i+1] = w+1;
        } else {
            sum_m[i+1] = w;
        }
    }

    for q in queries {
        println!("{}", solve(q, &s, &sum_m));
    }
}


Measured memory_bytes: 18676
import sys

S = input()
center = len(S) // 2

if len(S) % 2 == 1:
    b = S[center]
    for i in range(1, center + 1):
        if S[center + i] != b or S[center - i] != b:
            print(center + i)
            sys.exit()
else:
    b = S[center - 1]
    for i in range(center):
        if S[center - 1 - i] != b or S[center + i] != b:
            print(center + i)
            sys.exit()
print(len(S))


Measured memory_bytes: 3188
#ifndef DEBUG
#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (Int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP(i, n) for (Int i = 0, i##_len = (n); i <= i##_len; ++i)
#define rep3(i, l, r) for (Int i = l, i##_len = (r); i < i##_len; ++i)
#define REP3(i, l, r) for (Int i = l, i##_len = (r); i <= i##_len; ++i)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 62;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

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

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

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int n, x, t;
    cin >> n >> x >> t;

    cout << Ceil(n, x) * t << endl;

    return 0;
}

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

int main()
{
    long long h, w;
    cin >> h >> w;
    if(h == 1 || w == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    cout << (long long)(((h * w) / 2.0) + 0.5) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int a,n,h[20];
    int sum=0;
    int max;
    
    scanf("%d",&n);
    for(a=0; a<n; a++){
        scanf("%d",&h[a]);
    }

    max=h[0];

    for(a=0; a<n; a++ ){
        if(h[a] >= max) {
                if(max <= h[a]){
                    sum+=1;
                    max = h[a];   
                }
        }
    }
    
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

typedef vector<INTV> Graph;

void bfs(const int &s, const Graph &G, const int &N, int &ans){
  INTV dist(N, -1);
  queue<int> que; que.push(s); dist[s] = 0;
  while(!que.empty()){
    int pos = que.front(); que.pop();
    for(int nx : G[pos]){
      if(nx == s){
        if(dist[pos]+1 < ans){
          ans = dist[pos]+1;
          return;
        }
      } else if(dist[nx] == -1){
        dist[nx] = dist[pos]+1;
        que.push(nx);
      }
    }
  }
}

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

  int N, M, a, b; cin >> N >> M;
  Graph G(N);
  REP(i, M){
    cin >> a >> b; a--; b--;
    G[a].eb(b);
  }
  int ans = VERYBIG;
  INTV v;
  REP(i, N){
    bfs(i, G, N, ans);
  }
  if(ans == VERYBIG){
    cout << -1 << endl;
    return 0;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    char a,b;
    cin>>a>>b;
    if(a>b)cout<<">"<<endl;
    else if(a==b)cout<<"="<<endl;
    else cout<<"<"<<endl;
}


Measured memory_bytes: 892
#include <iostream>
using std::cin;
using std::cout;

int main() {
	int m, f, r;
	while(cin >> m >> f >> r && (m + 1 || f + 1 || r + 1)) {
		char res;
		if(m == -1 || f == -1 || m + f < 30) res = 'F';
		else if(m + f >= 30 && m + f < 50) res = r >= 50 ? 'C' : 'D';
		else if(m + f >= 50 && m + f < 65) res = 'C';
		else if(m + f >= 65 && m + f < 80) res = 'B';
		else if(m + f >= 80) res = 'A';
		cout << res << '\n';
	}
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n%10 == 9 || n/10 == 9) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
///
// File:  a.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 17 00:12:51 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint32_t a, b;
  cin >> a >> b;
  cout << (uint32_t)((double)(a + b) / 2 + 0.5) << endl;

  return 0;
}


Measured memory_bytes: 256