akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll N, X;
ll a[52], p[52];
 
ll f(ll n, ll x) {
    if(n == 0) return 1;
    if(x == 1) return 0;
    if(x <= a[n-1] + 1) return f(n-1, x-1);
    if(x == a[n-1] + 2) return 1 + p[n-1];
    if(x < a[n]) return p[n-1] + 1 + f(n-1, x - a[n-1] - 2);
    return p[n];
}
 
int main() {
    cin >> N >> X;
    a[0] = 1; p[0] = 1;
    rep1(i,N+1) {
        a[i] = 3 + 2 * a[i-1];
        p[i] = 1 + 2 * p[i-1];
    }
    cout << f(N, X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include "stdlib.h"

#define MAXN 100
#define MAXM 100

typedef unsigned int uint;
typedef int bool;

static struct {
    uint piece_pos[MAXN];
    uint piece_num;
    bool slots[2019];//记录各位置是否被占用
} checkboard;


int main() {
    uint N, M;
    scanf("%u", &N);
    checkboard.piece_num = N;

    for (uint i = 0; i < N; i++) {
        char str[5];
        uint pos;
        scanf("%s",str);
        pos=atoi(str);
        //初始化各棋子的位置
        checkboard.piece_pos[i]=pos;
        //更新空闲情况
        checkboard.slots[pos]=1;
    }

    scanf("%u",&M);
    for (uint i=0;i<M;i++){
        //获得要操作的棋子序号
        char str[5];
        uint index,pos;
        scanf("%s",str);
        index=atoi(str)-1;
        //printf("index is %u\n",index);

        pos=checkboard.piece_pos[index]+1>2019?checkboard.piece_pos[index]:checkboard.piece_pos[index]+1;
        if (!checkboard.slots[pos]){
            checkboard.piece_pos[index]=pos;
            checkboard.slots[pos-1]=0;
            checkboard.slots[pos]=1;
        }
    }
    for (uint i=0;i<checkboard.piece_num;i++)
        printf("%u\n",checkboard.piece_pos[i]);

    return 0;
}


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

#define N 200000
#define MOD 1000000007

int main() {

  int n, list[N];
  long long s = 0;
  cin>>n;
  for (int i = 0; i < n; i++) {
    cin>>list[i];
    s += list[i];
  }

  long ans = 0;
  for (int i = 0; i < n; i++) {
    long long sum = (s - list[i]) % MOD;
    ans += list[i] * sum;
    ans %= MOD;
    s -= list[i];
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4404
import itertools
import math
N = int(input())
S = input()
cot = 0
left_count = 0
for c in S:
    if c == ")":
        if cot > 0:
            cot -=1
        else:
            left_count += 1
    else:
        cot += 1
print("(" * left_count + S + cot * ")")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    n--;
    ll arr[n+5]={0};
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    ll sum=0;
    sum=arr[1]+arr[n];
    for(int i=1;i<=n-1;i++)
    {
        ll x=min(arr[i],arr[i+1]);
        sum+=x;
    }
    cout<<sum<<endl;



}


Measured memory_bytes: 3620
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
// int dx[]={0,1,0,-1,1,1,-1,-1};
// int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int dx[]={-1,-1,0,0,1,1};
int dy[]={-1,0,-1,1,0,1};//RDLU
int n,m;
vvp G;
vi used,co,t;
ll l=1,r=1000000010;
void dfs(int a,int b){
	used[a]=1;
	t[a]=b;
	if(!b)l=max(l,1-co[a]);
	else r=min(r,co[a]-1);
	
//	cout<<a<<" "<<b<<" "<<t[a]<<" "<<co[a]<<" "<<l<<" "<<r<<endl;
	rep(i,G[a].size()){
		int to=G[a][i].first;
		ll ne=G[a][i].second-co[a];
//		cout<<to<<" "<<ne<<" "<<l<<" "<<r<<endl;
		if(used[to]){
			if(b==t[to]){
				ll w=ne-co[to];
				if(b)w=-w;
				if(w%2)l=2,r=1;
				else{
					l=max(l,w/2);
					r=min(r,w/2);
				}
			}else{
				if(ne!=co[to])l=2,r=1;
			}
		}else{
			co[to]=ne;
			dfs(to,b^1);
		}
	}
}
int main(){
	cin>>n>>m;
	G=vvp(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		G[a].pb({b,c});
		G[b].pb({a,c});
	}
	used=co=t=vi(n);
	dfs(0,0);
	if(l<=r)cout<<r-l+1<<endl;
	else cout<<0<<endl;
}







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

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

	int mx = 0;
	int mn = 1e6;
	for(int i = 0; i < m; i++){
		int l,r;
		cin>>l>>r;
		mx = max(mx,l);
		mn = min(mn,r);
	}

	if(mx>mn) cout<<0;
	else cout<<(mn-mx+1);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 998244353
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<ll>().max();

ll exp(ll base, ll x) {
	ll r = 0;
	if (x > 0) {
		r = exp(base, x/2);
		r = r % mod;
		r = r * r;
		r = r % mod;
		if (x%2) {
			r = r*base;
			r = r % mod;
		}
	}
	if (r > 1) return r;
	else return 1;
}


int main() {
	ll n;
	cin >> n;
	vector<ll> v(n+1, 0); 
	for(ll i=1; i<=n; i++) {
		cin >> v[i]; 
	}
	v[0] = -1;
	ll ans = 1;
	if (v[1] > 0) ans = 0;
	sort(v.begin(), v.end());
	for(ll i=1; i<n; i++) {
		if (v[i] < v[i+1] - 1) ans = 0;
		if (i>1 and v[i] == 0) ans = 0;
	}

	map<ll, ll> total;
	for(ll i=1; i<=n; i++) {
		total[v[i]]++;
	}

	for(ll i=1; i<n; i++) {
		ans = ans * exp(total[i], total[i+1]); 
		ans = ans % mod;
	}

	cout << ans << endl;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

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

int main() {
	init();

	int N; cin >> N;
	vector<ll>a(N);
	rep(i, 0, N)cin >> a[i];
	sort(all(a));
	int x = a[N - 1];
	int y = INF;
	rep(i, 0, N) {
		if (abs(y - (x + 1) / 2) > abs(a[i] - (x + 1) / 2))y = a[i];
	}
	cout << x << " " << y << "\n";

	return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		vector< LL > csum( 1, 0 );

		REP( i, 0, n )
		{
			int a;
			cin >> a;

			csum.PB( csum.back() + a );
		}

		LL res = LLONG_MIN;

		REP( i, 0, n )
		{
			REP( j, i + 1, n + 1 )
			{
				res = max( res, csum[j] - csum[i] );
			}
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define mod 1000000007
#define pub(a) push_back(a)
#define mp(a,b) make_pair(a,b)

const ll N = 100004;
vector<ll>dp(N,-1);

ll call(ll h[],ll n){
    if(n==1){
        dp[1]= 0;
        return dp[1];
    }else if(n==2){
        dp[2] =  abs(h[2]-h[1]);
        return dp[2];
    }else{
        if(dp[n]!=-1){
            return dp[n];
        }
    }
    return dp[n] = min(abs(h[n]-h[n-1])+call(h,n-1),abs(h[n]-h[n-2])+call(h,n-2));

}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll h[n+1];
    for(ll i =1;i<=n;i++){
        cin>>h[i];
    }
    cout<<call(h,n);
    

    return 0;
}


Measured memory_bytes: 7920
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 100005
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, k, w[MAXN], v[MAXN];
LL ans, f[MAXN];

int main()
{
	scanf("%d%d", &n, &k);
	for(rint i=1; i<=n; ++i) scanf("%d%d", &w[i], &v[i]);
	for(rint i=1; i<=n; ++i)
	{
		for(rint j=k; j>=w[i]; j--) f[j]=max(f[j], f[j-w[i]]+v[i]);
	}
	for(rint i=0; i<=k; ++i) ans=max(f[i], ans);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 896
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n, m, p = map(int, raw_input().split())
            if n == 0 and m == 0 and p == 0:
                break
            a = []
            for i in range(n):
                a.append(input())
            if a[m-1] == 0:
                print 0
            else:
                print 100 * sum(a) * (100 - p) / (100 * a[m-1])
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4676
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main(){
	cin>>n>>a>>b;
	if(1ll*a*b<n||a+b-1>n){puts("-1");return 0;}
	if(a==1){for(int i=n;i;--i)printf("%d ",i);return 0;}
	for(int i=b;i;--i)printf("%d ",i);
	int x=(n-b)/(a-1);
	int d=(n-b)%(a-1);
	int z=b;
	for(int j=1;j<=d;++j){
		for(int i=z+x+1;i>z;--i)printf("%d ",i);
			z+=x+1;
	}
	while(z<n){
		for(int i=z+x;i>z;--i)printf("%d ",i);
			z+=x;
	}
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define mb      make_pair
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#define tr(c,i) 	for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) 	((c).find(x) != (c).end())

#define MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

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

	ll a,b,c;
	cin>>a>>b>>c;
	ll ans= a-b;
	ans= c- ans;
	if(ans>0)
		cout<<ans;
	else cout<<"0";
	
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
Xs=list(map(int,input().split()))


Xs.sort()
costs=[abs(Xs[i]-Xs[i+1]) for i in range(M-1)]
costs.sort(reverse=True)

for i in range(N-1):
    if not costs:
        print(0)
        exit(0)
    costs.pop(0)




print(sum(costs))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll n;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

int main(){
	n = read();
	REP(i, 0, 25)
		REP(j, 0, 14)
			if (i * 4 + j * 7 == n){
				puts("Yes");
				return 0;
			}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if(x[0]<x[1]&& x[1] < x[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 9420
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> H(N);
  for (int i = 0; i < N; i++) {
	  cin >> H[i];
	}
  bool ans = true;
  for (int i = N - 2; i >= 0; i--) {
	  if (H[i + 1] <= H[i] - 2) {
		  ans = false;
		  break;
		}
	  else if (H[i + 1] == H[i] - 1) {
		  H[i]--;
		}
	}
  if (ans) {
	  cout << "Yes" << endl;
	}
  else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define mod 1000000007
#define M 1000000
using namespace std;


void answer(){
    ll n,k,y,v;
    cin>>n>>k>>y;
    v = max(n,k);
    std::vector<ll> a;
    for(int i=0;i<n;i++){
        if(i<k) a.pb(y);
        else{
            if(y!=1000000000) a.pb(y+1);
            else a.pb(1);
        }
    }
    for(int i=0;i<n;i++) cout<<a[i]<<" ";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int q;
    //cin>>q; while(q--)
        answer();
    return 0;
}

Measured memory_bytes: 2292
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    sw = 0
    alice = 0
    bob = 0
    for i in a:
        if sw == 0:
            alice += i
            sw = 1
        else:
            bob += i
            sw = 0
    print(alice-bob)

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
import math
import decimal
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

class Library():
    @staticmethod
    def Swap(a,b):
        return [b,a]

    @staticmethod
    def myRound(a,dig=0): # 四捨五入
        p = 10 ** dig
        return (a * p * 2 + 1) // 2 / p

    @staticmethod
    def Roundup(a,dig=0): # 切り上げ
        if a < 0:
            return int(a)
        else:
            return int(a + 0.9)

    @staticmethod
    def Gcd(a,b): #最大公約数
        if (a<b):
            a,b = Library.Swap(a,b)
        if (b==0):
            return a
        else:
            return Library.Gcd(b,a%b)

    @staticmethod
    def Lcm(a,b): #最小公倍数
        return a//Library.Gcd(a,b)*b

    @staticmethod
    def Divisors(a): # 約数列挙
        divisors = []
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                divisors.append(i)
                if i!=a//i:
                    divisors.append(a//i)
        divisors.sort()
        return divisors

class Prime():
    # コンストラクタ
    # エラトステネスの篩
    def __init__(self,num):
        self.num = num
        self.sieve = [0 for i in range(self.num + 1)]
        self.sieve[0] = -1
        self.sieve[1] = -1
        for i in range(2,self.num + 1):
            if self.sieve[i] == 0:
                self.sieve[i] = i
                for j in range(i + i,self.num + 1,i):
                    if self.sieve[j]:
                        self.sieve[j] = i
    
    # 素数判定
    def isPrime(self,num = None):
        if num is None:
            num = self.num
        if self.sieve[num] == num:
            return True
        else:
            return False
    
    # 素数列挙
    def PrimeNum(self,num = None):
        if num is None:
            num = self.num
        prime = []
        for i in range(2,num):
            if self.sieve[i] == i:
                prime.append(i)
        return prime
    
    # 素因数分解
    def PrimeFact(self,num = None):
        if num is None:
            num = self.num
        fact = []
        cnt = 0
        while self.sieve[num] != 1:
            fact.append(self.sieve[num])
            num //= self.sieve[num]
        return fact

def main():
    s = input()
    t = s[0:-8]
    print(t)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 59116
H, W, K = map(int,input().split())
s=[]
for i in range(H):
    s.append(input())

strawberry = [0]*H
for i in range(H):
    strawberry[i]=0
    for j in range(W):
        if s[i][j] == '#':
            strawberry[i] += 1
            
count = 1
ans = [[0]*W for i in range(H)]
for i in range(H):
    count_r = 0
    if strawberry[i] != 0:
        for j in range(W):
            if s[i][j] == '.':
                if count_r == strawberry[i]:
                    ans[i][j] = count-1
                else:
                    ans[i][j] = count
            else:
                ans[i][j] = count
                count += 1
                count_r += 1
prev = -1
next_s = 0        
for i in range(H):
    if strawberry[i] == 0:
        if prev != -1:
            for j in range(W):
                ans[i][j] = ans[prev][j]
            
        else:
            for k in range(i+1,H):
                if strawberry[k] != 0:
                    break
            for j in range(W):
                ans[i][j] = ans[k][j]
        prev = i
    else:
        prev = i


for i in range(H):
    print(*ans[i])

Measured memory_bytes: 7580
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int X, Y, Z, K;
    vector<long long> A(1001, 0);
    vector<long long> B(1001, 0);
    vector<long long> C(1001, 0);

    vector<long long> ret;

    cin >> X >> Y >> Z >> K;
    for(int i = 0; i < X; i++) cin >> A[i];
    for(int i = 0; i < Y; i++) cin >> B[i];
    for(int i = 0; i < Z; i++) cin >> C[i];

    sort(A.begin(), A.end(), greater<long long>());
    sort(B.begin(), B.end(), greater<long long>());
    sort(C.begin(), C.end(), greater<long long>());

    for(int a = 0; a < X; a++) {
        for(int b = 0; b < Y; b++) {
            for(int c = 0; c < Z; c++) {
                if((a+1) * (b+1) * (c+1) <= K) ret.push_back(A[a] + B[b] + C[c]);
                else break;
            }
        }
    }
    sort(ret.begin(), ret.end(), greater<long long>());

    for(int i = 0; i < K; i++) {
        cout << ret[i] << endl;
    }


}

Measured memory_bytes: 1404
#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 a, b, c; cin >> a >> b >> c;
    int one = a - b;
    if(one - c < 0) cout << -(one - c) << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: [usize; n]);
    let mut ret = 0;
    for i in (0..n).step_by(2) {
        if a[i] % 2 == 1 {
            ret += 1;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2112
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int INF = (int)1e9;

        while(true){

            int n = sc.nextInt();
            if(n==0) break;

            int[] p = new int[n];
            int[] t = new int[n];
            for(int i=0; i<n; i++){
                p[i] = sc.nextInt();
                t[i] = sc.nextInt();
            }

            int[][] dp = new int[n][4];
            for(int i=0; i<n; i++) Arrays.fill(dp[i], INF);

            int NG = -1;
            if(p[0]<=t[0]){
                dp[0][1] = p[0];
                dp[0][0] = dp[0][1];
            }
            else NG = 1;

            for(int i=1; i<n; i++){
                if(NG!=-1) break;
                int time = t[i] - t[i-1];
                if(dp[i-1][3]!=INF && p[i-1]*4+p[i]<=time){
                    dp[i][1] = dp[i-1][3] + p[i-1] + p[i];
                }
                if(dp[i-1][2]!=INF && p[i-1]*3+p[i]<=time){
                    dp[i][1] = Math.min(dp[i][1], dp[i-1][2] + p[i-1] + p[i]);
                }
                if(dp[i-1][1]!=INF && p[i-1]*2+p[i]<=time){
                    dp[i][1] = Math.min(dp[i][1], dp[i-1][1] + p[i-1] + p[i]);
                }                
                if(dp[i-1][1]!=INF && Math.abs(p[i-1]-p[i])*2<=time){
                    dp[i][2] = dp[i-1][1] + Math.abs(p[i-1]-p[i]);
                }
                if(dp[i-1][2]!=INF && Math.abs(p[i-1]-p[i])*3<=time){
                    dp[i][3] = dp[i-1][2] + Math.abs(p[i-1]-p[i]);
                }
                dp[i][0] = Math.min(dp[i][1] ,Math.min(dp[i][2], dp[i][3]));
                if(dp[i][0]==INF){
                    NG = i+1;
                    break;
                }
            }


            if(NG!=-1) System.out.println("NG " + NG);
            else System.out.println("OK " + (dp[n-1][0]+p[n-1]));
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 25340
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

int main(){
    int W, H, N;
    cin >> W >> H >> N;
    int a[110][110];
    int x[110], y[110];
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> a[i][i];
    }

    int xmax = W, xmin = 0;
    int ymax = H, ymin = 0;

    for(int i = 0; i < N; i++){
        if(a[i][i] == 1 && xmin < x[i]){
            xmin = x[i];
        }
        else if(a[i][i] == 2 && xmax > x[i]){
            xmax = x[i];
        }
        else if(a[i][i] == 3 && ymin < y[i]){
            ymin = y[i];
        }
        else if(a[i][i] == 4 && ymax > y[i]){
            ymax = y[i];
        }
    
    }

    int xp = xmax - xmin, yp = ymax - ymin;

    if(xmax - xmin <= 0) xp = 0;
    if(ymax - ymin <= 0) yp = 0;

    cout << xp*yp << endl;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  string a,b,c;
  cin>>a>>b>>c;
  if(b[0]==a[a.size()-1]&&b[b.size()-1]==c[0])cout<<"YES";
  else cout<<"NO";
}


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

int main() {
    std::string s;
    std::cin >> s;

    std::ostringstream oss;
    for (size_t i = 0; i < s.size(); ++i) {
        if (i % 2 == 0) {
            oss << s[i];
        }
    }

    std::cout << oss.str() << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int N,M;
vector<int> v[200005];
int  ok[200005];

void dfs(int p, int n){
    ok[p] = 1;
    if(n == 2){
        return ;
    }


    for(auto &&c : v[p]){
        if(ok[c] == 0){
            dfs(c, n+1);
        }
    }
}

int main(void)
{
    cin >> N >> M;
    REP(i, M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    dfs(0,0);
    if(ok[N-1]==1)pr("POSSIBLE");
    else pr("IMPOSSIBLE");
}

Measured memory_bytes: 12784
/*
Till the roof comes off, till the lights go out
Till my legs give out, can’t shut my mouth.
Till the smoke clears out. Am I high? Perhaps
I'ma rip this shit till my bones collapse.
*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string.h>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <complex>


#define f first
#define s second
#define ll long long
#define sz(v)      ((int)((v).size()))
#define X real()
#define Y imag()
#define angle(a)                (atan2((a).imag(), (a).real()))
#define vec(a,b)                ((b)-(a))
#define same(p1,p2)             (dp(vec(p1,p2),vec(p1,p2)) < EPS)
#define dp(a,b)                 ( (conj(a)*(b)).real() )	// a*b cos(T), if zero -> prep
#define cp(a,b)                 ( (conj(a)*(b)).imag() )	// a*b sin(T), if zero -> parllel
#define len(a)               (hypot((a).imag(), (a).real()))
#define normalize(a)            (a)/length(a)

using namespace std;

typedef pair<int,ll>ii;
typedef pair<ii,int>node;
typedef complex<double>point;


const int N=2005;
const int M=101;
const double EPS = 1e-9;
const int INF =1e9;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
double getDist(point a,point b){return sqrt((a.X-b.X)*(a.X-b.X)+(a.Y-b.Y)*(a.Y-b.Y));}
int dcmp(double x, double y) {return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1;}

ll mod=1000000007,fib[N],dp[N][N];
ll power(ll base,int p){
  if(!p)return 1;
  ll ret=power(base,p/2);
  ret*=ret;
  ret%=mod;
  if(p&1)ret*=base,ret%=mod;
  return ret;
}
ll modInverse(int a){
  return power(a,mod-2);
}
ll ncr(int n,int r){
   return (((fib[n]*modInverse(fib[r]))%mod)*modInverse(fib[n-r]))%mod;
}

map<ll,int>mp;
int main()
{
    //freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    int n;
    scanf("%d",&n);
    set<int>st;
    ll area=0;
    for(int i=0;i<n;i++){
        ll a;
        scanf("%lld",&a);
        mp[a]++;
        if(mp[a]==2)st.insert(a);
        if(mp[a]==4)area=max(area,a*a);
    }
    if(st.size()>1){
        ll a=*(--st.end());
        st.erase(--st.end());
        ll b=*(--st.end());
        area=max(area,a*b);
    }
    cout<<area;
  return 0;
}

/*
100% reason to Remember THE NAME
*/


Measured memory_bytes: 6528
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	boolean[] isPrime = new boolean[100001];
	int[] tmp = new int[100001];
	int[] mu = new int[100001];
	{
		Arrays.fill(isPrime, true);
		isPrime[0] = isPrime[1] = false;
		for (int i = 2; i < isPrime.length; ++i) {
			if (!isPrime[i])
				continue;
			for (int j = 2 * i; j < isPrime.length; j += i) {
				isPrime[j] = false;
			}
		}
		Arrays.fill(tmp, 1);
		Arrays.fill(mu, 1);
		mu[0] = mu[1] = 0;
		for (int i = 2; i < isPrime.length; ++i) {
			if (isPrime[i]) {
				for (int j = i; j < isPrime.length; j += i) {
					tmp[j] *= i;
					mu[j] *= -1;
				}
			}
		}
		for (int i = 2; i < mu.length; ++i) {
			if (tmp[i] != i) {
				mu[i] = 0;
			}
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		long[][] a = new long[H][W];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				a[i][j] = sc.nextLong();
			}
		}

		long[][][] dp = new long[2][200][200];
		dp[0][0][0] = a[0][0];
		for (int t = 0; t < H + W - 2; ++t) {
			int next = (t + 1) % 2;
			int pre = t % 2;
			for (int i = 0; i < 200; ++i) {
				for (int j = 0; j < 200; ++j) {
					if (!(0 <= i && i < H && 0 <= j && j < H && 0 <= t - i && t - i < W && 0 <= t - j && t - j < W))
						continue;
					for (int to1 = 0; to1 <= 1; ++to1) {
						for (int to2 = 0; to2 <= 1; ++to2) {

							if (!(0 <= i + to1 && i + to1 < H && 0 <= j + to2 && j + to2 < H && 0 <= t - i + (to1 ^ 1)
									&& t - i + (to1 ^ 1) < W && 0 <= t - j + (to2 ^ 1) && t - j + (to2 ^ 1) < W))
								continue;

							long get = a[i + to1][t - i + (to1 ^ 1)] + a[j + to2][t - j + (to2 ^ 1)];
							if (i + to1 == j + to2 && t - i + (to1 ^ 1) == t - j + (to2 ^ 1))
								get /= 2;
							dp[next][i + to1][j + to2] = Math.max(dp[next][i + to1][j + to2], dp[pre][i][j] + get);
						}
					}
				}
			}
		}
		System.out.println(dp[(H + W - 2) % 2][H - 1][H - 1]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 44680
/*
 * Author: Utkal Sinha
 * Created on: 2020-08-22, Sat, 18:9
 * Problem:
 * Platfrom: General
 * */
#if USE_BOOST2
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; //int512_t or //int128_t
typedef bst::cpp_bin_float_100 vdouble;
#endif

#include <bits/stdc++.h>
using namespace std;
#define GETTIME std::chrono::system_clock::now()
#define DURATION std::chrono::duration<double>
#ifdef MY_DEV_ENV2
#define LOCALDEV
#endif
typedef long long ll;
typedef std::chrono::system_clock::time_point TPT;
static TPT starttime, endtime, timelimit;
static double problem_tle = 1.5;
static inline void calc_problem_end_time() {timelimit = starttime + std::chrono::milliseconds(int (problem_tle * 1000));}
// template end



void love() {
    string s;
    cin >> s;
    ll ans = 0;
    for(auto c: s) ans += c - '0';
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(time(0));
#ifdef LOCALDEV
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
#ifdef LOCALDEV
    starttime = GETTIME;
    calc_problem_end_time();
#endif
    while(t--) love();
#ifdef LOCALDEV
    endtime = GETTIME;
    DURATION elapsed_seconds = endtime - starttime;
    DURATION time_limit_seconds = timelimit - starttime;
    clog << "Elapsed time: " << elapsed_seconds.count() << "s\n";
    clog << "Time limit: " << time_limit_seconds.count() << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)
#define inf 2147483647
#define int long long

signed main(void)
{
	int a;
	double b;
	cin >> a >> b;
	int c;
	c = (b * 100.0) + 0.5;
	c *= a;
	c /= 100;
	cout << c << endl;
}


Measured memory_bytes: 3700
# 解説AC
N,M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

color = [0] * N

def is_bipartite():
    """ 二部グラフか判定する """
    stack = [(0,1)]
    while stack:
        v, c = stack.pop()
        color[v] = c
        for w in edge[v]:
            if color[w] == c: return False
            if color[w] == 0:
                stack.append((w, (-1) * c))
    return True

if is_bipartite():
    B = color.count(1)
    W = N - B
    print(B * W - M)
else:
    print(N * (N - 1) // 2 - M)

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

using namespace std;

#define NAX 1e9

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> arr(n),dp(n,NAX);

    for(int i=0;i<n;i++)
        scanf("%d",&arr[i]);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        if(i+1<n)
            dp[i+1]=min(dp[i+1],abs(arr[i+1]-arr[i])+dp[i]);
        if(i+2<n)
            dp[i+2]=min(dp[i+2],abs(arr[i+2]-arr[i])+dp[i]);
    }
    printf("%d",dp[n-1]);
}


Measured memory_bytes: 1024
K = int(input())


def f(n):
    s = 0
    for n_i in str(n):
        s += int(n_i)
    x = int(n) / s
    return x


order = 1
x = 1
for i in range(K):
    print(x)
    if f(x + 10 ** (order - 1)) > f(x + 10 ** (order)):
        order += 1
    x += 10 ** (order - 1)

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    int x = b - a;
    int ans = x * (x + 1) / 2 - b;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
long dp[10005][101][2];
 
int main(void) {
    long d;
    string s;
    cin >> s >> d;
    constexpr long MOD = 1e9 + 7;
 
    dp[0][0][1] = 1;
 
    for(int i=0; i<s.size(); i++) {
        for(int j=0; j<d; j++) {
            for(int k=0; k<=9; k++) {
                dp[i+1][(j+k)%d][0] += dp[i][j][0];
                dp[i+1][(j+k)%d][0] %= MOD;
            }
            for(int k=0; k<s[i]-'0'; k++) {
                dp[i+1][(j+k)%d][0] += dp[i][j][1];
                dp[i+1][(j+k)%d][0] %= MOD;
            }
            {
                int k = s[i]-'0';
                dp[i+1][(j+k)%d][1] += dp[i][j][1];
                dp[i+1][(j+k)%d][1] %= MOD;
            }
        }
    }
 
    cout << (dp[s.size()][0][1] + dp[s.size()][0][0]-1+MOD)%MOD << endl;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m,b,c,d,w,f=0,g;
   vector<int>t,r;
   cin>>n;
   for(int a=0;a<n;a++){
    cin>>b;
    t.push_back(b);
   }
      for(int p=0;p<n;p++){
    f=t[p]+f;
    f=f;
   }
   cin>>m;
   for(int i=0;i<m;i++){
    cin>>c;
    cin>>d;
    w=t[c-1];
    g=f-w+d;
    r.push_back(g);
   }

for(int l=0;l<m;l++){
    cout<<r[l]<<endl;
}


   return 0;






}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		if(num >= K){
			ans += 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S = list(input())[::-1]
N = len(S)
B = [10**i % 13 for i in range(6)]

dp = [[0]*13 for i in range(N+2)]
dp[0][0] = 1
for i in range(1,N+1):
    if S[i-1] == '?':
        for j in range(10):
            for k in range(13):
                dp[i][(k+(B[(i-1)%6]*j))%13] += dp[i-1][k]
                dp[i][(k+(B[(i-1)%6]*j))%13] %= 10**9+7
    else:
        for k in range(13):
            dp[i][(k+B[(i-1)%6]*int(S[i-1]))%13] = dp[i-1][k]
print(dp[N][5])

    

Measured memory_bytes: 65384
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def solve():
    n, k = map(int, input().split())
    small = 0
    large = 0
    ans = 0
    mod = 10**9+7
    for i in range(0, n+1):
        small += i
        large += n-i
        if i+1 >= k:
            ans = (ans + (large - small + 1)) % mod
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int main() {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  ll mi = min(min(min(min(A, B), C), D), E);
  ll group = (N + mi - 1) / mi;
  cout << group - 1 + 5 << endl;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

int S(int n) {
    string num = to_string(n);
    int res = 0;
    REP(i, num.length()) {
        res += num[i] - '0';
    }
    return res;
}

void solve() {
    int N;
    cin >> N;

    if (N % S(N) == 0) {
        print("Yes");
    } else {
        print("No");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 256
loop do
    h, w = gets.split(" ").map(&:to_i)

    if h == 0 && w == 0 then
        break;
    end
    
    h.times do |i|
        s = "#."

        w.times do |j|
            print s[(i + j) % 2]
        end

        print "\n"
    end
    
    print "\n"
end



Measured memory_bytes: 6860
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

int dp[N];
int H[N];

int main() {

	boost;
	int n, k; cin>>n>>k;
	for(int i=1; i<=n; i++) {
		cin>>H[i];
	}
	dp[n] = 0;
	for(int i=n-1; i>=1; i--) {
		dp[i] = abs(H[i]-H[i+1]) + dp[i+1];
		for(int j=i+2; j<=i+k and j<=n; j++) {
			dp[i] = min(dp[i], abs(H[i]-H[j]) + dp[j]);
		}
	}
	cout<<dp[1]<<"\n";
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;
int main()
{

int n,m;
cin>>n>>m;
long long x[1024],y[1024],z[1024];
for(int i=0;i<n;i++)
    cin>>x[i]>>y[i]>>z[i];

long long ans=0;
long long sum[1024];
for(int i=0;i<=1;i++)
for(int j=0;j<=1;j++)
for(int k=0;k<=1;k++)
    {
     long long cnt=0;
     for(int l=0;l<n;l++)
         sum[l]=((i==0)?-x[l]:x[l])+((j==0)?-y[l]:y[l])+((k==0)?-z[l]:z[l]);
     sort(sum,sum+n);
     for(int l=n-1;l>n-m-1;l--)
         cnt+=sum[l];
     ans=max(ans,cnt);
    }
cout<<ans;

return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))

dp = [float("INF")]*(N+1)
dp[0] = 0
for i in range(1, N):
  dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
  if i > 1:
    dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])

Measured memory_bytes: 13980
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c;
    cin >> a >> b >> c;
    cout << (a + b) * c / 2;
}

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

int main(){
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy";
	else if (s == "Cloudy" ) cout << "Rainy";
	else cout << "Sunny";
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string n;
    cin >> n;
    int sum = 0;
    for(int i=0; i<n.length(); i++){
        sum = sum + (n[i]-'0');
    }
    if(stoi(n)%sum==0) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def chk(i,j,f,s):
    while (j > i and f == 0):
        if s[i] != s[j]:
            f = 1
            break

        j = j-1
        i = i+1

    return f


s = input()
l = len(s)
lh = (l)//2
j = l-1
i = 0
f = 0
r = chk(i,j,f,s)
if r == 1:
    print("No")
    exit()

s1 = s[0:lh]
#lh1 = len(s1)//2
j = len(s1)-1
i = 0
f = 0
r = chk(i,j,f,s1)
if r == 1:
    print("No")
    exit()

s2 = s[lh+1:]


#lh2 = len(s2)//2
j = len(s2)-1
i = 0
f = 0
r = chk(i,j,f,s2)
if r == 1:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <iterator>
#define r(i,n) for(int i=0;i<n;i++)
#define R(i,c,n) for(int i=c;i<n;i++)
#define DEBUG(x) cerr << #x << ": " << x << endl;
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

int main(){
  ios::sync_with_stdio(false);
	cin.tie(0);
  double x,t;
  cin >> x >> t;
  cout << x/t << endl;
  
  return 0;
}

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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

int fact(int n) {
    int res = 0;
    while (n > 0) {
        res += n / 2;
        n /= 2;
    }
    return res;
}

int binom(int n, int k) {
    return fact(n) == fact(k) + fact(n - k);
}

int parity(vector<int> a) {
    int n = (int) a.size();
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2) {
            res ^= binom(n - 1, i);
        }
    }
    return res;
}

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    int is_one = 0;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        a[i] = c - '1';
        if (a[i] == 1)
            is_one = 1;
    }

    if (parity(a)) {
        cout << "1\n";
        return 0;
    }

    if (is_one) {
        cout << "0\n";
        return 0;
    }

    for (int i = 0; i < n; i++) {
        a[i] /= 2;
    }

    cout << 2 * parity(a) << "\n";

    return 0;
}


Measured memory_bytes: 8124
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>

using namespace std;

bool is_bad(int pos, int elem)
{
    return pos + 1 == elem;
}

int main()
{
    int n;

    cin >> n;

    vector<int> v(n);

    for(int i = 0; i < n; i++)
        cin >> v[i];

    int out = 0;

    for(int i = 0; i < n - 1; i++) {
        if(is_bad(i, v[i])) {
            swap(v[i], v[i + 1]);
            out++;
        }
    }

    if(is_bad(n - 1, v[n - 1]))
        out++;

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)break;
		for(i = 0;i < H;i++){
		 for(j = 0;j < W;j++){
		 	if(((i+1) + (j+1)) % 2 == 0){
		 		printf("#");
		 	}else{
			 	printf(".");
			 }
		 }
		 printf("\n");
	 }
	 printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
package main

import "fmt"

func main() {
	var N, tmp int
	fmt.Scan(&N)
	D := []int{}
	for n := 0; n < N; n++ {
		fmt.Scanf("%d", &tmp)
		D = append(D, tmp)
	}
	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			ans += D[i] * D[j]
		}
	}
	fmt.Println(ans)
}


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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll n, m;
    cin >> n >> m;
    cout << (m - 1) * (n - 1) << endl;
    return 0;
}


Measured memory_bytes: 256