akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let a = read::<u32>();
    let s = read::<String>();

    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red")
    }
}


Measured memory_bytes: 4352
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
        
//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




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

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ull modpow(ull a, ull b) {
	ll retval = 0;

	if (b == 0) { return 1; }

	else if (b % 2 == 0) {
		retval = modpow(a, b / 2) % mod;
		return (retval * retval) % mod;
	}

	else {
		
		return ((a % mod) * modpow(a, b - 1)) % mod;
	}
}

ull modkaijou(ull a) {

	if (a == 1 || a == 0) { return 1; }

	ll retval = 1;

	for (ull i = a; i >= 1; i--) {
		retval = (retval * (i % mod)) % mod;
	}

	return retval % mod;
}

ull modcomb(ull a, ull b) {

	if (a == 0 || b == 0) return 1;

	return (((modkaijou(a) * modpow(modkaijou(a-b), mod - 2)) % mod) * modpow(modkaijou(b), mod - 2)) % mod;
}



stack<int> to_1;


class DisjointSet {
public:
	vector<int> p, rank, num;


	DisjointSet() {}

	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		num.resize(size, 0);
		rep(i, size) { p[i] = i; rank[i] = 0; num[i] = 1; }
	}

	bool same(int x, int y) {

		return findSet(x) == findSet(y);

	}

	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {

			p[y] = x;
			num[x] += num[y];

		}

		else {
			p[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y]) {

				rank[y]++;
			}

		}


	}


	ll NumberOfElements(int x) {

		return num[findSet(x)];

	}


	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
			num[x] = 1;
		}

		return p[x];
	}



};




bool compare_b(pint a, pint b) {
	if (a.first < b.first) {
		return true;
	}
	else if (a.first == b.first) {
		return a.second < b.second;
	}

	else {
		return false;
	}

}

int ketasuu(int a) {

	int ret = 1;
	int val = a;
	while (val / 10 != 0) {

		ret += 1;
		val /= 10;
	}
	return ret;
}




string S;

ll N, M;


int main() {
	cin >> S;


	rep(i, S.size()) {

		if (S[i] == 'A') cout << 'T';

		else if (S[i] == 'C') cout << 'G';

		else if (S[i] == 'G') cout << 'C';
		else cout << 'A';

	}


	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, T;
	cin >> N >> T;

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	
	vector<int> cumax(N);
	cumax[N - 1] = A[N - 1];
	for (int i = N - 1; i > 0; i--) cumax[i - 1] = max(cumax[i], A[i - 1]);

	int profit = 0, ans = 1;
	for (int i = 0; i < N; i++) {
		if (profit < cumax[i] - A[i]) {

			profit = cumax[i] - A[i];
			ans = 1;
		}
		else if (profit == cumax[i] - A[i]) ans++;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main( void )
{
	int N, Q ;
	scanf("%d %d\n", &N, &Q ) ;
	char S[200000+2];
	scanf("%s\n", &S[1] ) ;
	S[0]='\0';
	char t[200000],d[200000];
	for( int n = 0 ; n < Q ; n++ ) {
		scanf("%c %c\n", &t[n], &d[n] ) ;
	}
	int l=0,r=N+1;
	for( int n=Q-1 ; n >= 0 ; n-- ) {
		if( d[n]=='L' ) {
			if( t[n] == S[l+1]) l++ ;
			if( t[n] == S[r]) r++ ;
		} else {
			if( t[n] == S[r-1]) r-- ;
			if( t[n] == S[l]) l-- ;
		}
	}
	int c=r-l-1;
	printf("%d\n", c<0?0:c ) ;
	return 0 ;
}



Measured memory_bytes: 768
S = input()
T = input()
 
N = len(S)
M = len(T)
 
ans = 'UNRESTORABLE'
for i in range(N-M,-1,-1):
    b = True
    for j in range(M):
        if S[i+j] == '?' or S[i+j] == T[j]:
            continue
        b = False
    if b:
        ans = S[:i] + T + S[i+j+1:]
        break
ans = list(ans)
for i in range(len(ans)):
    if ans[i] == '?':
        ans[i] = 'a'
print(''.join(ans))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int n, k;
        cin>>n>>k;
        vector<int>v(n);
        for(auto &x : v) cin>>x;
        sort(v.begin(), v.end());
        int ans = 0;
        for(int i = 0; i < k; i++)
        {
                ans += v[i];
        }
        cout<<ans;
}

Measured memory_bytes: 3588
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ma=0,go=0,se=0,n,y;
    cin >>n>>y;
    bool f=false;
    for(ma=0;ma*10000<=y;ma++){
        for(go=0;go*5000+ma*10000<=y;go++){
            se=(y-go*5000-ma*10000)/1000;
            if (ma+go+se==n){
                f=true;
                break;
            }
        }
        if (f)break;
    }
    if(f)cout <<ma<<" "<<go<<" "<<se<<endl;
    else cout <<"-1 "<<"-1 "<<"-1"<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  bool flg = true;
  rep(i,N){
    ll a;
    cin >> a;
    if(a%2 == 1) flg = false;
  }

  if(flg) cout << "second" << endl;
  else cout << "first" << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
struct card{
	    char b;
		char a;	
	};
int check(struct card a[],struct card b[],int n){
	int i,t=0;
	for(i=0;i<n;i++){
		if(a[i].a==b[i].a&&a[i].b==b[i].b)
		t++;
	}
	if(t==n)
	return 1;
	else
	return 0;
}
void out(struct card A[],int n){
	int i;
	for(i=0;i<n;i++){
		if(i>0)
		printf(" ");
		printf("%c%c",A[i].b,A[i].a);
	}
	printf("\n");
}
int main(){
	int n,i,j,min;
	char ch;
	scanf("%d",&n);
	getchar();
	struct card pai[n],mid,copy[n];
	for(i=0;i<n;i++){
		pai[i].b=getchar();
		pai[i].a=getchar();
		if(i!=n-1)
		ch=getchar();
		}
	for(i=0;i<n;i++)
	copy[i]=pai[i];
	for(i=0;i<n;i++){
	for(j=n-1;j>i;j--){
		if(pai[j].a<pai[j-1].a){
			mid=pai[j];
			pai[j]=pai[j-1];
			pai[j-1]=mid;
		}
	}}
	out(pai,n);
	printf("Stable\n");
	for(i=0;i<n;i++){
		min=i;
		for(j=i;j<n;j++){
			if(copy[j].a<copy[min].a)
			min=j;
		}
		mid=copy[min];
		copy[min]=copy[i];
		copy[i]=mid;
	}
	out(copy,n);
	if(check(pai,copy,n))
	printf("Stable\n");
	else
	printf("Not stable\n");
	return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int MAXN = 21;
const int LEN = 1048600;
const int mo = 1e+9+7;

int f[MAXN][LEN];
int N;
int n,m,k;
int ty[MAXN][MAXN];
int tr[LEN][MAXN];

inline int add(int x,int y){return x+y>=mo?x+y-mo:x+y;}

int main(){
	n=get();m=get();k=get();
	fo(i,1,k){
		int a=get(),b=get(),c=get();
		ty[a][n-b]=c+1;
	}
	N=1<<(n-1);
	fo(i,0,N-1){
		int w=-1;
		fo(j,0,n-2){
			if ((i&(1<<j))>0)w=j;
			if (w>-1)tr[i][j+1]=i^(1<<w)^(1<<j);else tr[i][j+1]=i^(1<<j);
		}
	}
	f[1][0]=1;
	fo(p,1,m){
		fo(i,0,N-1)f[n][i]=f[1][i];
		fo(x,1,n-1)fo(i,0,N-1)f[x][i]=0;
		fd(x,n-1,1){
			fo(i,0,N-1)
			if (f[x+1][i]){
				if (ty[p][x]==0){
					if ((i&(1<<(x-1)))==0)f[x][i]=add(f[x][i],f[x+1][i]);
					f[x][tr[i][x]]=add(f[x][tr[i][x]],f[x+1][i]);
				}
				if (ty[p][x]==1&&(i&(1<<(x-1)))==0)f[x][i]=add(f[x][i],f[x+1][i]);
				if (ty[p][x]==2)f[x][tr[i][x]]=add(f[x][tr[i][x]],f[x+1][i]);
			}
		}
	}
	int ans=0;
	fo(i,0,N-1)ans=add(ans,f[1][i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 129280
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



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

Measured memory_bytes: 256
//
// Created by Tetsuya Shiota on 2019/03/09.
//

#include<iostream>
#include <vector>

using namespace std;

int main(){
    int N, M, C;

    cin >> N >> M >>C;
    vector<int> B(M);

    for(int& b : B)cin >> b;

    int ans = 0;
    for(int i = 0; i< N; i++){
        int sum = 0;
        for(int j = 0; j<M; j++){
            int a;
            cin >> a;
            sum += B[j] * a;
        }
        if(sum + C> 0)ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// 座標圧縮
template <typename T> struct Compress {
    map<T, int> zip;
    vector<int> unzip;

    Compress(vector<T> v) {
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        for (int i = 0; i < v.size(); ++i) {
            zip[v[i]] = i;
            unzip.push_back(v[i]);
        }
    }

    int size() { return unzip.size(); }
};

int N, K;
int X[50][2], Y[50][2], Z[50][2];
int cum[200][200][200];

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

    cin >> N >> K;
    vector<int> vx, vy, vz;
    REP(i, N) REP(j, 2) {
        cin >> X[i][j] >> Y[i][j] >> Z[i][j];
        vx.push_back(X[i][j]);
        vy.push_back(Y[i][j]);
        vz.push_back(Z[i][j]);
    }
    Compress<int> cx(vx), cy(vy), cz(vz);
    REP(i, N) {
        FOR(z, cz.zip[Z[i][0]], cz.zip[Z[i][1]]) {
            ++cum[cx.zip[X[i][0]]][cy.zip[Y[i][0]]][z];
            --cum[cx.zip[X[i][0]]][cy.zip[Y[i][1]]][z];
            --cum[cx.zip[X[i][1]]][cy.zip[Y[i][0]]][z];
            ++cum[cx.zip[X[i][1]]][cy.zip[Y[i][1]]][z];
        }
    }
    REP(z, 200) REP(y, 200) FOR(x, 1, 200) cum[x][y][z] += cum[x - 1][y][z];
    REP(z, 200) REP(x, 200) FOR(y, 1, 200) cum[x][y][z] += cum[x][y - 1][z];
    int ans = 0;
    REP(x, cx.size() - 1) REP(y, cy.size() - 1) REP(z, cz.size() - 1) {
        if (cum[x][y][z] >= K) {
            ans += (cx.unzip[x + 1] - cx.unzip[x]) * (cy.unzip[y + 1] - cy.unzip[y]) * (cz.unzip[z + 1] - cz.unzip[z]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 65648
#include <iostream>
#include <queue>
#include <utility>
using namespace std;
typedef pair<int, int> P;

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

int main()
{
    while(true){
        int w, h;
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        int c[53][53];
        for(int j = 0; j < w + 2; j++){
            c[0][j] = c[h + 1][j] = 0;
        }
        for(int i = 1; i <= h; i++){
            c[i][0] = c[i][w + 1] = 0;
            for(int j = 1; j <= w; j++) cin >> c[i][j];
        }
        queue<P> que;
        int ans = 0;
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                if(c[i][j] == 1){
                    c[i][j] = 0;
                    que.push(P(i, j));
                    while(que.size()){
                        int x = que.front().first;
                        int y = que.front().second;
                        que.pop();
                        for(int k = x - 1; k <= x + 1; k++){
                            for(int l = y - 1; l <= y + 1; l++){
                                if(c[k][l] == 1){
                                    c[k][l] = 0;
                                    que.push(P(k, l));
                                }
                            }
                        }
                    }
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    if((n - k) % (k - 1) == 0){
        cout << (n - k) / (k - 1) + 1;
    }else{
        cout << (n - k) / (k - 1) + 2;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  ll a, b, x;
  cin >> a >> b >> x;
  if(a == 0){
    cout << b/x + 1 << endl;
    return 0;
  }
  --a;
  ll right = b/x;
  ll left = a/x;
  cout << right - left << endl;

  return 0;
}

Measured memory_bytes: 3608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	s := sc.NextLine()

	ans := 0
	for i := 1; i < n-1; i++ {
		a := map[string]int{}
		mx := 0
		for j := 0; j < i; j++ {
			a[string(s[j])]++
		}
		for j := i; j < n; j++ {
			if a[string(s[j])] > 0 {
				mx++
				a[string(s[j])] = 0
			}
		}
		if ans < mx {
			ans = mx
		}
	}

	fmt.Printf("%+v\n", ans) // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> v(n),vcopy(n);

  for(int i=0;i<n;++i){
    cin >> v[i];
    vcopy[i]=v[i];
  }
  int r=min(n,k);
  vector<ll> a(n+1),b(n+1);
  a[0]=0;
  for(int i=0;i<n;++i){
    a[i+1]=a[i]+v[i];
    //cout << a[i+1] << endl;
  }
  reverse(vcopy.begin(),vcopy.end());
  b[0]=0;
  for(int i=0;i<n;++i){
    b[i+1]=b[i]+vcopy[i];
    //cout << b[i+1] << endl;
  }
  int maxid;
  ll ans=0;
  for(int i=0;i<=r;++i){
    for(int x=0;x<=i;++x){
      int j=i-x;
      ll tmp=a[x]+b[j];
      //cout << a[x] << " " << b[j] << endl;
      //cout << tmp << endl;
      int K=k-i;
      priority_queue<int> que;
      for(int ai=0;ai<x;++ai){
        if(v[ai]<0) que.push(-v[ai]);
      }
      for(int bi=0;bi<j;++bi){
        if(vcopy[bi]<0) que.push(-vcopy[bi]);
      }
      for(int l=0;l<K;++l){
        if(que.size()){
          tmp+=que.top();
          que.pop();
        }
      }
      //cout << tmp << endl;
      ans=max(ans,tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N, total = 0;
  scanf("%lld", &N);
  std::vector<long long> A(N + 1), skips(N);
  for (int i = 1; i < N + 1; i++) scanf("%lld", &A[i]);
  A.pb(0);

  rep(i, 0, N + 1) { total += abs(A[i] - A[i + 1]); }
  rep(i, 0, N) { skips[i] = abs(A[i] - A[i + 2]); }
  rep(i, 0, N) put(total + skips[i] - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]));
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 2800
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
using namespace std;

int main(void){
    int a;
    cin>>a;
   if(100<=a&&a<=111){
       cout<<111<<endl;
   }else if(111<a&&a<=222){
       cout<<222<<endl;
   }else if(222<a&&a<=333){
       cout<<333<<endl;
   }else if(333<a&&a<=444){
       cout<<444<<endl;
   }else if(444<a&&a<=555){
       cout<<555<<endl;
   }else if(555<a&&a<=666){
       cout<<666<<endl;
   }else if(666<a&&a<=777){
       cout<<777<<endl;
   }else if(777<a&&a<=888){
       cout<<888<<endl;
   }else {
       cout<<999<<endl;
   }




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll k; cin >> k;
    vector <ll> suretu = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << suretu[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

def selectionSort(A, N):
    c = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            c += 1
            A[i], A[minj] = A[minj], A[i]
    print(' '.join(list(map(str, A))))
    print(c)


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    selectionSort(A, N)


Measured memory_bytes: 5608
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static int[] arrays, mode;
        static int number;
        static int index = 1;
        public static void main(String[] args) {
                arrays = new int[101];
                mode = new int[101];
                for(int i = 0; i < arrays.length; i++)
                        arrays[i] = 0;
 
                while(read()){
 
                }
                solve();
        }
        static  boolean read(){
                int data;
                if(!sc.hasNext())
                        return false;
                data = sc.nextInt();
                arrays[data]++;
                return true;
        }
        static void solve(){
                int max = 0;
                for(int i = 1; i < arrays.length; i++){
                        max = Math.max(max, arrays[i]);
                }
                for(int i = 0; i < arrays.length; i++){
                        if(arrays[i] == max){
                                System.out.println(i);
                        }
                }
        }
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
//region
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b); i >= (b); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repr1(i, n) for (int i = (n); i > 0; i--)
#define outif(b, t, f) cout << ((b) ? (t) : (f)) << endl
#define all(vec) (vec).begin(), (vec).end()
#define sz(x) (int((x).size()))
#define mset(v, n) std::memset((v), n, sizeof(v))
#define BIT(N) (1LL << (N))
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using vint = vector<int>;
using vlong = vector<ll>;
using vstr = vector<string>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpll = vector<pll>;
using vvi = vector<vint>;
using vvl = vector<vlong>;
vector<string> split(const string &s, const string &delim) {
  vector<string> res;
  uint pos = 0;
  while (true) {
    const int found = s.find(delim, pos);
    if (found < 0) {
      res.push_back(s.substr(pos));
      break;
    }
    res.push_back(s.substr(pos, found - pos));
    pos = found + delim.size();
  }
  return res;
}
template<typename T> string join(vector<T> &vec, const string &sep) {
  size_t size = vec.size();
  if (!size) return "";
  std::stringstream ss;
  for (int i = 0; i < size - 1; i++)
    ss << vec[i] << sep;
  ss << vec[size - 1];
  return ss.str();
}
template<typename T> std::istream &operator>>(std::istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template<typename Iter> inline void print(const Iter &first, const Iter &last, const std::string &d, bool endline) {
  cout << *first;
  for (Iter iter = first + 1; iter < last; ++iter) {
    cout << d << *iter;
  }
  if (endline) cout << "\n";
}
constexpr ll powmod(ll a, ull b, ull p) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % p;
    a = a * a % p;
    b >>= 1u;
  }
  return res;
}
template<class T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> void bsort(vector<T>& v) { std::sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T>& v) { std::sort(v.begin(), v.end(), std::greater<T>()); }
struct iii {
    iii() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
      cout << std::fixed << std::setprecision(16);
    }
} init;
//endregion

void solve();

int main() {
  int t = 1;
  // scanf("%d", &t);
  rep(_,t) solve();
  return 0;
}

void solve() {
  ll N,A,B;
  scanf("%lld%lld%lld",&N,&A,&B);
  ll min = A * (N-1) + B;
  ll max = A + (N - 1) * B;
  printf("%lld", std::max(0LL,max - min + 1));
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	for (int i = 0; i < 10; i++) {
		if (i == 3) cout << '8';
		else cout << S[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :2015 ho3
// Version     :???11:08
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int N,M,Q;
typedef pair<int,int> P;
int U[200001];
int V[200001];
int UV[200001]={};

vector<int> C[100001];
vector<int> C2[100001];
int R;
int dp[100001]={};
int man[100001]={};
const int INF=10000000;

int main() {
	cin>>N>>M>>Q;

	for(int i=1;i<M+1;++i){
		cin>>U[i]>>V[i];
		C[U[i]].push_back(i);
		C[V[i]].push_back(i);
	}
	for(int i=2;i<N+1;++i)dp[i]=INF;

	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,1));
	P p1;
	int cost,to,to2;
	while(que.size()){
		p1=que.top();que.pop();
		cost=p1.first;
		to=p1.second;
		if(cost>dp[to])continue;
		dp[to]=cost;
		for(auto it:C[to]){
			to2=U[it];
			if(to2==to)to2=V[it];
			if(cost+1<dp[to2]){
				que.push(P(cost+1,to2));
				dp[to2]=cost+1;
			}
		}
	}
	for(int i=2;i<N+1;++i){
		for(auto it:C[i]){
			if(dp[i]>dp[V[it]])C2[i].push_back(it);
			if(dp[i]>dp[U[it]])C2[i].push_back(it);
		}
	}

	int total=0;
	int flg;
	man[1]=1;
	queue<int> que2;
	for(int i=0;i<Q;++i){
		cin>>R;
		UV[R]=1;
		to=V[R];
		to2=U[R];
		que2.push(to);
		que2.push(to2);

		while(que2.size()){
			to=que2.front();que2.pop();
			flg=0;
			if(man[to]>0)continue;
			for(auto it:C2[to]){
				if((dp[V[it]]+1+UV[it]<=dp[to])||(dp[U[it]]+1+UV[it]<=dp[to])){
					flg=1;
					break;
				}
			}

			if(flg==0&&to>1){
				if(man[to]==0){
					man[to]=1;
					total+=1;
				}
				for(auto it:C[to]){
					to2=U[it];
					if(to2==to)to2=V[it];
					if(man[to2]==0)que2.push(to2);
				}
				dp[to]+=1;
			}
		}
		cout<<total<<endl;
	}
	return 0;
}

Measured memory_bytes: 18100
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e15;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
template<typename T, typename F> ll sum(T begin, T end, F func) {return accumulate(begin, end, 0ll, func);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  ll n, m;
  string s;
  cin >> n >> m >> s;
  n++;
  reverse(all(s));
  vector<ll> dp(n, inf);
  dp[0] = 0;
  REP(i, n) {
    if(dp[i] > 1e6) continue;
    for(int j = min(n-1, i+m); j > i; j--) {
      if(dp[j] < 1e6) {
        break;
      }
      if(s[j] == '1') continue;
      dp[j] = min(dp[j], dp[i] + 1);
    }
  }
  reverse(all(dp));
  if(dp[0] > 1e6) {
    cout << -1 << endl;
    return 0;
  }
  int lft = 0;
  int lft_value = dp[0];
  REP_FROM(i, 1, n) {
    if(lft_value != dp[i] && dp[i] < 1e6) {
      cout << i - lft << " ";
      lft = i;
      lft_value--;
    }
  }
  return 0;
}


Measured memory_bytes: 1488
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  int n;cin >> n;
  string s;cin >> s;
  vector<vector<mint>> dp(n,vector<mint>(n));
  rep(j,n) dp[0][j].x = 1;
  rep(i,n-1){
    vector<mint> sum(n+1);
    rep(j,n-i) sum[j+1] = sum[j] + dp[i][j];
    if(s[i]=='<') rep(j,n-i-1) dp[i+1][j] = sum[n-i] - sum[j+1];
    else rep(j,n-i-1) dp[i+1][j] = sum[j+1];
  }

  cout << dp[n-1][0].x << "\n";

  return 0;
}


Measured memory_bytes: 70784
# import bisect
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        s=str(input())
        s=deque(iterable=s)
        cnt=0
        if len(s)==1:
            return 0
        else:
            while len(s)>=2:
                sl=s.popleft()
                sr=s.pop()
                if sl==sr:
                    continue
                elif sl!='x' and sr!='x':
                    return -1
                elif sl!='x':
                    s.appendleft(sl)
                    s.append(sr)
                    s.appendleft('x')
                    cnt+=1
                else:
                    s.append(sr)
                    s.appendleft(sl)
                    s.append('x')
                    cnt+=1
            return cnt
    print(main())









resolve()

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


int main() {
	string s, T;
	cin >> s >> T;

	vector<string> S(20000);

	int sn, tn;
	sn = s.length(); tn = T.length();

	int cnt=0, fcnt=0;
	for (int i = 0; i < sn - tn + 1; i++) {
		bool flag=true;
		for (int j = 0; j < tn; j++) {
			if (s[i+j] != '?' && s[i+j] != T[j]) {
				flag=false;
				break;
			}
		}
		if (flag) {
			for (int j = 0; j < sn; j++) {
				if (i == j) {
					S[cnt] += T;
					j += tn-1;
				}
				else if(s[j]=='?')
					S[cnt].push_back('a');
				else
					S[cnt].push_back(s[j]);
				//cout << i <<" "<< S[cnt] << endl;
			}
			cnt++;
		}
		else fcnt++;
	}

	if(fcnt==(sn-tn+1)) cout << "UNRESTORABLE" << endl;
	else {
		sort(S.begin(), S.end());
		S.erase(unique(S.begin(),S.end()), S.end());
		cout << S[1] << endl;
	}
}

Measured memory_bytes: 384
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const r = parseInt(args[0][0], 10)
	if (r < 1200) console.log('ABC')
	else if (r < 2800) console.log('ARC')
	else console.log('AGC')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    if ((i % 3 != 0) && (i % 5 != 0)) {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3164
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m,X,Y = map(int, input().split())
    x = [X] + list(map(int, input().split()))
    y = [Y] + list(map(int, input().split()))
    if max(x) < min(y):
        print('No War')
    else:
        print('War')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAXN = 2e5 + 10;
int a[MAXN];
int ans[MAXN];

int main() {
    int n;
    scanf("%d", &n);// don't forget &
    for (int i = 2; i <= n; i++) {
        scanf("%d", &a[i]);// don't forget &
    }
    for (int i = 2; i <= n; i++) {
        int x = a[i];
        ans[x] += 1 + ans[i];
    }
    for (int i = 1; i <= n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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;
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 100005;

bitset<MX> solved;
map<int, int> waCnt;

int N, M, P;
string S;
int ac, wa;

void solve() {
    solved.reset();
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
		cin >> P >> S;
		if (S == "WA") waCnt[P]++;
		else if (!solved[P]) {
			solved[P] = 1;
			ac++;
			wa += waCnt[P];
		}
	}
	cout << ac << " " << wa;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

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

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

ll N,M;
vector<ll>A(106);

void batten(ll i,ll k){
	if(i==N)return;
	if((A[i]%k)>(A[i+1]%k)){
		swap(A[i],A[i+1]);
		batten(i+1,k);
		return;
	}else{
		batten(i+1,k);
		return;
	}
}

ll mapdata[310][310];
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll H,W,K;
	cin>>H>>W>>K;
	char map[H][W];
	for(int i=0;i<H;i++)cin>>map[i];
	ll dx[2]={-1,+1};
	
	ll _data=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(map[i][j]=='#'){
				_data++;
				mapdata[i][j]=_data;
			}
		}
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(map[i][j]=='#'){
				//bfs
				ll data=mapdata[i][j];
				queue<ll>que;
				que.push(j);
				while(!que.empty()){
					ll w=que.front();
					//cout<<i<<w<<data<<endl;
					que.pop();
					mapdata[i][w]=data;
					for(int k=0;k<2;k++){
						ll next_w=w+dx[k];
						if(0<=next_w&&next_w<W){
							if(mapdata[i][next_w]==0)que.push(next_w);
						}
					}
				}
			}
		}
	}
	
	for(int i=0;i<H;i++){
		if(mapdata[i][0]==0){
			//copy
			
			//cout<<i<<"findup"<<endl;
			//find up
			for(int h=i;h>=0;h--){
				if(mapdata[h][0]!=0){
					for(int w=0;w<W;w++){
						mapdata[i][w]=mapdata[h][w];
					}
					break;
				}
			}
		}
		if(mapdata[i][0]==0){
			//copy
			//find down
			
			//cout<<i<<"finddown"<<endl;
			for(int h=i;h<H;h++){
				if(mapdata[h][0]!=0){
					for(int w=0;w<W;w++){
						mapdata[i][w]=mapdata[h][w];
					}
					break;
				}
			}
		}
	}
	
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++)cout<<mapdata[i][j]<<endl;
	}
}



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

int main() {
  int N;
  cin>>N;
  int d=N%10;
  N/=10;
  int c=N%10;
  N/=10;
  int b=N%10;
  N/=10;
  int a=N%10;
  if(a+b+c+d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'+'<<d<<'='<<'7'<<endl;
  }
  else if(a+b+c-d==7){
    cout<<a<<'+'<<b<<'+'<<c<<'-'<<d<<'='<<'7'<<endl;
  }
  else if(a+b-c+d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'+'<<d<<'='<<'7'<<endl;
  }
  else if(a+b-c-d==7){
    cout<<a<<'+'<<b<<'-'<<c<<'-'<<d<<'='<<'7'<<endl;
  }
  else if(a-b+c+d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'+'<<d<<'='<<'7'<<endl;
  }
  else if(a-b+c-d==7){
    cout<<a<<'-'<<b<<'+'<<c<<'-'<<d<<'='<<'7'<<endl;
  }
  else if(a-b-c+d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'+'<<d<<'='<<'7'<<endl;
  }
  else if(a-b-c-d==7){
    cout<<a<<'-'<<b<<'-'<<c<<'-'<<d<<'='<<'7'<<endl;
  }
}

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

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var X = Console.ReadLine().Trim().Split(' ').Select(x => long.Parse(x)).ToArray();

            long ans = 0;
            int num = 1;
            for(var i = 0; i < 3; i++) {
                if (X[3] > X[i]) {
                    ans += num * X[i];
                    X[3] -= X[i];
                } else {
                    ans += num * X[3];
                    X[3] = 0;
                }
                num--;
            }

            Console.Write(ans);
        }
    }
}

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

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

    int ans = 0;
    int k2 = k;
    k = k - a;
    if(k > 0){
        ans += a;
        k = k - b;
        if(k > 0){
            ans -= k;
        }
    }
    else ans += k2;
    cout << ans << endl;
}



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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define vi vector<int>

#define ll long long int

int ctoi(char c) {return c-'0';}
int ord(char c) {return c-'a';}
int len(string s) {return s.length();}
int itoc(int i) {return i+'a';}


int main() {
vector<int> v(3);
cin>>v[0]>>v[1]>>v[2];
sort(all(v));
cout<<((v[0]==v[1] and v[1]<v[2]) or (v[1]==v[2] and v[0]<v[1]) ? "Yes" : "No")<<endl;
return 0;
}


Measured memory_bytes: 256
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()

    ans = n

    for i in range(n // 6 + 1):
        count = 0

        s6 = i * 6
        ii = i
        for j in range(1, n + 1):
            scount = ii % 6
            count += scount
            ii = ii // 6
            s6 -= (6**j) * scount
            if not s6:
                break

        s9 = n - i * 6
        ii = s9

        for j in range(0, n + 1):
            scount = ii % 9
            count += scount
            ii = ii // 9
            s9 -= (9**j) * scount
            if not s9:
                break

        ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <stack>
#include <unordered_set>
using namespace std;

int main(){
    string s;
    cin >> s;
    cout << (s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3596
import java.io.*;
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();
        int d,r;
        double f;
        d = a / b;
        r = a % b;
        f = (double)a / b;
        System.out.printf("%d %d %f", d, r, f);
    }
}


Measured memory_bytes: 26492