akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void pop();
void push(int);
int top=0;
int stack[200];
int main(){

  int i=0;
  char s[8];

  while((scanf("%s",s))!=EOF){

    if(strcmp(s,"+")==0){
	stack[top-1]=(stack[top])+(stack[top-1]);
	pop();
    }
    else if(strcmp(s,"-")==0){
       	stack[top-1]=(stack[top-1])-(stack[top]);
	pop();
    }
    else if(strcmp(s,"*")==0){
       	stack[top-1]=(stack[top])*(stack[top-1]);
	pop();
    }
    else{
	push(atoi(s));
    }
  }
    printf("%d\n",stack[1]);
    return 0;
}

void push(int a){
  stack[++top]=a;
}


void pop(){
  top--;
}
  

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

using namespace std;
#define int long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    bool pre = false;
    rep(i, n) {
        int p;
        cin >> p;
        if (p == i + 1) {
            if (!pre) {
                ans++;
                pre = true;
            } else {
                pre = false;
            }
        } else {
            pre = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
x=range(int(input())-1,-1,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]
print(_*0.5)

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

using namespace std;

typedef long long ll;

int main() {
  string s; cin >> s;
  ll k; cin >> k;
  int n = s.length();
  for(int i = 0; i < n; i++) {
    int id = s[i] - 'a';
    if((26 - id) <= k and s[i] != 'a') {
      s[i] = 'a';
      k -= (26ll - id);
    }
  }
  if(k) {
    s[n - 1] += k % 26;
  }
  cout << s << '\n';
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)

int main() {
    int n; cin >> n;
    vector<ll> A(n);
    ll x = 0;
    rep (i, n) {
        ll a; cin >> a;
        if (i % 2 == 0) x += a;
        else x -= a;
        A[i] = a;
    }
    cout << x << endl;
    rep (i, n - 1) {
        cout << A[i] * 2 - x << endl;
        x = A[i] * 2 - x;
    }
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int a, b; std::cin >> a >> b;
    if(a>=13) std::cout << b << std::endl;
    else if(a<=5) std::cout << 0 << std::endl;
    else std::cout << b / 2 << std::endl;
    return 0;
}

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

using namespace std;

int main()
{
  int n, cost;
  int res = 0;
  cin >> n;
  
  vector<int> v(n);
  
  for(int i = 0; i < n; i++)
  {
    
    cin >> v[i];
    
  }
  
  for(int i = 0; i < n; i++)
  {
    
   cin >> cost;
    
    if(cost < v[i])
       res += v[i] - cost;
    
  }
  cout << res;
  
  
  
  
  
  return 0;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

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

      if (K>=int(S.length())){
            for (int i=0; i<int(S.length()); i++)
                  if (S[i] != '1'){
                        cout << S[i] << endl;
                        exit(0);
                  }
      } else {
            for (int i=0; i<K; i++)
                  if (S[i] != '1'){
                        cout << S[i] << endl;
                        exit(0);
                  }
      }
      cout << 1 << endl;
      exit(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	string s;
	cin >> s;
	if (s == "ani")cout << "square1001" << endl;
	else cout << "e869120" << endl;
}





Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define maxn 100005

int vis[maxn],low[maxn],dfn[maxn],pre[maxn];
int ind ;
vector<int> g[maxn];
set<int> s;
set<int>::iterator it;
void tarjan(int u,int p)
{
    int child=0;
    pre[u]=p;
    dfn[u]=low[u]=++ind;
    vis[u]=1;
    for(int i=0;i<g[u].size();i++)
    {
        int v=g[u][i];
        if(v==p) continue;
        if(!vis[v])
        {
            child++;
            pre[v]=u;
            tarjan(v,u);
            low[u]=min(low[v],low[u]);
            if(dfn[u]<=low[v]&&pre[u]!=-1)
                s.insert(u);
            if(pre[u]==-1&&child>1)
                s.insert(u);
        }
        else low[u]=min(low[u],dfn[v]);
    }
}
int v,e;
int main()
{
    scanf("%d%d",&v,&e);
    for(int i=0;i<e;i++)
    {
        int s,t;
        scanf("%d%d",&s,&t);
        g[s].push_back(t);
        g[t].push_back(s);
    }
    tarjan(0,-1);
    for(it=s.begin();it!=s.end();it++)
        printf("%d\n",*it);
    return 0;
}

Measured memory_bytes: 7012
#include<stdio.h>
int main()
{
	int a,b,c,count,x,y,z;
	while(~scanf("%d %d %d", &a, &b, &c))
	{
		count = 0;
		if(!(a%2) && a==b && b==c)
			printf("-1\n");
		else
		{
			while( !(a%2) && !(b%2) && !(c%2))
			{
				count++;
				x = (b+c)/2;
				y = (a+c)/2;
				z = (a+b)/2;
				a = x;
				b = y;
				c = z;
			}
			printf("%d\n", count);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <limits>
#include <vector>

template <class T>
void chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
    }
}

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

    std::vector<long long> h;
    h.reserve(N);
    long long x;
    for (int i = 0; i < N; ++i) {
        std::cin >> x;
        h.push_back(x);
    }

    std::vector<long long> dp(N + K, std::numeric_limits<long long>::max());

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + std::abs(h[i + j] - h[i]));
        }
    }

    const auto ret = dp[N - 1];

    std::cout << ret << std::endl;
}


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

bool check(string& s) {
    int N = s.size();
    for (int i = 0; i < N; i++) {
        if (s[i] != s[N-1-i]) return false;
    }
    for (int i = 0; i < N/2; i++) {
        if (s[i] != s[N/2-1-i]) return false;
    }
    for (int i = (N+3)/2 -1; i < N; i++) {
        if (s[i] != s[N-1-i]) return false;
    }
    return true;
}

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

    string s; cin >> s;
    cout << (check(s) ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  for (int i = 0; i < n; i++){
    string S;
    cin >> S;
    int N = S.size();
    stack<vector<int>> st;
    st.push(vector<int>(0));
    for (int j = 0; j < N; j++){
      if (S[j] == '['){
        st.push(vector<int>(0));
      } else if (S[j] == ']'){
        if (S[j - 1] != ']'){
          st.top()[0] = (st.top()[0] + 1) / 2;
        }
        sort(st.top().begin(), st.top().end());
        int cnt = st.top().size();
        int sum = 0;
        for (int k = 0; k < (cnt + 1) / 2; k++){
          sum += st.top()[k];
        }
        st.pop();
        st.top().push_back(sum);
      } else {
        if (st.top().empty()){
          st.top().push_back(0);
        }
        st.top().back() *= 10;
        st.top().back() += S[j] - '0';
      }
    }
    cout << st.top()[0] << endl;
  }
}


Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

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

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;


/*
Euclidean Algorithm
 */
ll euclid(ll a, ll b){
  while (b>0){
    a = a % b;
    swap(a, b);
  }
  return a;
}



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

  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i,N){ cin >> A[i];}

  vector<ll> primes(0);
  REP(i,N){
    ll ai = A[i];
    for(ll& p : primes){
      if (ai%p==0){
        ai /= p;
      }
      if (ai==1) break;
    }

    if (ai>0){
      /*
      Prime factorization
      */
      for(ll i=2; i*i<=ai; i++) {
        if (ai%i == 0) {
          while(ai%i==0) {
            ai/=i;
            primes.push_back(i);
          }
        }
      }
    }
    if(ai>1) primes.push_back(ai);
  }

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

  ll ans = 0;
  REP(i,N){
    ll ai = A[i];
    ll bi = 1;
    for (ll& p : primes){
      if (ai%p==0){
        ai /= p;
      } else {
        bi *= p;
        bi %= MOD;
      }
    }
    ans += bi;
    ans %= MOD;
  }


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


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
#define JOI 1
#define IOI 0

int n;
vector<int> a;

ll dp[2003][2003][2];
ll solve(int left,int right,int player){
//    cout<<left<<" "<<right<<" "<<player<<endl;
    if(left==right){
        if(player==JOI)return a[left];
        else return 0;
    }
    if(dp[left][right][player]!=-1)return dp[left][right][player];
    
    ll maxi = -1;
    if(player==IOI){
        if(a[left]>a[right]) maxi = max<ll>(maxi,solve((left+1)%n , right         , JOI));
        if(a[left]<a[right]) maxi = max<ll>(maxi,solve(left       , (right-1+n)%n , JOI));
    }else{
        maxi = max<ll>(maxi,solve((left+1)%n , right         , IOI)+a[left]);
        maxi = max<ll>(maxi,solve(left       , (right-1+n)%n , IOI)+a[right]);
    }
//    cout<<left<<" "<<right<<" "<<player<<" "<<maxi<<endl;
    return dp[left][right][player] = maxi;
}


int main(){
    rep(i,2003)rep(j,2003)rep(k,2)dp[i][j][k] = -1;
    cin>>n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    
    ll maxi = -1;
    rep(i,n){
        int left = (i+1)%n;
        int right= (i-1+n)%n;

        ll res = solve(left,right,IOI);
//        cout<<i<<" "<<res<<endl;
        maxi = max(maxi,res+a[i]);
    }
    cout<<maxi<<endl;
}

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

int main(){
  long long int n;
  cin >> n;
  long int a = sqrt(n*2)+1;
  long long int x;
  for(int i=1;i<a;i++){
    if(i*(i+1)/2 == n){
      x = i;
      break;
    }
    if(i == a-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" <<endl;
  cout << x+1 <<endl;
  cout << x<<" ";
  for(int i=0;i<x-1;i++){
    cout << i+1<<" ";
  }
  cout <<x <<endl;
  for(int i=1;i<x+1;i++){
    cout << x<<" ";
    for( long long int j=0;j<i;j++){
      cout << j*x-j*(j+1)/2+i <<" ";
    }
    for( long long int j=i;j<x-1;j++){
      cout << i*x+1+j-i*(i+1)/2 << " ";
    }
    if(i != x) cout << (i+1)*x-i*(i+1)/2 << endl;
  }
}
    

Measured memory_bytes: 1408
N = int(input())
poll = {}
for i in range(N):
    S = input()
    if S in poll:
        poll[S] = poll[S] + 1
    else:
        poll[S] = 1

maxv = max(poll.values())
a = [k for k, v in poll.items() if v == maxv]
a.sort()

for el in a:
    print(el)

Measured memory_bytes: 32096
#include<stdio.h>
#include <math.h>

int main(){
  int n, i, j, sum = 0, flag;
  scanf("%d", &n);
  int A[n];
  for(i = 0 ; i < n ; i++){
    scanf("%d", &A[i]);
  }
  for(i = 0 ; i < n ; i++){
    flag = 0;
    for(j = 2 ; j <= sqrt((int)A[i]) ; j++){
      if(A[i] % j == 0) flag = 1;
    }
    if(flag == 0) sum++;
  }
  printf("%d\n", sum);
  return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int R, C;
vector<string> a;
queue<int> rq, cq;
vector<int> dr{ -1, 1, 0, 0 };
vector<int> dc{ 0, 0, 1, -1 };
int nodes_in_next_layer = 0, nodes_left_in_layer = 1;

void explore_neighbours(int r, int c, vector<vector<bool>> &visited) {
    
    for (int i = 0; i < 4; i++) {
        int rr = r + dr[i];
        int cc = c + dc[i];

        if (rr < 0 || cc < 0) continue;
        if (rr >= R || cc >= C) continue;
        
        if (visited[rr][cc]) continue;
        if (a[rr][cc] == '#') continue;

        rq.push(rr);
        cq.push(cc);
        visited[rr][cc] = true;
        nodes_in_next_layer++;
    }
}

int try_maze(int i, int j) {
    nodes_left_in_layer = 1;
    nodes_in_next_layer = 0;
    vector<vector<bool>> visited(R, vector<bool>(C));
    int move_count = 0;
    visited[i][j] = true;
    rq.push(i);
    cq.push(j);
    while (rq.size() > 0) {
        int r = rq.front();
        rq.pop();
        int c = cq.front();
        cq.pop();
        explore_neighbours(r, c, visited);
        nodes_left_in_layer--;
        if (nodes_left_in_layer == 0) {
            nodes_left_in_layer = nodes_in_next_layer;
            nodes_in_next_layer = 0;
            move_count++;
        }
    }
    while (rq.size() > 0) {
        rq.pop();
        cq.pop();
    }
    return move_count;
}

int main() {
    cin >> R >> C;
    for (int i = 0; i < R; i++) {
        string s;
        cin >> s;
        a.push_back(s);
    }
    int mx = 0;
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            if (a[i][j] == '.') mx = max(mx, try_maze(i, j));
        }
    }
    cout << mx-1;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265
const int MOD=1e9+7;
 
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

const int N=3e3+5;

int n,w;
string s,t;
int dp[N][N];

int go(int i,int j)
{
    if(i==s.size() || j==t.size())
        return 0;
    int &ans=dp[i][j];
    if(ans!=-1)
        return ans;
    ans=0;
    if(s[i]==t[j])
        ans=1+go(i+1,j+1);
    else
        ans=max(go(i+1,j),go(i,j+1));
    return ans;
}

void path(int i,int j)
{
    if(i==s.size() || j==t.size())
        return;
    int ans=dp[i][j];
    if(s[i]==t[j])
    {
        cout<<s[i];
        return path(i+1,j+1);
    }
    else
    {
        if(ans==dp[i+1][j])
            return path(i+1,j);
        return path(i,j+1);
    }
    
}

int32_t main()
{
    IOS;
    cin>>s>>t;
    memset(dp,-1,sizeof(dp));
    go(0,0);
    // cout<<go(0,0)<<endl;
    path(0,0);
    return 0;
}

Measured memory_bytes: 71168
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, ans;
    cin >> A >> B >> C;
    ans = max(max(A, B), C) - min(min(A, B), C);
    cout << ans<< endl;
    // if(A==12)
    // 	cout << 1<<endl;
    // else
    // 	cout << A+1<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(A%2==1 && B%2==1)
    // 	puts("Yes");
    // else
    // 	puts("No");
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
     
     
    // 定義：各、出発時刻を「 departureTime 」と置く
    vector<int> departureTime;
     
    // 定義・代入：飯盛山行きのバスの数を表す整数「 N 」と置く
    int N;
    cin >> N;
     
    // 定義：飯盛山行きのバス出発時刻「 h , m 」と置く
    int h, m;
     
     
    // 反復・代入：飯盛山行きのバス出発時刻「 h , m 」を入力
    for(int i = 0; i < N; i++){
        cin >> h >> m;
        departureTime.push_back(h*60+m);
    }   
     
    // 定義・代入：鶴ケ城行きのバスの数を表す整数「 M 」と置く
    int M;
    cin >> M;
     
    // 定義：鶴ケ城行きのバス出発時刻「 h , m 」と置く
    int k, g;
     
    //　反復・代入：鶴ケ城行きのバス出発時刻「 h , m 」を入力
    for(int i = 0; i < M; i++){
        cin >> k >> g;
        departureTime.push_back(k*60+g);
    }  
     
    // ソート：出発時刻を「 departureTime 」を昇順に並べ替え ➡　早い順に並べるから
    sort( departureTime.begin(), departureTime.end() );
     
    // 重複削除： sort と unique で erase の重複要素を削除する
    departureTime.erase(unique( departureTime.begin(),  departureTime.end()),  departureTime.end());
 
     
    // 出力：departureTimeから時間の形に変換して表示
    for(int i = 0; i < departureTime.size(); i++){
         
        //計算：departureTimeに60分を掛けたから元に戻すために60分で割る　＋　分数を求めるために60分の余りを求める
        cout << departureTime[i] / 60 << ":" << ( (departureTime[i] % 60 < 10) ? "0" : "" ) << departureTime[i] % 60  << ( (i != departureTime.size()-1) ? " " : "\n" );
    }
     
}


Measured memory_bytes: 3172
#include <stdio.h>
int main(void){
    int k,s,ans=0;
    scanf("%d%d",&k,&s);
    for (int x=0; x<=k; x++){
        int s2=s;
        s2-=x;
        if (s2>=0){
            for (int y=0; y<=k; y++){
                int s3=s2 ;
                s3-=y ;
                if (s3<=k && s3>=0){
                    ans++;
                }
            }
        }
    }
    printf ("%d\n",ans) ;
	return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n;
    cin >> n;
    cout << n * n * n << endl;
}

Measured memory_bytes: 256
while true
  h,w = gets.chomp.split.map{|e| e.to_i}
  break if (h == 0 && w == 0)
  h.times { |i|
    if (i == 0 || i == h-1)
      puts "#"*w
    else
      puts "#" + "."*(w-2) + "#"
    end
  }
  puts ""
end

Measured memory_bytes: 8884
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define X first
#define Y second
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define D double
#define ll long long
#define REP(i,a) for(int i=0;i<a;i++)
#define REP1(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i<=b;i++)
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define RREP1(i,a,b) for(int i=a;i>b;i--)
#define RREP2(i,a,b) for(int i=a;i>=b;i--)
#define SREP(i,x) for(auto i:x)
#define MS0(x) memset((x),0,sizeof((x)))
#define MS1(x) memset((x),-1,sizeof((x)))
#define MSF(x) memset((x),127,sizeof(x))
#define pb push_back
#define LE(x) (int)((x).size())
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<D,D>
#define im guagua
#define RI(x) x=rit()
#define RII(a,b) a=rit(),b=rit()
#define RIII(a,b,c) a=rit(),b=rit(),c=rit()
#define debug 0
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10 ;
const ll mod7 = 1e9+7;
const ll mod9 = 1e9+9;
using namespace std;
inline ll rit(){
    ll f=0,key=1;
    char c;
    do{
        c=getchar();
        if(c=='-') key=-1;
    }while(c<'0' || c>'9');
    do{
        f=f*10+c-'0';
        c=getchar();
    }while(c>='0' && c<='9');
    return f*key;
}
inline void fprt(D f){
    printf("%.08lf",f);
}
void init(){
}
const int Z = 100005;
ll n;
ll a[Z],mx,cnt[Z],ans[Z];
vector<ll> v,tag;
void read(){
    RI(n);
    v.pb(0);
    tag.pb(0);
    REP2(i,1,n){
        RI(a[i]);
        if(a[i]>mx){
            mx = a[i];
            v.pb(a[i]);
            tag.pb(i);
        }
    }
    // cout<<"v : ";
    // SREP(f,v) cout<<f<<' ';
    // cout<<endl;
}
void solve(){
    int f;
    REP2(i,1,n){
        f = lower_bound(ALL(v),a[i])-v.begin();
        cnt[f]++;
        ans[tag[f]]+=a[i]-a[tag[f]];
    }
    // REP(i,LE(v)) cout<<cnt[i]<<' ';
    // cout<<endl;

    RREP2(i,LE(v)-1,1){
        cnt[i]+=cnt[i+1];
        // cout<<"cnt "<<i<<" = "<<cnt[i]<<endl;
        ans[tag[i]] += cnt[i]*(a[tag[i]]-a[tag[i-1]]);
    }
    REP2(i,1,n) cout<<ans[i]<<endl;
}
int main(){
    int nn=1;
    // nn=rit();
    while(nn--){
        // while(cin>>n) 
            init(),read(),solve();
    }
    return 0;
}

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

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader =
				new BufferedReader(new InputStreamReader(System.in));

			String str = reader.readLine();
			int c1 = Integer.parseInt(str.split(" ",0)[0]);
			int c2 = Integer.parseInt(str.split(" ",0)[1]) * 5;
			int c3 = Integer.parseInt(str.split(" ",0)[2]) * 10;
			int c4 = Integer.parseInt(str.split(" ",0)[3]) * 50;
			int c5 = Integer.parseInt(str.split(" ",0)[4]) * 100;
			int c6 = Integer.parseInt(str.split(" ",0)[5]) * 500;
			int c = c1 + c2 + c3 + c4 + c5 + c6;
			
			if(c >= 1000)
				System.out.println(1);
			else
				System.out.println(0);
			
			reader.close();
	}
}

Measured memory_bytes: 17100
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>

using namespace std;

void Print(int wide, int height);

void Print(int wide, int height)
{
	for(int h = 0; h < height; h++){
		for(int w = 0; w < wide; w++){
			if(h != 0 && h != height - 1 
			&& w != 0 && w != wide - 1){
				cout << ".";
			} else{
				cout << "#";
			}
		}
		cout << endl;
	}
}

int main(){
	int w, h;
	vector<int> wide;
	vector<int> height;
	
	wide.clear();
	height.clear();
	while(1){
		cin >> h;
		cin >> w;
		if(h == 0 && w == 0)	break;
		height.push_back(h);
		wide.push_back(w);
	}
	
	for(int i = 0; i < height.size(); i++){
		Print(wide[i], height[i]);
		cout << endl;
	}
	
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    ll n;
    cin >> n;
    vector<ll> out;
    while(n != 0){
        n--;
        out.push_back(n % 26);
        n /= 26;
    }
    for(int i = out.size() - 1; i >= 0; i--){
        cout << (char)(out[i] + 97);
    }
}

Measured memory_bytes: 3592
N = int(input())
X = list(input())
one = X.count('1')
L1 = [1]
L2 = [1]

for _ in range(N-1):
    if one - 1 == 0:
        L1.append(0)
    else:
        L1.append((L1[-1] * 2) % (one - 1))
    L2.append((L2[-1] * 2) % (one + 1))

x1 = 0
x2 = 0
power1 = 1
power2 = 1

for i in range(N):
    if X[N-i-1] == '1':
        if one - 1 != 0:
            x1 += power1
        x2 += power2
    power1 *= 2
    power2 *= 2
    if one - 1 != 0:
        power1 %= one - 1
    power2 %= one + 1

def solve(X, cnt):
    if X == 0:
        return cnt
    
    X %= bin(X).count('1')
    return solve(X, cnt+1)

for i in range(N):
    if X[i] == '0':
        tmp = (x2 + L2[N-i-1]) % (one + 1)
        ans = solve(tmp, 0) + 1
    else:
        if one - 1 == 0:
            ans = 0
        else:
            tmp = (x1 - L1[N-i-1]) % (one - 1)
            ans = solve(tmp, 0) + 1
    print(ans)

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

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

	int N;
	cin >> N;
	vector<int> A(N);
	int xall = 0;
	for (int& e : A) {
		cin >> e;
		xall ^= e;
	}
	for (int i = 0; i < N; ++i) {
		cout << (xall^A[i]) << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3976
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

char return_prev(char c){
  if (c == 'a') return 'Z';
  if (c == 'A') return 'z';
  return c - 1;
}

                 
int main(){
  ios::sync_with_stdio(false);

  int n;
  while (cin >> n && n > 0){
    vector<int> keys(n);
    REP(i, n) cin >> keys[i];
    string s;
    cin >> s;
    int m = s.size();

    REP(i, m){
      int k = keys[i % n];
      REP(j, k) s[i] = return_prev(s[i]);
    }
    cout << s << endl;
  }
  return 0;
}

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

struct DSU{
	vector <int> p, sz;
	DSU(int n) {
		p.resize(n + 1); sz.resize(n + 1, 1);
		for(int i = 1; i <= n; i++) {
			p[i] = i;
		}
	}
	int find(int x) {
		return p[x] = (p[x] == x) ? p[x] : find(p[x]);
	}
	int merge(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) {
			return 0;
		}
		p[x] = y;
		sz[y] += sz[x];
		return 1;
	}
};

const int N = 2e5 + 7;

vector <int> lst[N];

int ans[N];

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k, l; cin >> n >> k >> l; DSU a(n), b(n);
	for(int i = 1; i <= k; i++) {
		int x, y; cin >> x >> y;
		a.merge(x, y);
	}
	for(int i = 1; i <= l; i++) {
		int x, y; cin >> x >> y;
		b.merge(x, y);
	}

	for(int i = 1; i <= n; i++) {
		lst[a.find(i)].push_back(i);
	}

	for(int i = 1; i <= n; i++) {
		vector <int> t;
		for(int x: lst[i]) {
			t.push_back(b.find(x));
		}
		sort(t.begin(), t.end());
		for(int x: lst[i]) {
			ans[x] = upper_bound(t.begin(), t.end(), b.find(x)) - lower_bound(t.begin(), t.end(), b.find(x));
		}
	}
	for(int i = 1; i <= n; i++) {
		cout << ans[i] << " ";
	}
}

Measured memory_bytes: 17316
/**
 * Created by hiramekun at 20:51 on 2020-04-04.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    string revs(s);
    reverse(all(revs));

    vl ltor(n, -1), rtol(n, -2);
    ll now = 1, nowrev = k;
    rep(i, n) {
        if (s[i] == 'x') {
            continue;
        } else if (now <= k) {
            ltor[i] = now++;
            i += c;
        }
    }
    rep(i, n) {
        if (revs[i] == 'x') {
            continue;
        } else if (nowrev >= 1) {
            rtol[i] = nowrev--;
            i += c;
        }
    }
    reverse(all(rtol));
    vl ans;
    rep(i, n) {
        if (ltor[i] == rtol[i]) ans.eb(i + 1);
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 6644
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int proc(int n){
  int res=0;
  for(int i=10; i<=1000000; i*=10){
    res = max(res, (n/i)*(n%i));
  }
  return res;
}

int main(){
  int q;
  cin>>q;
  rep(repeat, q){
    int n;
    scanf("%d", &n);

    int res=0;
    while(n>9){
      n = proc(n);
      res++;
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 1240
from sys import stdin

def waru(a,b):
  if a%b != 0:
    return 0
  if a/b == 1:
    return b
  return waru(a/b,b)
  

def main():
  s = []
  read = stdin.readline
  N =int(read())
  if N == 1:
    print(0)
    exit()
  i = 2
  table = []
  ap = table.append
  while i * i <= N:
    while N%i == 0:
      ap(i)
      N //= i
    i += 1
  if N > 1:
    ap(N)
  set_table = sorted(list(set(table)))
  kaisu = [0] * len(set_table)
  num = 0
  for i in table:
    if i == set_table[num]:
      kaisu[num] += 1
    else:
      num += 1
      kaisu[num] += 1
  maxk = max(kaisu)
  j = 1
  k = 0
  count = 0
  while j <= maxk:
    count += len([i for i in kaisu if i >= j])
    k += 1
    j = j + k + 1
  print(count)
    
      
      

  
  
  
if __name__ == "__main__":
  main()

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

bool f(const long kind, const size_t n, const vector<long>& a){
    map<long,long> c;
    long len = a[0];
    for(size_t i=1; i<n; i++){
        const long n_len = a[i];
        if(len>=n_len){
            c.erase(c.lower_bound(n_len), c.end());
            long j=n_len-1;
            auto oit = c.end();
            for(;;){
                auto it = c.find(j);
                if(it == c.end()){
                    it = c.insert(oit, make_pair(j, 1));
                }else{
                    it->second++;
                }
                if(it->second<kind){
                    //c.erase(c.upper_bound(j), c.end());
                    break;
                }else if(j<=0){
                    return false;
                }
                it->second = 0;
                oit = it;
                j--;
            }
        }
        len = n_len;
    }
    return true;
}

bool strict_increasing(const vector<long>& a){
    size_t n = a.size();
    for(size_t i=1; i<n; i++){
        if(a[i-1]>=a[i]){
            return false;
        }
    }
    return true;
}

int main(void){
    long n;
    cin >> n;
    vector<long> a(n);
    for(long i=0; i<n; i++){
        cin >> a[i];
    }
    if(strict_increasing(a)){
        cout << 1 << endl;
        return 0;
    }
    long left=1, right=n;
    for(;;){
        const long mid = (left+right)/2;
        if(right-left<=1){
            if(f(right, n, a)){
                cout << right << endl;
            }else{
                cout << left << endl;
            }
            return 0;
        }
        const bool b = f(mid, n, a);
        //printf("[%ld, %ld] %ld %s\n", left, right, mid, b ? "true" : "false");
        if(b){
            right=mid;
        }else{
            left=mid;
        }
    }
}


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

int n, a[100010];
bool used[100010];
int cnt = 0;

bool search(int x) {
	if (x == 1)return true;
	if (used[x])return false;
	used[x] = true;
	cnt++;
	search(a[x]-1);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		used[i] = false;
	}
	if (search(0))cout << cnt << endl;
	else cout << -1 << endl;
}

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

int n, l[300300], r[300300], ans;
char s[300300];

int main() {
	scanf("%d%s",&n,s+1);  ans = n;
	for (int i=1;i<=n;i++) l[i] = l[i-1] + ((s[i] == 'W') ? 1 : 0);
	for (int i=n;i>=1;i--) r[i] = r[i+1] + ((s[i] == 'E') ? 1 : 0);
	for (int i=1;i<=n;i++) ans = min(ans,l[i-1] + r[i+1]);
	printf("%d\n",ans);
}

Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x,count;
    for(;;){
        cin>>n>>x;
        count=0;
        if(n==0&&x==0)break;
        for(int i=1;i<=n;i++){
            for(int o=i+1;o<=n;o++){
                for(int v=o+1;v<=n;v++){
                    if(i+o+v==x){
                        count++;
                    }
                }
            }
        }
        cout<<count<<endl;
    }
}



Measured memory_bytes: 3076
#include <cstdio>
#define _USE_MATH_DEFINES
#include <cmath>

#include <iostream>
using namespace std;
int main() {
double r;
cin >> r;
printf("%0.8f %0.8f", pow((double)r, (double)2) * M_PI , (double)r * (double)2 * M_PI);

}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
using namespace std;
using ll=long long;
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

int main(){
    int n,cnt=0;
    cin>>n;

    ll l[105];
    rep(i,n) cin>>l[i];
    rep(i,n)rep(j,n)rep(k,n){
        if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i]){
            continue;
        }
        if(i<j && j<k){
            if(l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[j]+l[k]>l[i]){
                cnt++;
            }
        }

    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

	

int main(void)
{
	//変数の宣言
	int n;
	char s[110];
	int alphabet[2][30];
	int i,j,k;
	int count;
	int ans=0;
	
	//データの読み込み
	scanf("%d\n%s",&n,&s);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=1;i<n;i++){
		
		for(j=0;j<30;j++){
			alphabet[0][j]=0;
			alphabet[1][j]=0;
		}
		count=0;
		
		for(j=0;j<i;j++){
			for(k=0;k<26;k++){
				if(s[j]=='a'+k){
					alphabet[0][k]=1;
				}
			}
		}
		
		for(j=i;j<n;j++){
			for(k=0;k<26;k++){
				if(s[j]=='a'+k){
					alphabet[1][k]=1;
				}
			}
		}
		
		for(j=0;j<26;j++){
			if(alphabet[0][j]==1&&alphabet[1][j]==1){
				count++;
			}
		}
		
//		printf("%d文字目から右にしたとき、%d種類\n",i+1,count);
		
		if(count>ans){
			ans=count;
		}
	}
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int n, cnt = 0;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        if (h[i] == 0) continue;
        while (h[i] > 0) {
            for (int j = i; j < n; j++) {
                if (h[j] == 0) break;
                h[j]--;
            }
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a, b, c, k;
	cin>>a>>b>>c>>k;
	int cnt=0;
	while(b<=a){
		b=b*2;
		cnt++;
	}
	while(c<=b){
		c=2*c;
		cnt++;
	}
	if(cnt<=k){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3648
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t P, Q, R;

    scanf("%zu %zu %zu", &P, &Q, &R);

    printf("%zu\n", MIN(P + Q, MIN(Q + R, R + P)));

    return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n){
    cin>>a[i];
  }
  ll ans=1000;
  int j=1;
  rep2(i,1,n){
    if(a[i-1]<a[i]){
      j=i;
      break;
    }
  }
  int l=a[j-1];
  int h=a[j-1];
  rep2(i,j,n){
    if(h<=a[i]){
      h=a[i];
    }
    else{
      ans=ans/l*h+ans%l;
      l=a[i];
      h=a[i];
    }
  }
  ans=ans/l*h+ans%l;
  cout<<ans<<endl;
}




Measured memory_bytes: 3604
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in();
	vector<ll> A=vecin<ll>(N);
	vector<int> C(N,0);

	REP(i,N){
		int V=N-i,S=0;
		int D=V;
		while(V<=N){
			S += C[V-1];
			V += D;
		}
		if((A[N-i-1] && !(S%2)) || (!A[N-i-1] && (S%2))) C[N-1-i]=1;
	}
	vector<int> R;
	for(int i=0;i<N;i++){
		if(C[i]==1) R.push_back(i+1);
	}
	int M=R.size();
	if(M){
		out(M);
		PRINTALL(R);
	}
	else out(0);
	return 0;
}


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

int main(int argc, char *argv[])
{
  long long int d, n;

  cin >> d >> n;

  if (d == 0) {
    if (n == 100) {
      cout << 101;
    }
    else {
      cout << n;
    }
  }
  else if (d == 1) {
    if (n == 100) {
      cout << 101 * 100;
    } else {
      cout << n * 100;
    }
  }
  else if (d == 2) {
    if (n == 100) {
      cout << 101 * 10000;
    }
    else {
      cout << n * 10000;
    }

  }
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

long long gcf(long long a, long long b) {
    long long tmp;
    if(b>a){
        tmp = b;
        b = a;
        a = tmp;
    }
    while(a%b != 0){
        long long c = a%b;
        a = b;
        b = c;
    }
    return b;
}

int main() {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for(long long i = 0; i< n; i++){
        cin >> v[i];
    }
    long long ans = v[0];
    for(long long i = 1; i< n; i++){
        ans = gcf(ans, v[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
        int h,w,hc,wc;
        while(1){
	 scanf("%d %d",&h,&w);
         if(h==0 && w==0){
          break;
         }
	 for(hc=1;hc<=h;hc++){
 	        for(wc=1;wc<=w;wc++){
	 	        printf("#");
                 }
                 printf("\n");
	 }
        printf("\n");
        }
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int H[n];
  for(int i = 0;i < n;i++){
    cin >> H[i];
  }
  int first = H[0];
  int count = 1;
  for(int i = 1;i < n;i++){
    if(first <= H[i]){
      count++;
      first = H[i];
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

LL num[300005];
LL maxs[300005], mins[300005];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= 3 * n; i++) {
		scanf("%d", &num[i]);
	}
	LL sum = 0;
	priority_queue<LL> PQ;
	for (int i = 1; i <= n; i++) {
		PQ.push(-num[i]);
		sum += num[i];
	}
	maxs[n] = sum;
	for (int i = n + 1; i <= 3 * n; i++) {
		PQ.push(-num[i]);
		sum += num[i];
		LL u = PQ.top(); PQ.pop();
		sum += u;
		maxs[i] = sum;
	}

	sum = 0;
	while (!PQ.empty()) PQ.pop();
	for (int i = 3 * n; i >= 2 * n + 1; i--) {
		PQ.push(num[i]);
		sum += num[i];
	}
	mins[2 * n + 1] = sum;
	for (int i = 2 * n; i >= 1; i--) {
		PQ.push(num[i]);
		sum += num[i];
		LL u = PQ.top(); PQ.pop();
		sum -= u;
		mins[i] = sum;
	}

	LL ans = 1000000000;
	ans *= ans;
	ans = -ans;
	for (int i = n; i <= 2 * n; i++) {
		LL now = maxs[i] - mins[i + 1];
		ans = MAX(ans, now);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
char grid[55][55];
int n,m;
int dir[8][2]={1,0, 1,1 ,0,1 ,-1,1 ,-1,0 ,-1,-1 ,0,-1 ,1,-1};
int find(int x,int y)
{
	int xx,yy;
	int ans=0;
	for(int i=0;i<8;i++)
	{
		xx=x+dir[i][0],yy=y+dir[i][1];
		if(xx>=1&&xx<=n&&yy>=1&&yy<=m)
		{
			if(grid[xx][yy]=='#')
			ans++;
		}
	}
	return ans;
}
int main (void)
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		scanf(" %c",&grid[i][j]);
	}
	
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{ if(grid[i][j]=='.')
		grid[i][j]=find(i,j)+'0';
	}
	
	
	for(int i=1;i<=n;i++)
	{
	for(int j=1;j<=m;j++)
	{
		printf("%c",grid[i][j]);
	}
	printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=0
cnt=0
ans1=0
cnt1=1
for j in range(1,min(n+1,k)):
    cnt=j
    cnt1=1
    for i in range(k):
        if cnt>=k:
            ans+=cnt1
            break
        cnt*=2
        cnt1/=2
print((max((n-k+1),0)+ans)/n)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int a,b;

	scanf("%d %d", &a,&b);
	if(a > b){
	    printf("a > b\n");
	}else if(a < b){
	    printf("a < b\n");
	}else{
	    printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2044
while True:
    m,f,r = map(int,raw_input().split())

    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m+ f >= 80:
        print('A')
    elif m + f >= 65 and m + f < 80:
        print('B')
    elif m + f >= 50 and m + f < 65 or r >= 50:
        print('C')
    elif m + f >= 30 and m + f < 50:
        print('D')
    elif m + f <= 29:
        print('F')

Measured memory_bytes: 6268
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

const int MAXN = 300010;
int sumW[MAXN]; //include.
int main() {
	int n;
	int totW=0;
	cin>>n;
	for (int i=0; i<n; i++) {
		char c;
		cin>>c;
		sumW[i] = (i>0?sumW[i-1]:0) + (c=='W'?1:0);
		if (c=='W')
			totW++;
	}
	int ans=MAXN;
	for (int i=0; i<n; i++) {
		int leftW = (i>0?sumW[i-1]:0);
		int rightE = n - (i+1) - (totW-sumW[i]);
		ans = min(ans, leftW+rightE);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll a, b, k; cin >> a >> b >> k;
    ll c = max(a-k, (ll)0), d = max(b - max(k-a, (ll)0), (ll)0);

    cout << c << " " << d << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int n, K;
int a[maxn], b[maxn];

template<typename T>
inline void read(T &k)
{
    int f = 1; k = 0; char c = getchar();
    while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
    while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
    k *= f;
}

int main()
{
    read(K); read(n); 
    for (int i = 1; i <= n; i++) read(a[i]);

    sort(a + 1, a + 1 + n);

    for (int i = 1; i < n; i++) b[i] = a[i + 1] - a[i];

        sort(b + 1, b + 1 + n - 1);

    // for (int i = 1; i < n; i++) printf("%d ", b[i]); 
        // puts("");

    int ans = 0;
    for (int i = 1; i <= n - K; i++) ans += b[i];

    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B, C;
  std::cin >> A >> B >> C;
  std::cout << max(10*A+B+C,max(10* C +A+B, A+10*B+C)) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(j, n) for (int j = 0; j < (n); j++)

typedef long long ll;

int main(){
  string s;
  cin>>s;
  int n;
  cin>>n;
  for(int i=0;i<s.size();i+=n)
    cout<<s[i];
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 256
/*

*/
#include <bits/stdc++.h>

using namespace std;

#define ll          long long int
#define vi 			 vector<int>
#define pb           push_back
#define fi           first
#define si           second
#define pii 		 pair<int,int>
#define vii 		 vector<pair<int,int>>
#define F(a,n)       for(int i=0;i<n;i++){cin>>a[i];}
#define P(a,n)       for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define fastIO       ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F1(a,n)      for(int i=1;i<=n;i++){cin>>a[i];}
#define P1(a,n)      for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define mem(a,b)     memset(a, b, sizeof a)
#define matrix(x) 	 vector<vector<x>>
#define NF(a,n,m)    for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m)   for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m)   for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m)  for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
const int nax = 1e7;
const int mod = 1e9+7;



int main(){
fastIO
	int n, *a;
	cin>>n;
	a = new int[n];
	F(a, n);
	float pt=0;
	for(int i=0; i<n; i++){
		pt += a[i];
	}
	pt /= n;
	pt = round(pt);
	int ans=0;
	for(int i=0; i<n; i++){
		ans += pow(pt-a[i], 2);
	}
	cout<<ans;
}

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

int main()
{
   ll a,b,c;
   cin>>a>>b>>c;
   map<ll,ll>m;
   m[a]++,m[b]++,m[c]++;
   if(m[a]==2 || m[b]==2 || m[c]==2) puts("Yes");
   else puts("No");
}


Measured memory_bytes: 256