akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std;  

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=(a)-((a)>(n)); i!=(n)-((a)>(n)); i+=1-2*((a)>(n)))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_back
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12);
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000009

int main(){
	flash; QuickSilver;
	string s, t; cin>>s>>t;
	int n=sz(s), m=sz(t);
	vvl dp(n+1, vl(m+1,0));
	rep(i,1,n+1) rep(j,1,m+1) 
		if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
	int i=n, j=m, cnt=dp[n][m];
	string ans=""; 
	while(cnt)
		if(s[i-1]==t[j-1]) ans+=s[i-1], i--, j--, cnt--;
		else if(dp[i-1][j]>dp[i][j-1]) i--;
		else j--;
	reverse(all(ans));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 70784
n, h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
a,b=[],[]
for x in ab:
    a.append(x[0])
    b.append(x[1])
b.sort()
ans=0
i=0
b = b[::-1]
ma = max(a)
while(h>0 and i<n):
    if b[i]>=ma:
        h-=b[i]
        ans+=1
    i+=1
if h>0:
    if h%ma==0:
        ans+=h//ma
    else:
        ans+=h//ma+1
print(ans)

Measured memory_bytes: 29784
#include<stdio.h>

long long int gcd(long long int a, long long int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);      
} 

int main()
{
	long long int a,b;
    scanf("%lld%lld",&a,&b);
  	long long int t=gcd(a,b);
  	long long int u=(a*b)/t;
  	printf("%lld\n",u);
  	return 0;
}

Measured memory_bytes: 128
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-
n = INT()
a = LIST()
list = [0] * (n + 1)

for x in a:
    list[x] += 1

for x in range(1, n + 1):
    print(list[x])

Measured memory_bytes: 34484
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <sstream>
#include <deque>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <utility>   // std::pair, std::make_pair
#include <stdlib.h>  //atoi
using namespace std;
typedef long long ll;
const  double PI = 3.141592654;
#define rep(i,x) for(int(i)=0;(i)<(ll)(x);(i)++)
#define all(s)      (s).begin(),(s).end()
#define allv(v)      (v).begin(),(v).end()
#define pb          push_back
#define sz          s.size()
#define vz          v.size()
//x = atoi(a.c_str())
void fast()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL), cout.tie(NULL);
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main()
{
	fast();
	string s;
	cin >> s;
	int c = count(all(s), '1');
	cout << c << endl;
	return 0;
}

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

int N;
string S;

int main() {
  cin >> N >> S;
  int count = 0;
  for (int i = 0; i < N-2; i++) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
P = np.array([int(x) for x in input().split()])
count = 0
for n in range(N-2):
    if P[n] < P[n+1] and P[n+1] < P[n+2]:
        count += 1
    if P[n+2] < P[n+1] and P[n+1] < P[n]:
        count += 1
print(count)


Measured memory_bytes: 12384
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

N,K = mint()
A = lint()
d = dict()
for a in A:
    d.setdefault(a,0)
    d[a] += 1
l = []
for k in d:
    l.append(d[k])
l.sort(reverse=True)
print(N-sum(l[:K]))

Measured memory_bytes: 133880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll X, Y;
    cin >> X >> Y;
    ll ans = 1;
    while(X*2 <= Y){
        X *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B, add, sub, mul, ans;
    cin >> A >> B;
    add = A + B;
    sub = A - B;
    mul = A * B;
    ans = max(max(add, sub), mul);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = input()
K = len(N)
c = N[0]
a = 0
for i in range(1,K):
  if N[i] != "9":
    a = 1
if a == 0:
  print(int(c) + 9*(K-1))
else:
  print(int(c) + 9*(K-1)-1)
  



Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.ArrayList;

public class Main {
  /**
   * Iterate through each line of input.
   */
  public static void main(String[] args) throws IOException {
	  Scanner scanner = new Scanner(System.in);
	  String s = scanner.nextLine();
      String t = scanner.nextLine();
      if(t==null || t.length()==0) System.out.print("No");
      else if(t.substring(0,t.length()-1).contentEquals(s)) System.out.print("Yes");
      else System.out.print("No");
  }
}

Measured memory_bytes: 35812
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)

typedef long long ll;

int main(void) {
    int x,y;
    cin >> x >> y;
    if (x<=y)
        swap(x,y);
    while (x%y!=0){
        x %= y;
        swap(x,y);
    }

    cout << y << endl;

    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

long Max2(long a,long b){
if(a>b){
    return a;
}else{
    return b;
}
}

long Min2(long a,long b){
if(a>b){
    return b;
}else{
    return a;
}
}


string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {
Prinit();
long N,M;
cin>>N>>M;
vector<long> A(N);
vector<long> B(N);
for(long i=0;i<N;i++){
cin>>A.at(i);
}
long ok=1000000000;
long ng=-1;
long va=0;
long mid;
while(ok-ng>1){
 // cout<<ok<<endl;
    mid=(ok+ng)/2;
 // cout<<mid<<endl;
    va=0;
    for(long i=0;i<N;i++){
        B.at(i)=A.at(i);
        while(B.at(i)>mid){
            B.at(i)=B.at(i)/2;
            va++;
        }
        if(va>M+1){
            break;
        }
    }
    if(va>M){
        ng=mid;
    }else{
        ok=mid;
    }
}

 va=0; 
for(long i=0;i<N;i++){
    A.at(i);
    while(A.at(i)>ok){
        A.at(i)=A.at(i)/2;
        va++;
    }
}
 // cout<<A.at(0)<<A.at(1)<<A.at(2)<<va<<endl;
sort(A.begin(),A.end());
reverse(A.begin(),A.end());
long i=0;
while(va<M&&i<N){
    A.at(i)=A.at(i)/2;
    va++;
    i++;
}
long ans=0;
for(long i=0;i<N;i++){
    ans+=A.at(i);
}
cout<<ans<<endl;

}



Measured memory_bytes: 315660
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String s = in.next();
        boolean[] a = new boolean[3];
        for(int i = 0; i<3; i++){
            a[s.charAt(i)-'a'] = true;
        }
        boolean check = true;
        for(int i = 0; i<3; i++){
            if(!a[i]){
                out.println("No");
                check = false;
                break;
            }
        }
        if(check) out.println("Yes");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32764
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

int main()
{
	int n, m;
	while (scanf("%d %d", &n, &m)) {
		int sumn = 0, summ = 0;
		vector<int> num[2];
		if (n == 0)
			return 0;
		for (int i = 0; n > i; i++) {
			int a;
			scanf("%d", &a);
			num[0].push_back(a);
			sumn += a;
		}
		for (int i = 0; m > i; i++) {
			int a;
			scanf("%d", &a);
			num[1].push_back(a);
			summ += a;
		}
		if ((summ - sumn) % 2) {
			printf("-1\n");
			continue;
		}
		sort(num[0].begin(), num[0].end());
		
		int i;
			for (i = 0; n > i; i++) {
			for (int j = 0; m > j; j++) {
				if (num[1][j] - num[0][i] == (summ - sumn) / 2) {
					printf("%d %d\n", num[0][i], num[1][j]);
					i = n;
					break;
				}
			}
		}
			if (i != n + 1) {
				printf("-1\n");
			}

	}
}

Measured memory_bytes: 3192
#include<stdio.h>
int main()
{
	int n;
	int a=0;
	int i;
	double g;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		if(i%2==1)a++;
	} 
	g=a*1.0/n;
	printf("%.10lf",g);
	return 0;
} 

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (c >= a && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

vector<ll> divisor(ll n){
    vector<ll> ret;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            ret.pb(i);
            if(i!=n/i)ret.pb(n/i);
        }
    }
    //  sort(all(ret));
    return ret;
}

int main(){
    int n;
    cin>>n;
    
    int c = 0;
    for(int i=1;i<=n;i+=2){
        vector<ll> d = divisor(i);
        if(d.size()==8){
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    int b[n-1];
    rep(i, n-1) cin >> b[i];
    int ans = 0;
    rep(i, n){
        if(i == 0){
            ans += b[i];
        }else if(i == n - 1){
            ans += b[i-1];
        }else{
            ans += min(b[i], b[i-1]);
        }
        // cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX


using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(int (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl

llong n;


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

    int x[50];
    int a;
    cin >> n >> a;
    FOR(i, 0, n) {
        cin >> x[i];
    }

    llong  dp[51][51][3010];

    dp[0][0][0] = 1;
    FOR(i, 0, n)
        FOR(j, 0, n)
        FOR(k, 0, 2500)
        if (dp[i][j][k]) {
            dp[i + 1][j][k] += dp[i][j][k];
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        }
    llong ans = 0;
    FOR(i, 1, n + 1) {
        ans += dp[n][i][i*a];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1'000'000'007;
const int INF = 1e9;

vector<vector<ll>> dp(110, vector<ll>(100010, -1));
vector<ll> W(110), V(110);

ll rec(ll n, ll w){
    if (dp[n][w] != -1) return dp[n][w];
    if (n == 0) return dp[0][w] = 0;
    ll res = 0;
    res = max(res, rec(n-1, w));
    if (w >= W[n-1]) res = max(res, rec(n-1, w - W[n-1]) + V[n-1]);
    return dp[n][w] = res;
}

int main(){
    ll n, w;
    cin >> n >> w;
    rep(i,n) cin >> W[i] >> V[i];
    cout << rec(n, w) << endl;
    // rep(i,7){
    //     rep(j,20){
    //         printf("%3d", dp[i][j]);
    //     }
    //     printf("\n");
    //}
    return 0;
}


Measured memory_bytes: 90092
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>
#include <climits>

using namespace std;


int main(void)
{
    int n,V[50],C[50],i,dif[50],ans=0;


    scanf("%d",&n);

    
    for(i=0;i<n;i++)
    {
        scanf("%d",&V[i]);
    }

    for(i=0;i<n;i++)
    {
        scanf("%d",&C[i]);
    }

    for(i=0;i<n;i++)
    {
        dif[i]=V[i]-C[i];
        if(dif[i]>0)
        {
            ans+=dif[i];
        }
    }    

    printf("%d",ans);
    cout << endl;

    return 0;
}

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(0) cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1) cout<<#x<<":"<<x<<endl;
#define ll long long

//constant
const int MOD=1000000007;
const int INF=INT_MAX/3-1;
const double EPS=1e-9;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;



int m;
int mi;
int a[4]={10,50,100,500};
int b[4];
int c[4];
int d[4];

int check(int n){
    debug(n);
    if(n<0)
        return INF;
    int count=0;
    RREP(i,4)
        count+=n/a[i],n-=(n/a[i])*a[i];
    debug(count);

    return count;

}


int dfs(int n){
    if(n>=4){
        int summ=0,sumc=0;
        REP(i,4)
            summ+=d[i]*a[i],sumc+=b[i]-d[i];
        int memo;
        REP(i,4)
            debug(d[i]);
        debug(summ);
        debug(sumc);
        if(mi>(memo=check(summ-m)+sumc)){
            debug(memo);
            mi=memo;
            REP(i,4)
                c[i]=d[i];
        }

        return 1;
    }

    for(int i=0;i<=b[n];i++){
        d[n]=i;
        dfs(n+1);

    }

    return 0;

}

int main(){
    bool cr=0;
    while(cin>>m,m){
        if(cr)
            cout<<endl;
        cr=1;
        REP(i,4)
            cin>>b[i];
        mi=INF;
        dfs(0);
        REP(i,4)
            if(c[i])cout<<a[i]<<" "<<c[i]<<endl;;

    }

    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;

vector<ll> v;

void solve()
{
	ll k;
	cin>>k;
	ll n = k+100;
	list<ll> temp;
	rep2(i, 1, 10) temp.pb(i), v.pb(i);
	while(!temp.empty() and n--)
	{
		ll tmp = temp.front();
		temp.pop_front();
		if(tmp%10 - 1 >= 0)
			v.pb(tmp*10 + tmp%10 - 1), temp.pb(tmp*10 + tmp%10 - 1);
		v.pb(tmp%10 + tmp*10), temp.pb(tmp%10 + tmp*10);
		if(tmp%10 + 1 <= 9)
			v.pb(tmp%10 + 1 + tmp*10), temp.pb(tmp%10 + 1 + tmp*10);
	}
	cout<<v[k-1]<<endl;
}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


Measured memory_bytes: 11632
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    int s,a,b;
    cin>>s;
    a=s/100;
    b=s%100;

    if(a>12)
    {
        if(b>0&&b<=12)
            cout<<"YYMM"<<endl;
        else
            cout<<"NA"<<endl;
    }
    else if(a==0)
    {
        if(b==0||b>12)
            cout<<"NA"<<endl;
        else
            cout<<"YYMM"<<endl;
    }
    else
    {
        if(b==0||b>12)
            cout<<"MMYY"<<endl;
        else
            cout<<"AMBIGUOUS"<<endl;
    }

    return 0;
}





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

int main(void){
	string S,T;
	cin >> S >> T;
	int A,B;
	cin >> A >> B;
	string U;
	cin >> U;
	if(S == U){
		--A;
	}else{
		--B;
	}
	cout << A << ' ' << B << '\n';
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N,M;
	int i;
	scanf("%d %d",&N,&M);
	while(N!=0&&M!=0){
		int command[N];
		for(i=0;i<N;i++){//マス目の指示を受け取る
			scanf("%d",&command[i]);
		}
		int sai[M];
		for(i=0;i<M;i++){//サイコロの目を受け取る
			scanf("%d",&sai[i]);
		}
		int sugoroku=0;//今何マス目にいるか
		for(i=0;i<M;i++){
			sugoroku+=sai[i];//サイコロのマス目分進む
			if(sugoroku>=N-1){
				printf("%d\n",i+1);
				break;
			}
			sugoroku+=command[sugoroku];
			if(sugoroku>=N-1){//ゴール処理
				printf("%d\n",i+1);
				break;
			}
		}
		scanf("%d %d",&N,&M);
	}
	return 0;
}

Measured memory_bytes: 608
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

ll n, m, ans;
vector<ll> edge[110000];
bool done[110000];
ll dist[110000];
ll pre[110000];

void bfs(ll s) {
  queue<ll> q;
  
  q.push(s);
  done[s] = true;  

  while (q.size()) {
    ll u = q.front();
    q.pop();
    for (ll v: edge[u]) {
      if (done[v]) continue;
      dist[v] = dist[u] + 1;
      pre[v] = u;
      q.push(v);
      done[v] = true;
    }
  }
}

int main() {
  cin >> n >> m;
  
  for (ll i = 0; i < m; i++) {
    ll u, v;
    cin >> u >> v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  
  bfs(0);
  
  for (ll i = 0; i < n; i++) {
    if (not done[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  for (ll i = 1; i < n; i++) {
    cout << pre[i]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 14144
N, *A = map(int, open(0).read().split())
A.sort()

if N % 2:
  array1 = [-2] * (N // 2) + [1] * 2 + [2] * (N // 2 - 1)
  array2 = [-2] * (N // 2 - 1) + [-1] * 2 + [2] * (N // 2)
  
  ret1 = 0
  ret2 = 0
  for i in range(N):
    ret1 += A[i]*array1[i] 
    ret2 += A[i]*array2[i]
  ret = max(ret1, ret2)

else:
  array1 = [-2] * (N // 2 - 1) + [-1] + [1] + [2] * (N // 2 - 1)
  
  ret = 0
  for i in range(N):
    ret += A[i]*array1[i] 
  
print(ret)

Measured memory_bytes: 14452
def main():
    input()
    H=map(int,input().split())
    A=map(int,input().split())
    n=2*10**5+1

    def update_max(k,x):
        k += num_max-1
        seg_max[k] = x
        while k:
            k = (k-1)//2
            seg_max[k] = max(seg_max[k*2+1],seg_max[k*2+2])
    def query_max(p,q):
        if q<=p:
            return ide_ele_max
        p += num_max-1
        q += num_max-2
        res=ide_ele_max
        while q-p>1:
            if p&1 == 0:
                res = max(res,seg_max[p])
            if q&1 == 1:
                res = max(res,seg_max[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = max(res,seg_max[p])
        else:
            res = max(max(res,seg_max[p]),seg_max[q])
        return res
    ide_ele_max = 0
    num_max =2**(n-1).bit_length()
    seg_max=[ide_ele_max]*2*num_max

    for h,a in zip(H,A):
        update_max(h,query_max(0,h)+a)
    
    print(query_max(0,n))
main()

Measured memory_bytes: 123472
def dfs(i, sum, count, nokori):
    global ans
    if i == d:
        # G 点に満たなければ nokori のうち一番大きいものを解く
        if sum < g:
            use = max(nokori)
            # 解く問題が問題数を超えないように注意
            n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
            count += n
            sum += n * use * 100

        if sum >= g:
            ans = min(ans, count)
    else:
        # 総合スコア、解いた問題数、まだ解いてない問題を更新
        dfs(i + 1, sum, count, nokori)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], nokori - {i + 1})


d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)


Measured memory_bytes: 41840
#include<iostream>
using namespace std;
int main(){
	int n,a,b;
  	cin>>n>>a>>b;
  	int flag=0;
  	for(int i=a;i<=b;i++){
    if(i%n==0)
    {
    	flag=1;
      	break;
    }
    }
  if(flag==0)
    cout<<"NG"<<endl;
  else
    cout<<"OK"<<endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int SIZ = 100000;
int sieve[SIZ];

vector<int> getPrimes() {
    vector<int> primes;
    fill_n(sieve, SIZ, true);
    sieve[0] = sieve[1] = false;
    for (int i=2; i<SIZ; ++i) {
        if ( ! sieve[i]) continue;
        primes.push_back(i);
        if (i*i <= SIZ) {
            for (int j=i*2; j<SIZ; j+=i) {
                sieve[j] = false;
            }
        }
    }
    return primes;
}

int main() {
    ios::sync_with_stdio(false);
    vector<int> primes = getPrimes();
    int m, a, b;
    while (1) {
        cin >> m >> a >> b;
        if (!m && !a && !b) break;
        int p = 0, q = 0, max_m = 0;
        for (int i=0; i<(int)primes.size(); ++i) {
            for (int j=i; j<(int)primes.size(); ++j) {
                if (primes[i] * primes[j] < 0 || m < primes[i] * primes[j] || b * primes[i] < a * primes[j]) {
                    break;
                }
                if (max_m < primes[i] * primes[j]) {
                    p = primes[i];
                    q = primes[j];
                    max_m = primes[i] * primes[j];
                }
            }
        }
        cout << p << " " << q << endl;
    }
    return 0;
}

Measured memory_bytes: 1720
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define eps 1e-7
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
const int INF = 1<<29;
typedef unsigned long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n;
string s;

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

    cin >> n;
    string prev;

    bool flag=true;
    map<string,int> M;

    FOR(i,0,n){
        cin >> s;
        
        if(i!=0){
            if(s[0]!=prev[prev.size()-1])
                flag=false;
        }

        if(!M.count(s))
            M[s]++;
        else
            flag=false;
        prev=s;
    }

    if(flag)
        cout << "Yes\n";
    else
        cout << "No\n";

	return 0;
}



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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int m=n;
  do{
      m=1000-abs(m);
  }while(m<0);
  cout<<m;
  return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)

int main() {
	int N, T; cin >> N >> T;
	ll ans = 0, tmp = 0;
	rep(i, N) {
		int t;
		cin >> t;
		if (tmp - t > 0) {
			ans -= tmp - t;
		}
		ans += T;
		tmp = t + T;  
	}
	cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		byte[] st = sc.next().getBytes();

		int num = 0;
		if (st[0] == 'o') {
			num++;
		}

		if (st[1] == 'o') {
			num++;

		}

		if (st[2] == 'o') {
			num++;
		}

		System.out.println(700 + num * 100);

	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
using namespace std;
long long a[200005],n,k,ans,po[200005],o,ne[200005],e;
bool check(long long val){
    long long res=0;
    for(int i=1;i<=o;i++){
        long long l=i,r=o,mid,fin=i;
        while(l<=r){
            mid=(l+r)>>1;
            if(po[i]*po[mid]<val){
                fin=mid;
                l=mid+1;
            }else r=mid-1;
        }
        res+=fin-i;
    }
    for(int i=1;i<=e;i++){
        long long l=i,r=e,mid,fin=i;
        while(l<=r){
            mid=(l+r)>>1;
            if(ne[i]*ne[mid]<val){
                fin=mid;
                l=mid+1;
            }else r=mid-1;
        }
        res+=fin-i;
    }
    return res<=k-1;
}
bool checkx(long long val){
    long long res=0;
    for(int i=1;i<=e;i++){
        long long l=1,r=o,mid,fin=o+1;
        while(l<=r){
            mid=(l+r)>>1;
            if(ne[i]*po[mid]>val){
                fin=mid;
                r=mid-1;
            }else l=mid+1;
        }
        // cout<<fin<<" ";
        res+=o+1-fin;
    }
    // if(val==5)
        // cout<<res<<"Snoop\n";
    return res<=k-1;
}//也就是越大的反而越小。
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]>0)
            po[++o]=a[i];
        else ne[++e]=-a[i];
    }
    sort(po+1,po+o+1);
    po[0]=po[o+1]=1e8;
    sort(ne+1,ne+e+1);
    ne[0]=ne[e+1]=1e8;
    if(o*e>=k){
        long long l=0,r=1e18,mid;
        while(l<=r){
            mid=(l+r)>>1;
            // cout<<mid<<"SnoopDogg\n";
            if(checkx(mid)){//个数小于等于k-1（大于
                r=mid-1;
                ans=mid;
            }else l=mid+1;
        }
        cout<<-ans<<'\n';
    }else {
        k-=o*e;
        long long l=0,r=1e18,mid;
        while(l<=r){
            mid=(l+r)>>1;
            if(check(mid)){//个数小于或等于k-1（小于
                l=mid+1;
                ans=mid;
            }else r=mid-1;
        }
        cout<<ans<<'\n';
    }
}
/*
也就是它会有(n-1)*n/2个乘积，要找到第K小的那一个。
首先要把负数和正数分开。
我有了！二分结果。
然后枚举每一个点，二分找到使结果小于该结果的最大标号。
然后要是等于k-1，那么就对了。
答案就是每个行的最大标号的下一个取min。
先写一个正数的吧。
去掉了负数那一块居然只少了一个点……
分析一下，当答案是非正数的时候，现在我把0分到负数那一块去，
对于负数数组内的i，求正数数组内最小的使两者乘积大于规定的值
*/

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

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 10;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n;
ll mp[400][400];
ll mp2[400][400];

bool s() {
    int i, j, k;
    for (i = 1; i <= n; ++i) {
        for (j = 1; j <= n; ++j) {
            if (j == i)
                continue;
            for (k = j + 1; k <= n; ++k) {
                if (k == i)
                    continue;
                ll t = mp[j][i] + mp[i][k];
                if (t < mp[j][k])
                    return 0;
                if (mp2[j][k] == 0)
                    mp2[j][k] = t;
                else
                    mp2[j][k] = min(mp2[j][k], t);
            }
        }
    }
    return 1;
}

int main() {
    int i, j;
    cin >> n;
    for (i = 1; i <= n; ++i) {
        for (j = 1; j <=n; ++j) {
            cin >> mp[i][j];
        }
    }
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 2) {
        cout << mp[1][2] << endl;
        return 0;
    }
    if (!s()) {
        cout << -1 << endl;
        return 0;
    }
    ll sum = 0;
    for (i = 1; i <= n; ++i) {
        for (j = i + 1; j <= n; ++j) {
            if (mp2[i][j] > mp[i][j])
                sum += mp[i][j];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2176
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	ll A = 0;
	ll B = 0;
	ll X = 0;

	cin >> A >> B >> X;

	// solve
	// A = cat, B = cat + dog, X = all cat?
	if ( X >= A && X <= A + B ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N, K;
  cin>>N>>K;
  vector<ll> A(N);
  priority_queue<ll> B, S;
  ll ZeroCnt=0;
  ll Next=1;
  rep(i, N){
    cin>>A[i];
    if(A[i]>0)B.push(A[i]);
    if(A[i]<0)S.push(A[i]*-1);
    if(A[i]==0)ZeroCnt++;
  }
  if(ZeroCnt+K>N){
    cout<<0<<endl;
    return 0;
  }
  ll Ans=1;
  if(K%2){
    if(B.size()>0){
    Ans*=B.top();
    B.pop();
    K--;
    if(K==0){
      cout<<Ans<<endl;
      return 0;
    }
    }else{
      	if(ZeroCnt>0){
          cout<<0<<endl;
          return 0;
        }
      	else{
          sort(ALL(A));
          reverse(ALL(A));
          rep(i, K){
            Ans*=(A[i]+MOD);
            Ans%=MOD;
          }
          cout<<Ans<<endl;
          return 0;
        }
    }
  }
  
  ll Sz=B.size()/2+S.size()/2;
  if(Sz<K/2){
    if(ZeroCnt>0){
      cout<<0<<endl;
      return 0;
    }
    // 全て選ぶパターン？
    Ans=1;
    rep(i, N){
      Ans*=(A[i]+MOD);
      Ans%=MOD;
    }
    cout<<Ans<<endl;
    return 0;
  }
  ll Big=-1;
  ll Small=-1;
  if(B.size()>=2){
      Big=B.top();
      B.pop();
      Big*=B.top();
      B.pop();
  }
  if(S.size()>=2){
      Small=S.top();
      S.pop();
      Small*=S.top();
      S.pop();
  }
  if(Big>Small){
    Big%=MOD;
    Ans*=Big;
    Big=-1;
  }
  else{
    Small%=MOD;
    Ans*=Small;
    Small=-1;
  }
  Ans%=MOD;
  K-=2;
  while(K>0){
    if(Big==-1&&B.size()>=2){
      Big=B.top();
      B.pop();
      Big*=B.top();
      B.pop();
    }
    if(Small==-1&&S.size()>=2){
      Small=S.top();
      S.pop();
      Small*=S.top();
      S.pop();
    }
    if(Big>Small){
    Big%=MOD;
    Ans*=Big;
    Big=-1;
    }
    else{
    Small%=MOD;
    Ans*=Small;
    Small=-1;
    }
    Ans%=MOD;
    K-=2;

  }
  cout<<Ans<<endl;
  return 0;
} 

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

typedef double du ;
typedef string st ;
typedef long long ll ;

int main ()
{
    int num1 , num2 , mx , mn ;
    st s ;

    char res ;

    cin >> num1 >> num2 ;

    mx = max (num1 , num2 ) ;
    mn = min (num1 , num2 ) ;

    res = mn + 48 ;
    for (int i = 0 ; i < mx ; i++)
    {
        s[i] = res ;
    }
    for (int i = 0 ; i < mx ; i++)
    {
        cout << s[i] ;
    }
    return 0 ;
}


Measured memory_bytes: 256
N = int(input())
keta = len(str(N))
SN = str(N)
if N <= 9:
    print(N)
elif SN.count('9') == keta:
    print(9*keta)
elif SN.count('9') == keta-1 and SN[0] != '9':
    print((keta - 1) * 9 + int(SN[0]))
else:
    print((keta - 1) * 9 + int(SN[0])-1)

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

int main() {
    ll A, B, C; cin >> A >> B >> C;
    for (int i = 0; i < 10000; i++)
    {
        if(A*i%B==C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}

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


int main() {
  int n, k;
  cin>>n>>k;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin>>a[i];

  long long acc[n+1];
  long long plus_acc[n+1];
  acc[0] = 0;
  plus_acc[0] = 0;
  for (int i=0; i<n; i++) {
    acc[i+1] = acc[i] + a[i];
    if (a[i] > 0) {
      plus_acc[i+1] = plus_acc[i] + a[i];
    } else {
      plus_acc[i+1] = plus_acc[i];
    }
  }
  long long ans = -1e15;
  for (int i=0; i<=n-k; i++) {
    long long tmp = plus_acc[n] - plus_acc[i+k] + plus_acc[i];
    ans = max(tmp, ans);
    ans = max(tmp + acc[i+k] - acc[i], ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <cmath>
#include <string>
#include <vector>


using namespace std;

int retMaxPow2(int n){
  int i=0;
  while(true){
    int tmp = pow(2, i);
    if(n<tmp){
      break;
    }
    i++;
  }

  return (i-1);
}

int main(){
  int tmp;
  vector<int> nums;
  while(cin >> tmp){
    int n = tmp;
    while(true){   
      // cout << n << " >= " << "2^" << retMaxPow2(n) << endl;
      nums.push_back(pow(2, retMaxPow2(n)));
      n -= pow(2, retMaxPow2(n));
      
      if(n==0){
	break;
      }
    }

    for(int i=0;i<nums.size();i++){
      if(i==nums.size()-1){
	cout << nums[nums.size()-1-i] << endl;
      }else{
	cout << nums[nums.size()-1-i] << " ";
      }
    }
    nums.clear();
      
  }
}

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

int main(){
	while(1){
		int h, w;
		cin >> h >> w;
		if (h == 0 and w == 0)break;
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (i == 0)cout << "#";
				else if (i == (h-1))cout << "#";
				else if (j == 0)cout << "#";
				else if (j == (w-1)) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}

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

int main(void) {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> B(N);
  vector<long long> diff(N);
  long long sumDiff = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    diff[i] = A[i] - B[i];

    if (diff[i] < 0) {
      ans++;
      sumDiff += diff[i];
    }
  }

  if (accumulate(diff.begin(), diff.end(), 0LL) < 0) {
    cout << -1 << endl;
    return 0;
  }

  sort(diff.begin(), diff.end(), greater<long long>());
  for (auto d : diff) {
    if (sumDiff >= 0) break;
    sumDiff += d;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

signed main() {
#ifdef _DEBUG
	freopen("in", "r", stdin);
#endif
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << ' ' << y << ' ' << z << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int H,N,a;
    a=0;
    int A[100000];
    cin>>H>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int j=0;j<N;j++){
        a+=A[j];
    }
    if(a>=H){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>



int main()
{
    using namespace std;
    int N, Alice = 0, Bob = 0, stdin;
    vector<int>  b;
    
    cin >> N;
    vector<int> a(N, 0);

    for(int i = 0; i < N; ++i)
    {
	cin >> stdin;
	b.push_back(stdin);
    }

    int count = 0;
    while(b.size() != 0)
    {
	int max = b[0], max_num = 0;
	for(int i = 0; i < b.size(); ++i)
	{
	    if(max < b[i])
		max = b[i], max_num = i;
	}
	b.erase(b.begin() + max_num);
	a[count++] = max;
    }

    int pdiff = 0;
    for(int i=0; i<N; ++i)
    {
	if(i % 2 == 0)
	    pdiff += a[i];
	else
	    pdiff -= a[i];
    }
    
    cout << pdiff << endl;

}


Measured memory_bytes: 256
mod = 10**9+7

n,k=map(int, input().split())

ans = 0
for i in range(k,n+2):
    min_num = (0+i-1)*i//2
    max_num = (n+(n-i+1))*i//2
    ans += (max_num - min_num + 1) % mod
print(ans % mod)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int V_MAX = 1e6+10;
int N;
vector<vector<int> > G(V_MAX);
vector<bool> used(V_MAX,false);
vector<int> dp(V_MAX,0);

int dfs(int v){
  if(used[v])return MAX_I;
  if(dp[v]!=0)return dp[v];
  used[v] = true;
  int ret = 0;
  for(const int & u : G[v]){
    int x = dfs(u);
    if(x == MAX_I){
      ret = MAX_I;
      break;
    }
    ret = max(ret,x+1);
  }
  used[v] = false;
  return dp[v] = ret;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N;
  rep(i,N){
    int pre = 0;
    rep(j,N-1){
      int x;cin >> x;
      --x;
      int nxt = min(x,i)*N+max(x,i);
      G[pre].push_back(nxt);
      pre = nxt;
    }
  }
  int ans = dfs(0);
  if(ans == MAX_I)cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


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

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a/gcd(a,b)*b;
    }

int main() {
    long long a, b;
    cin >> a >> b;
    long long ans = lcm(a, b);
    cout << ans << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

double dp[3000][3000];

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

  double p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }

  dp[0][0] = 1.0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      dp[i+1][j+1] += dp[i][j] * p[i];
      dp[i+1][j] += dp[i][j] * (1-p[i]);
//      printf(" %.9f", dp[i][j]);
    }
//    cout << endl;
  }

  double ans = 0;
  for(int i = n/2+1; i <= n; i++){
    ans += dp[n][i];
  }

  printf("%.9f\n", ans);

  return 0;
}


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

#define ll long long

int N, M;
int v[111];

int main()
{
	//ios::sync_with_stdio(0); cin.tie(0);
	scanf("%d %d", &N, &M);
	int sum = 0;
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &v[i]);
		sum += v[i];
	}
	int cnt = 0;
	for(int i=1; i<=N; i++)
		if (v[i]*4*M >= sum)
			cnt++;
	if (cnt >= M) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
n,m,r = map(int, input().split())
INF = 1 << 40
edges = [[INF]*n for i in range(n)]
rs  = list(map(int, input().split()))
rs = [r-1 for r in rs]
for i in range(m):
    a,b,c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a][b] = c
    edges[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            tmp = edges[i][k] + edges[k][j]
            edges[i][j] = min(edges[i][j], tmp)

from itertools import permutations

ans = 1 << 50
for perm in permutations(rs):
    dist = 0
    for i in range(1,len(perm)):
        f = perm[i-1]
        t = perm[i]
        dist += edges[f][t]
    ans = min(ans, dist)
print(ans)

Measured memory_bytes: 74896
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll n, x[N], y[N];
char d[N];

long double f(long double val) {
  long double minX = inf, minY = inf, maxX = -inf, maxY = -inf;
  for (int i = 0; i < n; ++i) {
    ll dirX = 0, dirY = 0;
    if(d[i] == 'U')
      dirY = 1;
    else if(d[i] == 'D')
      dirY = -1;
    else if(d[i] == 'R')
      dirX = 1;
    else
      dirX = -1;
    minX = min(minX, 1.0 * x[i] + 1.0 * dirX * val);
    minY = min(minY, 1.0 * y[i] + 1.0 * dirY * val);
    maxX = max(maxX, 1.0 * x[i] + 1.0 * dirX * val);
    maxY = max(maxY, 1.0 * y[i] + 1.0 * dirY * val);
  }
  return (maxX - minX) * (maxY - minY);
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> d[i];
  }
  long double start = 0, end = 1e9 + 5;
  for (int i = 0; i < 750; ++i) {
    long double mid1 = start + (end - start) / 3;
    long double mid2 = end - (end - start) / 3;
    long double f1 = f(mid1);
    long double f2 = f(mid2);
    if(f1 < f2)
      end = mid2;
    else
      start = mid1;
  }
  cout << f(start);
  return 0;
}


Measured memory_bytes: 1920