akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int n;
int back[1000];

map<char,char> prev;

int main() {
    prev.clear();
    for (int i = 0; i < 25; ++i) {
        prev['a'+(i+1)] = 'a'+i;
        prev['A'+(i+1)] = 'A'+i;
    }
    prev['a'] = 'Z';
    prev['A'] = 'z';
    
    while (cin >> n) {
        if (n == 0) break;
        
        for (int i = 0; i < n; ++i) cin >> back[i];
        string str;
        cin >> str;
        
        for (int i = 0; i < str.size(); ++i) {
            for (int j = 0; j < back[ i%n ]; ++j) {
                str[i] = prev[str[i]];
            }
        }
    
        cout << str << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1212
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	long long a;scanf("%lld",&a);
	long long cur=100;
	int ret=0;
	while(cur<a){
		cur+=cur/100;ret++;
	}
	printf("%d\n",ret);
}


Measured memory_bytes: 1728
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    a = li()
    ans = 0
    m = a[0]
    for i in range(1, n):
        ans += max(0, m - a[i])
        m = max(m, a[i])
    print(ans)


main()


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

int sonod(int n){
  int ret = 0;
  for (int i = 1; i <= n; ++i){
    ret += n/i;
  }
  return ret;
}

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int n;  cin >> n;
  cout << sonod(n-1) << "\n";
  return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;

namespace Algo
{
    class Program
    {
        static void Main()
        {
            var s = Console.ReadLine();
            var arr = new int[s.Length];
            var (rCount, lCount)= (1, 1);
            for (var i = 1; i < s.Length; i++)
            {
                if (s[i-1] == 'R' && s[i] == 'L')
                {
                    arr[i - 1] += (rCount + 1) / 2;
                    arr[i] += rCount / 2;
                    rCount = 0;
                }
                else if (s[i] == 'R')
                {
                    rCount++;
                }
            }

            for (var i = s.Length - 2; i >= 0; i--)
            {
                if (s[i] == 'R' && s[i + 1] == 'L')
                {
                    arr[i + 1] += (lCount + 1) / 2;
                    arr[i] += lCount / 2;
                    lCount = 0;
                }
                else if (s[i] == 'L')
                {
                    lCount++;
                }
            }
            
            Console.WriteLine(string.Join(' ', arr));
        }
    }
}

Measured memory_bytes: 27412
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;

int main() {
    long long int N, K;
    cin >> N >> K;
    long long int count = N / K;
    long long int even = (N + (K / 2)) / K;
    if(K % 2 == 1) cout << (long long  int)pow(count, 3) << endl;
    else cout << (long long  int)pow(count, 3) + (long long int)pow(even, 3) << endl;
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define show(x) cout<<#x<<" = "<<(x)<<" "
#define ENA cout<<endl;
#define ENAA cout<<endl<<endl;

int MAX = 1e+6+5;
int BIG = 1e+9;
int MOD = 1e+9+7;

set<int>gr[1000];

int findPathLength(int source)
{
    queue<int>q;
    q.push(source);
    bool vis[499]={false};
    vis[source]=true;
    int depth[500]={0};

    while(!q.empty())
    {
        int cur = q.front();
        q.pop();

        for (auto it:gr[cur])
        {
            if (!vis[it])
            {
                vis[it]=true;
                q.push(it);
                depth[it]=depth[cur]+1;
            }
        }
    }
    int maxv=0;
    repa(i,0,499)
        maxv=max(maxv,depth[i]);
    return maxv;
}

signed main()
{
    IOS;
    int n,m; cin>>n>>m;
    vector<int>valids;
    char maze[n+1][m+1];

    repa(i,1,n)
     repa(j,1,m)
     {
        cin>>maze[i][j];
        if (maze[i][j]=='.')
            valids.pb( (i-1)*m+j );
    }

    repa(i,1,n)
    {
        repa(j,1,m)
        {
            if (maze[i][j]=='.')
            {
                if (i>1)
                    if (maze[i-1][j]=='.')
                    {
                        gr[((i-1)*m+j)].insert((i-2)*m+j);
                        gr[((i-2)*m+j)].insert((i-1)*m+j);
                    }

                if (i<n)
                    if (maze[i+1][j]=='.')
                    {
                        gr[((i-1)*m+j)].insert((i)*m+j);
                        gr[((i)*m+j)].insert((i-1)*m+j);
                    }

                if (j>1)
                    if (maze[i][j-1]=='.')
                    {
                        gr[((i-1)*m+j)].insert((i-1)*m+j-1);
                        gr[((i-1)*m+j-1)].insert((i-1)*m+j);
                    }
                    
                if (j<m)
                    if (maze[i][j+1]=='.')
                    {
                        gr[((i-1)*m+j)].insert((i-1)*m+j+1);
                        gr[((i-1)*m+j+1)].insert((i-1)*m+j);
                    }
            }
        }
    }
    int sz=valids.size();
    sz--;
    int ans(0);

    repa(i,0,sz)
        ans=max(findPathLength(valids[i]),ans);
    

    cout<<ans<<endl;

}

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

using ll = long long;
using namespace std;

int main() {
    ll n;
    cin>>n;
    cout<<"50"<<endl;
    ll a=(n-1)/50+1;
    ll b=50-n%50;
    if(b==50){
        b=0;
    }
    if(n==0){
        a=0;
        b=0;
    }
    for(int i=0;i<50;i++){
        if(i<b){
            cout<<a+b-2;
        }else{
            cout<<a+b+49;
        }
        if(i!=49){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }

    return 0;

}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <sstream>
#include <complex>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define ull unsigned long long

const int MAXN = 100005;
const int INF = 0x3f3f3f3f;
const ll INFLL = 9223372036854775807;
const int MOD = 1e9 + 7;
const double PI=2.0*asin(1.0);

ll N, ans, arr[200005];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	while(cin>>N){
		ans=INFLL;
		for(int i=1; i<=N; i++){
			cin>>arr[i];
			arr[i]+=arr[i-1];
		}
		for(int i=1; i<N; i++){
			if(abs(arr[N]-arr[i]-arr[i])<ans) ans=abs(arr[N]-arr[i]-arr[i]);
		}
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll h,w;
ll idx;
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
vector<vector<bool> >seen;
vector<vector<ll> >id;
vector<string>s;
void dfs(ll x,ll y){
    rep(dir,4){
        ll nx = x + dx[dir];
        ll ny = y + dy[dir];
        if(nx<0||nx>=h||ny<0||ny>=w)continue;
        if(seen[nx][ny])continue;
        if(s[nx][ny]==s[x][y])continue;
        id[nx][ny]=idx;
        seen[nx][ny]=true;
        dfs(nx,ny);
    }
    return;
}

int main(){
    cin >> h >> w;
    s.resize(h);
    rep(i,h)cin>>s[i];
    seen.resize(h);
    rep(i,h)seen[i].resize(w);
    rep(i,h)rep(j,w)seen[i][j]=false;
    id.resize(h);
    rep(j,h)id[j].resize(w);
    rep(i,h)rep(j,w)id[i][j]=0;
    idx = 1;
    rep(i,h){
        rep(j,w){
            if(seen[i][j])continue;
            dfs(i,j);
            idx++;
        }
    }
    //vector<pair<ll,ll> >ans(200000,{0,0});
    vector<ll>ans1(200000,0);
    vector<ll>ans2(200000,0);
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#')ans1[id[i][j]]++;
            else ans2[id[i][j]]++;
        }
    }
    ll res = 0;
    for(ll i=1;i<=200000;i++){
        res += ans1[i]*ans2[i];
    }

    cout << res << endl;
    return 0;
}


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

using namespace std;

#define ll long long

#define watch(x) cerr << (#x) << " = " << x << "\n";
 
const int N = 101;

ll dp[N * 1000 + 10];
ll weight[N], value[N];
ll sum_val;

const ll INF = 1e12 + 10;

ll dp1[N][N * 1000];


int n, w;

ll f(int i, int val) {
    if(dp1[i][val] != -1) {
        return dp1[i][val];
    }else if(val == 0) {
        return 0;
    }else {

        if(value[i] > val)
            return dp1[i][val] = f(i - 1, val);
        else  
            return dp1[i][val] = min(f(i - 1, val - value[i]) + weight[i], f(i - 1, val));

    }
}

int main() {

    cin >> n >> w;
    for(int i = 0 ; i < n ; i++) {
        cin >> weight[i] >> value[i];
        sum_val += value[i];
    }

    memset(dp, INF, sizeof(dp));

    dp[0] = 0;

    for(int i = 0 ; i < n ; i++) {
        for(int val = sum_val ; val >= value[i] ; val--) {
            dp[val] = min(dp[val - value[i]] + weight[i], dp[val]);
        }
    }

    ll ans = 0;
    for(int i = 0 ; i <= sum_val ; i++) {
        if(dp[i] <= w) {
            ans = i;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 2944
n,m=map(int,input().split())
ab=[]
l=[[] for i in range(m+1)]
for i in range(n):
    tmp=[int(j) for j in input().split()]
    ab.append(tmp)
    a,b=tmp
    if a<=m:
        l[a].append(b)
import heapq
q=[]
ans=0
for i in range(1,1+m):
    for j in l[i]:
        heapq.heappush(q,-j)
    if q:
        ans-=heapq.heappop(q)
print(ans)

Measured memory_bytes: 33172
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = 0 ;
	vll cnt(n+1,0) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		if(a>n) ans++ ;
		else cnt.at(a)++ ;
	}
	for(int i=0;i<n+1;i++){
		if(i!=cnt.at(i)){
			if(cnt.at(i)>i) ans += cnt.at(i)-i ;
			else ans += cnt.at(i) ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
  ll dp0[101][4]; // i桁目までみてnより小さいことが確定していない
  ll dp1[101][4]; // i桁目までみてnより小さいことが確定している

  for (auto i = 0; i <= 100; i++)
  {
    for (auto j = 0; j <= 3; j++)
    {
      dp0[i][j] = 0;
      dp1[i][j] = 0;
    }
  }

  string N;
  ll K;

  cin >> N;
  cin >> K;

  int digit = N.at(0) - '0';

  // i桁目までNと一致
  dp0[0][0] = 0; // 1桁目は0以上なので.
  dp0[0][1] = 1;
  // i桁目まででNより小さい
  dp1[0][0] = 1;
  dp1[0][1] = digit - 1; // digit, 0を除く (digit + 1) - 2;

  for (auto i = 1; i < N.size(); i++)
  {
    int digit = N.at(i) - '0';
    // cout << "i: " << i << endl;
    for (auto k = 0; k <= K; k++)
    {
      // cout << "k: " << k << endl;
      if (k == 0)
      {
        // i桁目までNと一致
        dp0[i][0] = digit == 0 ? dp0[i - 1][0] : 0;
        // i桁目まででNより小さい
        dp1[i][0] = 1; // '000000...'のとき, 1になる。

        // cout << "dp0[i][k]: " << dp0[i][0] << endl;
        // cout << "dp1[i][k]: " << dp1[i][0] << endl;

        continue;
      }

      if (digit == 0)
      {
        // i桁目までNと一致
        dp0[i][k] = dp0[i - 1][k];
        // i桁目まででNより小さい
        dp1[i][k] = dp1[i - 1][k - 1] * 9 + dp1[i - 1][k];
      }
      else
      {
        // i桁目までNと一致
        dp0[i][k] = dp0[i - 1][k - 1];
        // i桁目まででNより小さい
        dp1[i][k] = dp1[i - 1][k - 1] * 9 + dp1[i - 1][k] + dp0[i - 1][k] + dp0[i - 1][k - 1] * (digit - 1);
      }

      // cout << "dp0[i][k]: " << dp0[i][k] << endl;
      // cout << "dp1[i][k]: " << dp1[i][k] << endl;
    }
  }

  cout << dp0[N.size() - 1][K] + dp1[N.size() - 1][K] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	int A = 1;
	while (A * (A - 1) / 2 < N) ++A;
	if (A * (A - 1) / 2 > N) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		vector<vector<int> > G(A);
		int cnt = 0;
		for (int i = 0; i < A; ++i) {
			for (int j = 0; j < i; ++j) {
				++cnt;
				G[i].push_back(cnt);
				G[j].push_back(cnt);
			}
		}
		cout << A << endl;
		for (int i = 0; i < A; ++i) {
			cout << G[i].size();
			for (int j : G[i]) {
				cout << ' ' << j;
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long i,j,k,a,b,c=0,d=0,n,m,t;
cin>>n;
vector<string>A(n);
vector<int>B(n);
string s;
for(i=0;i<n;i++)
  cin>>A[i]>>B[i];
cin>>s;
for(i=n-1;i>=0;i--)
{
  if(A[i]==s) break;
  else d+=B[i];
}
cout<<d<<endl;
return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;

const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=100+5;
const int mod=1e9+7;
const ll oo=1e18+5;

void max_self(ll& a,ll b){
	a=max(a,b);
}

struct IT{
	vector<ll> tree;
	int base;
	IT(int n){
		base=1;
		while(base<=n){
			base*=2;
		}
		tree.resize(base*2);
	}
	ll get_max(int id){
		ll best=0;
		while(id>1){
			if(id%2){
				max_self(best,tree[id-1]);
			}
			id/=2;
		}
		return best;
	}
	
	void update(int id,ll val){
		while(id>0){
			max_self(tree[id],val);
			id/=2;
		}
	}	
};

int n;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	cin>>n;
	vector<int> h(n);
	for(int& x:h) cin>>x;
	vector<int> a(n);
	for(int& x:a) cin>>x;
	vector<ll> dp(n+1); // dp of i is maximum beauty that flower height i taken in last
	IT it(n);
	cerr<<it.base<<endl;
	for(int flower=0;flower<n;++flower){
		int id=it.base+h[flower];
		ll best=it.get_max(id);
		dp[h[flower]]=best+a[flower];
		it.update(id,dp[h[flower]]);
	}
	ll ans=0;
	for(int i=0;i<=n;++i) max_self(ans,dp[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 7552
// 21:27

#include <cstdio>

using namespace std;
int main() {
  int N;
  int canDiv4=0;
  int cantDiv2=0;
  int canDiv2=0;
  scanf("%d", &N);
  for(int i=0;i<N;++i) {
    int a;
    scanf("%d", &a);
    if (a%4==0) {
      ++canDiv4;
    } else if(a%2!=0) {
      ++cantDiv2;
    }
  }
  canDiv2 = N-canDiv4-cantDiv2;
  if ((canDiv2==0 && canDiv4 + 1 == cantDiv2) || canDiv4>=cantDiv2) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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


int main()
{
  int N, K;
  cin >> N >> K;
  cout << (N - K + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
/*
....................
....................
*/
#include<bits/stdc++.h>
#define ll long long int
#define here cout<<"here\n"
#define pb push_back
#define mp make_pair
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pf printf
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
using namespace std;

const ll mod = 1e9+7;

const int MAX = 100005;


int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    string s[n];
    ll i,j,k;
    for(i=0;i<n;i++)
    	cin>>s[i];
    vector<vector<ll>>dp(n,vector<ll>(m,0));
    for(i=0;i<n;i++)
    {
    	if(s[i][0]=='.')
    	{
    		dp[i][0]=1;
    	}
    	else
    	{
    		break;
    	}
    } 
    for(i=0;i<m;i++)
    {
    	if(s[0][i]=='.')
    	{
    		dp[0][i]=1;
    	}
    	else
    	{
    		break;
    	}
    }
    for(i=1;i<n;i++)
    {
    	for(j=1;j<m;j++)
    	{
    		if(s[i][j]=='#')
    		{
    			dp[i][j]=0;
    		}
    		else
    		{
    			dp[i][j] = dp[i-1][j]+dp[i][j-1];
    		}
    		dp[i][j]%=mod;
    	}
    } 

    cout<<dp[n-1][m-1];
	
	return 0;
}

Measured memory_bytes: 12156
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int n, m, a, b;
    cin >> n >> m;
    vector<int> vec(n);
    for(int i=0; i<m; i++){
        cin >> a >> b;
        vec.at(a-1) += 1;
        vec.at(b-1) += 1;
    }
    for(int i=0; i<n; i++){
        cout << vec.at(i) << endl;
    }
}


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

// a と b の最大公約数を返す関数
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int main() {

    int K;

    cin >> K;

    int res=0;

    for(int l=1; l<K+1; l++){
        for(int m=1; m<K+1; m++){
            for(int n=1; n<K+1; n++){

                res=res+gcd(gcd(l,m),n);
            }
        }
    }
    cout << res << endl;
}


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

using namespace std;

long long check(int a, int h, int n, int w){

    long long l = 4LL * h * n * w;
    long long r = (long long)a * (n * w + h * w + h * n);

    return r - l;
}

int main(){

    int a;
    int l, r, m;
    cin >> a;

    for (int h = 1; h <= 3500; h++){

        for (int n = h; n <= 3500; n++){

            l = n;
            r = 3500;

            while(l < r){
                m = (l + r) / 2;
                long long b = check(a, h, n, m);
                if (check(a, h, n, m) == 0){
                    cout << h << ' ' << n << ' ' << m << endl;
                    goto end;
                }
                if(b > 0LL){
                    l = m + 1;
                }else{
                    r = m;
                }
            }

        }

    }

end:

    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int maxn = 310;

int a[maxn][maxn];
bool ok[maxn];
int ct[maxn], pos[maxn];

int n, m;

bool check(int x)
{
	bool tf = true;

	memset(ok, true, sizeof ok);
	memset(ct, 0, sizeof ct);
	for (int i = 1;i <= n;++i)
	{
		pos[i] = 1;
		ct[a[i][1]]++;
		if (ct[a[i][1]] > x) tf = false;
	}
	if (tf) return true;
	while (true)
	{
		for (int i = 1;i <= m;++i) if (ct[i] > x) ok[i] = false;
		for (int i = 1;i <= n;++i)
		{
			while (pos[i] <= m && !ok[a[i][pos[i]]]) pos[i]++;
			if (pos[i] == m + 1) return false;
		}
		tf = true;
		memset(ct, 0, sizeof ct);
		for (int i = 1;i <= n;++i)
		{
			ct[a[i][pos[i]]]++;
			if (ct[a[i][pos[i]]] > x)
			{
				tf = false;
				break;
			}
		}
		if (tf) return true;
	}
	return false;
}

int main(int argc, char * argv[])
{
	int ans;
	scanf("%d%d", &n, &m);
	for (int i = 1;i <= n;++i)
	{
		for (int j = 1;j <= m;++j)
		{
			scanf("%d", &a[i][j]);
		}
	}
	ans = n;
	int l = 1;
	int r = n;
	while (l <= r)
	{
		int mid = (l + r) >> 1;
		if (check(mid))
		{
			ans = mid;
			r = mid - 1;
		}
		else
		{
			l = mid + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int a,x,y;
	
	while( scanf("%d%d",&x,&y) != EOF ){
		if( x==0&&y==0 ) break;
		if(x>y){
			a=x;
			x=y;
			y=a;
		}
		printf("%d %d\n",x,y);
	}
return 0;
}

Measured memory_bytes: 600
N = int(input())
name = [input() for i in range(N)]
import collections
'''
name = ""
dic = {}
for i in range(N):
  name = input()
  dic[name] += 1
print(dic)
'''
c = collections.Counter(name)
values, counts = zip(*c.most_common(N))
maxim = counts[0]
answer = []
for val, cnt in zip(values,counts):
  if ( cnt == maxim):
    answer.append(val)
  else:
    break
answer = sorted(answer)
for i in answer:
  print(i)

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

int n;
int main(){
  cin >> n;
  int m;
  for(int i = 1; i*i<= n; i++){
    if(i*i <= n){
      m = i*i;
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    rep(i,n)cin>>a[i];
    vector<int> cnt(n+1);
    rep(i,n)cnt[a[i]]++;
    vector<int> dp(n+2);
    rep(i,n+1){
        dp[i+1]--;
        dp[max(0,i+1-cnt[i])]++;
    }
    rep(i,n)dp[i+1]+=dp[i];
    int ans = n;
    rep(i,n)ans -= !!dp[i+1];
    while(m--){
        int x,y;
        cin>>x>>y;
        --x;
        int idx = a[x]+1-cnt[a[x]];
        if(idx>0&&--dp[idx]==0)++ans;
        --cnt[a[x]];
        ++cnt[y];
        idx = y+1-cnt[y];
        if(idx>0&&++dp[idx]==1)--ans;
        a[x]=y;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    int t;
    cin>>t;
    string s;
    s=to_string(t);
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')
    cout<<"Yes\n";
    else
    cout<<"No\n";
}

        

Measured memory_bytes: 3692
#include<stdio.h>
main()
{
 int a,b,c=0;
 1<=a,b,c<=100;
 scanf("%d%d%d",&a,&b,&c);
 if(a+b==c|a+c==b|b+c==a){
 printf("Yes");
}else{
	printf("No");
}
return 0;
}
 

Measured memory_bytes: 128
//==========//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;//<key,value>


int main() {
int a,b,x;
cin>>a>>b>>x;
if(x>=a && x<=a+b)
cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return 0;
}







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

typedef long long LL;

const int N = 100010;

struct WEN {

int val, pos, type;

bool operator < (const WEN &b) {
    return val < b.val;
}

} num[N * 2];

LL pre[N * 2]; int pos[2][N]; 

int main() {
    int n, tp = 0; scanf("%d", &n); LL A = 0, B = 0;
    for (int i = 1; i <= n; i++) {
        int a, b; scanf("%d%d", &a, &b), A += a, B += b;
        num[++tp] = (WEN){ a, i, 0 }, num[++tp] = (WEN){ b, i, 1 };
    }
    sort(num + 1, num + tp + 1);
    for (int i = 1; i <= tp; i++) {
        pre[i] = pre[i - 1] + num[i].val;
        pos[num[i].type][num[i].pos] = i;
    }
    LL res = 1e18;
    for (int i = 1; i <= n; i++) {
        int a = pos[0][i], b = pos[1][i];
        if (a > b) swap(a, b);
        if (b <= n) { res = pre[n]; break; }
        if (a < n) res = min(res, pre[n - 1] + num[b].val);
        else res = min(res, pre[n - 2] + num[a].val + num[b].val);
    }
    printf("%lld\n", min(res, min(A, B)));
}

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

int main(){
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++){
		int ball[10]={};
		for(int j=0;j<10;j++) cin>>ball[j];
		int a=0,b=0,k;
		for(k=0;k<10;k++){
			if(a<ball[k]) a=ball[k];
			else if(b<ball[k]) b=ball[k];
			else break;
		}
		if(k==10) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)

int main() {
    ll n, m; cin >> n >> m;
    vector<long long> vec(n);
    ll num = 0;
    ll LC = 1;
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
        vec[i] = vec[i] / 2;

        ll tmp = vec[i], count = 0;
        while(tmp % 2 == 0){
            count++;
            tmp = tmp / 2;
        }
        if(i == 0){
            num = count;
        }else{
            if(num != count){
                cout << 0 << endl;
                return 0;
            }
        }

        LC = lcm(LC, vec[i]);
    }

    cout << (m / LC + 1) / 2 << endl;

}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (k < x / d) {
        x -= k * d;
        k = 0;
    } else {
        k -= x / d;
        x %= d;
    }
    cout << (k % 2 ? d - x : x) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main(){
    int a,b,c,d,e;
    int k;
    cin >> a >> b >> c >> d >> e;
    cin >> k;
    int sum = 0;
    
    sum = e - a;
    
    if(sum <= k)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#include <dirent.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define PLLI pair<LLI,LLI>
#define PDD pair<double,double>
#define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
#define INRANGED(val,l,r) (((l)<(val) || fabs((val)-(l))<eps) && ((val)<(r) || fabs((val)-(r))<eps))
#define INRANGEI(val,l,r) ((val)>=(l) && (val)<=(r))
#define MSET(a,b) memset(a,b,sizeof(a))
using namespace std;
using namespace __gnu_pbds;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction


//typedef tree < int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

int main(){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<n<<" "<<n<<" "<<n/2<<"\n";
        return 0;
    }
    FREP(h,1,3500){
        FREP(nn,1,3500){
            LLI hor = (LLI)nn*(LLI)h*(LLI)n;
            LLI lob = 4*(LLI)h*(LLI)nn-(LLI)n*(LLI)nn-(LLI)h*(LLI)n;
            if(lob>0 && hor%lob==0){
                cout<<h<<" "<<nn<<" "<<hor/lob<<"\n";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
const int N=1e6;
char arr[N];
int main ()
{
    scanf("%s",arr);
    int n=strlen(arr);
    int a,z;
    bool flag=false;
    for(int i=0;i<n;i++){
        if(arr[i]=='Z')
        z=i;
        if(arr[i]=='A' && flag==false){
        a=i;
        flag=true;
        }
    }

    z++;
    printf("%d\n",z-a);
}


Measured memory_bytes: 384
N, M = map(int, input().split())
ab = [[int(i) for i in input().split()] for j in range(M)]

G = [[] for i in range(N)]
for i in range(M):
    a, b = ab[i]
    G[a-1].append(b-1)
    G[b-1].append(a-1)

def rec(v, memo):
    memo[v] = 1

    if -1 not in memo:
        memo[v] = -1
        return 1

    count = 0
    for next_v in G[v]:
        if memo[next_v] == -1:
            count += rec(next_v, memo)

    memo[v] = -1
    return count

memo = [-1 for i in range(N)]
print(rec(0, memo))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 100005, MAXM = 2023, mod = 1000000007 , MAXLog = 20;

int Ans[MAXM][MAXM];

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;


    for (int i = 0; i < 2019; ++i) {
        for (int j = i + 1; j < 2019;  ++j) {
            Ans[i][j] = i * j % 2019;
        }
    }

    int l, r;
    cin >> l >> r;
    int diff = r - l;
    l %= 2019;
    if (diff >= 2019 - l) {
        cout << 0 << '\n';
        return 0;
    }

    r %= 2019;
    int ans = INT_MAX;
    for (int i = 0; i < 2019; ++i) {
        for (int j = i + 1; j < 2019;  ++j) {
            if (i >= l && j <= r) {
                ans = min(ans, Ans[i][j]);
            }
        }
    }

    cout << ans << '\n';

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n), num(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        num[i] = i + 1;
    }
    for (int i = 0; i < n; i++) cin >> q[i];

    int a, b;
    int count = 0;
    do {
        bool flag1 = true;
        bool flag2 = true;
        count++;
        for (int i = 0; i < n; i++){
            if(num[i] != p[i]) flag1 = false;
            if(num[i] != q[i]) flag2 = false;
        }
        if(flag1) a = count; 
        if(flag2) b = count; 
    }while(next_permutation(num.begin(), num.end()));
    
    cout << abs(a - b) << endl;
  
}   

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
k = int(input())
from collections import deque
d = deque()
for i in range(9):
    d.append(str(i+1)) # 初期

def dfs():
    global cnt
    a = d.popleft()
    
    #print(cnt)
    for i in range(-1,2,1):
        nya = a
        last_string = int(a[-1]) + i
        if last_string < 0 or last_string > 9:
            pass
        else:
            nya += str(last_string)
            cnt += 1
            if k == cnt:
                print(nya)
                exit()
            d.append(nya)
    dfs()

cnt = 9
if k <= cnt:
    print(k)
    exit()
dfs()


Measured memory_bytes: 76380
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
using namespace std;
typedef long long int ll;

std::vector<ll> fac(3000000, 1), finv(3000000, 1), inv(3000000, 1);

void c4_init(ll m) {
    for (ll i = 2; i < 3000000; i++) {
        fac[i] = fac[i - 1] * i % m;
        inv[i] = m - inv[m%i] * (m / i) % m;
        finv[i] = finv[i - 1] * inv[i] % m;
    }
}

ll c4(ll n, ll k, ll m) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % m) % m;
}


const ll M = 998244353;
ll N, a, b, K, ans;

int main() {
  c4_init(M);
  cin >> N >> a >> b >> K;
  // ax + by = K
  // y = (K-ax)/b
  for (ll x = 0; x <= N; x++) {
    ll y = (K-a*x)/b;
    if (a*x + b*y == K) {
      //cout << "x = " << x << " y = " << y << endl;
      (ans += (c4(N, x, M) * c4(N, y, M)) % M) %= M;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 70528
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int N, x;
	cin >> N >> x;
	vector<int>a(N);
	rep(i, N)cin >> a[i];

	int ans = intmax;
	rep(i, N) {
		int score = i*x;
		rep(j, N)score += a[j];
		ans = min(ans, score);

		vector<int>b(N);
		b[0] = min(a[0], a[N - 1]);
		REP(j, 1, N)b[j] = min(a[j], a[j - 1]);
		rep(j, N)a[j] = b[j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int a[3];
int main(int argc, char const *argv[]) {
  scanf("%d %d %d\n", &a[0], &a[1], &a[2]);
  std::sort(a, a+3);
  int l = a[2]*10 + a[1] + a[0];
  printf("%d\n", l);
  return 0;
}

Measured memory_bytes: 128
/*
  第4回ユニリタプログラミングコンテスト～練習サイト～
  C言語用
  ファイル名 qA.c
  作成者 228 金子幸裕 2017/05/25 13:45
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

int main( void )
{
    int  na,nb;

    scanf( "%d %d" , &na, &nb );

    if ( na > 0 && nb > 0 )
    {
    	printf("Positive");
    }

    if ( na <= 0 && nb >= 0 )
    {
    	printf("Zero");
    }

    if ( na < 0 && nb < 0 )
    {
        if ( (abs(na) - abs(nb)) % 2 == 0 )
        {
            printf("Negative");
        }
        else
        {
            printf("Positive");
        }
    }

    printf("\n");

    return ( 0 );

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int M=1000000007;
const int N=200005,E=524288;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int n,m,i,j,k,u,v,w,f[250005],g[250005],d[250005],num[250005],s,ans,pp[250005],p[250005],t;
bool cmp(int a,int b)
{
	return pp[a]<pp[b];
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<n;++i)
	{
		scanf("%d %d %d",&u,&v,&w);
		++u,++v;
		d[u]^=w,d[v]^=w;
	}
	for(i=1;i<=n;++i)
		++num[d[i]];
	for(i=0;i<16;++i)
	{
		if(i!=0)
			ans+=num[i]/2;
		num[i]&=1;
		s|=num[i]<<i;
	}
	for(i=0;i<(1<<16);++i)
	{
		p[i]=i;
		for(j=0;j<16;++j)
			if((i>>j)&1)
				++pp[i];
	}
	sort(p,p+(1<<16),cmp);
	for(t=0;t<(1<<16);++t)
	{
		i=p[t];
		if(i==0||i==1)
		{
			f[i]=0;
			continue;
		}
		f[i]=1000000007;
		for(j=1;j<16;++j)
			for(k=1;k<16;++k)
				if(j!=k)
					if(((i>>j)&1)&&((i>>k)&1))
						f[i]=min(f[i],f[i^(1<<j)^(1<<k)^(1<<(j^k))]+1+((i>>(j^k))&1));
	}
	cout<<ans+f[s];
}


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

int pos[100000];
int main()
{
    int n;
    cin >> n;

    for(int i = 1; i < n+1;i++)
    {
        cin >> pos[i];
    }
    int dis[100000];
    int sum = 0;
    for(int i = 0; i <= n; i++){
           dis[i] = abs(pos[i+1]-pos[i]);
           sum += dis[i];
    }
    for(int i = 1; i <= n; i++){
        cout << sum - dis[i] - dis[i-1] + abs(pos[i+1]-pos[i-1]);
        cout << '\n';
    }
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,ll>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,K;
    Scd2(N,K);
    if( N==K ) {
        printf ("%d\n", 0);
        return 0;
    }
    vi h(N);
    Rep(i,N) Scd(h[i]);

    vector<map<int,ll>> dp(K+1);
    map<int,ll> dpki;
    map<int,ll> dpkip1;
    dp[0][1] = 1;

    Rep(ni,N){
        RRep(ki,K+1){
            for( pii mi : dp[ki] ){
                int hi = mi.first;
                ll dphi = mi.second;
                // printf ("!dp[%lld][%d] = %lld\n", ki, mi.first, mi.second );
                // hi to hhi
                // dp[ki][hi] -> dp[ki+1][hhi];
                // hhi = hi (消費)
                if( ki != K ){
                    if( dpkip1.find(hi) == dpkip1.end() ) dpkip1[hi] = 1e18;
                    dpkip1[hi] = min( dpkip1[hi], dphi );
                }
                // hhi = hi[ni] (温存)
                if( dpki.find(h[ni]) == dpki.end() ) dpki[h[ni]] = 1e18;
                dpki[h[ni]] = min( dpki[h[ni]], dphi+max(0,h[ni]-hi) );
            }
            dp[ki].clear();
            for( pii mi : dpki ){
                // printf ("?dp[%lld][%d] = %lld\n", ki, mi.first, mi.second );
                dp[ki][mi.first] = mi.second;
            }
            if( ki != K ) for( pii mi : dpkip1 ){
                // printf ("?dp[%lld][%d] = %lld\n", ki+1, mi.first, mi.second );
                if( dp[ki+1].find(mi.first) == dp[ki+1].end() ) dp[ki+1][mi.first] = 1e18;
                dp[ki+1][mi.first] = min( dp[ki+1][mi.first], mi.second);
            }
            dpkip1.clear();
            dpki.clear();
        }
            // printf (" \n");
    }

    ll ans = 1e18;
    Rep(ki,K+1){
        for( pii mi : dp[ki] ){
            // printf ("dp[%lld][%d] = %lld\n", ki, mi.first, mi.second );
            if( mi.second == 0 ) continue;
            ans = min( ans, mi.second );
        }
    }

    printf ("%lld\n", ans );

    return 0;
}




Measured memory_bytes: 2304
#include<stdio.h>
using namespace std;

int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d\n", &W,&H,&x,&y,&r);
  if ((x>=r && x<=W-r) && (y>=r && y <= H-r)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}



Measured memory_bytes: 2704
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <stdio.h>
#define int long long
inline int in() { int32_t x; scanf("%d", &x); return x ;}
using namespace std;
const int INF = 1e18;
const int MAX_N = 1e5 + 5;
int32_t main()
{
    for (int i = 1 ; i <= 9 ; i ++)
    {
        for (int x = 1 ; x <= 9 ; x ++)
        {
//            printf("%d*%d=%d",i,x,i*x);
            cout << i << "x" << x << "=" << i * x;
            cout << endl;
        }
    }
}

Measured memory_bytes: 3092