akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
array<int, 101> factoring(int x) {
    array<int, 101> ret{};
    for (int i = 2; x >= i * i; i++) {
        while (x % i == 0) {
            ret[i]++;
            x /= i;
        }
    }
    if (x > 1) ret[x]++;
    return ret;
}

signed main() {
    int n, d;
    cin >> n >> d;
    vector<list<int>> l(n);
    REP(i, d) {
        // cout << i << endl;
        int a, t, x;
        cin >> a >> t;
        if (a == 0) {
            cin >> x;
            l[t].push_back(x);
        } else if (a == 1) {
            int k = 0;
            int sz = l[t].size();
            for (int x : l[t]) {
                k++;
                cout << x;
                if (k != sz) {
                    cout << " ";
                }
            }
            cout << "\n";
        } else {
            cin >> x;
            l[x].splice(l[x].end(), l[t]);
            l[t].clear();
        }
    }
}


Measured memory_bytes: 18788
#include <iostream>

using namespace std;



int main(){


    int n;
    cin >> n;

    int a, b, c, d;

    d = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    b = n % 10;
    n /= 10;
    a = n;

    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 2; j++){
            for (int k = 0; k < 2; k++){

                int ans1 = (i % 2 == 0) ? a + b : a - b;
                int ans2 = (j % 2 == 0) ? ans1 + c : ans1 - c;
                int ans3 = (k % 2 == 0) ? ans2 + d : ans2 - d;

                // cout << "ans3 : " << ans3 << endl;

                if (ans3 == 7){
                    string res = "";
                    res += to_string(a);
                    res += (i % 2 == 0) ? "+" : "-"; 
                    res += to_string(b);
                    res += (j % 2 == 0) ? "+" : "-"; 
                    res += to_string(c);
                    res += (k % 2 == 0) ? "+" : "-"; 
                    res += to_string(d);
                    res += "=7";
                    cout << res << endl;
                    return 0;
                }

            }
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to) : from(-1), to(to), cost(-1) {}
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T,int>>> que;que.push(P(0,s));
  while(!que.empty()){
    pair<T,int> p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(make_pair(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

  int n; string s;
int r, g, b;
signed main(){
  cin>>n>>s;
  rep(i,n){
    if(s[i] == 'R')r++;
    else if(s[i] == 'G')g++;
    else b++;
  }
  int ans = r*g*b;
  rep(i,n){
    repd(j,i+1,n){
      int k = j + (j-i);
      if(k >= n)continue;
      if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])ans--;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;

const int base = (int)1e9+7;
int n, m, dp[5005][5005];
char s[5005];

int main() {
	scanf("%d", &n);
	scanf("%s", s + 1);
	dp[0][0] = 1, m = strlen(s + 1);
	for (int i = 1; i <= n; ++i) {
		dp[i][0] = (dp[i - 1][0] + 2*dp[i - 1][1] % base) % base;
		for (int j = 1; j <= n; ++j)
			dp[i][j] = (dp[i - 1][j - 1] + 2*dp[i - 1][j + 1] % base) % base;
	}
	printf("%d", dp[n][m]);
	return 0;
}


Measured memory_bytes: 98048
n,p=map(int,input().split())
a=list(map(int,input().split()))
k=0
g=0
for i in range(n):
    if a[i]%2==0:
        g+=1
    else:
        k+=1
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
numg=0
numk=0
if p==0:
    for i in range(k//2+1):
        numk+=cmb(k,i*2)
    for i in range(g+1):
        numg+=cmb(g,i)
    print(numk*numg)
else:
    for i in range((k+1)//2):
        numk+=cmb(k,i*2+1)
    for i in range(g+1):
        numg+=cmb(g,i)
    print(numk*numg)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

ll dp[100055];

int N, W;

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

	cin >> N >> W;
	fill(dp+1, dp+100055, INFLL);
	
	for(int ni = 0, a, b; ni < N; ni++) {
		cin >> a >> b;
		for(int i = 100000; b <= i; i--) {
			ll t = dp[i-b] + a;
			if(t < dp[i]) dp[i] = t;
		}
	}

	for(int i = 100000; i; i--) if(dp[i] <= W) {
		cout << i << endl;
		return 0;
	}
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    vector<pair<int, int>> v;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int tx, ty;
        cin >> tx >> ty;
        v.push_back(make_pair(tx, ty));
    }
    sort(all(v));

    map<pair<int, int>, int> m;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            m[make_pair(v[i].first - v[j].first, v[i].second - v[j].second)]++;
            // cout << v[i].first - v[j].first << "," << v[i].second - v[j].second << endl;
        }
    }

    int mx = -1;
    pair<int, int> p;
    p.first = v[0].first;
    p.second = v[0].second;
    for (auto itr = m.begin(); itr != m.end(); itr++)
    {
        int tmp = mx;
        mx = max(mx, itr->second);
        if (mx != tmp)
        {
            p.first = itr->first.first;
            p.second = itr->first.second;
        }
    }
    // cout << p.first << " " << p.second << "," << mx << endl;
    if (n != 1)
        cout << n - mx << endl;
    else
    {
        cout << 1 << endl;
    }
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int A[N]; rep(i, N) cin >> A[i];
    int ans = 0;
    for(int i = 1; i <= min(N, K); i++){
        //計i回取り出す
        int rem = K-i;
        for(int left = 0; left <= i; left++){
            int res = 0;
            vector<int> have;

            rep(j, left) have.push_back(A[j]);
            for(int right = N-1; right >= N-(i-left); right--) have.push_back(A[right]);

            sort(have.begin(), have.end());
            int sz = have.size();
            rep(j, sz) res += have[j];
            rep(j, min(rem, sz)){
                if(have[j] < 0) res -= have[j];
                else break;
            }
            ans = max(ans, res);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main( String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[9];
        for (int i = 0; i < 9; i++) {
            array[i] = sc.nextInt();
            // System.out.println(sc.nextInt());
        }
         int [] re = new int[9];
         int num = sc.nextInt();//N個
        for (int i=0; i < num; i++){
            int hikaku = sc.nextInt();
            for(int n=0 ; n < array.length; n++){
                if(array[n] == hikaku){
                    if(re[n] == 0 ){
                        re[n] = 1;
                    }
                } else {
                    if(re[n] != 1){
                        re[n] =0 ;
                    }
                }
            }
        }
        
        if(re[0] == 1 && re[1] ==1 && re[2] ==1){
            System.out.println("Yes");
        } else if(re[3]==1 &&re[4] ==1&& re[5] ==1 ){
            System.out.println("Yes");
        } else if(re[6]==1 &&re[7] ==1&& re[8] ==1 ){
            System.out.println("Yes");
        } else if(re[0]==1 &&re[3] ==1&& re[6] ==1 ){
            System.out.println("Yes");
        } else if(re[1]==1 &&re[4] ==1&& re[7] ==1 ){
            System.out.println("Yes");
        } else if(re[2]==1 &&re[5] ==1&& re[8] ==1 ){
            System.out.println("Yes");
        } else if(re[0]==1 &&re[4] ==1&& re[8] ==1 ){
            System.out.println("Yes");
        } else if(re[2]==1 &&re[4] ==1&& re[6] ==1 ){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
/**
 * author:    Ziel
 * created:   04.05.2020 18:44:53
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int aim = 1, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == aim)
      aim++;
    else
      ans++;
  }
  if (aim == 1) cout << -1; 
  else cout << ans;
  
  return 0;
}

/*
  Raise your standard.
*/

Measured memory_bytes: 1024
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

def judge(a: list, n: int):
    for ai in a:
        if ai >= n:
            return True
        
    return False

ans = 0
while judge(a, n):
    amax = max(a)
    argmax = a.index(amax)
    x = -( -(amax-(n-1)) // n)
    ans += x
    
    nex = [ai + x if i != argmax else ai - n*x for (i,ai) in enumerate(a)]
    a = nex
    
print(ans)

Measured memory_bytes: 3064
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
  int N, A[220000], max1=-1, max2=-1;
  cin >> N;
  rep(i, N) {
    cin >> A[i];
    if(A[i]>max1){
      max2=max1;
      max1=A[i];
    }
    else if(A[i]>max2) max2=A[i];
  }
  if(max1==max2){
    rep(i,N) cout<<max1<<endl;
  }
  else{
    rep(i,N) {
      if(A[i]==max1) cout<<max2<<endl;
      else cout<<max1<<endl;
    }
  }
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			StringBuilder out = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			int n = Integer.parseInt(in.readLine());
			String[] line = in.readLine().split("[\\s]+");
			in.close();
			
			int[] seq = new int[n];
			for (int i = 0; i < seq.length; i++) {
				seq[i] = Integer.parseInt(line[i]);
				out.append(String.valueOf(seq[i])).append(i < n-1 ? " " : lb);
			}
			
			for (int i = 1; i < seq.length; i++) {
				final int key = seq[i];
				int j = i-1;
				while (0 <= j && key < seq[j]) {
					seq[j+1] = seq[j];
					j--;
				}
				seq[j+1] = key;
				
				for (int k = 0; k < n; k++) {
					out.append(String.valueOf(seq[k])).append(k < n-1 ? " " : lb);
				}
			}
			System.out.print(out.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 23108
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

string S = "";

int main() {
	cin >> S;
	if(S == "Sunny") {
		cout << "Cloudy";
	}
	else if(S == "Cloudy") {
		cout << "Rainy";
	}
	else if(S == "Rainy") {
		cout << "Sunny";
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  string s;
  cin >> s;
  int a=0,b=0,c=0,d=0;
  rep(i,0,s.size()){
    if(s[i]=='N')a++;
    if(s[i]=='S')b++;
    if(s[i]=='W')c++;
    if(s[i]=='E')d++;
  }
  if(a>0&&b==0) {cNo;return 0;}
  if(b>0&&a==0) {cNo;return 0;}
  if(d>0&&c==0) {cNo;return 0;}
  if(c>0&&d==0) {cNo;return 0;}
  
  
  cYes;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
ans=0


ans+=A[0]
if (N-2)%2==0:
    ans+=sum(A[1:int((N-2)/2)+1])*2
else:
    ans+=sum(A[1:int((N-3)/2)+1])*2
    ans+=A[int((N-1)/2)]


print(ans)

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

int calc(int x) {
    int sum = 0;
    sum += x / 100000;
    x %= 100000;
    sum += x / 10000;
    x %= 10000;
    sum += x / 1000;
    x %= 1000;
    sum += x / 100;
    x %= 100;
    sum += x / 10;
    x %= 10;
    sum += x;
    return sum;
}

int main(void) {
    int n, ans = 114514;
    cin >> n;
    
    for (int i = 1; i <= n / 2; i++) {
        if (ans > calc(i) + calc(n - i))
            ans = calc(i) + calc(n - i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def solve n
  result = Array.new
  while n > 0 do
    l = n % 8
    n = n / 8
    result.push(change(l))
  end
  result.reverse.join()
end

def change n
  case n
  when 0..3
    n
  when 4
    n + 1
  when 5..7
    n + 2
  end
end

while (n = $stdin.gets.to_i) != 0 do
  puts solve(n)
end

Measured memory_bytes: 6116
N,M = map(int,input().split())

divisors = set()
d = 1
while d*d <= M:
    if M%d == 0:
        divisors.add(d)
        divisors.add(M//d)
    d += 1

ans = 0
for d in divisors:
    a = M//d
    if a >= N:
        ans = max(ans,d)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    // Your code here!
    int N,X,T;
    int i,times;
    
    scanf("%d %d %d",&N,&X,&T);
    
    for(i=0;;i++){
        if(N <= X*i){
            times = T*i;
            break;
        }
    }
    
    printf("%d\n",times);
    return 0;
}


Measured memory_bytes: 1708
//曜日判定
using System;

namespace tst
{
    
    class Program
    {
        public static void Main()
        {

            //アルファベット配列//alphas[0]="A"
            string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            string[] alphas = new string[26];
            for (int i = 0; i < 26; i++)
            {
                alphas[i] = alpha.Substring(i, 1);
            }

            //int読み込み
            int n = int.Parse(Console.ReadLine());
            //string読み込み
            string text=Console.ReadLine();
            string[] words = new string[10000];
            for (int i = 0; i < text.Length; i++)
            {
                //読み込んだもの配列
                words[i] = text.Substring(i, 1);
                //比較
                for(int j=0; j<26; j++)
                {
                    if (words[i] == alphas[j])
                    {
                        int next = j + n;
                        if (next>=26)
                        {
                            //Zを超えるときはAに戻す
                            next -= 26;
                        }
                        words[i] = alphas[next];
                        break;
                    }
                }
                Console.Write(words[i]);

            }


            
        }

    }
}

Measured memory_bytes: 13180
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
char table[8][8];
string s = "ox";
bool range_check(int y, int x)
{
    if(y < 0 || x < 0 || y >= 8 || x >= 8) return false;
    else return true;
}
void Put(int y, int x, int flag)
{
    table[y][x] = s[flag];
    for(int k = 0; k < 8; k++)
    {
        int ny = y;
        int nx = x;
        bool ok = false;
        while(1)
        {
            ny += dy[k];
            nx += dx[k];
            if(!range_check(ny, nx)) break;
            if(table[ny][nx] == '.') break;
            if(table[ny][nx] == s[flag])
            {
                ok = true;
                break;
            }
        }
        if(ok)
        {
            ny = y;
            nx = x;
            while(1)
            {
                ny += dy[k];
                nx += dx[k];
                if(table[ny][nx] == s[flag]) break;
                table[ny][nx] = s[flag];
            }
        }
    }
}
int Search(int y, int x, int flag)
{
    int ret = 0;
    for(int k = 0; k < 8; k++)
    {
        int ny = y;
        int nx = x;
        int cnt = 0;
        while(1)
        {
            ny += dy[k];
            nx += dx[k];
            if(!range_check(ny, nx)) break;
            if(table[ny][nx] == '.') break;
            if(table[ny][nx] == s[flag])
            {
                ret += cnt;
                break;
            }
            if(table[ny][nx] == s[!flag]) cnt++;
        }
    }
    return ret;
}
void Solve()
{
    bool ok = false;
    priority_queue<PP> que;
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            if(table[i][j] != '.') continue;
            int cnt = Search(i, j, 0);
            if(cnt >= 1) que.push(PP(cnt, P(-i, -j)));
        }
    }
    if(!que.empty())
    {
        PP p = que.top();
        Put(-p.second.first, -p.second.second, 0);
        ok = true;
    }
    //clear()がない( 一一)
    que = decltype(que)();
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++)
        {
            if(table[i][j] != '.') continue;
            int cnt = Search(i, j, 1);
            if(cnt >= 1) que.push(PP(cnt, P(i, j)));
        }
    }
    if(!que.empty())
    {
        PP p = que.top();
        Put(p.second.first, p.second.second, 1);
        ok = true;
    }
    if(ok) Solve();
    else return;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++) cin >> table[i][j];
    }
    Solve();
    for(int i = 0; i < 8; i++)
    {
        for(int j = 0; j < 8; j++) cout << table[i][j];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

struct prob { ll num; ll bonus; };

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll D; ll G;
  cin >> D >> G;
  
  vector<prob> ps(D);
  
  rep(i, D) {
    ll p, c;
    cin >> p >> c;
    ps[i] = { p, c };
  }
  
  //まずビット全探索
  ll minprob = LLINF;
  for(int bit=0; bit<(1<<D); bit++) {
    ll sum = 0;
    ll prob = 0;
    //まず最初にボーナスを全て入れないといけない
    for(int d=D-1; d>=0; d--) {
      if(bit & (1<<d)) {
        //ボーナス入れる
        sum += ps[d].bonus + ((d+1) * 100 * (ps[d].num));
        prob += ps[d].num;
        
        if(sum >= G) {
          break; 
        }
      }
    }
    
    if(sum >= G) {
      chmin(minprob, prob);
    } else {
      for(int d=D-1; d>=0; d--) {
        if(bit & (1<<d)) {
        } else {
          //普通に解く (最大，全問題数-1まで) これは，得点が大きい順に見ること！
          ll pers = (d+1) * 100;
          ll nes = (G - sum) / pers + ((G - sum) % pers ? 1 : 0);
          ll addp = min(nes, ps[d].num - 1);  //解ける問題数
          sum += addp * pers;
          prob += addp;
          
          if(sum >= G) {
            break; 
          }
        }
      } 
      if(sum >= G) {
        chmin(minprob, prob);
      }
    }
  }
  
  fin(minprob);
  
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int k = Integer.parseInt(reader.readLine());
		int N = (int) (Math.sqrt(8*k + 1) - 1) / 2;
		int missing = 0;
		if (N*(N + 1)/2 < k) {
			missing = (N + 1) * (N + 2) / 2 - k;
			N++;
		}
		for (int j = 1; j<=N; j++)
			if (j != missing)
				System.out.println(j);
	}
	
}


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

int main()
{
    int n ;
    cin>>n;
    vector<int>v(n);
    for(int i = 0 ;i<n;i++)
    {
        cin>>v[i];
    }
    //int tmp = (n*(n-1))/2;
    long long ans = 0 ;
    for(int i = 0;i<n-1;i++)
    {
        for(int j = i+1;j<n;j++)
        {
            //cout<<v[j]<<endl;
            ans+=v[i]*v[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int n;
  vector<int> p[100001];
  cin >> n;
  int u,v;
  cin >> u >> v;
  LOOP(i,n-1){
    int a,b;
    cin >> a >> b;
    p[a].push_back(b);
    p[b].push_back(a);
  }

  int tak[100001]={};
  LOOP(i,100001){
    tak[i]=INF;
  }
  bool f[100001]={};
  queue<P> q;
  q.push(P(u,0));
  while(!q.empty()){
    P pp = q.front();
    int t = pp.first;
    int sc = pp.second;
    q.pop();
    if(tak[t]<=sc){
      continue;
    }
    tak[t] = sc;
    LOOP(i,p[t].size()){
      q.push(P(p[t][i],sc+1));
    }
  }

  int ao[100001]={};

  q.push(P(v,0));
  while(!q.empty()){
    P pp = q.front();
    int t = pp.first;
    int sc = pp.second;
    q.pop();
    if(f[t])continue;

    f[t] = true;
    ao[t] = sc;
    LOOP(i,p[t].size()){
      q.push(P(p[t][i],sc+1));
    }
  }

  q.push(P(u,0));
  tak[u] = -1, ao[v] = -1;
  int maxt = p[u][0];
  while(!q.empty()){
    P pp = q.front();
    int t = pp.first;
    int sc = pp.second;

    // cerr << "*" << t << ":" << sc << endl;
    q.pop();
    if(!f[t])continue;
    if(sc>ao[t])continue;
    f[t]=false;
    // cerr << "-verifired" << endl;
    if(t!=v)
    if(ao[maxt] < ao[t]){
      maxt = t;
    }

    if(sc==ao[t]) continue;
    // cerr << "--verifired" << endl;
    LOOP(i,p[t].size()){
      q.push(P(p[t][i],sc+1));
    }
  }

  // LOOP1(i,n){
  //   // cerr << i << ":" << tak[i] << " " << ao[i] << endl;
  // }

  // cerr << maxt << endl;

  tak[u] = 0, ao[v] = 0;
  if(maxt==v){
    cout << 0 << endl;
  }
  // else if((ao[maxt]-tak[maxt])%2){
    cout << ao[maxt]-1 << endl;
  // }
}


Measured memory_bytes: 6912
#include<stdio.h>
int num1[512],num2[512];
int wz[512];
int dp[512];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int now=(n<<1)-1;
	for(int i=0;i<n;i++)
	{
		while(i*i+now*now>=n*n)
		{
			now--;
		}
		num1[now]++;
	}
	now=(n<<1)-1;
	for(int i=0;i<(n<<1);i++)
	{
		while(i*i+now*now>(n<<1)*(n<<1))
		{
			now--;
		}
		if(i<n)
		{
			wz[i]=now;
		}
		else
		{
			num2[now]++;
		}
	}
	int ans=0;
	for(int k=0;k<=n;k++)
	{
		for(int i=0;i<=k;i++)
		{
			dp[i]=0;
		}
		dp[0]=1;
		int now=n,numb=0;
		for(int i=0;i<(n<<1);i++)
		{
			int val=num1[i];
			while(val--)
			{
				now--;
				for(int j=k;j>=0;j--)
				{
					if(j<k&&i-j-numb+1>0)
					{
						dp[j+1]+=(long long)dp[j]*(i-j-numb+1)%m;
						if(dp[j+1]>=m)
						{
							dp[j+1]-=m;
						}
					}
					if(wz[now]-(n+n-1-now)-(k-j)+1>0)
					{
						dp[j]=(long long)dp[j]*(wz[now]-(n+n-1-now)-(k-j)+1)%m;
					}
					else
					{
						dp[j]=0;
					}
				}
			}
			val=num2[i];
			while(val--)
			{
				for(int j=0;j<=k;j++)
				{
					if(i-j-numb+1>0)
					{
						dp[j]=(long long)dp[j]*(i-j-numb+1)%m;
					}
					else
					{
						dp[j]=0;
					}
				}
				numb++;
			}
		}
		if(k&1)
		{
			ans-=dp[k];
			if(ans<0)
			{
				ans+=m;
			}
		}
		else
		{
			ans+=dp[k];
			if(ans>=m)
			{
				ans-=m;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc018/tasks/abc018_4

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e18;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
// int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

_Graph _G;
queue<int> que;
int K;

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

 int N;
  cin>>N;
  vector<vector<int>> G(N);
  vector<pair<int,int>> vp;
  for(int i=1;i<N;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a,b);
  }
 
  int K=0;
  map<pair<int,int>,int> I;
  vector<int> cs(N,0); // color of edge between its parent
 
  vector<int> used(N,0);
  queue<int> que;
  used[0]=1;
  que.emplace(0);
  while(!que.empty()){
    int v=que.front();que.pop();
    if(K<(int)G[v].size()) K=G[v].size();
    int cur=1;
    for(int u:G[v]){
      if(used[u]) continue;
      if(cur==cs[v]) cur++;
      cs[u]=I[make_pair(u,v)]=I[make_pair(v,u)]=cur++;
      used[u]=1;
      que.emplace(u);
    }
  }
 
  cout<<K<<endl;
  for(auto p:vp) cout<<I[p]<<endl;
  return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 20084
#include <iostream>
using namespace std;
int main(){
	int k;
	int a,b;
	cin >> k;
	cin >> a >> b;
	for(int i = a;i <= b;i++){
		if(!(i % k)){
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;

}


Measured memory_bytes: 3636
import numpy as np
from scipy import signal

def main():
    N, K = map(int, input().split(" "))
    P = np.array(list(map(int, input().split(" "))))

    e = (P + 1) / 2

    t = np.ones((K))

    print(np.amax(
        signal.fftconvolve(
            e,
            t
        )
    ))

if __name__ == "__main__":
    main()

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

int main(void)
{
    long N;
    cin >> N;
    string c;
    long C[4]={};
    
    while(N!=0)
    {
        cin >> c;
        if(c == "AC")
        {
            C[0]++;
        }
        else if(c == "WA")
        {
            C[1]++;
        }
        else if(c == "TLE")
        {
            C[2]++;
        }
        else if(c == "RE")
        {
            C[3]++;
        }
        N--;
    }
    cout << "AC x " << C[0] << endl << "WA x " << C[1] << endl << "TLE x " << C[2] << endl << "RE x " << C[3] << endl;
    return 0;
}


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

int main(void)
{
  char start, end;
  cin >> start;
  end = start;
  while (cin >> end)
  {
  }
  if (start != end or start == 'o')
  {
    cout << 'o' << endl;
  }
  else
  {
    cout << 'x' << endl;
  }
  return 0;
}

Measured memory_bytes: 1132
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,v,w,t;
int main(){
	scanf("%lld%lld%lld%lld%lld",&a,&v,&b,&w,&t);
	if(v<=w)puts("NO"),exit(0);
	puts(abs(a-b)<=t*(v-w)?"YES":"NO");
	return 0;
}

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

int main() {
    int K;
    string S;
  	cin >> K;
  	cin >> S;
    if ((int)(S.length()) <= K) {
        cout << S;
    } else {
        cout << S.substr(0, K) << "...";
    }
}

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

typedef long long ll;

string S, T;
ll N, M;
string S2;
const ll BASE = 34567, MOD = 1e9 + 7;
ll BASE_POW_N;
vector<vector<ll>> Out;
vector<ll> Seen;
vector<ll> Order;
vector<ll> Dp;
ll R;

void make_graph() {
  while (S2.size() < M + N) S2 += S;
  BASE_POW_N = 1;
  for (ll i = 0; i < M; ++i) (BASE_POW_N *= BASE) %= MOD;
  ll t_hash = 0;
  for (ll i = 0; i < M; ++i) {
    (t_hash = t_hash * BASE + (T[i] - 'a')) %= MOD;
  }
  Out.resize(N);
  ll hash = 0;
  for (ll i = 0; i < M; ++i) {
    (hash = hash * BASE + (S2[i] - 'a')) %= MOD;
  }
  for (ll i = 0; i < N; ++i) {
    if (hash == t_hash) {
      Out[i].push_back((i + M) % N);
    }
    (hash = hash * BASE + (S2[i + M] - 'a')) %= MOD;
    (hash += MOD - BASE_POW_N * (S2[i] - 'a') % MOD) %= MOD;
  }
}
bool dfs(ll v) {
  if (Seen[v] == 1) return true;
  if (Seen[v] == -1) return false;
  Seen[v] = -1;
  for (ll w : Out[v])
    if (!dfs(w)) return false;
  Seen[v] = 1;
  Order.push_back(v);
  return true;
}
ll solve() {
  Seen.resize(N);
  for (ll v = 0; v < N; ++v) {
    if (!dfs(v)) return -1;
  }
  reverse(Order.begin(), Order.end());
  Dp.resize(N);
  for (ll v : Order) {
    R = max(R, Dp[v]);
    for (ll w : Out[v]) Dp[w] = max(Dp[w], Dp[v] + 1);
  }
  return R;
}
int main() {
  cin >> S >> T;
  N = S.size();
  M = T.size();
  make_graph();
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 64140
def main():
    N, W = map(int, input().split())
 
    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))
 
 
main()

Measured memory_bytes: 9772
#include <iostream>
using namespace std;
int M[10][10];

int count(int &a, int &b, int &c, int &d, int &e){
  int cnt = 0;
  int A[5] = {a,b,c,d,e};
  for(int i = 0; i < 5; ++i){
    for(int j = 0; j < 10; ++j){
      int B[5];
      if(A[i] == j) continue;
      for(int k = 0; k < 5; ++k){
	if(k == i) B[k] = j;
	else B[k] = A[k];
      }
      if(!M[M[M[M[M[0][B[0]]][B[1]]][B[2]]][B[3]]][B[4]])
	++cnt;
    }
  }
  for(int i = 0; i < 4; ++i){
    if(A[i] == A[i+1]) continue;
    swap(A[i],A[i+1]);
    if(!M[M[M[M[M[0][A[0]]][A[1]]][A[2]]][A[3]]][A[4]])
      ++cnt;
    swap(A[i],A[i+1]);
  }
  if(cnt) return 1;
  else return 0;
}

int main(){
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j)
      cin >> M[i][j];
  int ans = 0;
  for(int i = 0; i < 10; ++i){
    for(int j = 0; j < 10; ++j){
      for(int k = 0; k < 10; ++k){
	for(int l = 0; l < 10; ++l){
	  int e = M[M[M[M[0][i]][j]][k]][l];
	  ans += count(i,j,k,l,e);
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	vector<map<char, int>>hash(n);
	string s;
	rep(i, n) {
		cin >> s;
		for (auto& c : s)hash[i][c]++;
	}
	for (int i = 'a';i <= 'z';++i) {
		int mn = 1e9;
		for (int j = 0;j < n;++j) {
			mn = min(mn, hash[j][i]);
		}
		if (mn > 0)cout << string(mn, i);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
/*
      H   H
       \ / 	
        C
       / \ 
      H   H
*/

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        998244353
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  100005

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int k;
		cin >> k;
		string s;
		cin >> s;
		int n = sz(s);
		if(n<=k)
			cout << s;
		else
			cout << s.substr(0, k) << "...";
	}
	return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int main(){

    int H, W, K;
    int i,j;
    cin >> H >> W >> K;

    vector<vector<char> > s(H, vector<char>(W));
    vector<vector<int> > ans(H, vector<int>(W));

    for(i=0; i<H; i++)
        for(j=0; j<W; j++)
            cin >> s.at(i).at(j);

   
    int ncol = 0;
    int cake = 1;
    int straw = 0;

    for(i=0; i<H; i++){
        
        // check whether '#' exists in s[i] row
        for(j=0; j<W; j++){
            if(s.at(i).at(j) == '#') straw++;
        }
        
        // which means '#' does not exist
        if(straw == 0){
            ncol++;
            continue;
        }
        
        // there are strawberries in right above row.
        if(straw == 1){
            for(j=0; j<W; j++) ans.at(i).at(j) = cake;
            cake++;
        }
        else{
            for(j=0; j<W; j++){
                if(straw == 1){
                    ans.at(i).at(j) = cake;
                }
                else{
                    ans.at(i).at(j) = cake;
                    if(s.at(i).at(j) == '#'){
                        straw--;
                        cake++;
                    }
                }
            }
            cake++;
        }

        // fill right above row if there is no strawberry in there
        if(ncol != 0){
            for(; ncol > 0; ncol--){
                for(j=0; j<W; j++){
                    ans.at(i-ncol).at(j) = ans.at(i).at(j);
                }
            }
        }
        
        straw = 0;
    }
   
    // need to fill out if there is no strawberry in s.at(H)
    if(ncol != 0){
        for(i=H-ncol; i<H; i++){
            for(j=0; j<W; j++){
                ans.at(i).at(j) = ans.at(H-ncol-1).at(j);
            }
        }
    }
   
   
   
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            cout << ans.at(i).at(j) << " ";
        }
        cout << endl;
    }
    


    return 0;
}



Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
 
using namespace std;
  
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  
  string ans = "APPROVED";
  for(int i=0;i<N;i++){
    if((A[i]%2) == 0){
      if(!(((A[i]%3) == 0) || ((A[i]%5) == 0))){
        ans = "DENIED";
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int N = 20000;
const int M = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int t1=h1*60+m1;
	int t2=h2*60+m2;
	cout<<t2-t1-k;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = 1e9+7;

using namespace std;
int N,M,R;
vector<vector<int>> g;

vector<int> r;

bool v[205];

long long dfs(int d,int now,long long cost){
	long long ret = INF;
	if(d==R){
		return cost;
	}
	rep(i,R){
		if(v[r[i]])continue;
		v[r[i]] = 1;
		ret = min(ret,dfs(d+1,r[i],cost + g[now][r[i]]));
		v[r[i]] = 0;
	}
	return ret;
}


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M >> R;
	r = vector<int>(R);
	rep(i,R){
		cin >> r[i];
		r[i]--;
	}
	g = vector<vector<int>>(N,vector<int>(N,inf));
	rep(i,M){
		int a,b,c;
		cin >> a >> b >> c;
		a--;b--;
		g[a][b] = min(g[a][b],c);
		g[b][a] = min(g[b][a],c);
	}
	rep(k,N)rep(i,N)rep(j,N)g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
	long long ans = INF;
	rep(i,R){
		v[r[i]] = 1;
		ans = min(ans,dfs(1,r[i],0));
		v[r[i]] = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner (System.in);
		int a = 0;
		for(int i = 1;i>0;i++){
			int n = scan.nextInt();
			if(n>=0&n<=999) {
				a = n;
				break;
			}}
			if(a>=100) {
				for(int j =0;j<11;j++) {
					a=a-100;
					if(a<100) {
						break;
					}
					
				}
			}
			else {}
				
				if(a>=10) {
					for(int j =0;j<11;j++) {
						a=a-10;
						if(a<10) {
							break;
						}
					}
				}
					else {
					}
			
				if(a==2||a==4||a==5||a==7||a==9) {
					System.out.println("hon");
				}
				else if(a==0||a==1||a==6||a==8) {
					System.out.println("pon");
				}
				else {
					System.out.println("bon");
				}
		}
		
		
		
	}

Measured memory_bytes: 35728
s = input()
if s == 'SUN':
	print('7')
elif s == 'MON':
	print('6')
elif s == 'TUE':
	print('5')
elif s == 'WED':
	print('4')
elif s == 'THU':
	print('3')
elif s == 'FRI':
	print('2')
elif s == 'SAT':
	print('1')


Measured memory_bytes: 2940
import copy
from collections import defaultdict


num = int(input())

d = defaultdict(int)
for i in range(1, num+1):
    s = str(i)
    start = int(s[0])
    end = int(s[-1])
    d[(start, end)] += 1

ans = 0
queue = sorted(d.keys())
for (start, end) in queue:
    if start > end:
        continue
    elif start == end:
        ans += d[(start, end)] ** 2
    else:
        ans += (d[(start, end)] * d[(end, start)]) * 2

print(ans)


Measured memory_bytes: 3444
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, C, X, Y = map(int, read().split())

cnt_A = max(X, Y)
cnt_B = max(X, Y)

ans = 10**9 + 1

for i in range(int(1e5 + 1)):
    acc = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, acc)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b;

    cin >> a >> b;

    if (a + b < 10) {
        cout << a + b;
    } else {
        cout << "error";
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<string> S(N);
  rep(i,N) cin>>S[i];

  vector<int> sumd(N,0),mid(N,0);
  for(int i=0;i<N;i++){
      int dep=0;
      for(int j=0;j<S[i].size();j++){
          if(S[i][j]=='(') dep++;
          else dep--;
          chmin(mid[i],dep);
      }
      sumd[i]=dep;
  }

  int sum=0;
  rep(i,N) sum+=sumd[i];
  if(sum!=0){
      cout<<"No"<<endl;
      return 0;
  }

  vector<pair<int,int>> plus,minus;
  int zero=0;
  for(int i=0;i<N;i++){
      if(sumd[i]>0) plus.push_back(mkp(mid[i],i));
      else if(sumd[i]<0) minus.push_back(mkp(sumd[i]-mid[i],i));
      else chmin(zero,mid[i]);
  }
  sort(plus.rbegin(),plus.rend());

  int depth=0;
  for(int i=0;i<plus.size();i++){
      int now=plus[i].second;
      if(depth+mid[now]<0){
          cout<<"No"<<endl;
          return 0;
      }
      depth+=sumd[now];
  }
  if(zero+depth<0){
      cout<<"No"<<endl;
      return 0;
  }

  sort(minus.rbegin(),minus.rend());

  for(int i=0;i<minus.size();i++){
      int now=minus[i].second;
      if(depth+mid[now]<0){
          cout<<"No"<<endl;
          return 0;
      }
      depth+=sumd[now];
  }

  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 50296