akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            if (Sarray()[0] == 1)
                WriteLine("Hello World");
            else
                WriteLine(Sarray()[0] + Sarray()[0]);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 27960
n = int(input())
a = list(sorted(map(int, input().split())))

alice = []
bob = []

while len(a) > 0:
    if len(a) > 0:
        alice.append(a.pop())
    if len(a) > 0:
        bob.append(a.pop())

print(sum(alice) - sum(bob))

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

long long int parent[100001];
long long int n;
int m;
vector <pair<int,int>> edge;
long long int cnt;

void init()
{
	memset(parent,-1,sizeof(parent));
}

int find(int x)
{
	if(parent[x] < 0)
	{
		return x;
	}
	return parent[x] = find(parent[x]);
}

void merge(int x,int y)
{
	x = find(x);
	y = find(y);

	if(x==y)
	{
		return;
	}

	long long int a = abs(parent[x]);
	long long int b = abs(parent[y]);
	//cout << "before: " << x << ' ' << y << ' ' << parent[x] << ' ' << parent[y] << '\n';
	parent[x] += parent[y];
	parent[y] = x;
	//cout << "after: " << x << ' ' << y << ' ' << parent[x] << ' ' << parent[y] << '\n';
	cnt += ((a)*(a-1)/2);
	cnt += ((b)*(b-1)/2);
	a = abs(parent[x]);
	cnt -= ((a)*(a-1)/2);
	return;
}
int main(void)
{	
	cin.tie(0);
	ios::sync_with_stdio(false);

	vector <long long int> res;
	int a,b;

	cin >> n >> m;

	for(int i=0;i<m;i++)
	{
		cin >> a >> b;
		edge.push_back(make_pair(a,b));
	}	

	init();
	reverse(edge.begin(),edge.end());
	cnt = (n*(n-1))/2;

	for(int i=0;i<m;i++)
	{
		res.push_back(cnt);
		a = edge[i].first;
		b = edge[i].second;
		merge(a,b);
	}

	for(int i=res.size()-1;i>=0;i--)
	{
		cout << res[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>

using namespace std;
int main(){
    // cin.tie(0);
   	// ios::sync_with_stdio(false);
    string s;
    int n, k;
    cin >> n >> k;
    char* c = (char *)calloc(n, sizeof(char));
    for(int i=0;i<n;++i){
        cin >> c[i];
    }
    for(int i=0;i<n;++i){
        if(i==k-1){
            printf("%c", c[i] + 0x20);
        } else {
            printf("%c", c[i]);
        }
    }
    printf("\n");
    
    return 0;
}

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

using namespace std;

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

    vector<int> vt(N);
    for (int i = 0; i < N; ++i) {
        cin >> vt[i];
    }

    int mx = K - (vt[N - 1] - vt[0]);
    for (int i = 0; i < N; ++i) {
        mx = max(mx, vt[i + 1] - vt[i]);
    }

    int ans = K - mx;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ma = sc.nextInt();
        int mb = sc.nextInt();

        int a[] = new int[n];
        int b[] = new int[n];
        int c[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        int inf = 100000000;
        int dp[][][] = new int[n+1][n*10+1][n*10+1];
        for (int i = 0; i < n+1; i++){
            for (int j = 0; j<n*10+1;j++){
                for (int k=0;k<n*10+1;k++){
                    dp[i][j][k] = inf;
                }
            }
        }
        dp[0][0][0]=0;
        //DP
        for (int i=1;i<n+1;i++){
            for (int j=0;j<n*10+1;j++){
                for (int k=0;k<n*10+1;k++){
                    int x = j-a[i-1];
                    int y = k-b[i-1];
                    if (x>=0 && y>=0) {
                        dp[i][j][k] = Math.min(dp[i-1][j][k],dp[i-1][x][y]+c[i-1]);
                    } else {
                        dp[i][j][k] = dp[i-1][j][k];
                    }
                }
            }
        }
        int candA = ma;
        int candB = mb;
        int answer = inf;
        while (candA <=n*10 && candB <=n*10) {
            answer = Math.min(answer,dp[n][candA][candB]);
            candA += ma;
            candB += mb;
        }
        if (answer == inf){
            System.out.println(-1);
        } else {
            System.out.println(answer);
        }
    }
}

Measured memory_bytes: 53556
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
ll a[maxn];
int main()
{
   int n;
   while(cin>>n)
   {
       for(ll i = 1; i <= n; ++i)
       {
           scanf("%lld",a+i);
           a[i] -= i;
       }
       sort(a+1,a+n+1);
       ll now = a[(n+1)/2];
       ll dd = 0;
       for(int i = 1; i <= n; ++i)
       {
           dd += abs(a[i] - now);
       }
       printf("%lld\n",dd);
   }

}















Measured memory_bytes: 1792
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as np
def run():
    N,K = map(int, sysread().split())
    A = [0] + list(map(int, sysread().split()))
    perm = [1]
    seen = [[-1, False] for _ in range(N+1)]
    seen[1] = [1,True]
    l = 1
    while True:
        v = perm[-1]
        idx, boo = seen[A[v]]
        if boo: break
        l += 1
        perm.append(A[v])
        seen[A[v]] = [l,True]

    if K <= idx -1:
        print(perm[K])
        return None
    K -= idx - 1
    perm = perm[idx-1:]
    print(perm[K % len(perm)])

if __name__ == "__main__":
    run()

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

int main(){
    int n, a[100];
    int cnt[100] = {0};
    cin >> n;
    int mn = n, mx = 0;
    for(int i=0;i<n;++i){
        cin >> a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
        ++cnt[a[i]];
    }
    if(mx % 2){
        if(cnt[mn] != 2) goto l_ng;
        for(int i=mn+1;i<=mx;++i){
            if(cnt[i] == 0) goto l_ng;
        }
        goto l_ok;
    }else{
        if(cnt[mn] != 1) goto l_ng;
        for(int i=mn+1;i<=mx;++i){
            if(cnt[i] == 0) goto l_ng;
        }
        goto l_ok;
    }
l_ng:
    cout << "Impossible" << endl;
    return 0;
l_ok:
    cout << "Possible" << endl;
    return 0; 
}

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

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

using namespace std;

int main(){
	int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
	int vx=x2-x1,vy=y2-y1;
	int x3=x2-vy,y3=y2+vx;
	int x4=x3-vx,y4=y3-vy;
	cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;

	return 0;
}


Measured memory_bytes: 256
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

bool vst[1<<20];


int main(){	
	int m,k;cin>>m>>k;
	vector<int>t;
	int lim=1<<m;
	if(k>=lim){
		cout<<"-1"<<endl;
		return 0;
	}
	if(m==1&&k==1){
		cout<<"-1"<<endl;
		return 0;
	}
	if(m==0&&k==0){
		cout<<"0 0"<<endl;
		return 0;
	}
	if(k==0){
		For(i,0,lim)cout<<i<<" "<<i<<" ";
		cout<<endl;
		return 0;
	}

	For(i,0,lim)if(!vst[i]){
		t.pb(i);
		t.pb(i^k);
		vst[i]=true;
		vst[i^k]=true;
	}
	For(i,0,sz(t))cout<<t[i]<<" ";
	for(int i=0;i<lim;i+=2)
		swap(t[i],t[i+1]);
	For(i,0,sz(t))cout<<t[i]<<" ";
	cout<<endl;
	
	return 0;
}


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

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

  if (a <= b && b <= a+W) {
    cout << 0 << endl;
  } else if (a <= b+W && b+W <= a+W) {
    cout << 0 << endl;
  } else {
    if (b+W < a) {
      cout << a - (b+W) << endl;
    } else if (a+W < b) {
      cout << b - (a+W) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[102];
char T[102];
int main(){
  rd(S);
  rd(T);
  wt_L(T);
  wt_L(S);
  wt_L("\n");
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// char S[102], T[102];
// {
//   rd(S,T);
//   wtN(T,S,"\n");
// }


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

int main(){
    long long a;
    double b;
    cin >> a >> b;
    a *= (int)(b * 100 + .1);

    cout << a / 100 << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N;
    vector<tuple<string,int,int> > rest(0);
    reps(i,1,N+1){
        cin>>S>>M;
        M = 100 - M;
        rest.push_back(tuple<string,int,int>{S,M,i});
    }
    std::sort(rest.begin(),rest.end());
    rep(i,N) cout << get<2>(rest.at(i)) << endl;
}

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

namespace Algorithm
{
    class Program
    {
        const int NumberOfAntennas = 5;

        static void Main(string[] args)
        {
            var array = new int[NumberOfAntennas];

            for (var i = 0; i < NumberOfAntennas; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }

            var k = int.Parse(Console.ReadLine());

            for (var i = 0; i < NumberOfAntennas; i++)
            {
                for (var j = i+1; j < NumberOfAntennas; j++)
                {
                    if (array[j] - array[i] > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }

            Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 13140
n, m, l = map(int, input().split())
A, B = [list(map(int, input().split())) for r in range(n)], [list(map(int, input().split())) for r in range(m)]
for i in range(n):
    for j in range(l):
        Cij = 0
        for k in range(m):
            Cij += A[i][k]*B[k][j]
        if j < l-1:
            print('%d' %(Cij), end=' ')
        else:
            print('%d' % (Cij))

Measured memory_bytes: 8604
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define FOR(i,n) for(int i=0;i<n;i++)
 
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k ;
  int ans = 0;
  
  for(int i = 0;i < k;i++){
    if(a > 0){
      a--;
      ans++;
      continue;
    }else if(b > 0){
      b--;
      continue;
    }else{
      ans--;
    }
    
  }
  cout << ans << endl;

}


Measured memory_bytes: 3636
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [a, b] = input[0];

  return a === b ? "H" : "D";
};

console.log(main(read()));


Measured memory_bytes: 29600
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;

  i64 k=1;
  rep(i,N+1){
    if(i*(i+1)>=2*N){
      k=i;
      break;
    }
  }

  i64 a = -1, b = -1;
  a = (k*(k+1)/2)-N;
  if(a>k){
    a = (a-1)/2;
    b = (k*(k+1)/2)-N-a;
  }



  

  rep(i,1,k+1){
    if(i==a or i==b) continue;
    cout << i << "\n";
  }



}

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
ll dp[310][310][310];
vector<P> a[310];

bool check(int r, int g, int b, int t) {
    int m = max(r, max(g, b));
    int p, q;
    switch(t) {
    case 0: p = min(g, b); q = max(g, b); break;
    case 1: p = min(r, b); q = max(r, b); break;
    case 2: p = min(g, r); q = max(g, r); break;
    }
    for (int i = 0; i < a[m+1].size(); i++) {
        int idx = a[m+1][i].first;
        switch(a[m+1][i].second) {
        case 1: if (q >= idx) return false; break;
        case 2: if (!(q >= idx && p < idx)) return false; break;
        case 3: if (p < idx) return false; break;
        }
    }
    return true;
}

ll solve() {
    dp[0][0][0] = 1;
    for (int r = 0; r <= n; r++) {
        for (int g = 0; g <= n; g++) {
            for (int b = 0; b <= n; b++) {
                int m = max(r, max(g, b)) + 1;
                if (check(r, g, b, 0)) dp[m][g][b] = (dp[m][g][b] + dp[r][g][b]) % mod;
                else dp[m][g][b] = 0;
                if (check(r, g, b, 1)) dp[r][m][b] = (dp[r][m][b] + dp[r][g][b]) % mod;
                else dp[r][m][b] = 0;
                if (check(r, g, b, 2)) dp[r][g][m] = (dp[r][g][m] + dp[r][g][b]) % mod;
                else dp[r][g][m] = 0;
            }
        }
    }

    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            res += dp[n][i][j] + dp[i][n][j] + dp[i][j][n];
            res %= mod;
        }
    }
    return res;
}

void input() {
    cin >> n >> m;
    int l, r, x;
    for (int i = 0; i < m; i++) {
        cin >> l >> r >> x;
        a[r].push_back(make_pair(l, x));
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 227584
integer(16) N
integer(16),allocatable,dimension(:)::A
integer(16),allocatable,dimension(:,:)::DP
read*,N
allocate(A(N))
read*,A
allocate(DP(N,N))
DP=huge(N)

print"(i0)",DFS(1,1)

contains
recursive function DFS(turn,l)result(res)
  integer,intent(in)::turn,l
  integer(16) res
  integer r
  if(DP(turn,l)/=huge(N))then
    res=DP(turn,l)
    return
  endif
  r=N-turn+l
  select case(mod(turn,2))
    case(1)!Taro's turn
      if(turn==N)then
        res=A(l)
        return
      endif
      res=max(DFS(turn+1,l+1)+A(l),DFS(turn+1,l)+A(r))
    case(0)!Jiro's turn
      if(turn==N)then
        res=-A(l)
        return
      endif
      res=min(DFS(turn+1,l+1)-A(l),DFS(turn+1,l)-A(r))
  end select
  DP(turn,l)=res
  return  
end function
end

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

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

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n, m;
V<int> v;

const int c[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7 ,6 };

V<int> dp;
V<int> memo;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> n; cin >> m;
    REP(i, m) {
        int x; cin >> x;
        v.push_back(x);
    }

    dp.resize((n+1), -1000000);
    memo.resize((n+1), -1000000);

    dp[0] = 0;
    memo[0] = 0;
    REP(i,n+1) {
        if(dp[i] < 0) continue;
        REP(j,m) {
            if(i+c[v[j]] > n) continue;
            if(dp[i+c[v[j]]] < dp[i]+1) {
                dp[i+c[v[j]]] = dp[i]+1;
                memo[i+c[v[j]]] = c[j];
                memo[i+c[v[j]]] = v[j];
            } else
            if(dp[i+c[v[j]]] == dp[i]+1) {
                memo[i+c[v[j]]] = max(memo[i+c[v[j]]], v[j]);
            }
        }
    }

    int match = n;
    while(match > 0) {
        int val = memo[match];
        REP(i,m) if(c[v[i]] == c[memo[match]]) val = max(val, v[i]);
        cout << val;
        match -= c[val];
    }
    cout << "\n";
}

Measured memory_bytes: 384
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	cin >> K >> L >> R;
	M = K + L + R;
	M--;
	vector<vector<long long int>>dp(2, vector<long long int>(1 << M));
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < 1 << M; j++) {
			dp[i % 2][j] = 0;
		}
		for (int j = 0; j < 1 << M; j++) {
			for (int k = 1; k <= 10; k++) {
				int box = j;
				box <<= k;
				box |= 1 << (k - 1);
				box &= (1 << (M + 1)) - 1;
				if ((box >> (R - 1)) & 1 && (box >> (L + R - 1)) & 1 && (box >> M) & 1) {
					continue;
				}
				box &= (1 << M) - 1;
				dp[i % 2][box] += dp[(i - 1) % 2][j];
				dp[i % 2][box] %= MOD;
			}
		}
	}
	long long int ans = 1;
	for (int i = 0; i < N; i++) {
		ans *= 10;
		ans %= MOD;
	}
	for (auto i : dp[N % 2]) {
		ans += MOD;
		ans -= i;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

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

    return ans;
}
int main()
{
          ios_base::sync_with_stdio(0);
          cin.tie(0);

          int t=1;
          //cin>>t;
          while(t--)
          {
                         int a,b,c;
                         cin>>a>>b>>c;
                         int k;
                         cin>>k;
                         if(c>b && b>a)
                              cout<<"Yes";
                         else
                         {

                              while(b<=a && k>0)
                              {
                                   b*=2;
                                   k--;
                              }
                              while(c<=b && k>0)
                              {
                                   c*=2;
                                   k--;
                              }
                              if(c>b && b>a)
                                   cout<<"Yes";
                              else
                                   cout<<"No";

                         }
          }

          return 0;
}


Measured memory_bytes: 3692
sx, sy, tx, ty = map(int, input().split())
diff_x = tx - sx
diff_y = ty - sy
ans = 'U' * diff_y + 'R' * diff_x + 'D' * diff_y + 'L' * diff_x
ans += 'LU' + 'U' * diff_y + 'R' * diff_x + 'RDRD' + 'D' * diff_y + 'L' * diff_x + 'LU'
print(ans)

Measured memory_bytes: 3060
// D - Preparing Boxes
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	vector<int> ans(n);

	for (int i = n - 1; i >= 0; i--) {
		int c = 0;
		for (int j = i + (i + 1); j < n; j += (i + 1)) c += ans[j];
		if (c % 2 != a[i]) ans[i] = 1;
	}

	int k = 0;
	for (int i = 0; i < ans.size(); i++) k += ans[i];
	cout << k << endl;
	for (int i = 0; i < ans.size(); i++)
		if (ans[i]) cout << i + 1 << ' ';
	cout << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>

#include <algorithm>

using std::max;
using std::min;
using std::sort;

int n, a[1005][1005], cur[1005], mark[1005], idx = 0, ttt[1005], cnt = 0, ttt2[1005];

int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n - 1; ++j)
      scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; ++i)
    cur[i] = 1, ttt[++cnt] = i;
  for (; ; ) {
    ++idx;
    bool label = false;
    int tmpCnt = 0;
    for (int j = 1; j <= cnt; ++j) {
      int i = ttt[j];
      if (cur[i] >= n || mark[i] == idx)
        continue;
      int tmp = a[i][cur[i]];
      if (mark[tmp] == idx)
        continue;
      if (a[tmp][cur[tmp]] == i) {
        mark[i] = mark[tmp] = idx;
        ++cur[i], ++cur[tmp];
        label = true;
        if (cur[i] < n)
          ttt2[++tmpCnt] = i;
        if (cur[tmp] < n)
          ttt2[++tmpCnt] = tmp;
      }
    }
    cnt = tmpCnt;
    for (int i = 1; i <= cnt; ++i)
      ttt[i] = ttt2[i];
    if (!label) {
      printf("-1\n");
      break;
    }
    if (cnt == 0) {
      printf("%d\n", idx);
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mx = 2e5;
vector<ll> lazy(3*mx+5);
vector<ll> segtree(3*mx+5);

void push(int k, int l, int r)
{
	if (l != r)
	{
		lazy[2*k] += lazy[k];
		lazy[2*k+1] += lazy[k];
	}
	segtree[k] += lazy[k];
	lazy[k] = 0;
}

void pull(int k)
{
	segtree[k] = max(segtree[2*k], segtree[2*k+1]);
}

void update(int a, int b, int k, int x, int y, ll inc)
{
	push(k,x,y);
	if (x > b || y < a)
	{
		return;
	}
	if (a <= x && y <= b)
	{
		lazy[k]=inc;
		push(k,x,y);
		return;
	}
	int m = (x+y)/2;
	update(a,b,2*k,x,m,inc);
	update(a,b,2*k+1,m+1,y,inc);
	pull(k);
}

ll get(int a, int b, int k, int x, int y)
{
	push(k,x,y);
	if (x > b || y < a)
	{
		return LLONG_MIN;
	}
	if (a <= x && y <= b)
	{
		return segtree[k];
	}
	int m = (x+y)/2;
	return max(get(a,b,2*k, x, m), get(a,b,2*k+1,m+1,y));
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<ll> inc[n+1];
	vector<pair<ll, ll>> rem[n+1];
	for (int q = 0; q < m; q++)
	{
		ll l,r,a;
		cin >> l >> r >> a;
		inc[l].push_back(a);
		rem[r].push_back({l,a});
	}
	ll ans = 0;
	for (int q = 1; q <= n; q++)
	{
		for (ll w : inc[q])
		{
			update(0,q-1,1,0,n,w);
		}
		ll best = get(0,q-1,1,0,n);
		update(q,q,1,0,n,best);
		for (pair<ll,ll> w : rem[q])
		{ 
			update(0,w.first-1,1,0,n,-1 * w.second);
		}
		ans = max(ans, best);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 1000000000
#define inf 1000000000000000000
#define M 998244353
using namespace std;
typedef long long ll;
const int N = 1e6+300;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);
const double TAU = 2*PI;

int ans[100000];
int n;
inline void solve(){
  cin >> n;
  for(int i = 1 ; i <= 100 ; i++){
    for(int j = 1 ; j <= 100 ; j++){
      for(int k = 1 ; k <= 100 ; k++){
        ll res = i*i+j*j+k*k+i*j+i*k+j*k;
        if(res<100000)ans[res]++;
      }
    }
  }
  for(int i = 0 ; i < n ; i++){
    cout << ans[i+1] << endl;
  }
}

signed main() {
    int t=1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

/*
  C = A-B とする
  先頭から C*iの石と、末尾から  C*iの石 を踏むことになる

*/
ll N;

int main(){
	cin >> N;
	
	
	vector<ll> S(N);
	for ( int i = 0; i < N; i++ )
		cin >> S[i];
	
	ll M = N-1;
	
	ll max_score = 0; // 1歩でゴールの場合
	for ( int C = 1; C < M-C; C++ ){
		ll score = 0;
		bool can_drown = M % C == 0;
		for ( int j = C; j < M-C; j += C ){
			if ( can_drown && j >= M-j )
				break;
			score += S[j] + S[M-j];
			//cout << C << "  " << score << endl;
			max_score = max( max_score, score );
		}
	}
	
	
	cout << max_score << endl;
	
	return 0;
}



Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int n = in.nextInt();

        out.println(n * n * n);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

}


Measured memory_bytes: 20692
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
#define MOD 1000000007
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n),small(n,0),v(n);
    for(ll i=0;i<n;i++){
    	cin>>a[i];
    }
    ll count=0;
    for(ll i=0;i<n;i++){
    	for(ll j=i+1;j<n;j++){
    		if(a[i]>a[j]){
    			count++;
    		}
    	}
    }
    //cout<<"c="<<count<<endl;
    v=a;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		if(a[i]>v[j]){
    			small[i]++;
    		}
    	}
    }
    ll sum=0;
    for(ll i=0;i<n;i++){
    	sum+=small[i];
    }
    //cout<<"sum="<<sum<<endl;
    ll ans=(k)*(k-1)/2;
    ans=ans%MOD;
    ans=(sum%MOD*ans%MOD)%MOD;
    ans=((ans%MOD)+((count%MOD*k%MOD)%MOD))%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
 
int na,nb;
int a[5000],b[5000];
int dp[2][5001];
 
int main(){
  scanf("%d%d",&na,&nb);
  for(int i=0;i<na;i++)scanf("%d",&a[i]);
  for(int i=0;i<nb;i++)scanf("%d",&b[i]);
  
  for(int i=0;i<2;i++)
    for(int j=0;j<=nb;j++)dp[i][j] = 0;
   
  int ans = 0;
  for(int i=0;i<na;i++)
    for(int j=0;j<nb;j++){
      int t = (i&1)?1:0;
      dp[1-t][j+1] = max(dp[1-t][j+1],dp[t][j+1]);
      if(a[i] == b[j]){
    dp[1-t][j+1] = max(dp[1-t][j+1],dp[t][j]+1);
    ans = max(ans,dp[1-t][j+1]);
      }
    }
  printf("%d\n",ans);
}

Measured memory_bytes: 792
//
// Created by YGH on 2020-01-28.
//

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll dp[105][100005];
ll W;
int n;
ll w[105], v[105];

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

    cin>>n>>W;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=100000;j++){
            dp[i][j] = W+1;
        }
    }
    dp[0][v[0]] = w[0];
    dp[0][0] = 0;
    for(int i=1;i<n;i++){
        for(int j=0;j<=100000;j++){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j-v[i]>=0 && dp[i-1][j-v[i]] + w[i] <= W){
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
            }
        }
    }

    int ans = -1;
    for(int i=100000;i>=0;i--){
        if(dp[n-1][i] != W+1) {
            ans = i;
            break;
        }
    }
    cout<<ans;


    return 0;
}

Measured memory_bytes: 80128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long


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

    int h,w; cin >> h >> w;
    vector<vector<int> > a(h,vector<int>(w));
    for(int i = 0;i < h;i ++){
        for(int j = 0;j < w;j ++){
            cin >> a.at(i).at(j);
        }
    }

    int odd = 0;

    for(int i = 0;i < h;i ++){
        for(int j = 0;j <  w;j ++){
            if(a.at(i).at(j) % 2 == 1) odd ++;
        }
    }


    vector<int> x(0),y(0),xd(0),yd(0);
    int n = 0;
    int i = 0,j = 0;
    while(odd > 1){
        if(i % 2 == 0 && a.at(i).at(j) % 2 == 1){

            y.push_back(i);
            x.push_back(j);
            if(j == w - 1){
                a.at(i).at(j) --;
                i ++;
                a.at(i).at(j) ++;
            }else{
                a.at(i).at(j) --;
                j ++;
                a.at(i).at(j) ++;
            }

            yd.push_back(i);
            xd.push_back(j);
            n ++;
            if(a.at(i).at(j) % 2 == 0) odd -= 2;
            continue;
        }

        if(i % 2 == 1 && a.at(i).at(j) % 2 == 1){

            y.push_back(i);
            x.push_back(j);

            if(j == 0){
                a.at(i).at(j) --;
                i ++;
                a.at(i).at(j) ++;
            }else{
                a.at(i).at(j) --;
                j --;
                a.at(i).at(j) ++;
            }

            yd.push_back(i);
            xd.push_back(j);
            n ++;
            if(a.at(i).at(j) % 2 == 0) odd -= 2;
            continue;
        }

        if(i % 2 == 0){
            if(j == w-1){
                i ++;
            }else{
                j ++;
            }
        }else{
            if(j == 0){
                i ++;
            }else{
                j --;
            }
        }
    }

    cout << n << endl;

    for(int k = 0;k < n;k ++){
        cout << y.at(k)+1 << " " << x.at(k)+1 << " " << yd.at(k)+1 << " " << xd.at(k)+1 << endl;
    }

}

Measured memory_bytes: 8148
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  map<long long, int> cnt;
  for(int i = 0; i < n; i++){
    long long a;
    cin >> a;
    if(cnt[a] == 0) cnt[a]++;
    else cnt[a] = 0;
  }
  long long res = 0;
  for(auto p: cnt)
    if(p.second == 1) res++;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<char> C(3);
  for(int i=0;i<3;i++){
    cin >> C.at(i);
  } 
  int top = 0;
  for(int i=0;i<3;i++){
    if(C.at(i) == 'o'){
    top++;
  }
  }
  cout << 700+top*100 <<endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll INFLL = 9e18;
const int N = 1e6;
int _w;

ll n;
int a, b, c, d;
map<ll,ll> f;
ll table[N];

void calc_table() {
	table[0] = 0;
	for( int i = 1; i < N; ++i ) {
		table[i] = table[i-1] + d;
		if( i % 2 == 0 )
			table[i] = min(table[i], table[i/2] + a);
		if( i % 3 == 0 )
			table[i] = min(table[i], table[i/3] + b);
		if( i % 5 == 0 )
			table[i] = min(table[i], table[i/5] + c);
	}
}

ll dp( ll n ) {
	// if( n < N ) return table[n];
	if( f.count(n) ) return f[n];
	ll &now = f[n];
	if( n == 0 ) return now = 0;
	now = INFLL;
	
	if( n % 2 ) {
		now = min(now, dp(n-n%2) + n%2*d);
		if( n/2+1 != n )
			now = min(now, dp(n/2+1) + (2-n%2)*d + a);
	} else {
		now = min(now, dp(n/2) + a);
		if( n/2 <= INF )
			now = min(now, dp(n/2) + n/2*d);
	}
	if( n % 3 ) {
		now = min(now, dp(n-n%3) + n%3*d);
		if( n/3+1 != n )
			now = min(now, dp(n/3+1) + (3-n%3)*d + b);
	} else {
		now = min(now, dp(n/3) + b);
		if( n/3*2 <= INF )
			now = min(now, dp(n/3) + n/3*2*d);
	}
	if( n % 5 ) {
		now = min(now, dp(n-n%5) + n%5*d);
		if( n/5+1 != n )
			now = min(now, dp(n/5+1) + (5-n%5)*d + c);
	} else {
		now = min(now, dp(n/5) + c);
		if( n/5*4 <= INF )
			now = min(now, dp(n/5) + n/5*4*d);
	}
	if( n <= INF )
		now = min(now, n*d);
	return now;
}

int main() {
	int T;
	cin >> T;
	while( T-- ) {
		cin >> n >> a >> b >> c >> d;
		calc_table();
		f.clear();
		cout << dp(n) << endl;
	}
	return 0;
}


Measured memory_bytes: 16748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) 
{
  return (a + b - 1) / b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int a, b;
  cin >> a >> b;
  cout << CEIL(a, b) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;








int main(){
    ll n,m,a,b;
    cin>>n>>m>>a>>b;
    vector<vector<char>> A(n,vector<char>(m,'.'));
    
    if(n&1){
        for(int i=0;i+1<m && a>0;i+=2){
            A[n-1][i]='<';
            A[n-1][i+1]='>';
            a--;
        }
    }
    if(m&1){
        for(int i=0;i+1<n && b>0;i+=2){
            A[i][m-1]='^';
            A[i+1][m-1]='v';
            b--;
        }
    }
    for(int i=0;i+1<n;i+=2){
        for(int t=0;t+1<m;t+=2){
            if(a>=2){
                A[i][t]='<';
                A[i][t+1]='>';
                A[i+1][t]='<';
                A[i+1][t+1]='>';
                a-=2;
            }
            else if(b>=2){
                A[i][t]='^';
                A[i][t+1]='^';
                A[i+1][t]='v';
                A[i+1][t+1]='v';
                b-=2;
            }
            else if(a==1){
                A[i][t]='<';
                A[i][t+1]='>';
                a--;
            }
            else if(b==1){
                A[i][t]='^';
                A[i+1][t]='v';
                b--;
            }
        }
    }
    vector<vector<char>> Sp={{'^','<','>'},{'v','.','^'},{'<','>','v'}};
    if(n%2 && m%2 && a+b==1 && n>=3 && m>=3 && A[n-2][m-2]=='.'){
        for(int i=0;i<3;i++){
            for(int t=0;t<3;t++){
                A[n-3+i][m-3+t]=Sp[i][t];
            }
        }
        a=0;
        b=0;
    }
    if(a>0 || b>0){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
        for(int i=0;i<n;i++){
            for(int t=0;t<m;t++){
                cout<<(char)A[i][t];
            }
            cout<<endl;
        }
    }
    
    
    
    
    return 0;
}


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

int main() {
    int N = 0 , W = 0 , S = 0 , E = 0;
    string F;
    cin >> F;
    int T = F.size();
    for(int i = 0; i < T; i++){
        if(F.at(i) == 'N'){
            N++;
        }
        if(F.at(i) == 'W'){
            W++;
        }
        if(F.at(i) == 'S'){
            S++;
        }
        if(F.at(i) == 'E'){
            E++;
        }
    }
    if(N > 0 && S > 0 && W > 0 && E > 0){
        cout << "Yes" << endl;
        return 0;
    }
    else if(N == 0 && S == 0 && W > 0 && E > 0){
        cout << "Yes" << endl;
        return 0;
    }
    else if(N > 0 && S > 0 && W == 0 && E == 0){
        cout << "Yes" << endl;
        return 0;
    }
    else if(N == 0 && S == 0 && W == 0 && E == 0){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
  int a=0, b=0;

  cin >> a >> b;

  if( a <= 5){
    b = 0;
  }
  if( a <= 12 && a>= 6){
    b=b/2;
  }

  cout << b << endl;

  return 0;
}


Measured memory_bytes: 256
# 入力
A,B,K=map(int,input().split())

if B-A+1<2*K:
  # 範囲内の全数字を出力
  for i in range(A,B+1):
    print(i)
else:
  # 小さい方からK個出力
  for i in range(A,A+K):
    print(i)
  # 大きい方からK個出力
  for i in range(B-K+1,B+1):
    print(i)

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

using namespace std;
using ll = long long int;

ll powmod(ll base, ll exp, ll mod) {
    if (exp == 0) {
        return 1;
    }
    if (exp % 2 == 0) {
        ll t = powmod(base, exp / 2, mod);
        return (t * t) % mod;
    }
    return (base * powmod(base, exp - 1, mod)) % mod;
}

unordered_map<ll, ll> primefactordecomp(ll n) {
    unordered_map<ll, ll> ans = unordered_map<ll, ll>();
    ll m = pow(n, 0.5) + 1;
    for (ll i = 2; i < m; i++) {
        while (n > 1) {
            if (n % i != 0) {
                break;
            } else {
                ans[i] = ans[i] + 1;
                n = ll(n / i);
                continue;
            }
        }
    }
    if (n > 1) {
        ans[n] = 1;
    }
    return ans;
}

int main() {
    int N;
    unordered_map<ll, ll> total_primes = unordered_map<ll, ll>();
    vector<unordered_map<ll, ll>> each_primes = vector<unordered_map<ll, ll>>();

    ll M = pow(10, 9) + 7;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++) {
        ll c;
        cin >> c;
        A[i] = c;

        unordered_map<ll, ll> primes = primefactordecomp(c);
        for (pair<ll, ll> p: primes) {
            total_primes[p.first] = max(p.second, total_primes[p.first]);
        }
    }

    ll lcm = 1;
    for (pair<ll, ll> p: total_primes) {
        lcm *= powmod(p.first, p.second, M);
        lcm %= M;
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += (lcm * powmod(A[i], M - 2, M)) % M;
        ans %= M;
    }
    cout << ans << endl;
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  string s;
  int ans;
  
  cin >> s;
  
  if(s == "SUN") ans = 7;
  else if(s == "MON") ans = 6;
  else if(s == "TUE") ans = 5;
  else if(s == "WED") ans = 4;
  else if(s == "THU") ans = 3;
  else if(s == "FRI") ans = 2;
  else if(s == "SAT") ans = 1;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define LL long long int

LL solve(LL h) {
    if (h == 0)
        return 0;

    return 1 + 2 * solve(h/2);
}

int main() {
    LL H;
    cin >> H;

    cout << solve(H) << endl;
}


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

int main() {
    string S;
    cin >> S;
    int N;
    N = S.size();
    string A=S;
    string B=S;
    for (int i=0;i<N;i++){
        if (i%2==0) {
            A.at(i)='0';
            B.at(i)='1';
        }else{
            A.at(i)='1';
            B.at(i)='0';
        }
    }
    
    int cnt1=0;
    int cnt2=0;
    for (int i=0;i<N;i++){
        if (S.at(i)!=A.at(i)){
            cnt1 = cnt1 + 1;
        }
        if (S.at(i)!=B.at(i)){
            cnt2 = cnt2 + 1;
        }
    }
    if (cnt1 < cnt2){
        cout << cnt1 << endl;
    }else{
        cout << cnt2 << endl;
    }
}


Measured memory_bytes: 512