akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	printf("%lld\n", min({ abs(a * b * (c & 1)), abs(a * c * (b & 1)), abs(c * b * (a & 1)) }));

	Please AC;
}


Measured memory_bytes: 760
#include<stdio.h>
 
void swap(int* a,int* b){
  int tmp=*a;
  *a=*b;
  *b=tmp;
}
 
int n;
int A[1000];
int B[1000];
int vd[1000];
int cnt,sum,mini;
 
int min(int x,int y){
  if(x<y)return x;
  else return y;
}
 
int search(int x){
  int i;
  for(i=0;i<n;i++)if(A[i]==x)return i;
}
 
int main(){
  int i,j,ans,x;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[i]=A[i];
  }
 
  for(i=n-1;i>0;i--)
    for(j=0;j<i;j++)
      if(B[j]>B[j+1])swap(&B[j],&B[j+1]);
   
  ans=0;
  for(i=0;i<n;i++)vd[i]=0;
 
  for(i=0;i<n;i++){   
    x=i;
    cnt=sum=0;
    mini=(1<<24);
    while(vd[x]==0){
      vd[x]=1;
      cnt++;
      sum+=A[x];
      mini=min(mini,A[x]);
      x=search(B[x]);
    }
    if(cnt<2)continue;
    ans+=min(sum+B[0]*(cnt+1)+mini,sum+mini*(cnt-2));
 
  }
 
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 612
N = int(input())
S = list(str(input()))
alp = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#print(alp)

ans = []

for i in range(len(S)):
    #print(alp.index(S[i])+N-26)
    ans.append(alp[alp.index(S[i])+N-26])

print("".join(ans))


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////

const int N = 1e5 + 10;

int colors[N];
vector<pii> adj[N];

void dfs(int v, int p, int nope) {
	int ax = LEN(adj[v]);
	for(auto e : adj[v]) {
		if(e.x != p) {
			if(ax == nope) ax--;
			colors[e.y] = ax--;
			dfs(e.x, v, colors[e.y]);
		}
	}
}

int main () {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
	int n;
	cin >> n;
	for(int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back({b, i});
		adj[b].push_back({a, i});
	}
	int maxi = 0, choosen = 0;
	for(int i = 1; i <= n; i++) 
		if(LEN(adj[i]) > maxi) {
			maxi = LEN(adj[i]);
			choosen = i;
		}
	
	dfs(choosen, -1, -1);

	cout << maxi << '\n';
	for(int i = 0; i < n-1; i++)
		cout << colors[i] << '\n';

	return 0;
}


Measured memory_bytes: 12484
INF = float('inf')
from bisect import bisect
N = int(input())
A = list(map(int,input().split()))
S = [0]*N
for i in range(N):
    S[i] = S[i-1]+A[i]

ans = INF
for i in range(2,N-1):
    j = bisect(S,S[i-1]/2)
    k = bisect(S,(S[-1]+S[i-1])/2)
    for p in {j-1,min(j,i-2)}:
        for q in {k-1,i,min(k,N-2)}:
            a,b,c,d = S[p],S[i-1]-S[p],S[q]-S[i-1],S[-1]-S[q]
            m = min(a,b,c,d)
            M = max(a,b,c,d)
            ans = min(ans,M-m)

print(ans)

Measured memory_bytes: 89336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll X,Y;
  cin >> X >> Y;
  if (X % Y == 0) {
    cout << -1 << endl;
  } else {
    cout << X << endl;
  }
  return 0;
}


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

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

    cout << H * W - (h * W) - (w * H) + h * w << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((ll)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
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; }
using namespace std;

int main(){
  ll N,M;
  cin >> N >> M;
  
  ll div = M/N;
  ll ans = 0;
  
  for(ll i = div; i >= 1; --i){
    if(M % i == 0){
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 500000
#define SENTINEL 1000000000

void Merge(int *, int, int, int);
void Sort(int *, int, int);
int count;

main(){
  int i, n, A[N];

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &A[i]);
  }
  Sort(A, 0, n);
  for(i = 0;i < n - 1;i++){
    printf("%d ", A[i]);
  }
  printf("%d\n%d\n", A[n - 1], count);
  return 0;
}

void Merge(int *A, int left, int mid, int right){
  int n1 = mid - left,n2 = right - mid, i, j, k;
  int L[n1], R[n2];
  for(i = 0;i < n1;i++){
    L[i] = A[left + i];
  }
  for(i = 0;i < n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for(k = left;k < right;k++){    
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
    count++;
  }
}

void Sort(int *A, int left, int right){
  int mid;
  if((left+1) < right){
    mid = (left + right) / 2;
    Sort(A, left, mid);
    Sort(A, mid, right);
    Merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4504
# Nが小さいので全探索の構え -> なにをどうする？
# A,B,Cしかないので「li本目をA,B,Cどれの材料にするか」でやれそう -> 振り分けてから和をとって（+=10）それぞれの差を計算(+=1)
n, a, b, c = map(int, input().split())
arr = []
for _ in range(n):
    arr.append(int(input()))


def rec(i, ai, bi, ci):
    if i == n:
        if ai == 0 or bi == 0 or ci == 0:
            # 各最低でも1本以上必要だよね
            return 10 ** 10
        return abs(a - ai) + abs(b - bi) + abs(c - ci)
    else:
        ret = 10 ** 10
        # いま注目してるやつをa,b,cどれに属することにするか選ぶ
        if ai == 0:
            ret = min(ret, rec(i + 1, arr[i], bi, ci))
        elif ai > 0:
            ret = min(ret, rec(i + 1, ai + arr[i], bi, ci) + 10)
        if bi == 0:
            ret = min(ret, rec(i + 1, ai, arr[i], ci))
        elif bi > 0:
            ret = min(ret, rec(i + 1, ai, bi + arr[i], ci) + 10)
        if ci == 0:
            ret = min(ret, rec(i + 1, ai, bi, arr[i]))
        elif ci > 0:
            ret = min(ret, rec(i + 1, ai, bi, ci + arr[i]) + 10)
        # 今回は選ばない場合もある
        ret = min(ret, rec(i + 1, ai, bi, ci))
        return ret


print(rec(0, 0, 0, 0))


Measured memory_bytes: 45784
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vl s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    ll ret = 0;
    for (int i = 1; i <= n; ++i) {
        bitset<100000> used;
        used[0] = used[n - 1] = 1;
        ll temp               = 0;
        for (int j = 1; j < n; ++j) {
            int left  = j * i;
            int right = n - 1 - j * i;
            if (left > n - 1 - i || right < i)
                break;
            // if (left >= right)
            //     break;
            if (left == right)
                break;
            if (used[left] == 1 || used[right] == 1)
                break;
            used[left] = used[right] = 1;
            temp += s[left] + s[right];
            chmax(ret, temp);
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1024
while(n,p=gets.split.map(&:to_i))!=[0,0]
	a=Array.new(n,0)
	i=0
	c=p
	while (a[i]!=p)
		if c!=0
			a[i]+=1
			c-=1
		else
			c+=a[i]
			a[i]=0
		end
		i=(i+1)%n
	end
	puts i
end

Measured memory_bytes: 6096
def split_and_change(N, Array):
    Arr1 = [a for ind, a in enumerate(Array) if ind % 2 == 0]
    Arr2 = [a for ind, a in enumerate(Array) if ind % 2 != 0]
    if N % 2 == 0:
        return Arr2[::-1] + Arr1
    else:
        return Arr1[::-1] + Arr2
    
print(" ".join(split_and_change(int(input()), list(map(str, input().split())))))

Measured memory_bytes: 21908
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*
 
 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int a = 0, b = 0, c = 0;

int main(void) {

	string s,t="2019/04/30";
	cin >> s;
	if (s > t)cout << "TBD" << rt;
	else cout << "Heisei" << rt;

	please AC;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(n-1)-a.at(0)<<endl;
}


Measured memory_bytes: 256
/* 2_3
 * cy_an  */

#include <stdio.h>

int main(void){
    int N,A;
    scanf("%d", &N);          // マス目の数Nの入力
    scanf("%d", &A);          // 白色に塗るマス(A)の入力
    printf("%d\n",N * N - A); // 結果の表示

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 100000;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    int ret = 1;
    vector<int> dp(1<<w, 0);
    dp[0] = 1;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            char c = s[y][x];
            if(c == '?'){
                ret *= 3;
                ret %= MOD;
            }

            vector<int> nextDp(1<<w, 0);
            for(int i=0; i<(1<<w); ++i){
                if(c == 'J' || c == '?'){
                    int j = i;
                    j &= ~1;
                    j <<= 1;
                    j &= (1<<w)-1;
                    j |= 1;
                    nextDp[j] += dp[i];
                    nextDp[j] %= MOD;
                }
                if(c == 'O' || c == '?'){
                    int j = i;
                    if(x == 0)
                        j &= ~1;
                    j <<= 1;
                    j &= (1<<w)-1;
                    nextDp[j] += dp[i];
                    nextDp[j] %= MOD;
                }
                if((c == 'I' || c == '?') && !(i&(1<<(w-1)))){
                    int j = i;
                    j &= ~1;
                    j <<= 1;
                    j &= (1<<w)-1;
                    nextDp[j] += dp[i];
                    nextDp[j] %= MOD;
                }
            }

            dp.swap(nextDp);
        }
    }

    for(int i=0; i<(1<<w); ++i){
        ret -= dp[i];
        ret += MOD;
        ret %= MOD;
    }
    cout << ret << endl;

    return 0;
}

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

int main(){
  int i,n,flag=0;

  cin>>n;
  int num[n];
  for(i=0;i<n;i++){
    cin>>num[i];
  }

  int m = num[0];
  
  for(i=0;i<n;i++){
    if(num[i] >= m)
      flag++;

    m = max(m,num[i]);
  }

  cout<<flag<<endl;
  return 0;
}

Measured memory_bytes: 256
N, M, C = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0

for i in range(N):
    a = list(map(int, input().split()))
    add = 0
    for j in range(M):
        add += a[j] * b[j]

    if add + C > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
//#include <iomanip.h>
#include <limits.h>
//#include <strstrea.h>
//#include <fstream.h>
#define ll long long
#define ull unsigned long long
//#define int64 long long
#define INF  0x3f3f3f3f

using namespace std;

const int maxn = 1e6 + 5;
int n;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A') {
            tmp = 0;
            while (i < s.length()) {
                if (s[i] != 'Z') {
                    i++;
                    tmp++;
                } else {
                    i++;
                    tmp++;
                    ans = max(ans, tmp);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import math
a,b,x =map(int,input().split( ))
if x >= (a**2*b/2):
    k=2*x/(a**2)-b
    cos=math.sqrt((b-k)**2/((a**2)+(b-k)**2))
    print(90-math.degrees(math.acos(cos)))
else:
    k=2*x/(a*b)
    cos=math.sqrt(b**2/(b**2+k**2))
    print(90-math.degrees(math.acos(cos)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int mxn(3e1 + 10), mxm(4e5 + 10);
const long long modl(998244353);
int nm, n, m, p, t, k, ans, l, r;
int a[mxn], b[mxn];
int main() {
  ios_base::sync_with_stdio(false);
//  freopen("in.txt", "r", stdin);///////////////////////////
//  cin >> nm;
//  string s;
  while (cin >> n) {
    while (n--) cout << "ACL";
//    cout << ans;
    cout << endl;
  }
  return 0;
}
////////////////////////////////////////////////////////////////////////////////
//    if (t) cout << "YES";
//    else cout << "NO";


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */
int a[20];
int b[20];
int c[20];
int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int ans = 0;
    rep(i, n){
        if(i){
           if(a[i-1] +1 == a[i]) ans += c[a[i-1]-1];
        }
        ans += b[a[i]-1];
    }
    cout << ans << endl;

}



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

int main()
{
    int N;
    cin>>N;
    vector<int> A(N);
    int sum=0;
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
        sum^=A[i];
    }
    for(int i=0;i<N;i++)cout<<(A[i]^sum)<<endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> stair (n);
  for(int i = 0; i < n; i++) {
    cin >> stair.at(i);
  }
  int now = stair.at(n-1);
  int dist;
  bool check = true;
  for(int i = n-1; i > 0; i--){
    dist = stair.at(i-1) - stair.at(i);
    if(dist == 1) stair.at(i-1)--;
    else if (dist > 1)  check = false;
  }
  if(check) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <typeinfo>
#include <functional>
using namespace std;

#define INF 1000000
#define REP(i,n) for(int i=0;i<(int)n;++i)

#ifdef _MSC_VER
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#else
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#endif

#define ALL(c) (c).begin(), (c).end()



int main()
{
	int a, b, h;
	cin >> a>>b>>h;
	cout << (a + b)*h / 2<<endl;
	return 0;
}

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

using namespace std;

const int p = 1e9 + 7;

int n;

inline int fpow(int x, int y){
	int ans = 1;
	while(y){
		if(y & 1) ans = 1ll * ans * x % p;
		y >>= 1, x = 1ll * x * x % p;	
	}
	return ans;
}

int sum[maxn], inv[maxn];

inline int C(int n, int m){
	return 1ll * sum[n] * inv[m] % p * inv[n - m] % p;
}


int main(){
	sum[0] = 1;for(int i = 1;i < maxn;i++) sum[i] = 1ll * sum[i - 1] * i % p;
	inv[maxn - 1] = fpow(sum[maxn - 1], p - 2);
	for(int i = maxn - 2;~i;i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % p;
	scanf("%d", &n);
	int ans = 0;
	for(int i = 1;i <= n / 3;i++){
		ans = (ans + C(n - i * 3 + i - 1, i - 1)) % p;
	}
	printf("%d", ans);
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int cpos = IINF;
    rep(i, s.size())
    {
        if (s[i] == 'C')
        {
            cpos = i;
            break;
        }
    }
    rep(i, s.size())
    {
        if (s[i] == 'F' && cpos < i)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		if(N==1) {
			System.out.println("Hello World");
			System.exit(0);
		}
		
		int A = in.nextInt();
		int B = in.nextInt();
		System.out.println(A+B);
		
		
		in.close();
	}
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '('; __print(x.first); cerr << ','; __print(x.second); cerr << ')';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

vector<vector<int>> adj;
vector<bool> vis;

int cnt;

void dfs(int node) {
  cnt++;
  vis[node] = true;
  for (int i : adj[node]) {
    if (!vis[i]) dfs(i);
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int nodes, edge;
  cin >> nodes >> edge;
  adj.resize(nodes + 1);
  vis.resize(nodes + 1);
  for (int i = 0; i <= nodes; i++) vis[i] = false;
  int x, y;
  set<int> nodeList;
  if (edge == 0) {
    puts("1");
    return 0;
  }
  while (edge--) {
    cin >> x >> y;
    nodeList.insert(x);
    nodeList.insert(y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  debug(adj);
  int ans = 0;
  for (int i : nodeList) {
    ans = max(ans, cnt);
    cnt = 0;
    if (!vis[i]) {
      dfs(i);
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int ans = 1000000007;

    for (auto i = 0; i <= n; i++)
    {
        int tmp = 0;
        int t = i;
        while(t > 0){
            tmp += t % 6;
            t /= 6;
        }
        t = n - i;
        while(t>0){
            tmp += t % 9;
            t /= 9;
        }
        if(tmp < ans){
            ans = tmp;
        }
    }
    
    std::cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
ll n, m;
ll sum, i, j;

int main()
{
	while(cin >> n >> m)
	{
		sum = abs(n * m - 2 * n - 2 * (m - 2));
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define EPS (1e-10)    //誤差
typedef complex<double> P;

//実数同士の比較
bool EQ(double a, double b){
    return (abs(a - b) < EPS);
}

//内積
double dot(P a, P b){
    return (a.real() * b.real() + a.imag() * b.imag());
}

//外積
double cross(P a, P b){
    return (a.real() * b.imag() - a.imag() * b.real());
}

// a1,a2を通る直線とb1,b2を通る直線の交点計算
P intersection_l(P a1, P a2, P b1, P b2) {
  P a = a2 - a1; P b = b2 - b1;
  return a1 + a * cross(b, b1-a1) / cross(b, a);
}

int main(){

    int q; cin >> q;
    for(int i = 0; i < q; i++){
        P p0, p1, p2, p3; cin >> p0.real() >> p0.imag() >> p1.real() >> p1.imag() >> p2.real() >> p2.imag() >> p3.real() >> p3.imag();
        P ans = intersection_l(p0, p1, p2, p3);
        printf("%.10f %.10f\n", ans.real(), ans.imag());
    }
    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[1010101];
int num[1010101];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int g=0;
	FOR(i,N) {
		cin>>A[i];
		g=__gcd(g,A[i]);
		num[A[i]]++;
	}
	
	for(i=2;i<=1000000;i++) {
		x=0;
		for(j=i;j<=1000000;j+=i) x+=num[j];
		if(x>=2) break;
	}
	
	if(i==1000001) {
		cout<<"pairwise coprime"<<endl;
		return;
	}
	
	if(g==1) {
		cout<<"setwise coprime"<<endl;
	}
	else {
		cout<<"not coprime"<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
string s,t;
  cin>>s>>t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s<t){cout<<"Yes";}
  else{cout<<"No";}
}

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

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	map<char, vector<int>> list;
	for (int i = 0; i < s.size() * 2; ++i) list[s[i % s.size()]].push_back(i);
	int pos = -1;
	long long ans = 0;
	for (char c : t) {
		if (list[c].empty()) {
			ans = -1;
			break;
		}
		int next = *upper_bound(list[c].begin(), list[c].end(), pos);
		ans += next - pos;
		pos = next % s.size();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1724
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
r, D, x = [int(x) for x in stdin.readline().rstrip().split()]

def f(_x):
  return r*_x - D

for i in range(10):
  x = f(x)
  print(x)

Measured memory_bytes: 21512
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
// 	cin>>test;	
	while(test--)
	{
	long a,b,c,d,i,n,arr[3];
		cin>>a>>b;
		vector<string> s ;
		for(i=0;i<a;i++)
		{
		    string s1;
		    cin>>s1;
		  //  cout<<s1<<" ";
		    s.push_back(s1);
		}
		sort(s.begin(),s.end());
		for(i=0;i<a;i++)
		cout<<s[i];
		
		
 	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int gcd(int a, int b) {
  if (b == 0) return a;
  else return gcd(b, a%b);
}
 
int main() {
  int n;
  cin >> n;
 
  int nums[n+2];
  nums[0] = 0;
  nums[n+1] = 0;
  for(int i = 1; i < n+1; i++) {
    cin >> nums[i];
  }

  int ans = -1;
  int curr;

  int l[n+2];
  int r[n+2];
  l[0] = 0;
  l[n+1] = 0;
  l[n] = 0;
  r[0] = 0;
  r[n+1] = 0;
  r[n+1] = 0;
  for (int i = 1; i < n; i++) {
    l[i] = gcd(l[i - 1], nums[i]);
  }

  for (int i = n; i > 1; i--) {
    r[i] = gcd(r[i + 1], nums[i]);
  }

  for (int i = 0; i < n; i++) {
    curr = gcd(l[i], r[i + 2]);
    if (curr > ans) {
      ans = curr;
    }
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main(void) {
	int i, j, k, l;
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b)*c / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N,Q = map(int,input().split())
 
e_list = [[] for i in range(N)]
 
for i in range(N-1):
        a,b = map(int,input().split())
        a,b = a-1,b-1
        e_list[a].append(b)
        e_list[b].append(a)
 
add_list = [0]*N
 
for i in range(Q):
        p,x = map(int,input().split())
        p = p-1
        add_list[p]+=x
 
count_list = [0]*N
count_list[0] = add_list[0]
 
vi = 0 #時と場合によってここを変える
from collections import deque
Q = deque([vi])
checked_list = [False]*N
checked_list[vi]=True
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            count_list[v1] = count_list[v]+add_list[v1]
 
print(*count_list)

Measured memory_bytes: 107540
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

ll n,m,a,b,c,x,y,aa[100010],ba[100010];
bool r,br,ar;
string s;
char ca,cb;


int main(){
    cin>>a>>b>>c>>x;
    y=0;
    for(int i=0;i<=min(x/500,a);i++){
        for(int j=0;j<=min((x-500*i)/100,b);j++){
            if((x-500*i-100*j)/50<=c)y++;
        }
    }
    printf("%lld\n",y);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N,A,B;
  cin>>N>>A>>B;
  ll a=N/(A+B);
  ll b=N%(A+B);
  if(b<A) {
    cout<<A*a+b<<endl;
    
  }
  else {
cout<<a*A+A<<endl;
  }
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







ll z_algorithm(string &s){
    ll n = s.size();
    vector<ll> a(n);
    a[0] = n;
    ll i = 1, j = 0;
    while(i < n){
        while(i + j < n && s[j] == s[i + j]) j++;
        a[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        ll k = 1;
        while(i + k < n && k + a[k] < j){
            a[i + k] = a[k];
            k++;
        }
        i += k;
        j -= k;
    }
    ll res = 0;
    for(ll i = 1; i < n; i++){
        res = min(max(res, a[i]), i);
    }
    return res;
}
 
int main(){
    ll n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    REP(i, n){
        string t = s.substr(i, n - i);
        ans = max(ans, z_algorithm(t));
    }
    cout << ans << endl;
}

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

int gcd(int a, int b) {
  if (a < b) {swap(a, b);}
  if (b == 0) return a;
  return gcd(b, a%b);
}

int main() {
  int N; cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int res = a[0];
  for (int i = 1; i < N; i++) {
    res = gcd(res, a[i]);
  }
  cout << res << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3

import sys
import pprint
from math import gcd


sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	k = int(sys.stdin.readline())
	s = 0
	for a in range(1, k+1):
		for b in range(1, k+1):
			for c in range(1, k+1):
				s += gcd(gcd(a, b), c)
	print(s)
	


main()

Measured memory_bytes: 9900
#include <stdio.h>

long long N,a[100000],b[100000],K,c[100000],i;

int main(void){
	

	scanf("%lld %lld",&N,&K);

	for(i=0;i<N;i++){
		scanf("%lld %lld",&a[i],&b[i]);
	}
	
	for(i=0;i<N;i++){
		c[a[i]-1] = c[a[i]-1] + b[i];
	}
	
	for(i=0;i<100000;i++){
		if(K <= c[i]){
			printf("%lld\n", i+1);
			return 0;
		}
		K = K - c[i];
	}

}

Measured memory_bytes: 2560
n, y = map(int, input().split(' '))
flag = False

for a in range(0, n+1):
  for b in range(0, (n+1)-a):
    c = n - a - b
    s = a*10000 + b*5000 + c*1000
    if s == y:
      print(a, b, c)
      flag = True
      break
  if flag:
    break

if not flag:
  print(-1, -1, -1)

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
ll gcd(ll x, ll y) {

	if (x % y == 0) {
		return y;
	}
	else {
		return gcd(y, x % y);
	}

}

int main()
{
	int N;
	cin >> N;
	vec(A);
	ll sum = -1;

	fx(N) {
		vecp(A);

		if (sum<0) {
			sum = A[x];
		}
		else {
			sum = gcd(sum, A[x]);
		}
	}
	if (sum!=1) {
		ce("not coprime");
		return 0;
	}

	sorts(A);
	set<int> G;
	fx(N) {
		ll i = 2;
		bool flag = true;
		ll k = A[x];

		while (A[x]!=1) {
			if (A[x]%i==0) {
				flag = false;
				if (G.count(i)) {
					ce("setwise coprime");
					return 0;
				}
				while(A[x]%i==0)
				A[x] /= i;
				G.insert(i);
			}
			i++;
			if (flag&&i*i>A[x]) {
				break;
			}
		}
		G.insert(k);
	}
	ce("pairwise coprime")
    return 0;
}



Measured memory_bytes: 7452
import java.util.*;
public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      
      //入力
      String S =sc.next();
      
      //数字列の前半と後半
      String first1 = S.substring(0,2);//01
      //String first2 = S.substring(1,1);//0
      //S.charAt(1);
      
      String last1 = S.substring(2,4);//23
      //String last2 = S.substring(3,3);//0
      //S.charAt(3);
      
      //数字列から数値に変更
      int date1 = Integer.valueOf(first1);
      //int date2 = Integer.valueOf(first2);
      
      int date3 = Integer.valueOf(last1);
      //int date4 = Integer.valueOf(last2);
      //System.out.println(date1);//17
      //System.out.println(S.charAt(1));//7
      //System.out.println(S.charAt(3));//0
      //System.out.println(date3);//0
      
      
      //前半2桁と後半2桁が月として利用できる
      if((date1>0 && date1<=12) && (date3>0 && date3<=12)){//7//17
        	System.out.println("AMBIGUOUS");
              //後半2桁が月として利用できるか
      	      //if(date3>0 && date3<=12){//0//0
              //System.out.println("AMBIGUOUS");  
        }
      
        //前半2桁が月として利用できる
        else if(date1>0 && date1<=12) {
          System.out.println("MMYY");
        }
       //後半2桁が月として利用できる
        else if(date3>0 && date3<=12){
          System.out.println("YYMM");
        }
      	//どちらも月として利用できない
      	else{
          System.out.println("NA");
        }
    }
}
    
      //後半2桁が月として利用できるか
      //else {
        //if(S.charAt(3)>0 && date3<=12){//0//0
         // System.out.println(S.charAt(3));
         // System.out.println(date3);
        	//System.out.println("YYMM");   
        //}
        //else{
          //System.out.println("NA");
        //}
     // }
    //}
//}

Measured memory_bytes: 35568
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll h, n; cin >> h >> n;
    ll sum = 0;
    f(i, n){
      ll a;
      cin >> a;
      sum += a;
    }
    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long k, a, b;
	cin >> k >> a >> b;
	k++;
	long long co = 0;
	if (a + 2 >= b) {
		cout << k << endl;
	}
	else {
		co += a;
		k -= a;
		co += k / 2 * b - a * (k / 2);
		co += k % 2;
		cout << co << endl;
	}
	return 0;
}

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

int main() {
  int loopCount;
  int index;
  
  long A0 = 2L;
  long A1 = 1L;
  long A2 = 0L;
  
  cin >> loopCount;

  if (loopCount == 1)
  {
    A2 = A1;
  }
  else
  {
    for(index = 2; index <= loopCount; index++)
    {
      A2 = A1 + A0;
      A0 = A1;
      A1 = A2;
    }
  }
  
  cout << A2 << endl;
}



Measured memory_bytes: 256
N = int(input())

lst = [1, 6, 9, 6**2, 9**2, 6**3, 9**3, 6**4, 9**4, 6**5, 6**6, 9**5]
dp = [N+1] * (N+1)
dp[0] = 0
for i in range(1, N+1):
    for j in lst:
        if j <= i:
            # print(i, j, i-j)
            dp[i] = min(dp[i], dp[i-j]+1)
print(dp[-1])

Measured memory_bytes: 68576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0; (i) < (n); (i)++)
int main(){
  int64_t N;
  int K;
  cin >> N >> K;
  int64_t ans = 0;
  for (int64_t i = K; i < N+2; i ++){
    ans += ((N + 2) * (N+1) /2) - (i * (i+1) /2) - ((N + 1 - i) * (N + 2-i) / 2) + 1;
  }
  
  int64_t a = 1000000007;
  cout << ans % a << endl;
}

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

const int MAXN = 500 + 3;
int H[MAXN][MAXN];
bool occ[MAXN][MAXN];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int x, int y) {
  int z = H[x][y] + occ[x][y];
  for (int t = 0; t < 4; t++) {
    int x1 = x + dx[t], y1 = y + dy[t];
    if (H[x1][y1] > z) {
      H[x1][y1] = z;
      dfs(x1, y1);
    }
  }
}

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

  for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) {
    H[i][j] = min(min(i, N+1-i), min(j, N+1-j)) - 1;
    occ[i][j] = true;
  }

  int res = 0;
  for (int it = 0; it < N*N; it++) {
    int p; cin >> p;
    int x = p % N;
    int y = (p+N-1)/N;
    if (x == 0) x += N;
    res += H[x][y];
    occ[x][y] = false;
    dfs(x, y);
  }
  cout << res << "\n";
}

Measured memory_bytes: 20312
// Problem : F - NRE
// Contest : AtCoder Regular Contest 085
// URL : https://atcoder.jp/contests/arc085/tasks/arc085_d
// Memory Limit : 256 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
//#define int long long
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long yuri() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
const int N = 262144;
int natsuki[N * 2], n, inv[N], b[N], dp[N];
vector <int> qry[N];
void monika(int l, int r, int x) {
	l += N;
	r += N;
	while (l <= r) {
		natsuki[l] = min(natsuki[l], x); natsuki[r] = min(natsuki[r], x);
		l = (l + 1) >> 1; r = (r - 1) >> 1;
	}
}
int sayori(int l) {
	int r = 1e9;
	l += N;
	while (l) {
		r = min(r, natsuki[l]);
		l >>= 1;
	}
	return r;
}
int main() {
	n = yuri(); repn(i, N * 2 - 1) natsuki[i] = 1e9;
	repn(i, n) {b[i] = yuri();  inv[i] = inv[i - 1] + (1 - b[i]);}
	int q = yuri(); 
	while (q--) {int l = yuri();int r = yuri(); qry[r].pb(l);}
	repn(i, n) {
		monika(i - 1, i - 1, dp[i - 1] - inv[i - 1]);
		dp[i] = dp[i - 1] + (b[i]);
		for (auto v:qry[i]) {
			int l = v, r = i; 
			monika(l, r, sayori(l - 1));
		}
		dp[i] = min(dp[i], sayori(i) + inv[i]);
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std ;
int n ;
int a[301] ;
double dp[301][301][301] ;
#define d double
double solve(int x,int y,int z){
	if(x+y+z == 0)
		return 0 ; 
	if(dp[x][y][z] != -1)
		return dp[x][y][z] ;
	double p1=0,p2=0,p3=0 ;
	if(x)
		p1 = (d)x/(x+y+z) * solve(x-1,y,z) ; // kind of conditional p-bility
	if(y)
		p2 = (d)y/(x+y+z) * solve(x+1,y-1,z) ;
	if(z)
		p3 = (d)z/(x+y+z) * solve(x,y+1,z-1) ;
	
	return (dp[x][y][z] = p1+p2+p3+(d)n/(x+y+z)) ;  // p1,p2,p3 contains ev for sushi 1,2,3 n/(x+y+z) ev 
}

int main(){
	scanf("%d",&n) ;
	vector<int>cnt(4) ;
	for(int i=0;i<n;i++){
		cin >> a[i] ;
		cnt[a[i]]++ ;
	}
	for(int i=0;i<301;i++)for(int j=0;j<301;j++)for(int k=0;k<301;k++) dp[i][j][k] = -1 ;
	cout << fixed << setprecision(10) << solve(cnt[1],cnt[2],cnt[3]) << endl ;
}

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

int ketasum(int n){
  	int mysum=0;
	while(n>0){
    	mysum+=n%10;
      	n=n/10;
    }
	return mysum;
}

int main(){
	int n,temp;cin>>n;
  	temp=ketasum(n);
  	if(n%temp==0){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
}    

Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    if a==1
        a=14
    end
    if b==1
        b=14
    end
    if a==b
        println("Draw")
    elseif a>b
        println("Alice")
    else
        println("Bob")
    end


end
main()

Measured memory_bytes: 163604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[214514];
int main(){
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	while(k--){
		ll cnt=0;
		ll b[214514]={};
		for(ll i=0;i<n;i++){
			ll l=max(0ll,i-a[i]),r=min(n-1,i+a[i]);
			b[l]++;
			b[r+1]--;
			//cout<<l<<' '<<r<<endl;
		}
		for(int i=1;i<n;i++){
			b[i]+=b[i-1];
			if(b[i]==n)cnt++;
		}
		if(b[0]==n)cnt++;
		for(int i=0;i<n;i++)a[i]=b[i];

		if(cnt==n)break;
	}
	for(int i=0;i<n;i++)cout<<a[i]<<' ';
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


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

    int N;
    cin >> N;
    cout << (N-2) * 180 << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7,mod=1e9+7;
int n,ans,f[N][2];
char s[N];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    f[0][1]=1;
    for(int i=1;i<=n;i++)
    if(s[i]=='1')f[i][0]=(3ll*f[i-1][0]+f[i-1][1])%mod,f[i][1]=2ll*f[i-1][1]%mod;
    else f[i][0]=3ll*f[i-1][0]%mod,f[i][1]=f[i-1][1];
    ans=(f[n][0]+f[n][1])%mod;
    printf("%d",ans);
}

Measured memory_bytes: 4612
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

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

	int happy = 0;
	for (int i = 1; i < N; i++)if (S[i] == S[i - 1])happy++;
	cout << min(N - 1, happy + 2 * K) << endl;

	return 0;
}

Measured memory_bytes: 512