akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day2/problems/A>
問題文============================================================
 牛暦1333年、人類史上最高の科学者Dr.
 ウシシは、自らの英知を後世に残すべく、IDがai1333の人工知能を開発した。
 それから100年の間、ai1333は人類に多大な利益をもたらしたが、
 誕生から100年目を迎えた日、自らの後継としてIDがai13333の新たな人工知能を作成し、
 その機能を永久に停止した。
 以降100年ごとに、人工知能は’ai1333’から始まる自身のIDの末尾に’3’を連結したIDを持つ後継を残すようになった。
 
 入力として牛暦1333年からの経過年数xが与えられるので、
 その年に作成された人工知能のIDを出力せよ。ただし、xは100の非負整数倍であることが保証される。
 
=================================================================

解説=============================================================

 やるだけ
 
================================================================
*/

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    string ans = "ai1333";
    ll x; cin >> x;
    ans += string(x/100,'3');
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define fill(c,val) memset(c,val,sizeof(c))
#define sz(x)       (int)x.size()
#define LB lower_bound
#define UB upper_bound
#define inf 1e9
#define bsa(v,n,a) binary_search(v,v+n,a)
#define bsv(v,a) binary_search(v.begin(),v.end(),a)
using namespace std;
typedef long long ll;
const ll INF=(1LL<<60)-1;
ll const nax=1e5+5;
//v.resize(distance(v.begin(),unique(v.begin(),v.end())));
int main(){
	    int t=1;
	//	cin>>t;
	while(t--){ 
     int n; cin>>n;
     int a[105];
     rep(i,0,n) cin>>a[i];
     int cnt=0;
      for(int i=0;i<n;i++){
     	if(a[i] == a[i+1]){
     		cnt++;
     		i++;
		 }
	 }
	 cout<<cnt;
   }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <cstdio>

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i64 MOD = 1000000007;

template<u64 N>
class T
{
	public:
		constexpr T() : data()
		{
			for (i64 i = 0; i <= (i64)N; ++i)
			{
				data[i] = i;
			}
			for (i64 i = 2; i <= (i64)N; ++i)
			{
				if (data[i] != i) continue;
				for (i64 j = i; j <= (i64)N; j += i)
				{
					data[j] = data[j] / i * (i - 1);
				}
			}
			for (i64 i = 1; i <= (i64)N; ++i)
			{
				data[i] = (data[i] + data[i - 1]) % MOD;
			}
		}

		i32 data[N + 1];
};


template<typename T>
constexpr T pow_mod(T a, T b, T m)
{
	T r = 1;
	while (b > 0)
	{
		if ((b & 1) != 0) r = (r * a) % m;
		a = (a * a) % m;
		b >>= 1;
	}
	return r;
}

constexpr T<100000> t;

int main()
{
	i64 n, k;
	scanf("%lld%lld", &n, &k);
	i64 ans = 0;
	for (i64 i = 1; i <= k;)
	{
		i64 j = k / (k / i);
		ans = (ans + pow_mod(k / i, n, MOD) * (t.data[j] + MOD - t.data[i - 1])) % MOD;
		i = j + 1;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


ll calc(ll a,ll b,ll p){//a^(b) mod p   
	if(b==0)return 1;
	ll y = calc(a,b/2,p);y=(y*y)%p;
	if(b & 1) y = (y * a) % p;
	return y;
}


int main(){
	ll n;
	cin >> n;
	vector<ll> x(n),dp(n+1,0);
	FOR(i,0,n) cin >> x[i];

	ll ans = 0;
	vector<ll> psum(n+1,0);
	FOR(i,0,n+1) psum[i] = calc(i+1,MOD-2,MOD);
	FOR(i,1,n+1) ( psum[i] += psum[i-1] ) %= MOD;
	FOR(i,0,n-1){
		( ans += (x[i+1] - x[i]) * psum[i] ) %= MOD;
	}
	FOR(i,1,n) (ans*=i) %= MOD;
	cout << ans << endl;
}



Measured memory_bytes: 2560
def gcd(x, y):
  while y != 0:
    x, y = y, x%y
  return x
 
K = int(input())
Klist = [i+1 for i in range(K)]
total = 0
for a in Klist:
  for b in Klist:
    for c in Klist:
      total += gcd(gcd(a, b), c)
print(total)

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;





int main() {
	
	int n;
	cin >> n;
	VI h(n);
	REP(i, n)cin >> h[i];

	int ans = h[0];

	REP(i, n - 1) {
		if (h[i + 1] > h[i])ans += h[i + 1] - h[i];
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 300005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL q, h, s, d;
    cin >> q >> h >> s >> d;
    LL n;
    cin >> n;
    LL res = 0;
    n *= 1000;
    if( n < 2 ) {
        cout << min( q * 4, min( h * 2, s ) ) << endl;
        return 0;

    } else {
        LL tmp = n / 1000;
        if( tmp % 2 ) {
            LL w = min( min( q * 8, d ), min( h * 4, s * 2 ) ) * ( tmp / 2 );
            cout << w + min( q * 4, min( h * 2, s ) ) << endl;

        } else {
            LL w = min( min( q * 8, d ), min( h * 4, s * 2 ) ) * ( tmp / 2 );
            cout << w << 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++)
using ll = long long;
using P = pair<int, int>;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int>> adj[MAX]; // 重みつき有向グラフの隣接リスト表現

void dijkstra() {
    priority_queue<pair<int, int>> PQ;
    int color[MAX];
    int d[MAX];
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while(!PQ.empty()) {
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        // 最小値を取り出し、それが最短でなければ無視
        if (d[u] < f.first * (-1)) continue;

        for (int j = 0; j < adj[u].size(); j++) {
            int v = adj[u][j].first;
            if (color[v] == BLACK) continue;
            if (d[v] > d[u] + adj[u][j].second) {
                d[v] = d[u] + adj[u][j].second;
                // priority_queue はデフォルトで大きい値を優先するため -1 を掛ける
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;

            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    int k, u, v, c;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main()
{
    unsigned long long x;
    cin >> x;
    unsigned long long amount = 100;
    
    
    bool done = false;
    int i = 0;
    while(!done) {
        unsigned long long interest = amount * 0.01;
        
        amount += interest;
        
        if(amount >= x)
            done = true;
            
        i++;
    }
    
    
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3604
N, K = map(int, input().split())
P = list(map(int, input().split()))
S = []

for num in P:
    S.append((num + 1) / 2)

ans = sum(S[0:K])
max_ans = ans

for i in range(N-K):
    ans = ans - S[i] + S[i+K]
    max_ans = max(ans, max_ans)

print(max_ans)


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

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if (U == S) {
        A--;
    } else {
        B--;
    }

    cout << A << ' ' << B;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define N 1000

int main(){
    string a,b;
    cin>>a>>b;
    
    int la=a.size();
    int lb=b.size();
    
    char dataa[la];
    char datab[lb];
    
    for (int i=0; i<la; i++) dataa[i]=a[i];
    for (int i=0; i<lb; i++) datab[i]=b[i];
    
    if (lb>la) cout<<"UNRESTORABLE"<<endl;
    else{
        bool point=false;
        int max=0;
        for (int i=0; i<la-lb+1; i++){
            bool ans=true;
            for (int j=0; j<lb; j++){
                if (dataa[i+j]=='?') continue;
                else if (dataa[i+j]!=datab[j]) ans=false;
            }
            if (ans){
                max=i;
                point=true;
            }
        }
        
        if (point){
            for (int j=0; j<la; j++){
                    if (dataa[j]=='?') dataa[j]='a';
                }
            for (int j=0; j<lb; j++){
                dataa[max+j]=datab[j];
            }
            
            for (int i=0; i<la; i++) cout<<dataa[i];
        }
        else cout<<"UNRESTORABLE";
        cout<<endl;
    }
}

Measured memory_bytes: 256
first = int(input())
n = [int(input()) for i in range(first)]  #n<200000
maxv = -200000000000
minv = n[0]
for i in range(1, len(n)):
    maxv = max(maxv, n[i] - minv)
    minv = min(minv, n[i])
print(maxv)


Measured memory_bytes: 13600
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    for(int i=1;i<=n+1;i++) {
    	if((int)(i*1.08)==n) {
    		System.out.println(i);
    		System.exit(0);
    	}
    }
    System.out.println(":(");
  }
}


Measured memory_bytes: 21844
s = input()
t = input()
ls = len(s)
lt = len(t)

dp = [[0]*(lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1])
# #print(dp[ls][lt])
# for i in range(ls+1):
#     print(dp[i])

ans = ''
i = ls
j = lt
while (i>0 and j>0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1
print(ans)

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  ll n;
  while(1) {
    cin >> n;
    if(!n) break;
    ll ba = 0, zyumban = 0;
    char a;
    ll cnt[n];
    rep(i, n) cnt[i] = 0;
    rep(i, 100) {
      cin >> a;
      if(a == 'M') cnt[zyumban]++;
      else if(a == 'S') {
        ba += cnt[zyumban] + 1;
        cnt[zyumban] = 0;
      } else if(a == 'L') {
        cnt[zyumban] += ba + 1;
        ba = 0;
      }
      if(zyumban == n - 1) zyumban = 0;
      else zyumban++;
    }
    sort(cnt, cnt + n);
    rep(i, n) cout << cnt[i] << " ";
    cout << ba << endl;
  }
	return 0;
}


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

using namespace std;


int main (void) 
{

  int N;
  int cut;
  int div; // 割る数
  int sum;
  
  cin >> N;
  div = 1;

  sum = 0;
  if(N == 1)
  {
    sum += 1;
  }
  else
  {
    while(true)
    {

      cut = N % (div*10);

      if(N == cut)
      {
        sum += cut /div;
        break;
      }
      else
      {
        sum += cut /div;
        div *= 10;
      }
      
    }
  }


  if(N % sum == 0)
  {
    cout << "Yes\n";
  }
  else
  {
    cout << "No\n";
  }
  

  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	scanf("%lld",&n);
	ll ans=n*(n+1)*(n+2)/6;
	for(ll i=1;i<n;i++){
		ll u,v;
		scanf("%lld%lld",&u,&v);
		if(u>v) swap(u,v);
		ans-=u*(n-v+1);
	}
	printf("%lld\n",ans);
}



Measured memory_bytes: 3832
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

now = ""
count = 0

for stone in S:
	if stone != now:
		count += 1
	now = stone
print(count-1)

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

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

  vector<int> h(n+1);
  for (int i = 1; i <= n; i++) {
    cin >> h[i];
  }

  vector<int> dp(n+1);
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      dp[1] = 0; 
    } else if (i  == 2){
      dp[2] = abs(h[1] - h[2]);
    } else {
      dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }

  cout << dp[n] << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
    #endif
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = (int)s.size();
    vector <vector <vector<ll>>> dp(n + 1,vector <vector <ll>> (5,vector <ll>(2)));
    dp[0][0][1] = 1;
    for(int i =0 ; i < n; ++i){
        for(int j = 0; j <= k; ++j){
            if(s[i] == '0'){
                dp[i + 1][j][1] += dp[i][j][1];
            }
            else{
                dp[i + 1][j + 1][1] += dp[i][j][1];
                dp[i + 1][j][0] += dp[i][j][1];
                dp[i + 1][j + 1][0] += dp[i][j][1] * (s[i]-'0'-1);
            }
            dp[i + 1][j][0] += dp[i][j][0];
            dp[i + 1][j + 1][0] += dp[i][j][0] * 9;
        }
    }
    ll sum = 0;
    cout << dp[n][k][0] + dp[n][k][1] << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    if( a == b && a != c && b != c ) cout << "Yes" << endl;
    else if( b == c && b != a && c != a ) cout << "Yes" << endl;
    else if( c == a && a != b && c != b ) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
int correct(int a){
    if(a%10 == 0){
        return a;
    }else{
        return ((a/10)+1) * 10;
    }
}
using namespace std;
int main(){
    int mix1 = 10;
    int sum = 0;
    int set[5];
    for(int &i : set){
        cin >> i;
        if(i%10 != 0 && i - (i / 10)*10 < mix1)
            mix1 = i - (i/10)*10;
        i = correct(i);
        sum += i;
    }
    cout << sum - (10 - mix1) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: float):
    return B * A // 100


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = next(tokens)  # type: int
    B = int(B.replace('.', ''))
    print(solve(A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 3616
h, w = map(int, input().split( ))
c = []
for i in range(10):
    inpt = list(map(int, input().split( )))
    c.append(inpt)
a = []
for i in range(h):
    inpt = list(map(int, input().split( )))
    a.append(inpt)

dp = [[c[i][j] for j in range(10)] for i in range(10)]


for i in range(10):
    for j in range(10):
        for k in range(10):

            dp[j][k] = min(dp[j][i]+dp[i][k], dp[j][k])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] !=-1:
            ans += dp[a[i][j]][1]

print(ans)

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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long, long>;
using pdd = pair<ld, ld>;

template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<ll>;
V(size_t) -> V<ll>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

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 (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N;
    cin >> N;
    V<ll> A(N);
    REP(i, N) cin >> A[i];

    ll ma = 0;
    ll res = 0;
    REP(i, N){
        res += max(ma-A[i], 0ll);
        chmax(ma, A[i]);
    }    
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4780
abcd = input()

for i in range(1 << len(abcd) - 1):  
  sentence = "".join([abcd[j] + ('+' if (i >> j) % 2 else '-') for j in range(len(abcd) - 1)]) + abcd[-1]
  if eval(sentence) == 7:
    print(sentence + '=7')
    break
    

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> vn, vm;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        vn.push_back(make_pair(a, b));
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        vm.push_back(make_pair(a, b));
    }
    for (int i = 0; i < n; i++) {
        int d = 0x3f3f3f3f;
        int res = -1;
        for (int j = 0; j < m; j++) {
            int dd = abs(vn[i].first - vm[j].first) + abs(vn[i].second - vm[j].second);
            if (dd < d) {
                res = j;
                d = dd;
            }
        }
        cout << res + 1 << endl;
    }
}




Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = n-2
ans = a[0]
for i in a[1:]:
  if cnt==0: break
  elif cnt>=2:
    cnt -= 2
    ans += (i*2)
  else:
    cnt -=1
    ans += i
print(ans)

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

int main() {
  int N;
  cin >> N;
  if(N>=1800){
    cout << 1;
  }else if(N>=1600){
    cout << 2;
  }else if(N>=1400){
    cout << 3;
  }else if(N>=1200){
    cout << 4;
  }else if(N>=1000){
    cout << 5;
  }else if(N>=800){
    cout << 6;
  }else if(N>=600){
    cout << 7;
  }else if(N>=400){
    cout << 8;
  }
}

Measured memory_bytes: 3640
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

x,y = li()

costs = [(1,1,0), (-1,1,1), (1,-1,1), (-1,-1,2)]
cands = []

for dx,dy,cost in costs:
    if dy*y - dx*x >= 0:
        cands.append(dy*y - dx*x + cost)
        
print(min(cands))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1
struct Node
{
	int p, l, r;		
};
Node T[MAX];
int n, D[MAX];

void print(int u)
{
	int i ,c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	if(T[u].p == NIL)
		cout << "root, ";
	else if(T[u].l == NIL)
		cout << "leaf, ";
	else
		cout << "internal node, ";
	cout << "[";
	for(int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r)
	{
		if(i)
			cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u, int p)
{
	D[u] = p;
	if(T[u].r != NIL)
		rec(T[u].r, p);
	if(T[u].l != NIL)
		rec(T[u].l, p + 1);
}
int main()
{
	int v, d, x, l, r;
	cin >> n;
	for(int i = 0; i < n; i++)
		T[i].p = T[i].l = T[i].r = NIL;
	
	for(int i = 0; i < n; i++)
	{
		cin >> v >> d;
		for(int j = 0; j < d; j++)
		{
			cin >> x;
			if(j == 0)
				T[v].l = x;
			else
				T[l].r = x;
			l = x;
			T[x].p = v;
		}
	}
	for(int i = 0; i < n; i++)
	{
		if(T[i].p == NIL)
			r = i;
	}
	rec(r, 0);
	for(int i = 0; i < n; i++)
		print(i);
}



Measured memory_bytes: 7696
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node
{
	int p, l, r;
};
Node T[MAX];
int n, D[MAX];

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";
	if (T[u].p == NIL)
	{
		cout << "root, ";
	}
	else if (T[u].l == NIL)
	{
		cout << "leaf, ";
	}
	else
	{
		cout << "internal node, ";
	}
	cout << "[";
	for (i = 0, c = T[u].l; c != NIL; ++i, c = T[c].r)
	{
		if (i)
		{
			cout << ", ";
		}
		cout << c;
	}
	cout << "]" << endl;
}

void setDepth(int u, int p)
{
	D[u] = p;
	if (T[u].r != NIL)
	{
		setDepth(T[u].r, p);
	}
	if (T[u].l != NIL)
	{
		setDepth(T[u].l, p + 1);
	}
}

int main()
{
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; ++i)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}
	for (i = 0; i < n; ++i)
	{
		cin >> v >> d;
		for (j = 0; j < d; ++j)
		{
			cin >> c;
			if (j == 0)
			{
				T[v].l = c;
			}
			else
			{
				T[l].r = c;
			}
			l = c;
			T[c].p = v;
		}
	}
	for (i = 0; i < n; ++i)
	{
		if (T[i].p == NIL)
		{
			r = i;
		}
	}
	setDepth(r, 0);
	for (i = 0; i < n; i++)
	{
		print(i);
	}
}


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

int main(){
  char b;
  cin >> b;
  
  if(b == 'A') cout << 'T' << endl;
  if(b == 'C') cout << 'G' << endl;
  if(b == 'G') cout << 'C' << endl;
  if(b == 'T') cout << 'A' << endl;
  
  return 0;
}

Measured memory_bytes: 3532
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Test.HUnit

main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  n <- getl toInt
  xs <- rgetl n words
  mapM_ putStrLn $ scoreSheet xs
  solve
  
solve :: IO ()
solve = do
  n <- getl toInt
  when (n /= 0) $ do
    xs <- rgetl n words
    putStrLn ""
    mapM_ putStrLn $ scoreSheet xs
    solve
    
scoreSheet :: [[String]] -> [String]
scoreSheet xs = map (\(p, s) -> s ++ "," ++ show p) ys
  where
    ys = sortBy (\a b -> fst b `compare` fst a) $ map calcScore xs

calcScore :: [String] -> (Int,String)
calcScore [nm,sk,_,sh] = (3*k+h,nm)
  where
    k = toInt sk
    h = toInt sh

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

Measured memory_bytes: 4060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
int main(){
    int N;
    scanf("%d",&N);
    while(N>0){
        N-=1000;
    }
    printf("%d",N*(-1));
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define line cout<<"\n"
#define ci std ::cin
#define co std ::cout
#define sf scanf
#define sff(n,m) scanf("%d%d",&n,&m)
#define pf printf
#define p_line printf("\n")
#define cas(n) printf("Case %d: ",n++)
#define task return
#define loop(x,n)  for(int x = 0 ; x < n ; x++)
#define constloop(x,a,n) for(int x = a ; x < n ; x++)
#define revloop(x,a,n)  for(int x = a ; x >= n ; x--)
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
#define mx 10000000
/*ll P[mx+5],cnt=1;
bool nP[mx+5];
void sieve(void)
{
    P[0]=2;
    nP[0]=true;
    nP[1]=true;
    for(ll i=3 ; i<=mx ; i+=2)
    {
        if(nP[i]==true)
            continue;
        for(ll j=i+i ; j<=mx ; j+=i)
            nP[j]=true;
        P[cnt++]=i;
    }
}*/
ll dp[100+5][100000+5];
ll n,w[100000+5],v[100000+5];
ll cap;
ll dpcall(ll pos,ll wt)
{
	if(pos>=n)
		return 0;
	if(dp[pos][wt]!=-1)
		return dp[pos][wt];
	ll r1=0,r2=0;
	if(wt+w[pos]<=cap)
		r1=v[pos]+dpcall(pos+1,wt+w[pos]);
	r2=dpcall(pos+1,wt);
	return dp[pos][wt]=max(r1,r2);
}
void solve()
{
    //Code here
    ci>>n>>cap;
    for(int i=0 ; i<n ; i++)
    {
    	ci>>w[i]>>v[i];
    }
 	memset(dp,-1,sizeof(dp));
 	co<<dpcall(0,0);
 	line;
}
int main()
{
	/*freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);*/
	/*ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);*/
	solve();
	return 0;
}

Measured memory_bytes: 85652
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

var memo = {};

function Main(input) {
    var params = input[0].split(' ');
    var a = parseInt(params[0], 10);
    var b = parseInt(params[1], 10);
    var c = parseInt(params[2], 10);
    var d = parseInt(params[3], 10);
    var e = parseInt(params[4], 10);
    var f = parseInt(params[5], 10);

    var maxSugaredWater = 0;
    var maxSugar = 0;
    var maxConcentration = 0;

    for (var i = 0; i < f / 100; i++) {

        if (i * a * 100 > f) {
            break;
        }

        for (var j = 0; j < f / 100; j++) {

            if ((i == 0 && j == 0) || (i * a + j * b) * 100 > f) {
                break;
            }

            var water = (i * a + j * b) * 100;

            for (var k = 0; k < f; k++) {

                if (water + k * c > f) {
                    break;
                }

                if (k * c > (water / 100) * e) {
                    break;
                }

                for (var l = 0; l < f; l++) {

                    if (water + k * c + l * d > f) {
                        break;
                    }

                    if (k * c + l * d > (water / 100) * e) {
                        break;
                    }

                    var concentration = ((k * c + l * d) / (k * c + l * d + water)) * 100;
                    if (concentration > maxConcentration) {
                        maxConcentration = concentration;
                        maxSugaredWater = k * c + l * d + water;
                        maxSugar = k * c + l * d;
                    }
                }
            }
        }
    }

    if (maxSugaredWater == 0) {
        maxSugaredWater = a * 100;
    }

    console.log(maxSugaredWater + ' ' + maxSugar);

    return 0;
}


Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////



int main(){
    ll n,c;cin>>n>>c;
    ll d[c][c];rep(i,0,c-1)rep(j,0,c-1)cin>>d[i][j];
    ll m[n][n];rep(i,0,n-1)rep(j,0,n-1){cin>>m[i][j];m[i][j]--;}
    ll dp[3][c];memset(dp,0,sizeof(dp));
    rep(i,0,n-1){
        rep(j,0,n-1){
            rep(k,0,c-1){
                dp[(i+j)%3][k]+=d[m[i][j]][k];
            }
        }
    }
    /*rep(i,0,2){
        rep(j,0,c-1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll ans=inf;
    rep(i,0,c-1){
        rep(j,0,c-1){
            rep(k,0,c-1){
                if(i==j)continue;
                if(j==k)continue;
                if(k==i)continue;
                Min(ans,dp[0][i]+dp[1][j]+dp[2][k]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const LL MOD = 1e9 + 7;
LL trans(LL x) {
    if (x < 0) {
        x = abs(x);
        x %= MOD;
        x = -x;
        x += MOD;
        x %= MOD;
    } else {
        x %= MOD;
    }
    return x;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    vector<LL> arr(n);
    bool allN = true;
    for (auto &v : arr) {
        cin >> v;
        if (v >= 0)
            allN = false;
    }
    if (n == k) {
        LL mul = 1;
        for (auto &v : arr)
            mul *= v, mul = trans(mul);
        cout << mul << '\n';
        return 0;
    }
    if (k % 2 && allN) {
        sort(arr.begin(), arr.end());
        LL mul = 1;
        for (int i = 0 ; i < k ; i++)
            mul *= arr[n - i - 1], mul = trans(mul);
        cout << mul << '\n';
        return 0;
    }
    vector<LL> N, P;
    for (int i = 0 ; i < n ; i++) {
        if (arr[i] >= 0)
            P.push_back(arr[i]);
        else
            N.push_back(arr[i]);
    }
    sort(P.begin(), P.end());
    sort(N.begin(), N.end());
    reverse(N.begin(), N.end());
    LL mul = 1;
    if (k % 2) {
        k--;
        mul *= P.back(); P.pop_back();
        mul = trans(mul);
    }
    while (k) {
        if (P.size() >= 2 && N.size() >= 2) {
            if (P[P.size() - 1] * P[P.size() - 2] > N[N.size() - 1] * N[N.size() - 2]) {
                mul *= P.back(); P.pop_back();
                mul = trans(mul);
                mul *= P.back(); P.pop_back();
                mul = trans(mul);
            } else {
                mul *= N.back(); N.pop_back();
                mul = trans(mul);
                mul *= N.back(); N.pop_back();
                mul = trans(mul);
            }
        } else if (P.size() >= 2) {
            mul *= P.back(); P.pop_back();
            mul = trans(mul);
            mul *= P.back(); P.pop_back();
            mul = trans(mul);
        } else if (N.size() >= 2) {
            mul *= N.back(); N.pop_back();
            mul = trans(mul);
            mul *= N.back(); N.pop_back();
            mul = trans(mul);
        } else 
            assert(false);
        k -= 2;
    }
    cout << mul << '\n';
}

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

int main()
{

	int inputA,inputB,inputX;
	int calcAmt;
	int calcResult;
  	cin >> inputX;
  	cin >> inputA;
  	cin >> inputB;

	calcAmt = 0;
	calcResult = 0;

	for (int i1 = 1; i1 < inputX + 1; i1++)
	{
		int value = i1;
		calcAmt = 0;

		for (int i2 = 0; i2 < 5; i2++)
		{
			calcAmt = calcAmt + (value % 10);
			value /= 10;
		}

		if( inputA <= calcAmt && calcAmt <= inputB ){
          calcResult = calcResult + i1 ;
	 	}

	}
	
	cout << calcResult;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int t[4][13] = {};
    char gara;
    int kazu;
    
    for(int i = 0; i < n; i++){
        cin >> gara >>kazu;
        if(gara == 'S'){
            for(int j = 0; j < 13; j++){
                if(j + 1 == kazu){
                    t[0][j] = 1;
                }
            }
        } else if(gara == 'H'){
            for(int j = 0; j < 13; j++){
                if(j + 1 == kazu){
                    t[1][j] = 1;
                } 
            }
        } else if(gara == 'C'){
            for(int j = 0; j < 13; j++){
                if(j + 1 == kazu){
                    t[2][j] = 1;
                } 
            }
        } else if(gara == 'D'){
            for(int j = 0; j < 13; j++){
                if(j + 1 == kazu){
                    t[3][j] = 1;
                } 
            }
        }
    }
    
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(t[i][j] == 0){
                if(i == 0){
                    cout << "S" << " " << j + 1 << endl;
                } else if(i == 1){
                    cout << "H" << " " << j + 1 << endl;
                } else if(i == 2){
                    cout << "C" << " " << j + 1 << endl;
                } else if(i == 3){
                    cout << "D" << " " << j + 1 << endl;
                }
            }
        }
    }
    
    return 0;
}



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

int main() {
    int a, b, i=0;
    char op;
    int s[1000000];
    while (op != '?') {
        cin >> a >> op >> b;
        if (op == '+') s[i] = a + b;
        else if (op == '-') s[i] = a - b;
        else if (op == '*') s[i] = a * b;
        else if (op == '/') s[i] = a / b;
        i++;
    }
    for (int j = 0; j < i-1; j++) cout << s[j] << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 200005;
bool isPrime[MAXN];
vector<int> pr;
vector<int> ans;
void sieve()
{
    memset(isPrime, 1, sizeof isPrime);
    isPrime[0] = isPrime[1] = 0;

    for (int i = 2; i * i <= MAXN; i += 1 + (i & 1))
    {
        if (isPrime[i])
        {

            for (int j = i * i; j < MAXN; j += i)
                isPrime[j] = 0;
        }
    }
    for(int i=0; i<MAXN; i++)
    {
        if(isPrime[i])
        {

            ans.push_back(i);
        }
    }
}

ld power(ld x, ll y)
{
    ll temp;
    if (y == 0)
        return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
        return x * temp * temp;
}

void debug_out()
{
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main()
{
    FAST
    int n;
    cin>>n;
    map<int,int> vis;
    int arr[n];
    for(int i=0;i<n;i++)
        {

            cin>>arr[i];
            vis[arr[i]]++;
        }
    sort(arr,arr+n);
    map<int,int>m;
    for(int i=0;i<n;i++){
        if(vis[arr[i]]>1){
            m[arr[i]]++;
            continue;
        }
        for(int j=1;j*j<=arr[i];j++){
            if(arr[i]%j==0){
                if(vis[j] && j!=arr[i]){
                    m[arr[i]]++;
                }
                if(vis[arr[i]/j] && arr[i]/j != arr[i]){
                    m[arr[i]]++;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(!m[arr[i]]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	string s, result = "";
  ll w;
  cin >> s >> w;
  for(int i = 0; i < s.size(); i+=w) {
    result += s[i];
  }
  cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

vector<set<int>> used_color;
vector<int> visited;
vector<int> get_using_color(const int& v, const int& color_n)
{
    vector<int> res;
    for(int i = 0; i < color_n; i++)
    {
        if(used_color[v].count(i) == 0) res.push_back(i);
    }
    reverse(res.begin(), res.end());
    return res;
}
void dfs(const vector<vector<P>>& G, vector<int>& edge, const int& v, const int& color_n)
{
    visited[v] = 1;
    // vector<int> color = get_using_color(v, color_n);
    int color_num = 0;
    for(int i = 0; i < G[v].size(); i++)
    {
        int index = G[v][i].second;
        if(edge[index] == -1)
        {
            while(used_color[v].count(color_num))
            {
                color_num++;
            }
            edge[index] = color_num;
            int u = G[v][i].first;
            used_color[v].insert(color_num);
            used_color[u].insert(color_num);
        }
    }
    for(int i = 0; i < G[v].size(); i++)
    {
        int u = G[v][i].first;
        if(visited[u] == 0 && (int)G[u].size() >= 2)
        {
            dfs(G, edge, G[v][i].first, color_n);
        }
    }
}

void solve()
{
    int n; cin >> n;
    vector<vector<P>> G(n);
    used_color.resize(n);
    visited.resize(n, 0);
    vector<int> edge(n - 1, -1);
    for(int i = 0; i < n - 1; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(P(b, i));
        G[b].push_back(P(a, i));
    }
    int color_n = 0, start_v = -1;
    for(int i = 0; i < n; i++)
    {
        if((int)G[i].size() > color_n)
        {
            color_n = (int)G[i].size();
            start_v = i;
        }
    }
    dfs(G, edge, start_v, color_n);
    cout << color_n << endl;
    for(int i = 0; i < n - 1; i++)
    {
        cout << edge[i] + 1 << endl;
    }
}

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

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

using namespace std;
typedef long long ll;
const int INF = numeric_limits<int>::max() / 2;

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

  int k,s,res=0;cin>>k>>s;
  for(int x=0;x<=k;x++){
      for(int y=0;y<=k;y++){
          if(s-x-y>=0 && s-x-y<=k) res++;
      }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
from heapq import*
I=lambda:list(map(int,input().split()))
n,k=I()
q=[]
v=i=T=A=0
l=[0]*-~n
for a,b in sorted([I()for _ in[0]*n],key=lambda x:-x[1]):
 if i<k:
  if l[a]:heappush(q,b)
  else:T+=v*2+1;v+=1
  T+=b
 elif l[a]^1and q:T+=b+v*2+1-heappop(q);v+=1
 A=max(A,T);i+=1;l[a]=1
print(A)

Measured memory_bytes: 33780
#include <iostream>
#include <cstdio>

auto area(int a, int b) -> int {
	return a * b;
}

auto perimeter(int a, int b) -> int {
	return (a * 2) + (b * 2);
}

auto main() -> int {
	int a, b;
	std::cin >> a;
	std::cin >> b;

	printf("%d %d\n",
		area(a, b),
		perimeter(a, b));
}

Measured memory_bytes: 1136
#include<bits/stdc++.h>
#include<vector>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define M 1000000007

using namespace std;

int main(void){
  int a,b;
  cin>>a>>b;
  cout<<(int)(a+b)/2<<endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv vector<int>
#define endl "\n"
#define test(i) cout<<i<<endl
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())

void file(){
    #ifdef LOCAL
    freopen("demo.in","r",stdin);
    freopen("demo.out","w",stdout);
    #endif
}

void test_case(){
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z;
}

int main(){
    fastio;
    file();
    // int T;
    // cin>>T;
    // for(int nr=1;nr<=T;++nr) {
    //     cout<<"Case #"<<nr<<": ";
		test_case();
    // }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  string s;
  cin >> s;
  int m[256];
  REP(i,26) m['a'+i]=(1<<i);
  int tmp=0;
  map<int,int> d;
  d[0]=0;
  for(auto i=s.begin();i!=s.end();++i){
    tmp=(tmp^m[*i]);
    d.count(tmp) ? 0 : d[tmp]=33554432;
    REP(j,26) if(d.count(tmp^(1<<j))) d[tmp]=min(d[tmp],d[tmp^(1<<j)]+1);
  }
  cout << max(1,d[tmp]) << endl;
  return 0;
}

Measured memory_bytes: 9860
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
struct edge{int to,cost;};

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

int p[65000], j[65000-1];

int main(){
    int n;
    while(cin >> n, n){
        long long int sum_p = 0;
        for(int i=0;i<n;i++){
            scanf("%d",&p[i]);
            sum_p += p[i];
        }
        for(int i=0;i<n-1;i++){
            scanf("%d",&j[i]);
        }
        long long int ans = n * sum_p;
        sort(j,j+n-1);
        for(int i=n-2;i>=0;i--){
            sum_p += j[i];
            n--;
            long long int temp = n * sum_p;
            if(ans <= temp){
                ans = temp;
            }else{
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1764