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

int main()
{

	int n,ans=0;


	cin >> n;

	if (n % 2 == 0) n--;

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

		int yaku = 0;
		for (int j=0;j < i;j++) {
			if (i % (j + 1) == 0)yaku++;
		}
		if (yaku == 8) ans++;
		yaku = 0;
	}


	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,m;
    cin >> n >> m;

    vector<ll> s(n+1),t(m+1);
    for(int i = 1; i <= n; i++){
        cin >> s[i];
    }

    for(int i = 1; i <= m; i++){
        cin >> t[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(m+1,0));

    dp[0][0] = 1;

    vector<vector<ll>> sum(n+1,vector<ll>(m+1,0));

    for(int i = 0; i < m+1; i++){
        sum[0][i] = 1;
    }

    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= m; j++){
            dp[i][j] = dp[i-1][j];
        }
        for(int j = 1; j <= m; j++){
            if(s[i] == t[j]){
                dp[i][j] += sum[i-1][j-1];
                dp[i][j] %= MOD;
            }
        }
        sum[i][0] = dp[i][0];
        for(int j = 1; j <= m; j++){
            sum[i][j] = (sum[i][j-1] + dp[i][j])%MOD;
        }
    }

    cout << sum[n][m] << endl;

    return 0;
}

Measured memory_bytes: 62976
n = int(input())
a = [0]
a.extend([int(i) for i in input().split()])
a.append(0)
b = [0]*(n+2)
for i in range(n+1):
    b[i+1] = b[i] + abs(a[i+1] - a[i])
for i in range(n):
    ans = b[-1] + abs(a[i+2] - a[i]) - abs(a[i+1]-a[i]) - abs(a[i+2]-a[i+1])
    print(ans)

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

int main(){
  int N, M;
  cin >> N >> M;
  int a[N], b[N], c[M], d[M];
  rep(i, N){
    cin >> a[i] >> b[i];
  }
  
  rep(i, M){
    cin >> c[i] >> d[i];
  }
  
  rep(i, N){
    int64_t min_ = pow(10, 9);
    int64_t ans = 0;
    rep(j, M){
      int64_t manhat = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (min_ > manhat) ans = j + 1;
      min_ = min(manhat, min_);
    }
    cout << ans << endl;
  }
  
  
}

Measured memory_bytes: 256
/*
.....   .   .   .   .
  .    . .   . .   . .
  .   .....   .   .....
  .  .     .  .  .     .
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>
#include <sstream>
 
using namespace std;

#define int long long
#define double long double
#define time time228
#define left left228
#define right right228

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

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

int cnt[100];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char c : s) {
        ++cnt[c - 'a'];
    }
    int res = 1;
    for (int i = 0; i < 26; ++i) {
        res *= (cnt[i] + 1);
        res %= (1000 * 1000 * 1000 + 7);
    }
    cout << res - 1 << '\n';
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long N){
    cout << N/3 << endl;
}

int main(){

    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}



Measured memory_bytes: 256
import collections
import sys

l = collections.deque(sys.stdin.readlines())
l.pop()
s = ""
while l:
    a = 0
    b = 0
    for i in range(int(l.popleft())):
        x,y = map(int, l.popleft().split())
        if x > y:
            a = a + x + y
        elif x < y:
            b = b + x + y
        else:
            a += x
            b += y
    s += str(a) + " " + str(b) + "\n"

print(s,end="")

Measured memory_bytes: 8924
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
// BFS algorithm
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, char **argv)
{
        int V, E;
        cin >> V >> E;
        vector<vector<int>> A(V);
        vector<int> B(V);
        for (int i = 0; i < E; i++) {
                int s, t;
                cin >> s >> t;
                A[s].push_back(t);
                B[t]++;
        }
        vector<bool> U(V);
        vector<int> L;
        queue<int> S;
        int e = E;
        for (int i = 0; i < V; i++) {
                if (B[i] || U[i])
                        continue;
                S.push(i);
                while (!S.empty()) {
                        auto c = S.front();
                        S.pop();
                        U[c] = true;
                        L.push_back(c);
                        for (auto a: A[c])
                                if (--e, --B[a] == 0)
                                        S.push(a);
                }
        }
        if (e > 0) {
                cout << "Found cyclic path" << endl;
        }
        else {
                for (auto l: L)
                        cout << l << endl;
        }
        return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
static const int MAX = 100000;
static const int NIL = -1;

int main(void) {
    ll n, i, j, k, tmp1, tmp2, ans=0;
    cin >> n;
    ll a[n], b[n], c[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    for(i=0; i<n; i++)
        cin >> b[i];
    for(i=0; i<n; i++)
        cin >> c[i];
    
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    
    for(j=0; j<n; j++) {
        tmp1=lower_bound(a, a+n, b[j])-a;
        tmp2=upper_bound(c, c+n, b[j])-c;
        ans += tmp1*(n-tmp2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n): N(n), G(N), used(N,false) {}

    void add_edge(ll s, ll t){
        G[s].emplace_back((edge){t});
        //G[t].emplace_back((edge){s}); //無向ならON
    }

    void dfs(ll v=0){
        used[v]=true;
        for(auto E : G[v]){
            if(!used[E.to]){
                dfs(E.to);
            }
        }
    }
};
//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N) cin>>A[i];
    rep(i,N) cin>>B[i];
    ll ans=0;
    vector<bool> iru(51,0);
    rep(i,51){
        ll x=51-i; //xをとばす
        graph g(51);
        rep(j,51){ //jをkでわる
            reps(k,1,x){
                if(j%k!=j) g.add_edge(j,j%k);
            }
            reps(k,x+1,51){
                if(!iru[k]) continue;
                if(j%k!=j) g.add_edge(j,j%k);
            }
        }
        bool ok=true;
        rep(j,N){
            rep(k,51) g.used[k]=false;
            g.dfs(A[j]);
            if(!g.used[B[j]]) ok=false;
        }
        if(!ok){
            if(i==0) dame;
            iru[x]=true; ans+=1LL<<x;
        }
    }
    cout<< ans <<"\n";
}
 
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if(m == 0 || m == n){
        return 1;
    } else if(m == 1){
        return n;
    }
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;
    string s = to_string(n);

    string tmp = s;

    reverse(tmp.begin(), tmp.end());

    if(s == tmp){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def count_divisor(a, b, c):
    count = 0
    value = a
    while value <= b:
        if c % value == 0:
            count += 1
        value += 1
    return count


if __name__ == "__main__":
    a, b, c = map(int, input().split())
    print(count_divisor(a, b, c))



Measured memory_bytes: 5600
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
ans = 0
a=0
b=0
c=0

for i in range(n):
    s = ns()
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        c += 1
    elif s[0] == 'B':
        b += 1
    elif s[-1] == 'A':
        a += 1

ans += min(n-1,a,b)+c
if a+b == 0 and c > 0:
    ans -= 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;

bool data[10];

int main(){
	fill(data,data+10,true);
	int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int d;
		cin>>d;
		data[d]=false;
	}
	int ans=1e7;
	for(int i=n;i<=1e6;i++){
		int t=i;
		while(t){
			if(!data[t%10])break;
			t/=10;
			if(t==0)ans=min(ans,i);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

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

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

int main(void){
    cin >> n;
    for(int i=0; i<n; i++) scanf("%d", &A[i]);
    cnt = 0;
    
    shellSort(A, n);
    
    cout << G.size() << "\n";
    for(int i=G.size()-1; i>=0; i--){
        printf("%d", G[i]);
        if(i)printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for(int i=0; i<n; i++) printf("%d\n", A[i]);
    
    return 0;    
}


Measured memory_bytes: 7120
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    int dp[n][3];
    cin >> dp[0][0]>>dp[0][1]>>dp[0][2];
    
    int a,b,c;
    for(int i=1;i<n;i++){
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][2],dp[i-1][0])+b;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 1408
import bisect
from collections import deque

N = int(input())
A = []
for _ in range(N):
  a = int(input())
  A.append(a)

b = deque([])
for a in A:
  if len(b) == 0:
    b.append(a)
  else:
    if a <= b[0]:
      b.appendleft(a)
    else:
      b[bisect.bisect_left(b, a) - 1] = a
print(len(b))

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

const int INF = 1e9+7;

int main(){
    int n;  cin >> n;
    int k;  cin >> k;
    vector<int>h(n);
    rep(i, n)   cin >> h[i];
    vector<int>dp(n);
    rep(i, n){
        if(!i)  continue;
        int tmp = INF;
        for(int j = 1; j <= k; j++){
            if(i-j<0)   continue;
            tmp = min(tmp, dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i] = tmp;
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  char a, b, c, d;
  a = s.at(0);
  b = s.at(1);
  c = s.at(2);
  d = s.at(3);
  
  if(a == b && b == c && c == d){
    cout << "No";
  }
  else if(a == b && c == d){
    cout << "Yes";
  }
  else if(a == c && b == d){
    cout << "Yes";
  }
  else if(a == d && b == c){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc064/tasks/abc064_d
# カッコこっかを対応させたい → 前か後ろに追加するだけで良い


def n_fusoku(S, target='('):  # 順方向で書いておく (を先頭に追加すべき個数
    stack = []
    ret = 0
    for s in S:
        if s == target:
            stack.append(s)
        else:
            if stack:
                stack.pop()
            else:
                ret += 1  # 不足分
    return ret


N = read_a_int()
S = input()
n_kakko = n_fusoku(S)
n_kokka = n_fusoku(reversed(S), target=')')
print('(' * n_kakko + S + ')' * n_kokka)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
 int n;
  cin>>n;
  vector<string> w(n);
  rep(i,0,n) cin>>w[i];
  map<string,int> g;
  bool ok=true;
  char end=w[0][w[0].size()-1];
  g[w[0]]++;
  rep(i,0,n-1){
    if(w[i][w[i].size()-1]!=w[i+1][0]) ok=false;
    else{
      if(g[w[i+1]]>0) ok=false;
      g[w[i+1]]++;
    }
  }
  if(ok){
    cout<<"Yes" <<endl;
  }
  else cout<< "No" <<endl;
}








Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<30;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
//vector< vector<int> > v (max1, vector<in t>(max2) );

int a[31] = {};


int main() {
	string a;
	cin >> a;
	int ans = 0;
	rep(i, (int)a.length()) {
		if (a[i] == '-')ans--;
		else ans++;
	}
	cout << ans << endl;
	int n;
	cin >> n;
	
	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 REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n;
	cin >> n;
	cout << (n*(n-1)/2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
	string S;
	cin >> S;

	if(S=="zyxwvutsrqponmlkjihgfedcba"){
		cout << -1 <<endl;
		return 0;
	}

	int N = S.size();
	if(N==26){
		int i = 25;
		while(S[i]>S[i+1]){
			i--;
		}
		for(int k=0;k<i;k++){
			cout << S[k];
		}
		int k = 25;
		while(S[k]<S[i]){
			k--;
		}
		cout << S[k] <<endl;
		
		return 0;
	}

	bool flag[26];
	for(int i=0;i<26;i++) flag[i] = false;

	for(int i=0;i<N;i++){
		flag[S[i]-'a'] = true;
	}

	cout << S;
	for(int i=0;i<26;i++){
		if(flag[i]==false){
			cout << char(i+'a') <<endl;
			break;
		}
	}
   
  	return 0;
}



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	ll now = 1000;
	rep(i,n-1) {
		ll cnt = 0;
		if (a[i] < a[i+1]) {
			cnt = now / a[i];
			now +=(a[i+1] - a[i])*cnt;
		}
	}
	cout << now << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <cctype>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <unordered_map>
using namespace std;

constexpr int MAX = 20;
constexpr int mask = 0xf;
constexpr int dx[4] = {1, -1, 0, 0};
constexpr int dy[4] = {0, 0, 1, -1};

const unordered_map<char, int> dir{{'>', 0}, {'<', 1}, {'v', 2}, {'^', 3}, {'_', 0}, {'|', 2}};

int h, w;
bool visited[MAX][MAX][4][mask];
string program[MAX];

bool dfs(int x, int y, int d, int m) {
	if(program[y][x] == '@') {
		return true;
	}
	else if(dir.count(program[y][x])) {
		d = dir.at(program[y][x]);
		if(m && (program[y][x] == '_' || program[y][x] == '|')) ++d;
	}
	else if(isdigit(program[y][x])) {
		m = program[y][x] - '0';
	}
	else if(program[y][x] == '+') {
		m = ((m + 1) & mask);
	}
	else if(program[y][x] == '-') {
		m = ((m - 1) & mask);
	}

	if(visited[x][y][d][m]) return false;

	if(program[y][x] == '?') {
		for(int i = 0; i < 4; ++i) visited[x][y][i][m] = true;
		for(int i = 0; i < 4; ++i) {
			if(dfs((x + dx[i] + w) % w, (y + dy[i] + h) % h, i, m)) return true;
		}
		return false;
	}
	else {
		visited[x][y][d][m] = true;
		return dfs((x + dx[d] + w) % w, (y + dy[d] + h) % h, d, m);
	}
}

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

	cin >> h >> w;

	for(int i = 0; i < h; ++i) cin >> program[i];
	cout << (dfs(0, 0, 0, 0) ? "YES" : "NO") << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1332
#include <iostream>
using namespace std;
int main(){
	int K[100];
	int P[100];
	int A[100];
	int N;
	cin>>N;
	
	for(int i=0;i<N;i++){
		cin>>K[i]>>P[i];
		if(K[i]%P[i]==0)
			A[i]=P[i];
		else
			A[i]=K[i]%P[i];
		cout<<A[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N - 1];
  for(int i = 0; N > i; i++) cin >> a[i];
  int mx = a[1] - a [0];
  int mn = a[0];
  for(int i = 1; N > i; i++){
    if(mx < a[i] - mn)  mx = a[i] - mn;
    if(mn > a[i]) mn = a[i];
  }
  cout << mx << endl;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const long INF = 1L << 60;

bool f[110][10];
int p[110][11];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> f[i][j];
		}
	}

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

	vector<int> adj[10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < n; j++) {
			if (f[j][i]) adj[i].push_back(j);
		}
	}

	long ans = -INF;
	for (int i = 0; i < (1 << 10); i++) {
		long sum = 0;
		vector<int> cnt(n, 0);
		for (int j = 0; j < 10; j++) {
			if (i & (1 << j)) {
				for (auto s : adj[j])
					cnt[s]++;
			}
		}
		bool flag = true;
		for (int j = 0; j < n; j++) {
			sum += p[j][cnt[j]];
			if (cnt[j]) flag = false;
		}
		if (flag) continue;
		ans = max(ans, sum);
	}
	cout << ans << endl;
}

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



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

using namespace std;
string s;
string t;

int main(){
  int f2 = 0;
  cin >> s >> t;
  if(s.size()<t.size()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for(int i = (s.size()-t.size());i>=0;i--){
    int frag = 1;
    for(int j = 0;j<t.size();j++){
      if(s[i+j]!=t[j]&&s[i+j]!='?') frag = 0;
    }
    if(frag == 1&&f2==0){
      for(int k = 0;k<i;k++){
        if(s[k]!='?') cout << s[k];
        else cout << "a";
      }
      cout << t;
      for(int k = i+t.size();k<s.size();k++){
        if(s[k]!='?') cout << s[k];
        else cout << "a";
      }
      f2 = 1;
    }
  }
  if(f2==0) cout << "UNRESTORABLE";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var line = consoleReader.SplitInt32();
            return line.Any(i => i == 2) ? "No" : "Yes";
        }


        public const int mod = 1000000007;
        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program().Calc());
        public static string MultiLine<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

    #region Console
    public class ConsoleReader { public virtual string String() => Console.ReadLine(); public int Int32() => int.Parse(String()); public long Int64() => long.Parse(String()); public ulong UInt64() => ulong.Parse(String()); public double Double() => double.Parse(String()); public string[] Split() => String().Split().ToArray(); public int[] SplitInt32() => String().Split().Select(int.Parse).ToArray(); public long[] SplitInt64() => String().Split().Select(long.Parse).ToArray(); public ulong[] SplitUInt64() => String().Split().Select(ulong.Parse).ToArray(); public double[] SplitDouble() => String().Split().Select(double.Parse).ToArray(); public IEnumerable<string> Repeat(int count) { for (int i = 0; i < count; i++) yield return String(); } public IEnumerable<int> RepeatInt32(int count) { for (int i = 0; i < count; i++) yield return Int32(); } public IEnumerable<long> RepeatInt64(int count) { for (int i = 0; i < count; i++) yield return Int64(); } public IEnumerable<string[]> RepeatSplit(int count) { for (int i = 0; i < count; i++) yield return Split(); } public IEnumerable<int[]> RepeatSplitInt32(int count) { for (int i = 0; i < count; i++) yield return SplitInt32(); } }
    #endregion
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    string n;
    cin >> n;
    int sum = 0;
    for (auto c : n) {
        sum += c - '0';
    }
    cout << (sum %9==0?"Yes" : "No") << endl;
}

Measured memory_bytes: 3676
import math
x = int(input())
ans = 1 # 1^b = 1
n = math.floor(math.sqrt(x))
for i in range(2, n+1): # [2,n]
    a = i # a^1
    while a < x:
        a *= i # a^b,(b>=2)
        if a <= x: ans = max(ans, a)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
   int s, w;
   cin >> s >> w;
   
   if (w >= s)
   {
       cout << "unsafe" << endl;
   }
   
   else
   {
       cout << "safe" << endl;
   }
   
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
int graph[100][100];
int a[100],b[100];
bool vis[100];
int n , m;
void dfs(int x){
	vis[x] = true;
	for(int i = 0 ; i < n ; i++)
	{
		if(graph[x][i] == 0)continue;
		if(vis[i] == true)	continue;
		dfs(i);
	}
}
int main()
{
	dhoom;
	cin >> n >> m;
	for(int i = 0; i < m ; i++){
		cin >> a[i] >> b[i];
		a[i]-- ;
		b[i]--;
		graph[a[i]][b[i]] = 1;
		graph[b[i]][a[i]] = 1;
	}
	int ans = 0;
	for(int i = 0 ; i < m ; i++)
	{
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = 0;
		for(int j = 0 ; j < n ; j++)	
			vis[j] = false;
		bool flag = true;
		dfs(0);
		for(int j = 0 ; j < n ; j++)
			if(vis[j] == false)	
				flag = false;
		if(flag == false)
			ans++;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> table(k, 0);
    rrep(i, n) {
        table[i % k]++;
    }
    ll ans = 0;
    rrep(i, n) {
        int a = i % k;
        int b = (k - a) % k;
        int c = (k - a) % k;
        if((b + c) % k == 0) ans += table[b] * table[c];
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main () {
    int N, s1, s2, d;
    cin >> N;
    vector<int> W;
    W.resize(N);
    int m = 0;
    for (int i = 0; i < N; i++) {
        cin >> W[i];
        m += W[i];
    }
    for (int T = 1; T < N; T++) {
        s1 = 0;
        s2 = 0;
        for (int i = 0; i < N; i++) {
            if (i <= T) {
                s1 += W[i];
            } else {
                s2 += W[i];
            }
        }
        d = abs(s1 - s2);
        if (d < m) {
            m = d;
        }
    }
    cout << m << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;

int main(){
    int n;cin>>n;
    map<long long, int> nums;
    long long temp;
    for (int i=0;i<n;i++){
        cin >> temp;
        if (nums[temp] == 0){
            nums[temp]++;
        } else {
            nums[temp] = 0;
        }
    }
    int acc=0;
    for (auto item : nums){
        if (item.second != 0){
            acc++;
        }
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


#define BUF_SIZE 10000

int comp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}

int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num;
  sscanf(line, "%d", &num);
  int *arr = malloc(sizeof(int)*num);
  
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmpbuf = line;
  int i, j, k;
  for(i = 0; i < num; i++) {
    char* tmp = strtok(tmpbuf, " ");
    arr[i] = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
  }

  qsort(arr, num, sizeof(int), comp);
  int cnt = 0;
  int map[4001] = {0};
  int pos = 0;
  int cum = 0;
  for(i = 2; i < num; i++) {
    int longest = arr[i];
    int pivot = arr[i-1];
    for(j = 0; j <= i-2; j++) {
      map[pivot+arr[j]]++;
      if(pos <= pivot+arr[j]) cum++;
    }
    while(pos <= longest) {
      cum -= map[pos++];
    }
    cnt += cum;
  }

  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A, B;
    in >> A >> B;
    //vector<ll> X(N)

    if(A+B > A-B && A+B > A*B){
        out << A+B << endl;
    }else if(A-B > A*B){
        out << A-B << endl;
    }else {
        out << A*B << endl;
    }
 

}

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

int main(){
	int n;
	cin >> n;
	
	int a, b;
	int ans = 9999999, tmp;
	for(int i = 1;i <= n/2;i++){
		tmp = 0;
		a = i;
		b = n - i;
		while(a != 0){
			tmp += a % 10;
			a = a / 10;
		}
		while(b != 0){
			tmp += b % 10;
			b = b / 10;
		}
		if(ans > tmp){
			ans = tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

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

long long int N, a[111], m = 1, A;

int main(){
    scanf("%lld", &N);
    for(int i = 0; i < N; ++i){
        scanf("%lld", a + i);
    }
    for(int i = 0; i < N - 1; ++i){
        a[i] -= a[i + 1];
    }
    for(int i = 0; i < N - 1; ++i){
        if(a[i]){
            A += m / 2;
            m = 1;
        }else{
            ++m;
        }
    }
    A += m / 2;
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc075/tasks/abc075_c

#include <iostream>
#include <vector>
#include <functional>

using namespace std;
using ll = long long;

struct C {
    vector<ll> src_{};
    vector<ll> tgt_{};
    ll N_{};
    vector<vector<ll>> e_{};

    explicit C(vector<ll> src, vector<ll> tgt, ll N) : src_(move(src)), tgt_(move(tgt)), N_(N){
        e_.resize(N_+1);
        for(int i=0; i < src_.size(); ++i) {
            e_[src_[i]].emplace_back(tgt_[i]);
            e_[tgt_[i]].emplace_back(src_[i]);
        }
    }
    void dfs(vector<bool>& visited, ll prev, ll cur, std::function<bool(ll, ll)> l) {
        visited[prev] = true;
        for(auto t : e_[cur]) {
            if (t == prev || !l(cur, t) || visited[t]) {
                continue;
            }
            dfs(visited, cur, t, l);
        }
        visited[prev] = false;
    }
    bool check(ll src, ll tgt) {
        bool unreached = true;
        vector<bool> visited;
        visited.resize(N_+1, false);
        dfs(visited, src, tgt, [&src, &tgt, &unreached](auto a, auto b) {
            if (a == src && b == tgt) {
                return false;
            }
            if (b == src) {
                unreached = false;
                return false;
            }
            return true;
        });
        return unreached;
    }
    ll resolve() {
        ll count = 0;
        for(int i=0; i < src_.size(); ++i) {
            if(check(src_[i], tgt_[i])) {
                ++count;
            }
        }
        return count;
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> src{};
    vector<ll> tgt{};
    for (int i=0; i < M; ++i) {
        ll x;
        ll y;
        cin >> x >> y;
        src.emplace_back(x);
        tgt.emplace_back(y);
    }
    C c{move(src), move(tgt), N};
    cout << c.resolve() << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC143C()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<char> x;
	x.push_back(S.front());
	for (int i = 1; i < N; ++i)
	{
		if (S[i] != x.back())
			x.push_back(S[i]);
	}
	cout << x.size() << endl;
}
int main()
{
	ABC143C();
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int n, m, k;
vi color;
map<int, int> siz;
vector<vi> adj, block;

void dfs(int node, int c){
	if(color[node] != -1) return;
	color[node] = c;
	for(int i : adj[node]) dfs(i, c);
}

void solve() {
	cin >> n >> m >> k;
	
	adj.resize(n), block.resize(n);
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		adj[u].pub(v);
		adj[v].pub(u);
	}
	
	for(int i = 0; i < k; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		
		block[u].pub(v);
		block[v].pub(u);
	}
	
	int col = 0;
	color.resize(n, -1);
	for(int i = 0; i < n; i++) {
		dfs(i, col++);
	}
	
	for(int i = 0; i < n; i++) {
		siz[color[i]]++;
	}
	
	for(int i = 0; i < n; i++) {
		int ans = 0;
		ans += siz[color[i]] - adj[i].size();
		for(int j : block[i]) {
			if(color[j] == color[i]) ans--;
		}
		
		cout << ans - 1 << " ";
	}
}

int main(){
#define MULTITEST 0
#if MULTITEST   
 
    CASET {
        solve();
    }
    
#else

    solve();
    
#endif

    return 0;
}

Measured memory_bytes: 15496
#include<stdio.h>
#include<string.h>
int main()
{
	char  s[790000];
	scanf("%s",s);
	int x=strlen(s);
	if(s[x-1]=='2'||s[x-1]=='4'||s[x-1]=='5'||s[x-1]=='7'||s[x-1]=='9')
	{
		printf("hon\n");
	}
	else if(s[x-1]=='3')
	{
		printf("bon\n");
	}
	else printf("pon\n");
}


Measured memory_bytes: 1648
n,x,m=map(int,input().split())
ans=x
rp=[x]
if n<=m:
    for i in range(n-1):
        x=pow(x,2,m)
        ans+=x
    print(ans)
    exit()
for i in range(m+1):
    x=pow(x,2,m)
    if x in rp:
        tt=rp.index(x)
        t=len(rp)-tt
        break
    else:
        rp.append(x)
tmp=sum(rp[tt:])
wari=(n-tt)//t
amari=(n-tt)%t
ans=sum(rp[:tt])+tmp*wari+sum(rp[tt:tt+amari])
print(ans)

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

using namespace std;

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

int main()
{
	int n;
	vector<int> vi;

	cin >> n;
	rep (i, n) {
		int p;
		cin >> p;
		vi.push_back(p);
	}

	sort(vi.begin(), vi.end(), greater<int>());

	vi[0] = vi[0] / 2;

	cout << accumulate(vi.begin(), vi.end(), 0) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    int L[N];
    int x=0;
    int sum=0;
    rep(i,N){
        cin >> L[i];
        x=max(x,L[i]);
        sum+=L[i];
    }
    if(x<sum-x) cout << "Yes" << endl;
    else cout << "No" << endl;


}


Measured memory_bytes: 256
from math import factorial as f
n, m = map(int, input().split())
if abs(n-m)>1:
    print(0)
else:
    if n==m:
        print(f(n)*f(m)*2%(pow(10,9)+7))
    else:
        print(f(n)*f(m)%(pow(10,9)+7))

Measured memory_bytes: 5180
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

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

    IFOR(i, 1, n){
        if((int)(i * 1.08) == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

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

const int mx=3009;
ll r,c,k;
ll dp[mx][mx][5];

ll arr[mx][mx];
ll sum=0;
ll solve(int x,int y,int num){
   if(x==r&&y==c){
       if(arr[x][y]&&num<3){return arr[x][y];}else{return 0;}
   }
    if(x>r||x<1||y>c||y<1||num>3){return sum;}
    
    ll &ret = dp[x][y][num];
    if(ret!=-1){return ret;}
    
    if(arr[x][y]==0){
       ret=max(solve(x,y+1,num),solve(x+1,y,0));
    }else{
        if(num<3){
            ret=max(ret,solve(x,y+1,num+1)+arr[x][y]);
            ret=max(ret,solve(x,y+1,num));
            ret=max(ret,solve(x+1,y,0)+arr[x][y]);
           // ret=max(ret,solve(x+1,y,0));
        }else{
            ret=max(solve(x,y+1,num),solve(x+1,y,0));
        }
        
       
    }return ret;
    
}
int main()
{
  cin>>r>>c>>k;
  memset(dp, -1, sizeof dp);
  for(int i=0;i<k;i++){
      ll x,y,z;
      cin>>x>>y>>z;sum+=z;
      arr[x][y]=z;
  }sum*=-1;
  cout<<solve(1,1,0);
}

Measured memory_bytes: 428172
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[][] island = new char[12][12];
            int[][] map = new int[12][12];
            for (int i = 0; i < 12; i++) {
                Arrays.fill(map[i], 999);
            }
            for (int i = 0; i < 12; i++) {
                island[i] = sc.next().toCharArray();
            }
            int count = 0;
            for (int i = 0; i < 12; i++) {
                for (int j = 0; j < 12; j++) {
                    if (island[i][j] != '0') {
                        if (i == 0 && j == 0) {
                            map[i][j] = count++;
                        } else {
                            if (i - 1 >= 0 && island[i][j] == island[i - 1][j]) {
                                if (map[i][j] >= 0) {
                                    map[i][j] = Math.min(map[i][j], map[i - 1][j]);
                                }
                            } else if (j - 1 >= 0 && island[i][j] == island[i][j - 1]) {
                                map[i][j] = Math.min(map[i][j], map[i][j - 1]);
                            } else if (j + 1 < 12 && island[i][j] == island[i][j + 1]) {
                                for (int k = j; k < 11; k++) {
                                    if (i - 1 >= 0 && island[i][k] == island[i][k + 1] && island[i][k + 1] == '1' && island[i - 1][k + 1] == '1') {
                                        map[i][j] = map[i - 1][k + 1];
                                        count--;
                                        break;
                                    }
                                }
                                map[i][j] = count++;
                            } else {
                                map[i][j] = count++;
                            }
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}



Measured memory_bytes: 26040
# 7_C
r,c=map(int,input().split())
table=[[0 for i in range(c+1)]for n in range(r+1)]
for i in range(r):
    var=list(map(int,input().split()))
    for n in range(len(var)+1):
        if(n==c):
            table[i][n]=sum(var)
        else:
            table[i][n]=var[n]

for i in range(r):
    for n in range(c):
        table[r][n]+=table[i][n]
table[r][c]=sum(table[r])
for line in table:
    length=len(line)
    for col in line:
        length-=1
        if length ==0 :
            print(str(col))
        else:
            print(str(col)+" ",end='')
        


Measured memory_bytes: 6220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }




int main() {
  cout<<fixed<<setprecision(10);

  string S;cin>>S;

  int a,b;
  a = stoi(S.substr(0,2));
  b = stoi(S.substr(2,2));

  string ans;
  int af,bf;
  if(a>=1 && a<=12) af = true;
  else af = false;

  if(b>=1 && b<=12) bf = true;
  else bf = false;

  if(af && bf){
    ans = "AMBIGUOUS";
  }else if(af  && !bf){
    ans = "MMYY";
  }else if(!af && bf){
    ans = "YYMM";
  }else{
    ans = "NA";
  }

  cout << ans << endl;
}

















//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007


int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> job(N);
    rep(i,N){
        int A,B;
        cin >> A >> B;
        job[i]=make_pair(B,A);
    }
    sort(job.begin(),job.end());
    ll time = 0;
    for(int i=0;i<N;i++){
        time+=job[i].second;
        if(time>job[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int H, W;

    scanf("%d%d", &H, &W);

    char C[H][W+1];

    for(int i = 0; i < H; i++){
        scanf("%s", C[i]);
    }

    for(int i = 0; i < H; i++){
        printf("%s\n", C[i]);
        printf("%s\n", C[i]);
    }

    return 0;
}

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

int main() {
    int n, count, ans=0, i=1;
    cin >> n;
    while(n>=i) {
        count=0;
        for(int j=1; j<=i; j++) {
            if(i%j==0) count++;
        }
        if(count==8) {
            ans++;
        }
        i += 2;
    }
    cout << ans;
}

Measured memory_bytes: 256