akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
const int INF = 1e9;
const int MOD = 1000000007;

ll dp[105][5][3];

int main(){
    string s;
    int K;
    cin >> s >> K;
    dp[0][0][0] = 1;
    for(int i=1;i<=s.size();i++){
        int sd = s[i-1] - '0';
        rep(j,K+1)rep(d,10){
            if(d==0){
                if(d < sd){
                    dp[i][j][1] += dp[i-1][j][0];
                }else if(d==sd){
                    dp[i][j][0] += dp[i-1][j][0];
                }
                dp[i][j][1] += dp[i-1][j][1];
            }else{
                if(d < sd){
                    if(j>0) dp[i][j][1] += dp[i-1][j-1][0];
                }else if(d==sd){
                    if(j>0) dp[i][j][0] += dp[i-1][j-1][0];
                }
                if(j>0) dp[i][j][1] += dp[i-1][j-1][1];
            }
        }
    }
    cout << dp[s.size()][K][0] + dp[s.size()][K][1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';


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

int main()
{
    int r;
    io >> r;
    int ans = r * r;
    io << ans << BR;
}

Measured memory_bytes: 3816
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		char[] c=new char[n];
		
		int nr=0;
		int ans=0;
		
		for(int i=0;i<n;i++) {
			c[i]=s.charAt(i);
			if(c[i]=='R')nr++;
		}
		
		for(int i=0;i<n;i++) {
			if(nr==0)break;
			if(c[i]=='W') {
				nr--;
				ans++;
			}else {
				nr--;
			}
		}
		
	 System.out.println(ans);
		
	}

}


Measured memory_bytes: 40752
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  map<int,ll> mp;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }
  ll sum = 0;
  for(auto it:mp){
    sum += it.S*(it.S-1)/2;
  }

  rep(i,n){
    ll tmp1 = mp[a[i]]*(mp[a[i]]-1)/2;
    ll tmp2 = (mp[a[i]]-1)*(mp[a[i]]-2)/2;
    ll ans = sum - tmp1 + tmp2;
    cout << ans << ln;
  }
  return 0;
}

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

int N, p[100000];
bool dp[100000] = { false };
queue<int> q;

int rec(int turn=1) {
	int r, d;
	int sz = q.size();
	for (int I = 0; I < sz; I++) {
		r = q.front(); q.pop();
		for (int i = 6; i >= 0; i--) {
			d = i;
			while (true) {
				if (r + d < N - 1) {
					if (!dp[r + d]) {
						dp[r + d] = true;
						if (p[r + d] != 0) {
							d += p[r + d];
							continue;
						}
						else {
							q.push(r + d);
							break;
						}
					}
					else {
						break;
					}
				}
				else {
					return turn;
				}
			}
		}
	}
	return rec(turn + 1);
}

int main(){
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	dp[0] = true;
	q.push(0);
	int a = rec();
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 4632
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
using namespace std;

ll n, a, b;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), a = read(), b = read();
	if (a - b >= n) puts("OK");
	else {
		REP(i, a, b)
			if (i % n == 0){
				puts("OK");
				exit(0);
			}
		puts("NG");
	}
}

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

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

using namespace std;

int strDiff(string s, string t, size_t s_offset){
    int diff = 0;
    for(size_t i=0; i<t.size(); i++){
        if(s[s_offset+ i] != t[i])
            diff++;
    }
    return diff;
}

int main()
{
    string s, t;
    cin >> s >> t;
    
    auto solver = [&](){
        int minDiff = t.size();
        for(size_t i=0; i<=s.size() - t.size(); i++){
            int diff = strDiff(s, t, i);
            if(diff < minDiff)
                minDiff = diff;
        }
        return minDiff;
    };
    
    cout << solver() << endl;

    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  string s;
  cin >> s;
  int len = s.length();
  rep(i, len){
    if(s.at(i) == '?')
      s.at(i) = 'D';
  }
  cout << s << endl;
}

Measured memory_bytes: 3700
#include<stdio.h>
#include<iostream>
using namespace std;
int main() {
	int a[2019];
	int i, j, l, n,m,f;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	scanf("%d", &m);
	for (i = 0; i < m; i++) {

		scanf("%d", &l);
		l--;
		f = 0;
		for (j = 0; j < n; j++) {
			if ((a[l] + 1) == a[j]) { f++; }
			if ((a[l] == 2019)) { f++; }

		}
		if (f == 0)a[l]++;
	}
	for (i = 0; i < n; i++) {
		printf("%d\n", a[i]);
	}
}


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

    for(int i=0; i<=n; i++){
        for (int j=0; i+j<=n; j++){
            for(int k=0; i+j+k<=n; k++){
                if(i+j+k == n && (10000*k + 5000*j + 1000*i == y)){
                    cout << k  << " " << j << " " << i;
                    return 0;
                }
            }
        }
        
    }

    cout << -1 << " " << -1 << " " << -1;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int TABLE[] = { 0, 2, 4, 6, 8, 1, 3, 5, 7, 9 };

int memo[8][8][10];

int recur(int odd, int even, const vector<int> &a, int sum){
	if(memo[odd][even][sum] >= 0){ return memo[odd][even][sum]; }
	int answer = 0;
	if(odd > 0){
		for(int i = 0; i < a.size(); ++i){
			answer += recur(odd - 1, even, a, (sum + a[i]) % 10);
		}
	}else if(even > 0){
		for(int i = 0; i < a.size(); ++i){
			answer += recur(odd, even - 1, a, (sum + TABLE[a[i]]) % 10);
		}
	}else if(sum == 0){
		answer = 1;
	}
	memo[odd][even][sum] = answer;
	return answer;
}

int main(){
	int n;
	string s;
	cin >> n >> s;
	int sum = 0, odd = 0, even = 0;
	reverse(s.begin(), s.end());
	for(int i = 0; i < n; ++i){
		if(s[i] == '*'){
			if(i % 2 == 0){
				++odd;
			}else{
				++even;
			}
		}else{
			int d = (s[i] - '0');
			if(i % 2 == 1){ d = TABLE[d]; }
			sum += d;
		}
	}
	int m;
	cin >> m;
	vector<int> a(m);
	for(int i = 0; i < m; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	memset(memo, -1, sizeof(memo));
	cout << recur(odd, even, a, sum % 10) << endl;
	return 0;
}

Measured memory_bytes: 1336
d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
     [[-1,  0], [0, -1], [1,  0], [1, 1], [0, 1], [-1, 1]]]

w, h = gets.split.map(&:to_i)
fld = (h+2).times.map{ [false]*(w+2) }
(1..h).each do |i|
  gets.split(" ").each_with_index{ |e, j| fld[i][j+1] = true if e == "1" }
end

prt = (h+2).times.map{ [false]*(w+2) }
arr = []
arr << [0, 0]
prt[0][0] = true
until arr.empty?
  y, x = arr.pop
  d[y%2].each do |dy, dx|
    u = y + dy; v = x + dx
    next if u < 0 || u > h+1 || v < 0 || v > w+1
    if !fld[u][v] && !prt[u][v]
      prt[u][v] = true
      arr << [u, v]
    end
  end
end

fld = fld.flatten.zip(prt.flatten).map{|f,p| !(!f&p) }

p ((w+2)+1...(h+1)*(w+2)).collect{ |i| u, v = i.divmod(w+2); d[u%2].count{ |y, x| !fld[(u+y)*(w+2)+v+x] } if fld[u*(w+2)+v]}.compact.reduce(:+)

Measured memory_bytes: 9548
#include<stdio.h>
int main(void)
{
	int i,N,A[21],B[21],C[20];
	int sum=0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
	}
	for(i=0;i<N;i++)
	{
		scanf("%d",&B[i]);
	}
	for(i=0;i<N-1;i++)
	{
		scanf("%d",&C[i]);
	}
	for(i=0;i<N;i++)
	{
		if(A[i]==A[i+1]-1)
		sum=B[A[i]-1]+C[A[i]-1]+sum;
		else
		sum=B[A[i]-1]+sum;
	}
	printf("%d",sum);
	return 0;
	
}


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

using namespace std;

int outPow2Mod107(int p)
{
	unsigned int ans = 1;

	if (p <= 30){
		ans <<= p;
		return ans;
	} else {
		ans <<= 30;
		p -= 30;
	}
	while (p > 0){
		ans *= 2;
		p--;

		ans %= 1000000007;
	}

	return ans;
}

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

	int zerocnt = 0;
	for (int i = 0; i < n; i++){
		if (a[i] % 2 == n % 2){
			cout << 0 << endl;
			return 0;
		}

		if (a[i] == 0){
			if (zerocnt == 1){
				cout << 0 << endl;
				return 0;
			} else {
				zerocnt++;
			}
		} else {
			cnt[(a[i] - 1) / 2]++;
			if (cnt[(a[i] - 1) / 2] > 2){
				cout << 0 << endl;
				return 0;
			}
		}
	}

	cout << outPow2Mod107(n / 2) << endl;

	return 0;
}

Measured memory_bytes: 768
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
s = list(ns())

a = s[k-1].lower()

s[k-1] = a

print("".join(s))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int N,M;
  vector<int>P,P2;
  int ans,sum;
  int low,high,medi;
  while(cin>>N>>M,N|M){
    P.resize(N);
    P2.clear();
    for(int i=0;i<N;i++){
      cin>>P[i];
      P2.push_back(P[i]);
    }
    for(int i=0;i<N;i++)for(int j=i;j<N;j++)P2.push_back(P[i]+P[j]);
    sort(P2.begin(),P2.end());
    ans=0;
    for(int i=0;i<P2.size();i++){
      low=0;
      high=P2.size();
      medi=(low+high)/2;
      while(low<high && low!=medi){
	sum=P2[i]+P2[medi];
	if(sum>M)high=medi;
	else low=medi;
	medi=(low+high)/2;
      }
      sum=P2[i]+P2[medi];
      if(sum>M)
	if(medi>0)medi--;
	else sum=0;
      ans=max(ans,sum);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
    
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
vec adj[100005]; ll dp1[100005],dp2[100005];
void dfs(ll x,ll p)
{
	ll s1=1,s2=1,c;
	rep(i,0,adj[x].size())
	{
		c=adj[x][i];
		if(c==p)
		continue;
		dfs(c,x);
		s1 = (s1*dp2[c])%mod;
		s2 = (s2*(dp1[c]+dp2[c])%mod)%mod;
	}
	dp1[x]=s1;
	dp2[x]=s2;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,k,l,m,first,last,n,x,y;
    	cin>>n;
    	rep(i,0,n-1)
    	{
    		cin>>x>>y;
    		adj[x].pb(y);
    		adj[y].pb(x);
		}
		dfs(1,0);
		cout<<(dp1[1]+dp2[1])%mod;
	}
	return 0;
}

Measured memory_bytes: 14208
import sys
sys.setrecursionlimit(10**5)

class Node:
    def __init__(self):
        self.val = None
        self.a = []

n = int(input())
nodes = []

for i in range(n):
    nodes.append(Node())

for i in range(n-1):
    u, v, w = map(int, input().split())
    node1 = nodes[u-1]
    node2 = nodes[v-1]
    node1.a.append([node2, w])
    node2.a.append([node1, w])

root = nodes[0]
root.val = True
nodeSet = set()

def traverse(node):
    if node in nodeSet:
        return
    else:
        nodeSet.add(node)

    for pair in node.a:
        adjNode = pair[0]
        dis = pair[1]
        if dis % 2 == 0:
            adjNode.val = node.val
        else:
            adjNode.val = not node.val
        traverse(adjNode)

traverse(root)

for i in range(n):
    node = nodes[i]
    if node.val:
        print(1)
    else:
        print(0)




Measured memory_bytes: 96116
#include <bits/stdc++.h>
using namespace std;
int main(){
  string w;
  cin >> w;
  int ans=0;
  if(w=="SSS"){
    ans=0;
  }
  else if(w=="RSS"||w=="SRS"||w=="SSR"||w=="RSR"){
    ans=1;
  }
  else if(w=="RRR"){
    ans=3;
  }
  else{
    ans=2;
  }
  cout << ans << endl;
  return 0;
}


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

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define fo(i, a, b, k) for(int i = a; i <= b; i += k)
#define _fo(i, a, b, k) for(int i = a; i >= b; i -= k)
#define foa(i, a) for (auto &i : a)
#define fod(i, a) for(int i = 1; i*i <= a; i++)
#define sz(a) ((int) a.size())
#define all(a) begin(a), end(a)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mk(x, y) make_pair(x, y)  
#define log2i(x) (31-__builtin_clz(x))
#define log2ll(x) (63-__builtin_clzll(x)) 
#define msz(x) __builtin_popcount(x) 
#define mszll(x) __builtin_popcountll(x) 
#define fom(i, a, b) for(int i = a; i < (1<<b); i++)
#define ifon(i, mask) if(mask&(1<<i))
#define ss(i, mask) while(i=(i-mask)&mask)
#define ifss(i, mask) if(i > (mask^i)) 

typedef int64_t ll;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b, sum;
	
	cin >> a >> b;
	sum = (a+b);
	
	if(sum % 2 == 0) cout << sum/2;
	else cout << "IMPOSSIBLE";	
}

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

//Ferris Wheel
int main(){
	int a, b;
	cin >> a >> b;
	if(a>=13){
		cout << b << endl;
	}else if(a >= 6){
		cout << b/2 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n,X = map(int,input().split())

def gcd(a,b):
    if a < b:
        a,b = b,a
    if b == 0:
        return a
    else:
        r = a%b
        return gcd(b,r)

x = list(map(int, input().split()))
ans = float("inf")
for i in range(0,n):
    x[i] = abs(x[i]-X)
    if i >= 1:
        x[i] = gcd(x[i],x[i-1])
    ans = min(ans,x[i])
print(ans)


Measured memory_bytes: 14252
#include<stdio.h>
#include<string.h>

int main(){
  int i,slen;
  char str[1002],b;
  fgets(str,1000,stdin);
  slen=strlen(str);
  for(i=0;i<slen;i++){
    if(str[i]=='a'&&i+4<slen){
      if(!strncmp(str+i+1,"pple",4)){
	b=str[i+5];
	strcpy(str+i,"peach");
	str[i+5]=b;
      }
    }else if(str[i]=='p'&&i+4<slen){
      if(!strncmp(str+i+1,"each",4)){
	b=str[i+5];
	strcpy(str+i,"apple");
	str[i+5]=b;
      }
    }
  }
  printf("%s",str);
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int h, w, ans[50][50];
  string s[50];
  cin >> h >> w;
  for(int i = 0; i < h; i++) cin >> s[i];
   
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      int num = -1;
      ans[i][j] = num;
      if(s[i].substr(j,1)=="#") continue;
      if(i-1  >= 0 ) {
        if(j-1 >= 0) 
          if(s[i-1].substr(j-1,1)=="#") num++;
        if(s[i-1].substr(j,1)=="#") num++;
        if(j+1 < w)  
          if(s[i-1].substr(j+1,1)=="#") num++;
      }
        if(j-1 >= 0) 
          if(s[i].substr(j-1,1)=="#") num++;
        //if(s[i].substr(j,1)=="#") ans[i][j]++;
        if(j+1 < w)  
          if(s[i].substr(j+1,1)=="#") num++;
      if(i+1 < h) {
        if(j-1 >= 0) 
          if(s[i+1].substr(j-1,1)=="#") num++;
        if(s[i+1].substr(j,1)=="#") num++;
        if(j+1 < w)  
        if(s[i+1].substr(j+1,1)=="#") num++;
      }
      ans[i][j] = num+1;
    }
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(ans[i][j] == -1) cout << "#";
      else cout << ans[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
char c[105][105];
int y[105];
int x[105];
int main(){
    int h,w;
    cin >> h >> w;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin >> c[i][j];
    int flag=0;
    int rm=0;
    for(int i=0;i<h;i++){
        flag=0;
        for(int j=0;j<w;j++)if(c[i][j]=='.')flag++;
        if(flag==w)y[i]++;
    }
    for(int i=0;i<w;i++){
        flag=0;
        for(int j=0;j<h;j++)if(c[j][i]=='.')flag++;
        if(flag==h)x[i]++;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)if(y[i]==0 && x[j]==0)cout << c[i][j];
        if(y[i]==0)cout << endl;
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	cout << v.back() - v.front() << endl;
}

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

using namespace std;

void test()
{
    long long int n;
    cin>>n;

    map<long long int,long long int>mp;

    long long int sim=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;

        mp[x]++;

        sim+=x;
    }

    int q;
    cin>>q;

    while(q--)
    {
        int l,r;
        cin>>l>>r;

        sim+=(r-l)*mp[l];
        mp[r]+=mp[l];
        mp[l]=0;

        cout<<sim<<"\n";

    }

}

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

    test();

    return 0;
}


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

int main(){ 
  int K, S;
  cin >> K >> S;
  int res = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      int d = S - (i + j);
      if (d < 0 || d > K) continue;
      res++;
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
n, t = list(map(int, input().split()))
mincost = 100000
for _ in range(n):
    ci, ti = list(map(int, input().split()))
    if ti > t:
        continue
    if ci < mincost:
        mincost = ci
if mincost == 100000:
    print("TLE")
else:
    print(mincost)
    

Measured memory_bytes: 2940
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
bool check(pi a,pi b){
    return a.F*b.S-a.S*b.F>=0;
}
template <class _T> _T line(_T a,_T b){
    return {b.F-a.F,b.S-a.S};
}
template <class _T> double dis(_T a,_T b){
    a=line(a,b);
    return sqrt(a.F*a.F+a.S*a.S);
}
double min(double a,double b){return a>b?b:a;}
pair<double,double> from,to;
double ans(pi x,pi y){
    pair<double,double>a,b,l,r;
    a={x.F,x.S};
    b={y.F,y.S};
    while(dis(a,b)>0.0001){
        l={(a.F*2+b.F)/3,(a.S*2+b.S)/3};
        r={(a.F+b.F*2)/3,(a.S+b.S*2)/3};
        if(dis(from,l)+dis(l,to)>dis(from,r)+dis(r,to))a=l;
        else b=r;
    }
    return min(dis(from,a)+dis(a,to),dis(from,b)+dis(b,to));
}
int main(){
    int n,now=0,cnt=2;
    vector<pair<pi,int>>v,ch;
    pi temp;
    double l=0,r=0;
    bool f=false;
    scanf("%d%d",&temp.F,&temp.S);
    from=temp;
    v.PB({temp,-2});
    scanf("%d%d",&temp.F,&temp.S);
    v.PB({temp,-1});
    to=temp;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&temp.F,&temp.S);
        v.PB({temp,i});
    }
    sort(v.begin(),v.end());
    ch.PB(v[0]);
    ch.PB(v[1]);
    for(int i=2;i<v.size();i++){
        while(ch.size()>1){
            if(!check(line(ch[ch.size()-2].F,ch.back().F),line(ch.back().F,v[i].F)))ch.pop_back();
            else break;
        }
        ch.PB(v[i]);
    }
    for(int i=(int)v.size()-2;i>=0;i--){
        while(ch.size()>1){
            if(!check(line(ch[ch.size()-2].F,ch.back().F),line(ch.back().F,v[i].F)))ch.pop_back();
            else break;
        }
        ch.PB(v[i]);
    }
    for(int i=1;i<ch.size();i++){
        if(f)l+=dis(ch[i].F,ch[i-1].F);
        else r+=dis(ch[i].F,ch[i-1].F);
        if(ch[i].S==-2||ch[i].S==-1)f=!f;
    }
    l=min(l,r);
    if(l==dis(from,to)||f){
        ch.clear();
        while(cnt){
            while(v[now].S==-1||v[now].S==-2)now++;
            ch.PB(v[now]);
            cnt--;
            now++;
        }
        while(now<v.size()){
            while(v[now].S==-1||v[now].S==-2){
                now++;
                if(now>=v.size())break;
            }
            if(now>=v.size())break;
            while(ch.size()>1){
                if(!check(line(ch[ch.size()-2].F,ch.back().F),line(ch.back().F,v[now].F)))ch.pop_back();
                else break;
            }
            ch.PB(v[now]);
            now++;
        }
        now=(int)v.size()-2;
        while(now>=0){
            while(v[now].S==-1||v[now].S==-2){
                now--;
                if(now<0)break;
            }
            if(now<0)break;
            while(ch.size()>1){
                if(!check(line(ch[ch.size()-2].F,ch.back().F),line(ch.back().F,v[now].F)))ch.pop_back();
                else break;
            }
            ch.PB(v[now]);
            now--;
        }
        l=ans(ch.front().F,ch.back().F);
        for(int i=1;i<ch.size();i++)l=min(l,ans(ch[i].F,ch[i-1].F));
    }
    printf("%.20lf\n",l);
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define Nmax 100005
using namespace std;

int n,x,y,_x,_y;

set<int> S;
pii v[Nmax];

int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v+1,v+n+1);
    ll ans = 0;
    for (int i=n;i>=1;i--){
        if (S.empty()){
            S.insert(v[i].second);
            continue;
        }
        auto it = S.upper_bound(v[i].second);
        if (it!=S.end()){
            x = *it;
            if (next(it) == S.end()) y = n+1;
            else y = *next(it);
        }
        else{
            x = n+1;
        }
        if (it!=S.begin()){
            it = prev(it);
            _x = *it;
            if (it!=S.begin()) _y = *prev(it);
            else _y = 0;
        }
        else{
            _x = 0;
        }
        // dbg(v[i].second);
        // dbg(x);dbg(y);dbg(_x);dbg(_y);
        if (_x != 0) ans += 1LL * v[i].first * (x - v[i].second) * (_x - _y);
        if (x != n+1) ans += 1LL * v[i].first * (v[i].second - _x) * (y - x);   
        S.insert(v[i].second);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N;
int a[MAX];

int main(void) {
    scanf("%d", &N);
    REP(i, N) scanf("%d", a + i);
    int odd = 0, even = 0;
    REP(i, N) {
        if (a[i] % 2) odd++;
        else even++;
    }
    if (odd % 2) {
        cout << "NO" << endl;
    } else {
        cout <<"YES" << endl;
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,a[200005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	int minp=2e5+1,ans=0;
	for(int i=1;i<=n;i++){
	    if(a[i]<=minp){
	        minp=a[i];
	        ans++;
	    }
	}
	cout<<ans;
}


Measured memory_bytes: 1024
from collections import Counter
from collections import defaultdict

def li():
    return [int(x) for x in input().split()]

H, W, M = li()
PH = []
PW = []
PHF = defaultdict(int)
PWF = defaultdict(int)
PF = defaultdict(int)

for i in range(M):
    h, w = li()
    PH.append(h)
    PW.append(w)
    PHF[h] += 1
    PWF[w] += 1
    PF[h, w] += 1

sorted_PHF = sorted(PHF.items(), key=lambda x: x[1], reverse=True)
sorted_PWF = sorted(PWF.items(), key=lambda x: x[1], reverse=True)
most_common_h_cnt = sorted_PHF[0][1]
most_common_w_cnt = sorted_PWF[0][1]

most_common_h_list = []
for x in sorted_PHF:
    if x[1] < most_common_h_cnt:
        break
    most_common_h_list.append(x[0])

most_common_w_list = []
for x in sorted_PWF:
    if x[1] < most_common_w_cnt:
        break
    most_common_w_list.append(x[0])

add = -1
for h in most_common_h_list:
    for w in most_common_w_list:
        if PF[h, w] == 0:
            add = 0
            break

cnt = most_common_h_cnt + most_common_w_cnt + add

print(cnt)

Measured memory_bytes: 239340
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) throws IOException {
        int n = scanner.nextInt();
        Map<String, Long> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            char[] s = scanner.next().toCharArray();
            Arrays.sort(s);
            map.compute(String.valueOf(s), (key, value) -> value == null ? 1 : value + 1);
        }
        long ans = 0;
        for (long value : map.values()) {
            ans += value * (value - 1) / 2;
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

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

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

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

Measured memory_bytes: 47460
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string N;
    cin >> N;
    int s = 0;
    REP(i, N.size()) s += N[i] - '0';
    if (s % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  string s;
  cin >> s;
  s.insert(4, " ");
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<limits>
#include<iomanip>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


vvi search(int n,int m,int a,int b,int c,int t){
    vvi r(n);
    for(int i=0;i<n;i++){
        r[i].resize(n);
    }
    if(t==0){
        for(int i=0;i<n;i++){
            r[i][i]=1;
        }
        return r;
    }
    if(t==1){
        for(int i=0;i<n;i++){
            if(i-1>=0){r[i-1][i]=a%m;}
            r[i][i]=b%m;
            if(i+1<n){r[i+1][i]=c%m;}
        }
        return r;
    }
    vvi ret=search(n,m,a,b,c,t/2);
    for(int i=0;i<n;i++){
        for(int h=0;h<n;h++){
            for(int k=0;k<n;k++){
                r[k][h]+=ret[i][h]*ret[k][i];
                r[k][h]%=m;
            }
        }
    }
    if(t%2==1){
        for(int i=0;i<ret.size();i++){
            for(int h=0;h<ret[i].size();h++){
                ret[i][h]=0;
            }
        }
        for(int i=0;i<n;i++){
            for(int h=0;h<n;h++){
                if(i-1>=0){ret[i-1][h]+=r[i][h]*a%m; ret[i-1][h]%=m;}
                ret[i][h]+=r[i][h]*b%m; ret[i][h]%=m;
                if(i+1<n){ret[i+1][h]+=r[i][h]*c; ret[i+1][h]%=m;}
            }
        }
        return ret;
    }
    return r;
}


int main(){
    while(1){
        
        
    int n,m,a,b,c,t;
    cin>>n>>m>>a>>b>>c>>t;
        if(n==0 && m==0 && a==0 && b==0 && c==0 && t==0){break;}
    swap(a,c);
    vi ans(n);
    vi in(n);
    for(int i=0;i<n;i++){
        cin>>in[i];
    }
    vvi vv=search(n,m,a,b,c,t);
    for(int i=0;i<n;i++){
        for(int h=0;h<n;h++){
            ans[i]+=in[h]*vv[i][h]%m;
        }
    }
    for(int i=0;i<n;i++){
        ans[i]%=m;
        cout<<ans[i];
        if(i!=n-1){cout<<" ";}
    }
    cout<<endl;
        
        
    }
    return 0;
}



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i=0; i<H; i++)
    cin >> a.at(i);
  for (int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
  for (int i=0; i<H; i++)
    cout << '#' << a.at(i) << '#' << endl;
  for (int i=0; i<W+2; i++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int m, n;
  scanf("%d %d", &m, &n);
  int a, sum=0;
  for(int i=0; i<n; i++){
    scanf("%d", &a);
    sum+=a;
  } 
  if(sum>m)printf("-1\n");
  else printf("%d\n", m-sum);
}

Measured memory_bytes: 1724
#include<stdio.h>
int main(){
   int x[5];
   for(int i=0;i<5;i++){
      scanf("%d",&x[i]);

  
   }


      for(int i=0;i<5;i++){


      if(x[i]==0){
         printf("%d",i+1);
      }
      }

   
   return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	string s;
	cin>>s;
	if (s=="AAA" || s=="BBB")
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int n;
vector<vector<int>> G;
vector<set<int>> colors;
vector<bool> seen;
map<P, int> mp;

void dfs(int v, int used) {
    debug(v, used);
    int color = 0;
    seen[v] = true;
    for(const auto& nv: G[v]) {
        if (seen[nv]) continue;
        if (color == used) color++;
        if (v<nv) mp[{v,nv}] = color;
        else mp[{nv, v}] = color;
        debug(v, nv, used, color);
        dfs(nv, color);
        color++;
    }
}

int main() {
    cin >> n;
    G.resize(n);
    colors.resize(n);
    seen.assign(n, false);
    vector<P> edges(n-1);
    rep(i, n-1) {
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
        edges[i] = {x, y};
    }
    // print(G);
    dfs(0, -1);
    int ans = 0;
    for(const auto& m: mp) chmax(ans, m.se);
    cout << ans+1 << endl;
    for(const auto& p: edges) {
        cout << mp[{p.fi, p.se}]+1 << endl;
    }
}

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

int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	if(s.substr(0, n/2) == s.substr(n/2, n/2) && (n%2==0)){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define N 200000000
struct card{
  char s;
  int nn;
};

struct card L[MAX], R[MAX];

void merge(struct card A[], int n, int left, int mid ,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i = 0 ; i<n1; i++){
    L[i] = A[left +i];
  }

  for(i = 0; i < n2; i++){
    R[i] = A[mid +i];
  }

  L[n1].nn = N;

  R[n2].nn = N;

  i = 0;
  j = 0;

  for(k = left ; k<right ; k++){
    if(L[i].nn <= R[j].nn){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}

void m_sort(struct card A[], int n, int left,int right){
  int m;
  if(left+1 < right){
    m = (left +right)/2;
    m_sort(A,n,left,m);
    m_sort(A,n,m,right);
    merge(A,n,left,m,right);
  }
}

int partition(struct card A[] ,int n, int p, int r){
  int i,j;
  struct card t,x;
  x = A[r];
  i = p - 1;
  for(j = p; j<r ; j++){
    if(A[j].nn <= x.nn){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i +1];
  A[i+1] = A[r];
  A[r] = t;
  return i + 1;
}

void quickSort(struct card A[], int n, int p,int r){
  int q;
  if(p < r){
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int i,n,v;
  struct card A[MAX],B[MAX];
  char M[10];
  int stable = 1;

  scanf("%d",&n);
  for(i = 0; i<n; i++){
    scanf("%s %d",M,&v);
    A[i].s = M[0];
    B[i].s = M[0];
    A[i].nn = v;
    B[i].nn = v;
  }
  m_sort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i = 0; i<n; i++){
    if(A[i].s != B[i].s){
      stable = 0;
    }
  }

  if(stable == 1){
    printf("Stable\n");
  }
  else {
    printf("Not stable\n");
  }
  for(i = 0 ;i < n ;i ++){
    printf("%c %d\n",B[i].s,B[i].nn);
  }
  return 0;
}



Measured memory_bytes: 4004
//============================================================================
// Name        : abc108.cpp
// Author      : sep
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

inline void main108A() {

	long int n;
	long int res;

	cin >> n;

	if (n % 2 == 1) {

		res = (n / 2) * (n / 2 + 1);
	} else {
		res = (n / 2) * (n / 2);
	}

	cout << res;

}

int main() {

#ifdef TEST
	struct timespec startTime, endTime;
	while (1) {
		clock_gettime(CLOCK_REALTIME, &startTime);
#endif

		main108A();

#ifdef TEST
		cout << flush;
		cerr << flush;
		cerr << endl << "Elapsed Time:";
		clock_gettime(CLOCK_REALTIME, &endTime);
		if (endTime.tv_nsec < startTime.tv_nsec) {
			cerr << endTime.tv_sec - startTime.tv_sec - 1 << "."
					<< endTime.tv_nsec + 1000000000 - startTime.tv_nsec << "s"
					<< endl;
		} else {
			cerr << endTime.tv_sec - startTime.tv_sec << "."
					<< endTime.tv_nsec - startTime.tv_nsec << "s" << endl;
		}

		cerr << endl;
	}
#endif

	return 0;
}


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

	#define E "\n"
	#define int long long 
	#define f(i,l,n) for(int i=l;i<n;i++)




	int solve()
	{
		string s,t,temp;
		cin >> s >> t;
		temp=t.substr(0,t.size()-1);
		//cout<<temp<<E;
		if(s==temp) cout<<"Yes\n";
		else cout<<"No\n";

		return 0;
	}

		


		int32_t main()
		{


		 	int t=1;
		 	//cin >> t;
		 	while(t--)
		 	{
		 		solve();
		 	}

		}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> A(n), B(n);
    vector<tuple<int, int, int>> all;
    ll sum_a = 0, sum_b = 0;
    fori(i, 0, n) {
        scanf("%d %d", &A[i], &B[i]);
        all.emplace_back(A[i], 0, i);
        all.emplace_back(B[i], 1, i);
        sum_a += A[i];
        sum_b += B[i];
    }
    sort(all.begin(), all.end());
    set<int> sA, sB;
    ll n_sum = 0;
    fori(i, 0, n) {
        n_sum += get<0>(all[i]);
        if(get<1>(all[i]) == 0) {
            sA.insert(get<2>(all[i]));
        }
    }
    fori(i, n, 2 * n) {
        if(get<1>(all[i]) == 1) {
            sB.insert(get<2>(all[i]));
        }
    }
    ll ans = n_sum;
    if(sA == sB && (int) sA.size() < n) {
        int min_diff = (int) 2e9 + 5;
        fori(i, n, 2 * n) {
            if(get<2>(all[n - 1]) != get<2>(all[i])) {
                min_diff = min(min_diff, get<0>(all[i]) - get<0>(all[n - 1]));
            }
            else {
                min_diff = min(min_diff, get<0>(all[i]) - get<0>(all[n - 2]));
            }
        }
        ans = n_sum + min_diff;
    }
    ans = min({ans, sum_a, sum_b});
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 12784
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    map<ll,ll>mp;
    ll a[300005];
    int main()
    {
        fastread;
        ll n,i,j,k,l,m;
        cin>>n;
        for(i=1;i<=n;i++){
        	cin>>a[i];
            mp[a[i]]++;
		}
		int flag=0;
		for(i=1;i<=n;i++){
			if(mp[a[i]]>1)
			flag=1;
		}
		if(flag==1)
		cout<<"NO";
		else
		cout<<"YES";
    	return 0;
    }

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

int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	cout << ((b - a) % 2 ? min(a - 1, n - b) + (b - a - 1) / 2 + 1 : (b - a) / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	string S;
	cin >> S;
	N = S.size();
	vl C(N);
	for (i = 0; i < N; i++) {
		C[i] = 0;
	}
	ll start = 0;
	ll point = 0;
	ll last = 0;
	for (i = 0; i < N-1; i++) {
		if (S[i] == 'R' && S[i + 1] == 'L') {
			point = i;
		}
		if ((S[i] == 'L' && S[i + 1] == 'R') || i == N - 2) {
			last = i;
			if (i == N - 2) {
				last++;
			}
			C[point] += (point - start + 1) / 2 + (point - start + 1) % 2;
			C[point + 1] += (point - start + 1) / 2;
			C[point] += (last - point) / 2;
			C[point+1] += (last - point) / 2 + (last - point) % 2;
			start = last + 1;
			last = last + 1;
		}
	}
	for (i = 0; i < N; i++) {
		cout << C[i] << endl;
	}
}

Measured memory_bytes: 1408