akhauriyash/Code-Regression huggingface dataset:
l = []
for i in range(6):
    l.append(int(input()))

flag = "Yay!"
for i in range(4):
    for j in range(i+1, 5):
        d = l[j]-l[i]
        # print(d)
        if d>l[-1]:
            flag = ":("
print(flag)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include <iomanip>
#define ll long long int
#define ld long double
#define IOS cin.tie(NULL);cout.tie(NULL)
#define f first
#define inf 100000000000000000
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define sc(i) scanf("%lld",&i);
#define s second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
ll const mod=1000000007;
 
ll arr1[100009];
//ll parent[1000009];
set<ll> sieve;
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
            for(ll j=i*i;j<=n;j+=i){
                arr1[j]=1;
            }
        }
    }
    for(int i=2;i<=n;i++){
    	if(arr1[i]==0)sieve.insert(i);
    }
}

ll temp[200][200];
ll mat[200][200];
void multiply(ll a[][200],ll b[][200],ll n){
	forn(i,n)forn(j,n)temp[i][j]=0;
	forn(i,n){
		forn(j,n){
			forn(k,n){
				temp[i][j]+=(a[i][k]*b[k][j])%mod;
				temp[i][j]%=(mod);
			}
		}
	}
	forn(i,n)forn(j,n)a[i][j]=temp[i][j];
}
ll tempmat[200][200];
ll ans[200][200];
void matrixexp(ll n,ll m){
	forn(i,m)forn(j,m){
		ans[i][j]=mat[i][j];
		tempmat[i][j]=mat[i][j];
	}
	n--;
	while(n>0){
		if(n%2==1){
			multiply(ans,tempmat,m);
			n--;
		}else{
			multiply(tempmat,tempmat,m);
			n/=2;
		}
	}
 
}
ll count(ll n,ll m){
	ll temp=0;
	while(n%m==0){
		temp++;
		n/=m;
	}
	return temp;
}
ll power(ll x, ll y) {
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2)%mod;
	if (y%2 == 0)
		return ((temp)*(temp))%mod;
	else
		return (((x%mod))*((temp*temp)%mod))%mod;
}
int main(){
	
    IOS;
    ll n,k;
    cin>>n>>k;
    
    forn(i,n)forn(j,n)cin>>mat[i][j];
    matrixexp(k,n);
    ll sum=0;
    forn(i,n)forn(j,n)sum=(sum+ans[i][j])%mod;
    cout<<sum;
 
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s, t;
  cin >> s >> t;

  sort(all(s));
  sort(all(t), greater<>());

  cout << (s < t ? "Yes" : "No") << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
void pr(int a[],int n){
	int first=1;
	for (int i=0;i<n;i++){
		if(first)first=0;else cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
}
int BubbleSort(int a[],int n){
	int cnt=0;
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(a[j]<a[j-1]){
				swap(a[j],a[j-1]);
				cnt++;
			}
		}
	}
	return cnt;
}
int main(){
	int n,a[102];
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int cnt=BubbleSort(a,n);
	pr(a,n);
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001

int main(){
	
	int N,H,D;
	cin>>N>>H>>D;
	
	int x = 1;
	int t = 1;
	for(int i=2;i<=N;i++){
		x = mod(x * i);
		t = mod(t + x);
	}
	//t=N;
	vector<int> dp(H+1,0);
	
	for(int i=1;i<=H;i++){
		dp[i] = mod(mod(dp[i-1]-dp[max(i-D-1,0)]) * t);
		if(i-D-1<0)dp[i] = mod(dp[i]+1);
		dp[i] = mod(dp[i] + dp[i-1]);
	}
	/*
	for(int i=0;i<=H;i++)cout<<dp[i]<<',';
	cout<<endl;
	*/
	int ans = mod(dp.back() - dp[H-1]);
	for(int i=2;i<=N;i++)ans = mod(ans * i);
	//ans = mod(ans * t);
	cout<<ans<<endl;
		

	return 0;
}


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


int main(){
	int a;
	string s;
	cin >> a >> s;
	if(a%2){
		cout << "No" << endl;
		return 0;
	}
	for(int i=0;i<a/2;i++){
		if(s[i]!=s[i+a/2]){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
#define debug(x) cerr << #x << " is " << x << endl;
using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define pis pair<ll,pll>
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// unordered_map<long long, int, custom_hash> safe_map;
// FOR VIEWERS, CODE STARTS HERE

int main()
{
   
    FIO;
    ll t, q, n, m, prev, maxx,  i, j, k1, k2, k3, k, x, y, flag, sum, cnt, ans, minn, cur;
    ll a, b;
    cin>>a>>b>>q;
    k = min(q, b - 1);
    ans = (a*k)/b - a*(k/b);
    cout<<ans<<endl;
    return 0;    
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

vector<ll>dv;
void divisor(ll n) {
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			if (i == n / i) {
				dv.push_back(i);
			}
			else {
				dv.push_back(i);
				dv.push_back(n / i);
			}
		}
	}
}

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

	ll N;
	cin >> N;
	divisor(N);
	ll ans = inf;
	fore(x, dv)ans = min(ans,(x-1LL) + (N/x - 1LL));
	puts(ans);

	return 0;
}

Measured memory_bytes: 384
/**
 *    author:  FromDihPout
 *    created: 2020-08-06
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int> (n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    
    vector<vector<bool>> inter(n, vector<bool> (n));
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (i == k) continue;
            for (int j = 0; j < n; j++) {
                if (j == i || j == k) continue;
                if (a[i][k] + a[k][j] < a[i][j]) {
                    cout << -1 << '\n';
                    return 0;
                }
                else if (a[i][k] + a[k][j] == a[i][j]) {
                    inter[i][j] = true;
                }
            }
        }
    }
    
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (!inter[i][j]) {
                ans += a[i][j];
            }
        }
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	long int l, r;
	cin>>l>>r;
	long long int ans;
	vector<int> v;
	if(r-l < 2019)
	{
	    for(long long int i=l; i<=r-1; i++)
	    {
	        for(long long int j=i+1; j<=r; j++)
	        {
	            v.push_back((i*j)%2019);
	        }
	    }
	    ans=*min_element(v.begin(), v.end());
	}
	else
	{
	    ans=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 9452
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL K = 750;
const LL MP = 20000;

LL pri[20005],pc = 0;
LL npr[20005] = {0};
LL w[505][505];

void sieve(LL x){
	for(LL i = 2;i <= x;i ++){
		if(npr[i]) continue;
		pri[++ pc] = i;
		for(LL j = i * i;j <= x;j += i){
			npr[j] = 1;
		}
	} 
}

LL gcd(LL x,LL y){
	if(!y) return x;
	return gcd(y,x % y);
}

LL lcm(LL x,LL y){
	return x / gcd(x,y) * y;
}

int main(){
	ios::sync_with_stdio(false);
	LL n; cin >> n;
	if(n == 2){
		cout << 4 << ' ' << 7 << endl;
		cout << 23 << ' ' << 10 << endl;
		return 0;
	}
	sieve(MP);
	for(LL i = 0;i <= n + 1;i ++){
		for(LL j = 0;j <= n + 1;j ++){
			w[i][j] = 1;
		}
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			if((i + j) & 1) w[i][j] = pri[(i + j) >> 1] * pri[((i - j) >> 1) + K];
		}
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			if(w[i][j] == 1) w[i][j] = lcm(lcm(w[i - 1][j],w[i][j - 1]),lcm(w[i + 1][j],w[i][j + 1])) + 1;
		}
	}
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			cout << w[i][j] << (j == n ? '\n' : ' ');
		}
	}
	return 0;
}
//

Measured memory_bytes: 5376
fun main(args: Array<String>) {
    val x = readInteger()
    for (i in x..100003) {
        if (i.isPrime()) {
            println(i)
            return
        }
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerArray() = readStringList().map(String::toInt).toIntArray()
fun readLongArray() = readStringList().map(String::toLong).toLongArray()


fun Int.isPrime(): Boolean {
    if (this <= 1) return false
    if (this == 2) return true
    if (this % 2 == 0) return false

    var i = 3
    while (i * i <= this) {
        if (this % i == 0) return false
        i += 2
    }

    return true
}


Measured memory_bytes: 31664
from functools import reduce

N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = A[i]-(i+1)
A.sort()
b = A[len(A)//2]
A = list(map(lambda n:abs(n-b),A))
print(reduce(lambda a,b:a+b,A))


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll N,P; cin>>N>>P;
  //Pを素因数分解すれば良い。
  if(N==1){
    cout<<P<<endl;
    return 0;
  }
  for(int i = sqrt(P); i >= 2 ; i--){
    if(P%i==0){
      ll tmp = 1;
      int flag = 0;
      rep(j,N){
        tmp *= i;
        if(tmp>P){
          flag = 1;
          break;
        }
      }
      if(!flag&&P%tmp==0){
        cout<<i<<endl;
        return 0;
      }
    }
  }
  cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;

int main() {
  int64_t N,M;
  cin>>N>>M;
  string s,t;
  cin>>s>>t;
  int g=__gcd(N,M);
  int64_t L=N*M/g;
  for(int i=0;i<g;i++){
    if(s[i*N/g]!=t[i*M/g]){cout<<-1<<endl;return 0;}
  }
  cout<<L<<endl;
  return 0;
}

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

int main(){
	int N;
	int ans = 0;
	int left=0,right=0,min=9999999999;
	int total;
	int temp;
	cin >> N;
	vector<int> ary(N);
	for(int i=0; i<N; ++i){
		cin >> ary[i];
	}   

	total = accumulate(ary.begin(),ary.end(),0);

	//i = どこで分けるか
	for (int i = 0; i < N-1; i++)
	{
	
		for (int j = 0; j <= i; j++)
		{
			left += ary[j];
		}
		
		right = total - left;

		temp = abs(right - left);
		if(min > temp){
			min = temp;
		}
		left = 0;
		right = 0;
	}


	


	cout << min << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll n,q;
  cin>>n;
  ll ans=0;
  vector<ll> cnt(110000,0);
  for(ll i=0;i<n;i++){
    ll tmp;
    cin>>tmp;
    ans+=tmp;
    cnt[tmp]++;
  }
  cin>>q;
  for(ll i=0;i<q;i++){
    ll x,y;
    cin>>x>>y;
    ans+=(y-x)*cnt[x];
    cnt[y]+=cnt[x];
    cnt[x]=0;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3988
#include <iostream>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 1e5;

int Q, H, S, D;
int n;
LL cost;
int main()
{
	while(scanf("%d %d %d %d", &Q, &H, &S, &D) != EOF)
	{
		scanf("%d", &n);
		cost = 0;
		int q1 = Q * 4, q2 = Q * 8;
		int h1 = H * 2, h2 = H * 4;
		int s1 = S, s2 = S * 2;
		int t2 = min(q2, min(h2, min(s2, D)));
		cost += 1LL * n / 2 * (LL)t2;
		if(n & 1) {
			int t1 = min(q1, min(h1, s1));
			cost += (LL)t1;
		}
		printf("%lld\n", cost);
	}
	return 0;
}

Measured memory_bytes: 128
N, K= map(int,input().split())
p = list(map(int,input().split()))

e = [(pi+1)/2 for pi in p]

f = sum(e[:K])
ans = f

for i in range(K,N):
    f = f - e[i-K] + e[i]
    ans = max(ans,f)

print(ans)





Measured memory_bytes: 77448
import sys

def getsqs(coor,h,w):
    l=[coor[0]+x+h*(coor[1]+y-1) for x in range(-1,2) for  y in range(-1,2) \
        if coor[0]+x>1 and coor[0]+x<h and coor[1]+y>1 and coor[1]+y<w]
    return l

def main(h,w,coords):
    sq=[]
    ans=[0 for _ in range(10)]
    for coor in coords:
        sq.extend(getsqs(coor,h,w))
#        print(coor,getsqs(coor,h,w))
    sq.sort()
    sq.append(h*w)
    ind=0
    for x in range(len(sq)-1):
        if sq[x+1]-sq[x]!=0:
            ans[x-ind+1]+=1
            ind=x+1
    ans[0]=max(0,(h-2)*(w-2)-sum(ans))
    return ans

h,w,n=map(int,sys.stdin.readline().strip().split())
coords=[list(map(int,sys.stdin.readline().strip().split())) for _ in range(n)]

for x in main(h,w,coords):
    print(x)



Measured memory_bytes: 80688
import java.util.*;

class Main{
	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		

		while(true){
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();
			
			if(op.equals("?")){break;}
			
			switch(op){
				case "+":
					System.out.println(a + b);
					break;
				case "-":
					System.out.println(a - b);
					break;
				case "*":
					System.out.println(a * b);
					break;
				case "/":
					System.out.println(a / b);
					break;
				default :
					break;
			}
		}
	}
}

Measured memory_bytes: 26288
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const INF: i64 = 1001001001001;

fn main() {
   input! {
      n: usize,
      k: usize,
      h: [i64; n]
   }
   let mut dp = vec![INF; n];
   dp[0] = 0;
   for i in 0..n {
      for j in i + 1..std::cmp::min(n, i + k + 1) {
         dp[j] = std::cmp::min(dp[j], dp[i] + (h[i] - h[j]).abs());
      }
   }
   println!("{}", dp[n-1]);
}


Measured memory_bytes: 6396
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };



int main() {
	ll N; cin >> N;
	vector<ll> A(3 * N+1); REP(i, 1, 3 * N+1)cin >> A[i];
	vector<ll> dp1(3 * N+1), dp2(3 * N+1);
	priority_queue<ll, vector<ll>, greater<ll>> qless;
	priority_queue<ll, vector<ll>, less<ll>> qgreater;
	ll sum = 0;
	REP(i, 1, N+1) {
		sum += A[i];
		qless.push(A[i]);
	}
	dp1[N] = sum;
	REP(i, N + 1, 2 * N + 1) {
		sum += A[i];
		qless.push(A[i]);
		sum -= qless.top();
		qless.pop();
		dp1[i] = sum;
	}
	sum = 0;
	for (int i = 3 * N; i >= 2 * N+1; --i) {
		sum += A[i];
		qgreater.push(A[i]);
	}
	dp2[2*N+1] = sum;
	for (int i = 2 * N; i >= N+1; --i) {
		sum += A[i];
		qgreater.push(A[i]);
		sum -= qgreater.top();
		qgreater.pop();
		dp2[i] = sum;
	}
	ll ans = -1e18;
	REP(i, N, 2 * N + 1)maxs(ans, dp1[i] - dp2[i + 1]);
	PRI(ans);
	return 0;
}

Measured memory_bytes: 12660
use std::io;
fn read() -> Vec<i32> {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input.trim().split(' ').map(|x| x.parse().ok().unwrap()).collect()
}
fn main() {
    let inputs = read();
    println!("{}", inputs[0] + (inputs[1] / 2));
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define maxN 200002
#define ll long long
#define lson 2 * nod
#define rson 2 * nod + 1
#define inf 10000000000000
using namespace std;

//FILE *fin = freopen("f.in", "r", stdin);

/* ---------------------------- */
int n, Q, a, b, q[maxN];
/* ---------------------------- */
ll add, dp[3][4 * maxN];
/* ---------------------------- */
ll ans;

void update(int t, int nod, int l, int r, int p, ll val)
{
    if (l > r)
        return ;
    if (l == r)
    {
        if (t == 0)
        {
            dp[0][nod] += val;
            dp[1][nod] += val;
            dp[2][nod] += val;
        }
        else if (t == 1)
        {
            dp[0][nod] = min(dp[0][nod], val - l);
            dp[1][nod] = min(dp[1][nod], val + l);
            dp[2][nod] = min(dp[2][nod], val);
        }
        else if (t == 2)
        {
            dp[0][nod] = -l;
            dp[1][nod] = l;
        }
        return ;
    }
    int mid = (l + r) >> 1;
    if (p <= mid)
        update(t, lson, l, mid, p, val);
    else
        update(t, rson, mid + 1, r, p, val);
    dp[0][nod] = min(dp[0][lson], dp[0][rson]);
    dp[1][nod] = min(dp[1][lson], dp[1][rson]);
    dp[2][nod] = min(dp[2][lson], dp[2][rson]);
}
ll query(int t, int nod, int l, int r, int x, int y)
{
    if (l > r || l > y || r < x)
        return inf;
    if (l >= x && y >= r)
        return dp[t][nod];
    ll q1 = inf, q2 = inf;
    int mid = (l + r) >> 1;
    if (mid >= x)
        q1 = query(t, lson, l, mid, x, y);
    if (y > mid)
        q2 = query(t, rson, mid + 1, r, x, y);
    return min(q1, q2);
}

int main()
{
    scanf("%d %d %d %d", &n, &Q, &a, &b);
    for (int i = 1; i <= Q; ++ i)
        scanf("%d", &q[i]);
    for (int i = 1; i <= n; ++ i)
        update(2, 1, 1, n, i, 0LL);
    for (int i = 1; i <= n; ++ i)
    {
        ll val = min(abs(q[1] - a) + abs(i - b), abs(q[1] - b) + abs(i - a));
        update(0, 1, 1, n, i, val);
    }
    ans = inf;
    for (int i = 2; i <= Q; ++ i)
    {
        ll dpmin = min(query(0, 1, 1, n, 1, q[i]) + q[i], query(1, 1, 1, n, q[i] + 1, n) - q[i]);
        add += abs(q[i] - q[i - 1]);
        //update(0, 1, 1, n, q[i], -(long long)abs(q[i] - q[i - 1]));
        update(1, 1, 1, n, q[i - 1], dpmin - abs(q[i] - q[i - 1]));

    }
    ans = query(2, 1, 1, n, 1, n);
    printf("%lld\n", ans + add);
    return 0;
}


Measured memory_bytes: 19456
#include<bits/stdc++.h>
using namespace std;
int mp[105][105];
int main(){
	int n,k;
	cin>>n>>k;
	int mx=(n-1)*(n-2)/2;
	if(mx<k){
		puts("-1");
		return 0;
	}
	int cnt=0;
	memset(mp,0,sizeof(mp));
	for(int i=2;i<=n;i++)
		mp[1][i]=mp[i][1]=1;
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(!mp[i][j]&&mx>k)
				mp[i][j]=mp[j][i]=1,--mx;
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			cnt+=mp[i][j];
	printf("%d\n",cnt);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(mp[i][j])
				printf("%d %d\n",i,j);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(1<<n);
	for(int i = 0; i < 1<<n; i++) cin >> a[i];
	multiset<int> has;
	for(int i = 0; i < 1<<n; i++) has.insert(a[i]);
	vector<int> now;
	now.push_back(*prev(has.end()));
	has.erase(prev(has.end()));
	for(int i = 0; i < n; i++){
		vector<int> upd;
		for(int v : now){
			auto it = has.lower_bound(v);
			if(it == has.begin()){
				cout << "No" << endl;
				exit(0);
			}
			it--;
			upd.push_back(*it);
			has.erase(it);
		}
		for(int v : upd){
			now.push_back(v);
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 14960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2505, M = 5005;
int n, m, p;
struct Edge{
    int u,v,w,next;
}e[M<<1];
int tot, head[N];
void adde(int u,int v,int w){
    e[tot].u=u;e[tot].v=v;e[tot].w=w;e[tot].next=head[u];head[u]=tot++;
}
bool ok[N], vis[N];
bool g[N][N];
int c[N], d[N], dis[N];
void dfs(int u) {
    ok[u] = 1;
    for(int i = 1; i <= n; i++) {
        if(g[u][i] && !ok[i]) dfs(i);
    }

}
int spfa(int s){
    queue <int> q;
    memset(d,0xcf,sizeof(d));
    memset(vis,0,sizeof(vis));memset(c,0,sizeof(c));
    q.push(s);vis[s]=1;d[s]=0;c[s]=1;dis[s]=0;
    while(!q.empty()){
        int u=q.front();q.pop();vis[u]=0;
        if(c[u]>n){
            return d[0];
        }
        for(int i=head[u];i!=-1;i=e[i].next){
            int v=e[i].v;
            if(!ok[v]) continue;
            if(d[v]<d[u]+e[i].w){
                d[v]=d[u]+e[i].w;
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    q.push(v);
                    c[v]++;
                }
            }
        }
    }
    return d[n];
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> p;
    memset(head, -1, sizeof(head));
    for(int i = 1; i <= m; i++) {
        int u, v, w; cin >> u >> v >> w;
        adde(u, v, w - p);
        g[v][u] = 1;
    }
    dfs(n);
    int t = spfa(1);
    if(t == d[0]) cout << -1;
    else cout << max(0, t);
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


int main() {
  int a, d, n;
  vector<bool> prime(1000100, true);
  prime[0] = prime[1] = false;
  for (unsigned int i = 2; i < prime.size(); i++) {
    if (prime[i]) {
      for (unsigned int j = 2 * i; j < prime.size(); j += i) {
	prime[j] = false;
      }
    }
  }
  
  while (cin >> a >> d >> n, a + d + n) {
    int sum = 0;
    while (1) {
      if (prime[a]) sum++;
      if (sum == n && prime[a]) {
	cout << a << endl;
	break;
      }
      a += d;
    }
  }
    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>

using namespace std;

int main() {
  int n;
  scanf("%d",&n);
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int a;
    scanf("%d",&a);
    while(a%2==0) {
      ans++;
      a/=2;
    }
  }
  printf("%d\n",ans);
}


Measured memory_bytes: 128
import sys
import re



def check(Sda, T, Slen, Tlen):
    matarr=[]
    endarr=[]

    getS = 'UNRESTORABLE'

    if(Slen<Tlen):
        return getS

    for i in reversed(range(0, Slen-Tlen+1)):


        mat = re.match(Sda[i:i+Tlen],T)
        try:
            if(mat.group() == T):
                matarr.append(Sda[:i]+T+Sda[i+Tlen:])

        except AttributeError:
            pass

        mat = 'None'

    if(matarr != []):
        for x in matarr:
            x = x.replace('.', 'a')
            endarr.append(x)

        getS = min(endarr)

    return getS



def main():
    Sda = input()
    T = input()
    Slen = len(Sda)
    Tlen = len(T)

    Sda = Sda.replace('?', '.')

    print(check(Sda, T, Slen, Tlen))


main()

Measured memory_bytes: 3188
N = int(input())
mod = 10 ** 9 + 7

if N == 0 or N == 1:
    print(0)

else:
    # DPテーブル
    dp = [0] * (N + 1)

    # 9の冪乗テーブル
    exp_9 = [0] * (N + 1)
    exp_9[0] = 1
    for i in range(1, N + 1):
        exp_9[i] = (exp_9[i - 1] * 9) % mod

    # 8の冪乗テーブル
    exp_8 = [0] * (N + 1)
    exp_8[0] = 1
    for i in range(1, N + 1):
        exp_8[i] = (exp_8[i - 1] * 8) % mod

    # DP計算
    for i in range(2, N + 1):
        dp[i] = (dp[i - 2] * 100 + 38 * exp_9[i - 2] - 36 * exp_8[i - 2]) % mod
        # print(i, dp[i])

    print(dp[N])


Measured memory_bytes: 127184
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

bool comp(PP a, PP b) {
	if(a.second.first > b.second.first) {
		return true;
	} else if(a.second.first < b.second.first) {
		return false;
	} else {
		if(a.second.second < b.second.second) {
			return true;
		} else if(a.second.second > b.second.second) {
			return false;
		} else {
			if(a.first < b.first) {
				return true;
			} else {
				return false;
			}
		}
	}
	return true;
}

int main(void) {
	int t, p, r, team, problem, time;
	string msg;
	vector<int> ans, pn, wtmp;
	vector<vector<int> > wrong;
	vector<PP> tres;
	PP res;
	P aw;
	int i;

	while(true) {
		cin >> t >> p >> r;
		if((t == 0 && p == 0 && r == 0)||cin.eof()) { break; }
		wtmp.clear();
		ans.clear();
		pn.clear();
		wrong.clear();
		for(i = 0; i < p; i++) {
			wtmp.push_back(0);
		}
		for(i = 0; i < t; i++) {
			ans.push_back(0);
			pn.push_back(0);
			wrong.push_back(wtmp);
		}
		for(i = 0; i < r; i++) {
			cin >> team >> problem >> time >> msg;
			if(msg=="CORRECT") {
				ans[team-1]++;
				pn[team-1] += wrong[team-1][problem-1] * 1200 + time;
			} else {
				wrong[team-1][problem-1]++;
			}
		}
		tres.clear();
		for(i = 0; i < t; i++) {
			aw = P(ans[i], pn[i]);
			res = PP(i+1, aw);
			tres.push_back(res);
		}
		sort(tres.begin(), tres.end(), comp);
		
		for(i = 0; i < t; i++) {
			cout << tres[i].first << " " << tres[i].second.first << " " << tres[i].second.second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 936
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N, -1);
    for(int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        if(a[s-1] == -1) {
            a[s-1] = c;
            continue;
        }
        if(a[s-1] != c) {
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < N; i++) {
        if(i == 0) {
            if(a[i] == 0 && N != 1) {
                cout << -1 << endl;
                return 0;
            }
            if(a[i] == -1) {
                if(N == 1) cout << "0";
                else cout << "1";
                continue;
            }
            cout << a[i];
            continue;
        }
        if(a[i] == -1) {
            cout << "0";
        } else {
            cout << a[i];
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H, W = [int(x) for x in input().split()]
N = int(input())
a = [int(x) for x in input().split()]
A = []
for i in range(N):
    A += [str(i + 1)] * a[i]

ans = [["0"] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        ans[i][j] = A.pop(0)

for i in range(H):
    if i % 2 == 0:
        print(*ans[i])
    else:
        print(*ans[i][::-1])


Measured memory_bytes: 41968
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9 + 7;
ll f[2000009],fi[2000009],inv[2000009],p[2000009];
ll C(ll n, ll m){
    if(m > n ||m < 0) return 0;
    return f[n] * fi[m] % mod * fi[ n - m] % mod;

}
main(){
    ll k;
    cin >> k;
    string s;
    cin>> s;
    ll n = s.size();
    inv[1] = 1;
    fi[0] = 1;
    f[0] = 1;
    p[0] = 1;
    for(ll i = 1; i <= n+k; i++){
        f[i] = f[i-1] * i % mod;
        if(i > 1) inv[i] = inv[mod % i] * (mod - mod/ i) % mod;
        fi[i] = fi[i-1] * inv[i] % mod;
        p[i]=  p[i-1] * 25 % mod;
    }
    ll ans = 0;
    for(ll l = n; l <= n+ k; l++){
        ans = (ans + C(n+k,l) * p[n+k-l]) % mod;
    }
    cout<<ans<<endl;
    /*

    */

}


Measured memory_bytes: 66740
while True:
	try:
		s = input()
	except:
		break

	for i in range(26):
		ss = ""
		for c in s:
			if c == ' ' or c == '.':
				ss += c
				continue
			c = ord(c)
			c = (c-ord('a')+i)%26+ord('a')
			ss += chr(c)
		a = ss.split()
		if "the" in a or "this" in a or "that" in a:
			print(ss)
			break

Measured memory_bytes: 7364
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	//ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    unordered_map<string,ll>m;
    vector<vector<string>>v(n+1);
    ll mx=-INF;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        m[s]++;
        mx=max(mx,m[s]);
        if(mx==m[s])v[mx].pb(s);
        //cout<<mx<<"\n";
    }
    vector<string>ans;
    for(auto u:v[mx]){
        ans.pb(u);
    }
    sort(all(ans));
    print(ans);
}


Measured memory_bytes: 40916
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
	int n;
	int sa=0, sb=0;
	int a, b;
	while (1){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 0; i < n; i++){
			cin >> a >> b;
			if (a>b){
				sa = sa + a + b;
			}
			else if (a < b){
				sb = sb + a + b;
			}
			else{
				sa = sa + a;
				sb = sb + b;
			}
		}
		cout << sa << " "<< sb<<endl;
		sa=0;
		sb=0;

	}
	return 0;
}

Measured memory_bytes: 3020
from collections import Counter

N,M = map(int,input().split())
a = [0]*M
for i in range(M):
    a[i] = int(input())

c = Counter(a).keys()

b = [(-1 if x in c else 0) for x in range(N+1)]

b[0] = 1

mod = 10**9+7
for i in range(1,N+1):
    if b[i] == -1:
        continue
    if i == 1:
        b[i] = b[0]
    else:
        b[i] = max(b[i-1],0) + max(b[i-2],0)
    b[i] %= mod

print(b[N])

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

int main(){
int K,S;
int K_buf,S_buf;
int X,Y,Z;
int cnt =0;
//for()
cin >> K_buf>> S_buf;

if(2<= K_buf <= 2500){  
if(0 <= S_buf <= 3*K_buf){
  K = K_buf;
  S = S_buf;
   }
}
  
  
for(int X = 0;X<=K;X++){
	for(int Y = 0;Y<=K;Y++){
    	Z = S - X - Y;
      if(Z>= 0 && Z <= K){
      cnt ++;
      }
       }
    }
cout << cnt << endl;
}

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

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

  int x[n];
  int tmp_a = 0,tmp_b = k;
  int dis_a,dis_b;
  int ans = 0;
  for(int i = 0;i < n;i++){
    cin >> x[i];
    dis_a = x[i] - tmp_a;
    dis_b = tmp_b - x[i];
    if(dis_a < dis_b)
      ans += (2 * dis_a);
    else
      ans += (2 * dis_b);
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;
const int maxn = 1004;
const int INF = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

struct Node {
    int x, y, step;
};

int m, n, ans, tot;
bool vis[maxn][maxn];
int G[maxn][maxn];
int posx[12], posy[12];

int bfs(int sx, int sy, char e) {
    queue<Node> que;
    que.push((Node){sx, sy, 0});
    while(!que.empty()) {
        Node t = que.front(); que.pop();
        vis[t.x][t.y] = true;
        if(G[t.x][t.y] == e) return t.step;
        for(int i = 0; i < 4; ++i) {
            int x = t.x + dx[i];
            int y = t.y + dy[i];
            if(x < 0 || y < 0 || x >= m || y >= n)
                continue;
            if(!vis[x][y] && G[x][y] != 'X') {
                vis[x][y] = true;
                que.push((Node){x, y, t.step + 1});
            }
        }
    }
    return -1;
}

int main() {
    scanf("%d%d%d", &m, &n, &tot);
    int sx, sy;
    for(int i = 0; i < m; ++i) {
        getchar();
        for(int j = 0; j < n; ++j) {
            G[i][j] = getchar();
            if(G[i][j] == 'S')
                G[i][j] = '0';
            if(G[i][j] <= '9' && G[i][j] >= '0') {
                int t = G[i][j] - '0';
                posx[t] = i;
                posy[t] = j;
            }
        }
    }
    for(int i = 0; i < tot; ++i) {
        ans += bfs(posx[i], posy[i], i + 1 + '0');
        memset(vis, 0, sizeof(vis));
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 7488
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 c1=a+b;
		int c2=a*b;
		int c3=a-b;
		int max=c1;
		if(max<c2) {
			max=c2;
		}
		if(max<c3) {
			max=c3;
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;
 
using namespace std;
int group[100010];
bitset<100010>verified;
vector<int>val;
vector<vector<int>>f(100010);
vector<vector<int>>b(100010);
 
void dfs(int i, int gr){
	if(verified[i]==true) return;
	verified[i]=true;
	val[gr]++;
	group[i] = gr;
 
	for(int j=0;j<f[i].size();j++){
		dfs(f[i][j], gr);
	}
 
 
	return;
}
 
 
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	int n,m,k,a,c;
 
	cin >> n >> m >> k;
 
	while(m--){
		cin >> a >> c;
		f[a].push_back(c);
		f[c].push_back(a);
	}
 
	while(k--){
		cin >> a >> c;
		b[a].push_back(c);
		b[c].push_back(a);
	}
 
	int cont=0;
	for(int i=1;i<=n;i++){
		if(verified[i]==false){
			val.push_back(0);
			dfs(i,cont);
			cont++;
		}
	}
 
	for(int i=1;i<=n;i++){
		cont = val[group[i]] - f[i].size();
		int g = group[i];
 
		for(int j=0;j<b[i].size();j++){
			if(g == group[b[i][j]])
				cont--;
		}
 
		cout << cont-1 << (i==n ? "\n": " ");
	}
 
	return 0;
}

Measured memory_bytes: 15320
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        h: usize,
        w: usize,
        a: [String; h],
    }

    let mut row_removed: Vec<_> = a.iter()
        .filter(|row| !row.chars().all(|c| c == '.'))
        .map(|row| row.chars().collect::<Vec<char>>())
        .collect();

    for column in 0..w {
        let mut only_white = true;
        for ref row in &row_removed {
            if row[column] == '#' {
                only_white = false;
                break;
            }
        }

        if only_white {
            for ref mut row in &mut row_removed {
                row[column] = '_';
            }
        }
    }

    for row in row_removed {
        for c in row {
            if c != '_' {
                print!("{}", c);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define sf1(a); scanf("%d",&a);
#define sf2(a,b); scanf("%d %d",&a, &b);
#define sf3(a,b,c); scanf("%d %d %d",&a, &b,&c);
#define sf4(a,b,c,d); scanf("%d %d %d %d",&a, &b,&c,&d);
#define pf1(a); printf("%d\n",a);
#define pf2(a,b); printf("%d %d\n",a,b);
#define pf3(a,b,c); printf("%d %d %d\n",a,b,c);
#define pf4(a,b,c,d); printf("%d %d %d %d\n",a,b,c,d);

using namespace std;

int main()
{
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int mn=500,mx=-500;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        mx=max(mx,k);
    }
    for(int i=0;i<m;i++)
    {
        int k;
        cin>>k;
        mn=min(mn,k);
    }
    if(mx<mn)
    {
        if(x<(mx+1) && mn<=y) cout<<"No War"<<endl;
        else cout<<"War"<<endl;
    }
    else
    {
        cout<<"War"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()

#define equal equalll
#define less lesss
const int N = -1;
const long long INF = 1e9 + 19;


void read() {
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') continue;
		int dist = 'z' - s[i] + 1;
		if (dist <= k) {
			k -= dist;
			s[i] = 'a';
		}
	}
	k %= 26;
	for (int i = 0; i < k; i++)
		s.back()++;

	cout << s << endl;

}

void solve() {

}

void stress() {

}

int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}



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

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	int a_end, b_begin;
	a_end = min(b, a+k-1)+1;
	b_begin = max(a_end, b-k+1);
	for (int i = a; i < a_end; i++) cout << i << endl;
	for (int i = b_begin; i <= b; i++) cout << i << endl;
}


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

int main() {
  string a,b;
  cin >> a;
  cin >> b;
  
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  
  if (a < b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

#define MAXN 1500
#define MAXKIND 1000*MAXN
int h[MAXKIND], w[MAXKIND];

void calLength(int n,int length[MAXKIND]){
    int l[MAXN] = {0};
    for(int i = 0; i < n; i++){
        cin >> l[i]; length[l[i]]++;
    }
    
    for(int i = 0; i < n; i++){
        int nowLength = l[i];
        for(int j = i+1; j < n; j++){
            nowLength += l[j];
            length[nowLength]++;
        }
    }
}

int main(int argc, const char * argv[]) {
    while(1){
        int n, m; cin >> n >> m;
        if(!n && !m) break;
        
        memset(h, 0, sizeof(h));
        memset(w, 0, sizeof(w));
        
        calLength(n, h);
        calLength(m, w);
        
        int cnt = 0;
        for(long i = 0; i < MAXKIND; i++){
            cnt += h[i] * w[i];
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 12888
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
  { 
  int a,b,c,t;
  cin>>a>>b>>c;
  t=b;
  b=a;
  a=c;
  c=t;
  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int n, k;
	int r, s, p;
	int sum = 0;

	char t[100001];

	scanf("%d %d", &n, &k);

	scanf("%d %d %d", &r, &s, &p);

	scanf("%s", t);

	for (int i = 0; i < k; i++) {
		if (t[i] == 'r')sum += p;
		if (t[i] == 's')sum += r;
		if (t[i] == 'p')sum += s;
	}

	for (int i = k; i < n; i++) {
		if (t[i] == t[i - k]) {
			if (i < n - k && t[i] == t[i + k])t[i] = 'a';
			continue;
		}
		else {
			if (t[i] == 'r')sum += p;
			if (t[i] == 's')sum += r;
			if (t[i] == 'p')sum += s;
		}
	}

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 256
nums = input().split()
N = int(nums[0])
A = int(nums[1])
B = int(nums[2])

n = 0
ans = 0
while n < N+1:
	n4 = n // 10**4
	n3 = n // 10**3 - n4 * 10
	n2 = n // 10**2 - n4 * 100 - n3 * 10
	n1 = n // 10 - n4 * 1000 - n3 * 100 - n2 * 10
	n0 = n % 10
	X = n4 + n3 + n2 + n1 + n0
	if X >= A and X <= B:     
		ans += n 
	n += 1

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	char[] c;
	int id;
	
	char not(char x){
		if(x=='0') return '2';
		else if(x=='2') return '0';
		else return '1';
	}
	
	char plus(char x, char y){
		if(x=='0' && y=='0') return '0';
		else if(x=='2' || y=='2') return '2';
		else return '1';
	}
	
	char mul(char x, char y){
		if(x=='0' || y=='0') return '0';
		else if(x=='2' && y=='2') return '2';
		else return '1';
	}
	
	char exp(){
		char a = fact();
		id++;
		if(id<c.length){
			if(c[id]=='+'){
				id++;
				a = plus(a, exp());
			}else if(c[id]=='*'){
				id++;
				a = mul(a, exp());
			}
		}
		return a;
	}
	
	char fact(){
		char b = c[id];
		if(b=='('){
			id++;
			b = exp();
		}else if(b=='-'){
			id++;
			b = not(fact());
		}
		return b;
	}
	
	
	void solve(){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String s = sc.next();
			if(s.compareTo(".")==0) break;
			
			int cnt = 0;
			String t;
			for(int p=48;p<51;p++){
				for(int q=48;q<51;q++){
					for(int r=48;r<51;r++){
						t = s;
						t = t.replaceAll("--", "");
						t = t.replace('P', (char)p).replace('Q', (char)q).replace('R', (char)r);
						c = t.toCharArray();
						
						id = 0;
						if(exp()=='2') cnt++;
					}
				}
			}
			System.out.println(cnt);
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();	
	}	
}

Measured memory_bytes: 35792
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    string s; cin >> s;
    set<string> st;
    string tmp = "",now = "";

    int mx = 0,cnt = 0;
    for (int i = 0; i < s.size(); i++){
        now += s[i];
        if (tmp != now){
            tmp = now;
            now = "";
            cnt++;
        }
    }
    mx = max(mx, cnt);

    cout << mx << endl;
}

Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[]L = new int[N];
 
    int all = 0;
    for(int i=0; i<N; i++){
        L[i] = sc.nextInt();
        all += L[i];
    }
        Arrays.sort(L);
        if(L[N-1]<all-L[N-1]) {
        System.out.println("Yes");
        }else {
        System.out.println("No");
    }
    }
}

Measured memory_bytes: 35828