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

#define ll long long

#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define fill(a,b) memset(a,b,sizeof(a))

#define f first
#define s second
#define pb push_back

#define inf 1e17
#define ninf -1*1e17
#define mod 1000000007
#define N 500005
#define Ns 5005

string s;
ll n,m,o,x,y,z,d,k,l,r;
ll a[N],b[N];

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--){
	    
	    ll ans=0;
	    cin>>n;
	    for(int i=0;i<n;i++){
	        cin>>a[i];
	    }
	    for(int i=0;i<n;i++){
	        cin>>b[i];
	    }
	    reverse(b,b+n);
	    
	    int j=0;
	    for(int i=0;i<n;i++){
	        if(a[i]==b[i]){
	            j=i;
	            break;
	        }
	    }
	   // cout<<j<<" ^\n";
	    ll val=b[j];
	   // cout<<val<<" $\n";
	    for(int i=0;i<n;i++){
	        
	        if(a[j]!=b[j]){
	            break;
	        }
	        if( a[i]!=b[i] && a[i]!=val && b[i]!=val){
	            
	            ll temp=b[i];
	            b[i]=b[j];
	            b[j]=temp;
	            
	            j++;
	        }
	    }
	   // cout<<j<<" *\n";
	    if(a[j]==b[j]){
	        cout<<"No\n";
	    }
	    else
	    {
	        cout<<"Yes\n";
	        for(int i=0;i<n;i++){
	           cout<<b[i]<<" ";
	        }
	        cout<<"\n";
	    }
	    
	}
	return 0;
}


Measured memory_bytes: 6820
# coding: utf-8
# Your code here!
N,W=map(int,input().split())

l=[-1]*(W+1)
l[0]=0
dp=l[:]

for i in range(N):
    w,v=map(int,input().split())
    for index,item in enumerate(l):
        if item!=-1 and W>=index+w:
            dp[index+w]=max(item+v,l[index+w])
    l=dp[:]
print(max(l))


Measured memory_bytes: 92240
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(void) {
	int h, w,bomb;
	char board[51][51] = {0};
	scanf("%d %d", &h, &w);

	for (int i = 1; i <= h; i++) {
		scanf("%s", &board[i][1]);
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (board[i][j] == '.') {
				bomb = 0;
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						if (board[i + k][j + l] == '#')bomb++;
					}
				}
				board[i][j] = '0' + bomb;
			}
		}
	}

	for (int k = 1; k <= h; k++) {
		for (int l = 1; l <= w; l++) {
			printf("%c", board[k][l]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 128
def calc(cum, p1, p2, p3):
    arr = [0]*4
    arr[0] = cum[p1]
    arr[1] = cum[p2] - cum[p1]
    arr[2] = cum[p3] - cum[p2]
    arr[3] = cum[-1] - cum[p3]
    return max(arr) - min(arr)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(n-1):
        a[i+1] += a[i]
    ans = float("inf")
    for i in range(1, n-2):
        p2 = i
        v = a[i]
        L, R = 0, p2
        while L+1 < R:
            P = (L+R)//2
            if a[P] <= v//2:
                L = P
            else:
                R = P
        p1 = L
        L, R = -1, p2-1
        while L+1 < R:
            P = (L+R+1)//2
            if a[P] <= v//2:
                L = P
            else:
                R = P
        p1_ = R
        L, R = p2+1, n-1
        while L+1 < R:
            P = (L+R)//2
            if a[P]-v <= (a[-1]-v)//2:
                L = P
            else:
                R = P
        p3 = L
        L, R = p2, n-2
        while L+1 < R:
            P = (L+R+1)//2
            if a[P]-v <= (a[-1]-v)//2:
                L = P
            else:
                R = P
        p3_ = R
        arr = [0]*4
        arr[0] = calc(a, p1, p2, p3)
        arr[1] = calc(a, p1_, p2, p3)
        arr[2] = calc(a, p1, p2, p3_)
        arr[3] = calc(a, p1_, p2, p3_)
        x = min(arr)
        if x < ans:
            ans = x
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 102440
from operator import itemgetter
N=int(input())
SP = [input().split() for l in range(N)]
SP2 = []
for i in range(N):
    SP[i][1]=int(SP[i][1])
    SP[i].append(i+1)
    SP2.append(tuple(SP[i]))
    
SP2 = sorted(SP2, key=itemgetter(1),reverse=True)
SP2 = sorted(SP2, key=itemgetter(0))
for j in range(N):
    print(SP2[j][2])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vct vector<ll>

struct Query{
    ll idx,l,r;
};
vct bit,lsv;
bool srt(Query a, Query b){
    return a.r<b.r;
}

void updateBit(ll idx, ll val, ll n){
    while(idx<=n){
        bit[idx]+=val;
        idx+=(idx&(-idx));
    }
}
ll queryBit(ll idx, ll n){
    ll ans=0;
    while(idx>0){
        ans+=bit[idx];
        idx-=(idx&(-idx));
    }
    return ans;
}

int main(){
    ll n,q;
    cin>>n>>q;
    vct v(n+1);
    for(ll i=0;i<n;i++)cin>>v[i+1];
    bit.resize(n+1,0);
    vector<Query> qry(q);
    for(ll i=0;i<q;i++){
        ll l,r;
        cin>>l>>r;
        qry[i]={i,l,r};
    }
    vct ans(q,0);
    sort(qry.begin(),qry.end(),srt);

    lsv.resize(1000001,-1);
    ll j=0;
    for(ll i=1;i<=n;i++){
        // for(ll i=0;i<=n;i++)cout<<bit[i]<<" ";
        cout<<"\n";
        ll cr=v[i];
        if(lsv[cr]!=-1)updateBit(lsv[cr],-1,n);
        updateBit(i,1,n);
        // for(ll i=1;i<=n;i++)cout<<bit[i]<<" ";
        lsv[cr]=i;
        while((j<q)&&(qry[j].r==i)){
            ans[qry[j].idx]=queryBit(qry[j].r,n)-queryBit(qry[j].l-1,n);
            j++;
        }
    }
    for(ll i=0;i<q;i++)cout<<ans[i]<<"\n";
}

Measured memory_bytes: 35460
import java.util.Scanner;

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

		if(a < b) {
			for(int i = 0; i < b; i++) {
				System.out.print(a);
			}
		}else {
			for(int i = 0; i < a; i++) {
				System.out.print(b);
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 23636
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

int main(){
    ll n; cin >> n;
    vector<ll> a; a.resize(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll cnt = 1;
    ll ans = 0;
    REP(i, n-1){
        if (a[i]==a[i+1]){
            cnt++;
        }
        else{
            ans = (cnt%2) ? ans+1: ans;
            cnt = 1;
        }
    }
    if (cnt%2) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


/////////////////////////////////////////////////////////////////////////////////////////
int dX[2] = {1,0};
int dY[2] = {0,1};

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

    int n;
    cin >> n;
    vector<int> l(n);

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

    sort(l.begin(),l.end());
    ll ans = 0;
    for (int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            auto itr = lower_bound(l.begin(),l.end(),l[i] + l[j]);

            ans += distance(l.begin() + j + 1,itr);
        }
    }

    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, ll, ll, ll>T;
#define PI 3.14159265359
#define MOD 1000000007
int main(){
 string s,t;
  cin>>s>>t;
  int n=s.size();
  int flag=0;
  rep(i,n){
    if(s[i]!=t[i]){flag=1;}
  }
  if(flag==1){cout<<"No";}
  else{cout<<"Yes";}
}

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

class Program
{
    static void Main(string[] args) {
        long n = long.Parse(Console.ReadLine());
        List<long> l = new List<long>();
        for (int i = 0;i < 5; i ++) {
            l.Add(long.Parse(Console.ReadLine()));
        }
        long min = l.Min();
        long t = n / min + (n % min == 0 ? 0 : 1) + 4;
        Console.WriteLine(t);
    }
}

Measured memory_bytes: 13268
#include <iostream>
 
  
 
using namespace std;
 
  
 
int main()
{
    int a, b, c;
     
    cin >> a >> b >> c;
    if (a < b && b < c )
      cout << "Yes" << endl;
 
    else
      cout << "No" << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	vector<int> arr(10);
	
	for(int i = 0; i < 10; i++){
		cin >> arr[i];
	}
	
	sort(arr.begin(),arr.end());
	
	printf("%d\n%d\n%d\n",arr[9],arr[8],arr[7]);
	
	return 0;
}

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

int main()
{
	int x[5];
	cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
	int out = 0;
	rep( i, 5 ) {
		if( x[i] == 0 ) {
			out = i;
			break;
		}
	}
	
	cout << (out+1);
	
	return 0;
}


Measured memory_bytes: 3588
N, K = map(int, input().split())

L, R = [], []

for _ in range(K):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

dp = [0] * 300000
dpsum = [0] * 300000
dp[1] = 1
dpsum[1] = 1

for i in range(2, N+1):
    for j in range(K):
        li = min(L[j], i)
        ri = min(R[j], i + 1)
        dp[i] += dpsum[i - li] - dpsum[i - ri - 1]

    dp[i] %= 998244353
    dpsum[i] = dpsum[i-1] + dp[i]

print(dp[N])

Measured memory_bytes: 29408
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Scan()
	a, _ := strconv.ParseFloat(sc.Text(), 64)
	sc.Scan()
	b, _ := strconv.ParseFloat(sc.Text(), 64)
	sc.Scan()
	x, _ := strconv.ParseFloat(sc.Text(), 64)
	var theta float64
	if x <= a*a*b/2 {
		surface := x / a
		base := 2.0 * surface / b
		theta = math.Atan(b/base) * 180 / math.Pi
	} else {
		surface := (a*a*b - x) / a
		base := 2.0 * surface / a
		theta = math.Atan(base/a) * 180 / math.Pi
	}
	fmt.Println(theta)
}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define fo(i,k,n) for(i=k;i<=n;i++)
#define endl '\n'
ll lcsh(char* s,char* t,ll m,ll n,ll** dp,bool** visit,string &answer){
	//already calculated
	//cout<<answer<<endl;
	if(visit[m][n]) return dp[m][n];
	//base case
	if(m==0 || n==0) {
		return 0;
	}
	//relation
	ll ans =0;
	if(s[0]==t[0]) {
		answer+=s[0];
		ans = 1+lcsh(s+1,t+1,m-1,n-1,dp,visit,answer);
		//cout<<s[0]<<endl
	}
	else{
		string myans1 = answer;
		ll op1 = lcsh(s+1,t,m-1,n,dp,visit,myans1);
		string myans2 = answer;
		ll op2 = lcsh(s,t+1,m,n-1,dp,visit,myans2);
		if(op1>op2) {
			ans = op1;
			answer = myans1;
		}
		else {
			ans = op2;
			answer = myans2;
		}
	}
	visit[m][n]=true;
	return dp[m][n]=ans;
}
ll lcs_length(char* s,char* t){
	ll i,j,m = strlen(s),n = strlen(t);
	ll** dp = new ll*[m+1];
	for(i=0;i<=m;i++){
		dp[i] = new ll[n+1];
	}
	bool **visit = new bool*[m+1];
	for(i=0;i<=m;i++) {
		visit[i] = new bool[n+1];
		for(j=0;j<=n;j++) visit[i][j]=false;
	}
	string aaa="";
	ll ans=lcsh(s,t,m,n,dp,visit,aaa);
	for(i=0;i<=m;i++){
		delete [] dp[i];
		delete [] visit[i];
	}
	delete [] dp;
	delete [] visit;
	return ans;
}
string lcs_i(char* s,char* t){
	ll m = strlen(s);
	ll n = strlen(t);
	ll dp[m+1][n+1];
	ll i,j;
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			if(i==0||j==0) dp[i][j]=0;
			else if(s[i-1]==t[j-1]){
				dp[i][j] = 1 + dp[i-1][j-1];
			}else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	//cout<<dp[m][n]<<endl;
	ll index = dp[m][n];
	i=m;j=n;
	char lcsstr[index+1];
	lcsstr[index]='\0';
	index--;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){
			lcsstr[index] = s[i-1];
			//cout<<s[i-1]<<endl;
			i--;j--;index--;
		}else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}else j--;
	}
	return lcsstr;
}
void solve(){
	ll i,j;
	char s[3005],t[3005];
	cin>>s>>t;
	//cout<<lcs_length(s,t)<<endl;
	cout<<lcs_i(s,t)<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 70656
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (i % 2 == 1 && a[i].second % 2 == 0)
      ++ans;
  cout << ans;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1024
P = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051,
1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451]
n = int(input())
for i in range(n-1):
    print(P[i], end = " ")
print(P[n-1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

vector<bool> SievePrimes(long long n) {
  vector<bool> primes(n,true);
  primes[0] = primes[1] = false;

  ll m = 6;
  bool flag = true;
  while (m*m <= n) {
    if (primes[m]) {
      for (ll i = m; i <= n; i += m) {
        if (i == m) continue;
        if (primes[i]) {
          primes[i] = false;
        }
      }
    }
    if (flag) {
      m += 2;
    } else {
      m += 5;
    }

    flag = !flag;
  }

  return primes;
}

int main() {
  auto p_primes = SievePrimes(300010);

  while (true) {
    int n;
    cin >> n;
    if (n == 1) break;
    cout << n << ": ";
    vector<int> ans;
    int cp = n;
    for (int i = 0; i <= cp; ++i) {
      if ((i % 7 == 1 || i % 7 == 6) && p_primes[i]) {
        auto prime = i;
        if (n % prime == 0) ans.push_back(i);
      }
    }
    for (int i = 0; i < ans.size(); ++i) {
      if (i == ans.size() - 1) {
        cout << ans[i];
      } else {
        cout << ans[i] << " ";
      }
    }
    cout << endl;
  }
}


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

#define all(v) (v).begin(), (v).end()
using namespace std;

int ceil(long long numerator, long long denominator)
{
	return (numerator/denominator + (numerator%denominator != 0));
}

int possible(vector <long long> H, long long A, long long B, long long explosions)
{
	for(int i = 1; i < H.size(); i++)
	{
		H[i] -= (explosions*B);
	}
	
	long long explosions_used = 0;
	for(int i = H.size() - 1; i > 0 && H[i] > 0; i--)
	{
		explosions_used += ceil(H[i], A - B);
	}
	
	return (explosions_used <= explosions);
}

int main() 
{
    int no_of_monsters, A, B;
    cin >> no_of_monsters >> A >> B;
    
    vector <long long> health(no_of_monsters + 1);
    for(int i = 1; i <= no_of_monsters; i++)
    	cin >> health[i];
    	
    sort(all(health));
    
    long long left = 1, right = 1e9;
    while(left <= right)
    {
    	long long mid = (left + right) >> 1;
    	
    	if(possible(health, A, B, mid))
    	{
    		if(mid == left || !possible(health, A, B, mid - 1))
    		{
    			printf("%lld\n", mid);
    			break;
    		}
    		else
    		{
    			right = mid - 1;
    		}
    	}
    	else
    	{
    		left = mid + 1;
    	}
    }
	return 0;
}


Measured memory_bytes: 1920
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s: String = line
        .trim()
        .split_whitespace()
        .map(|x| x.chars().nth(0).unwrap())
        .collect();
    println!("{}", s);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int x;
int main() {
    DAU
    cin >> x;
    cout << 10 - x / 200;
    PLEC
}


Measured memory_bytes: 3660
/*
    Partition
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_B
*/
#include <bits/stdc++.h>
using namespace std;

int Partition(vector<int> &A, int p, int r) {
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

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

    int n;
    cin >> n;
    vector<int> vi(n);

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

    int pivot = Partition(vi, 0, vi.size() - 1);
    for (size_t i = 0; i < vi.size(); i++) {
        if ((int)i == pivot) {
            cout << "[" << vi[i] << "]";
        } else {
            cout << vi[i];
        }

        if (i != vi.size() - 1)
            cout << " ";
        else
            cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	res := make(map[byte]int)

	for {
		s, err := reader.ReadString('\n')
		for i := 0; i < len(s); i++ {
			if s[i] < 'a' {
				res[s[i]+'a'-'A']++
			} else {
				res[s[i]]++
			}
		}
		if err != nil {
			break
		}
	}
	for i := byte('a'); i <= 'z'; i++ {
		fmt.Println(string(i), ":", res[i])
	}
}



Measured memory_bytes: 1104
#import 
#=input()
n=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]

print((10 ** n - 2 * (9 ** n) + 8 ** n) % (10 ** 9 + 7))

Measured memory_bytes: 11044
#include <stdio.h>
#include <stdlib.h>
 
typedef struct Bomb
{
    int map[8][8];
} BOMB;
 
int x_cnt, y_cnt;
 
Input(BOMB *);
BOMB *explode(BOMB *);  /*Recursion*/
 
int main()
{
    int input_times, input_cnt;
    BOMB Bomb[50];
    int x, y;
     
    scanf("%d", &input_times);
    for(input_cnt = 0; input_cnt < input_times; input_cnt++){
        Input(&Bomb[input_cnt]);
		scanf("%d\n%d", &x, &y);
		Bomb[input_cnt].map[x - 1][y - 1] = 2;
        explode(&Bomb[input_cnt]);
    }
    
    for(input_cnt = 0; input_cnt < input_times; input_cnt++){
        printf("Data %d:\n", input_cnt + 1);
        for(y_cnt = 0; y_cnt < 8; y_cnt++){
            for(x_cnt = 0; x_cnt < 8; x_cnt++)
                printf("%d", Bomb[input_cnt].map[x_cnt][y_cnt]);
            printf("\n");
        }
    }
	
    return 0;
}

Input(BOMB *bomb)
{
    /*Read input map*/
    char dump;      /*Get rid of enter*/
    dump = getchar();
    for(y_cnt = 0; y_cnt < 8; y_cnt++)
    {
        dump = getchar();
        for(x_cnt = 0; x_cnt < 8; x_cnt++)
            bomb->map[x_cnt][y_cnt] = getchar() - 48;    /*ASCII table*/
    }
    
}
 
BOMB* explode(BOMB* bomb_map)
{
    int explode_cnt;
    for(y_cnt = 0; y_cnt < 8; y_cnt++)
        for(x_cnt = 0; x_cnt < 8; x_cnt++)
        {
            /*Find exploded bomb and process*/
            if(bomb_map->map[x_cnt][y_cnt] == 2)
            {
                bomb_map->map[x_cnt][y_cnt] = 0;
                /*Left*/
                explode_cnt = 1;
                while((x_cnt - explode_cnt) >= 0 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt - explode_cnt][y_cnt]) == 1)
                        (bomb_map->map[x_cnt - explode_cnt][y_cnt]) = 2;
                    explode_cnt++;
                }
                /*Right*/
                explode_cnt = 1;
                while((x_cnt + explode_cnt) <= 7 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt + explode_cnt][y_cnt]) == 1)
                        (bomb_map->map[x_cnt + explode_cnt][y_cnt]) = 2;
                    explode_cnt++;
                }
                /*Down*/
                explode_cnt = 1;
                while((y_cnt - explode_cnt) >= 0 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt][y_cnt - explode_cnt]) == 1)
                        (bomb_map->map[x_cnt][y_cnt - explode_cnt]) = 2;
                    explode_cnt++;
                }
                /*Up*/
                explode_cnt = 1;
                while((y_cnt + explode_cnt) <= 7 && explode_cnt <= 3)
                {
                    if((bomb_map->map[x_cnt][y_cnt + explode_cnt]) == 1)
                        (bomb_map->map[x_cnt][y_cnt + explode_cnt]) = 2;
                    explode_cnt++;
                }
                return explode(bomb_map);
            }
        }
    return bomb_map;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
const int N = 45, S = 1 << 18, mod = 1000000007;
int n, X, Y, Z, dp[N][S];
int ksm(int a,int b)
{
	int ans = 1;
	while(b)
	{
		if(b & 1) ans = 1LL * ans * a % mod;
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return ans;
}
int main()
{
	scanf("%d%d%d%d", &n, &X, &Y, &Z);
	dp[0][0] = 1;
	int G = X + Y + Z;
	int tmp = (1 << (X + Y + Z - 1)) | (1 << (Y + Z - 1)) | (1 << (Z - 1));
	for(int i=1;i<=n;i++)
	{
		for(int s=0;s<(1<<G);s++) 
		{
			if(dp[i - 1][s])
			{
				for(int p=1;p<=10;p++)
				{
					int t = (s << p) | (1 << (p - 1));
					t &= ((1 << G) - 1);
					if(((t & tmp) != tmp))
						dp[i][t] = (dp[i][t] + dp[i - 1][s]) % mod;
				}
			}
		}
	}
	int res = 0;
	for(int s=0;s<(1<<G);s++) if((s & tmp) != tmp)
		res = (res + dp[n][s]) % mod;
	int powten = ksm(10, n); 
	printf("%d", (powten - res + mod) % mod);
}

Measured memory_bytes: 22372
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, a, b, c = map(int, input().split())
l = list(int(input()) for i in range(n))

ans = 0
mpa = mpb = mpc = 0
mp = [0,0,0]
INF = 10**4

groups = [[]*n for _ in range(3)]

def dfs(groups, parent=-1):
    groupa = groups[0]
    groupb = groups[1]
    groupc = groups[2]

    if parent == n-1:
        if len(groupa) > 0:mpa = 10 * (len(groupa)-1) + abs(sum(groupa)-a)
        else: mpa = INF

        if len(groupb) > 0:mpb = 10 * (len(groupb)-1) + abs(sum(groupb)-b)
        else: mpb = INF

        if len(groupc) > 0:mpc = 10 * (len(groupc)-1) + abs(sum(groupc)-c)
        else: mpc = INF

        return mpa+mpb+mpc

    else:
        parent+=1

        addl = [l[parent]]

        adda = dfs([groupa+addl ,groupb, groupc], parent)
        addb = dfs([groupa, groupb+addl, groupc], parent)
        addc = dfs([groupa, groupb, groupc+addl], parent)
        noadd = dfs([groupa,groupb,groupc],parent)

        return min(adda, addb, addc, noadd)

print(dfs(groups))


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

int main() {
    int W, H, K;
    scanf("%d %d %d", &W, &H, &K);
    auto solve = [&](int W, int H) {
        long long ans = 0;
        for (int d = 0; d <= H - 2; d++) {
            for (int j = 1; j < W && d * j <= 2 * K + W; j++) {
                int t = 2 * K - 2 - d * j + __gcd(W, d);
                if (t < 0) continue;
                int i = min(H - d - 1, t / W + 1);
                if (i * W - __gcd(i, j) - __gcd(W - j, i + d) > t) i--;
                ans += i * (!d ? 1 : 2);
            }
        }
        return ans;
    };
    printf("%lld\n", (solve(W, H) + solve(H, W)) * 2);
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define REP(a,b) for(int a=0; a<(b); ++a)
#define FWD(a,b,c) for(int a=(b); a<(c); ++a)
#define FWDS(a,b,c,d) for(int a=(b); a<(c); a+=d)
#define BCK(a,b,c) for(int a=(b); a>(c); --a)
#define ALL(a) (a).begin(), (a).end()
#define SIZE(a) ((int)(a).size())
#define VAR(x) #x ": " << x << " "
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define gcd __gcd
#define x first
#define y second
#define st first
#define nd second
#define pb push_back

using namespace std;

template<typename T> ostream& operator<<(ostream &out, const vector<T> &v){ out << "{"; for(const T &a : v) out << a << ", "; out << "}"; return out; }
template<typename S, typename T> ostream& operator<<(ostream &out, const pair<S,T> &p){ out << "(" << p.st << ", " << p.nd << ")"; return out; }

typedef long long LL;
typedef pair<int, int> PII;
typedef long double K;
typedef vector<int> VI;

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

int n;
int A[100010];

bool check(){
	int s = 0;
	int c = 0;
	bool o = 0;
	FWD(i,0,n){
		if(A[i] == 1) o = 1;
		if((A[i]-1)&1)
			s = 1-s;
		else
			++c;
	}
	if(o) return s;
	if(s) return 1;
	if(c != 1) return 0;
	FWD(i,0,n) if(A[i]&1) --A[i];
	int g = A[0];
	FWD(i,1,n) g = gcd(g, A[i]);
	FWD(i,0,n) A[i] /= g;
	return !check();
}

int main(){
	scanf("%d", &n);
	FWD(i,0,n){
		scanf("%d", &A[i]);
	}
	printf(check()?"First\n":"Second\n");
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int D = in.nextInt();
            System.out.println(Math.max(A * B, C * D));
        }
    }
}


Measured memory_bytes: 9680
import java.util.Scanner;

public class Main {
    public static void main(String[] agrs) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	if(a<3 || a>10000) {
    		System.exit(0);
    	}
    	for(int i=1;i<=a;i++) {
    		if(i%3==0 || i%10==3 || i%100==3 || (i % 100)/10==3||(i % 1000)/100==3||(i /1000)==3) {
    			System.out.print(" "+i);
    		}
    	}
    	System.out.println();
    	sc.close();
     	}
    }


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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	vector<int> ans(n);
	int ev(1), od(0);
	for(int i(1);i<n;++i){
		if(s[i] == 'R'){
			if(i % 2 == 0) ev++;
			else od++;
		}
		if(s[i-1] == 'R' && s[i] == 'L'){
			if(i % 2 == 0){
				ans[i] += ev;
				ans[i-1] += od;
			}else{
				ans[i] += od;
				ans[i-1] += ev;
			}
			ev = od = 0;
		}
	}
	vector<char> t(n);
	rep(i,n) t[n-1-i] = s[i];
	ev = 1;
	od = 0;
	for(int i(1);i<n;++i){
		if(t[i] == 'L'){
			if(i % 2 == 0) ev++;
			else od++;
		}
		if(t[i-1] == 'L' && t[i] == 'R'){
			if(i % 2 == 0){
				ans[n-1-i] += ev;
				ans[n-i] += od;
			}else{
				ans[n-1-i] += od;
				ans[n-i] += ev;
			}
			ev = od = 0;
		}
	}
	rep(i,n) cout << ans[i] << ' ';
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        String s = scanner.next();
        boolean bd;
        boolean ac;
        if (b < c && c < d) {
            bd = calculate(n, b, d, s)[d];
            ac = calculate(n, a, c, s)[c];
            if (bd && ac) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else if (c < b && b < d) {
            bd = calculate(n, b, d, s)[d];
            ac = calculate(n, a, c, s)[c];
            if (bd && ac) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            boolean[] dp = calculate(n, b, d, s);
            if (dp[d] == false) {
                System.out.println("No");
                return;
            }
            Set<Integer> bStands = new TreeSet<>();
            for (int i = b; i <= d; ++i) {
                if (dp[i]) {
                    bStands.add(i);
                }
            }
            boolean[] aDp = calculate(n, a, c, s);
            if (aDp[c] == false) {
                System.out.println("No");
                return;
            }
            Set<Integer> aStands = new TreeSet<>();
            for (int i = a; i <= c; ++i) {
                if (aDp[i]) {
                    aStands.add(i);
                }
            }
            for (int i = b; i <= d; ++i) {
                if (bStands.contains(i) && aStands.contains(i - 1) && aStands.contains(i + 1)) {
                    System.out.println("Yes");
                    return;
                }
            }
            System.out.println("No");

        }

    }

    public static boolean[] calculate(int n, int start, int end, String s) {
        boolean [] dp = new boolean[n + 1];
        for (int i = 1; i <= n; ++i) {
            dp[i] = false;
        }
        dp[start] = true;
        for (int i = start + 1; i <= end; ++i) {
            if (s.charAt(i - 1) == '#') {
                dp[i] = false;
            } else {
                if (i - 1 >= 1) {
                    dp[i] = dp[i - 1];
                }
                if (i - 2 >= 1) {
                    dp[i] = dp[i] || dp[i - 2];
                }
            }
        }
        return dp;
    }
}


Measured memory_bytes: 36892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

typedef long double ld;
const ld eps = 1.0e-14; // 許容される誤差

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if (c - a - b < 0) {
    cout << "No" << endl;
  } else if (4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    vi x(n), y(n), h(n);
    rep(i,n) cin >> x[i] >> y[i] >> h[i];

    bool can;
    int H;
    rep(X, 101)rep(Y, 101) {
        H = -1;
        can = 1;
        rep(i,n) {
            if(h[i] == 0) continue;
            int tmp = h[i] + abs(X-x[i]) + abs(Y-y[i]);
            if(H == -1) H = tmp;
            else if(H != tmp) can = 0;
        }
        rep(i,n) {  // 矛盾探し
            if(h[i] == 0) if(abs(X-x[i]) + abs(Y-y[i]) < H) can = 0;
        }
      
        if(can) {
            cout << X << ' ' << Y << ' ' <<  H << '\n';
            return 0;
        }
    }

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin >>n;
    vector<string> s;
    string v;
    for(int i=0;i<n;i++)
    {
        cin >>v;
        s.push_back(v);
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());
    long long int c=0,sum=0;
    for(int i=0;i<n;i++)
    {
        c=0;
        for(int j=i;j<n-1;j++)
        {
            if(s[i]==s[i+1]){c++;i++;}
            else break;
        }
        if(c>=2)
        {
            sum+=(c*(c+1))/2;
        }
        else sum+=c;
    }
    cout <<sum<<endl;
}


Measured memory_bytes: 5748
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
t2 = [''] * n
a = 0
for i in range(k):
    if t[i] == 'p':
        a += s
        t2[i] = 's'
    elif t[i] == 'r':
        a += p
        t2[i] = 'p'
    elif t[i] == 's':
        a += r
        t2[i] = 'r'
for i in range(k, n):
    if t[i] == 'p' and t2[i-k] != 's':
        a += s
        t2[i] = 's'
    elif t[i] == 'r' and t2[i-k] != 'p':
        a += p
        t2[i] = 'p'
    elif t[i] == 's' and t2[i-k] != 'r':
        a += r
        t2[i] = 'r'
print(a)

Measured memory_bytes: 4084
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    vl a(N);
    int r_count = N/R;
    int g_count = N/G;
    int b_count = N/B;
    int res = 0;
    rep(r, 0, r_count+1) {
        int n = N;
        n -= R*r;
        if (n == 0) {
            ++res;
            continue;
        }
        rep(g, 0, g_count+1) {
            int temp = n;
            temp -= G*g;
            if (temp == 0) {
                ++res;
                continue;
            }
            if (temp > 0 && temp%B==0) {
                ++res;
                continue;
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
}



Measured memory_bytes: 256
import math

N = int(input())

sqrtn = math.ceil(math.sqrt(N))
res = len(str(N))
for A in range(sqrtn,1,-1):
    if(N % A != 0):
        continue
    B = N//A
    
    tmpres = max(len(str(A)), len(str(B)))
    res = min(res, tmpres)
print(res)

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ; 
  vector<int> v(n+1) ; 
  rep(i,n) cin >> v.at(i) ;
  int ans = 0 ;
  int now = 0 ;
  rep(i,n+1){
    if(v.at(i) == i+1) now ++ ;
    else {  
      ans += (now+1)/2 ;
      now =0 ;
    }
  }
  cout << ans <<endl ;

}


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


template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> paths[650];
long double dp[650];
int N, M;
long double ans;
 
void input() {
    cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        int s, t; cin >> s >> t;
        paths[s].push_back(t);
    }
}
 
void f(int block) {
    dp[N] = 0;
    for (int i = N - 1; i >= 1; i--) {
        long double sum = 0.0;
        long double maxi = 0.0;
        int num = paths[i].size();
        for (auto to : paths[i]) {
            sum += dp[to];
            chmax(maxi, dp[to]);
        }
        if (i == block && num >= 2) {
            num--;
            sum -= maxi;
        }
        dp[i] = sum / num + 1;
    }
    chmin(ans, dp[1]);
}
 
void solve() {
    input();
    ans = 1e18;
    for (int i = 0; i < N; i++) f(i);
    cout << fixed << setprecision(10) << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	var count int
	for i := 1; i < n-1; i++ {
		if p[i-1] > p[i] && p[i+1] < p[i] {
			count++
		} else if p[i-1] < p[i] && p[i+1] > p[i] {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    double av = 0;
    for (int i=0; i<n; i++) {
        av += a.at(i);
    }
    av /= n;
    double mini = LINF;
    int ans = -1;
    for (int i=0; i<n; i++) {
        double diff = abs(av - a.at(i));
        if (chmin(mini, diff)) ans = i;
    }
    cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

int ans[600100];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,a,b; cin >> n >> a >> b;
	int cp=n;
	if(n<a+b-1||n>a*b){
		cout << -1 << endl;
		return 0;
	}
	for(int i=0;i<a;i++){
		ans[a-i-1]=n-i;
	}
	int now=a;
	n-=a;
	for(int i=0;i<b-1;i++){
		vector<int> v;
		for(int j=0;j<a;j++){
			if(n>b-2-i){
				v.push_back(n);
				n--;
			}
			else{
				break;
			}
		}
		sort(v.begin(),v.end());
		for(int j=0;j<v.size();j++){
			ans[now]=v[j];
			now++;
		}
	}
	for(int i=0;i<cp;i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3488
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n = int(readline())
  A = [int(input()) for _ in range(n)]
  B = sorted(A)
  last1 = B[-1]
  last2 = B[-2]
  if last1==last2:
    for _ in range(n):
      print(last1)
  else:
    for i in range(n):
      if A[i]==last1:
        print(last2)
      else:
        print(last1)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 16312
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

void dfs(int u, vector<vector<int>> g, vector<int> &dist, int a, int b){
    for(auto v: g.at(u)){
        if((u==a&&v==b)||(u==b)&&(v==a)) continue;
        if(dist.at(v)!=-1) continue;
        dist.at(v) = dist.at(u) + 1;
        dfs(v, g, dist, a, b);
    }
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n+1);
    vector<P> path;
    rep(i, m){
        int a, b; cin >> a >> b;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
        path.push_back(make_pair(a, b));
    }

    int cnt = 0;
    for(int k=0; k<m; k++){
        vector<int> dist(n+1, -1);
        dist.at(1) = 0;
        dfs(1, g, dist, path.at(k).first, path.at(k).second);
        for(int i=1; i<=n; i++){
            if(dist.at(i)==-1){
                cnt++; 
                break;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int ctoi(char n) {
	return n - '0';
}

int main() {
	string s;
	cin >> s;
	int nums[11];
	int num;
	for (int i = 0; i < s.length(); i++) {
		nums[i] = ctoi(s[i]);
	}
	int ans = 1e9;
	for (int i = 0; i < s.length() - 2; i++) {
		num = nums[i] * 100 + nums[i + 1] * 10 + nums[i + 2];
		ans = min(ans, abs(num-753));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF = 10**20
def main():
    N,M,K=mi()
    A=[0]+list(mi())
    B=[0]+list(mi())

    v = [0]*(N+1)
    u = [0]*(M+1)

    for i in range(N):
        v[i+1] = A[i+1] + v[i]
        
    for i in range(M):
        u[i+1] = B[i+1] + u[i]

    # print(u,v)
    ans = 0
    for i in range(M+1):
        if K-u[i] < 0: continue
        j = bisect.bisect_left(v,K-u[i])

        if j == 0 and K-u[i] < A[0]: continue

        if j<len(v) and v[j] != K-u[i]:
            j -= 1
        
            
        ans = max(ans,i+j)

    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 120056
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] <= x) {
            ++ans;
            x -= a[i];
        } else {
            cout << ans << endl;
            return 0;
        }
    }

    cout << n - (x != 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

signed main() {
  string s,t;
  cin >> s >> t;
  cout << t << s << endl;
}

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

int main() {
    cin >> s;
    int slen = s.length();
    vector<int> ans(slen+1, -1);
    for(int i = 0; i < slen; ++i) {
        if(i != 0) {
            if(s.at(i-1) == '>' && s.at(i) == '<') {
                ans.at(i) = 0;
            }else {
                if(i == slen-1) {
                    if(s.at(i) == '>') {
                        ans.at(i+1) = 0;
                    }
                }
            }
        }else {
            if(s.at(i) == '<') {
                ans.at(i) = 0;
            }else {
                ans.at(i+1) = 0;
            }
        }
    }

    for(int i = 0; i <= slen; ++i) {
        if(ans.at(i) == 0) {
            int j = i;
            while(j > 0 && s.at(j-1) == '>') {
                if(ans.at(j-1) <= ans.at(j)) {
                    ans.at(j-1) = ans.at(j)+1;
                }
                j--;
            }
            int k = i;
            while(k < slen && s.at(k) == '<') {
                if(ans.at(k+1) <= ans.at(k)) {
                    ans.at(k+1) = ans.at(k)+1;
                }
                k++;
            }
        }
    }

    long long sum = 0;
    for(int i = 0; i < slen+1; ++i) {
        sum += ans.at(i);
    }

    cout << sum << endl;
}

Measured memory_bytes: 2820
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  string a, b, c; cin >> a >> b >> c;
  if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES\n";
  else cout << "NO\n";
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256