akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define N -1
#define MAX 100001
 
struct Node{
  int p,l,r;
};
 
struct Node T[MAX];
int A[MAX];
 
int depth(int);
int sibling(int);
int degree(int);
int height(int);
 
main(){
  int parent;
  int n;
  int i;
   
  scanf("%d",&n);
   
  for(i=0; i < n; i++){
    T[i].p = T[i].l = T[i].r = N;
  }
   
  for(i = 0; i < n; i++){
    scanf("%d",&parent);
    scanf("%d %d",&T[parent].l,&T[parent].r);
    T[T[parent].l].p = parent;
    T[T[parent].r].p = parent;
  }
   
  for(i = 0; i < n; i++){
    A[i] = depth(i);
  }
   
  for(i = 0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,T[i].p, sibling(i), degree(i),A[i],height(i));    
    if(T[i].p == N) printf("root\n");
    else if(T[i].l != N || T[i].r != N)printf("internal node\n");
    else printf("leaf\n");
  } 
  return 0;
}
 
 
int depth(int i){
  int count = 0;
  while(T[i].p !=N){
    count++;
    i = T[i].p;
  }
  return count;
}
 
 
int sibling(int i){
  if(T[i].p == N) return N;
  if(T[T[i].p].r == i) return T[T[i].p].l;
  if(T[T[i].p].l == i) return T[T[i].p].r;
}
 
int degree(int i){
  int count = 0;
  if(T[i].l != N) count++;
  if(T[i].r != N) count++;
  return count;
}
 
int height(int i){
  int hl = 0;
  int hr = 0;
  if(T[i].l != N) hl = height(T[i].l) + 1;
  if(T[i].r != N) hr = height(T[i].r) + 1;
   
  if(hl < hr) return hr;
  else return hl;
}

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

int main() {
  int N, M;
  int a[60], b[60];
  int count[60]={0};
  cin >> N >> M;
  for(int i=0; i<M; i++) {
    cin>>a[i]>>b[i];
    count[a[i]-1]++;
    count[b[i]-1]++;
  }

  for(int i=0; i<N; i++) cout<<count[i]<<endl;

}


Measured memory_bytes: 256
import sys
a=input()
b=input()
c=input()
turn=0
ap=0
bp=0
cp=0
while True:
    if turn==0:
        ap+=1
        if ap==len(a)+1:
            print("A")
            sys.exit()
        if a[ap-1]=="a":
            turn=0
        elif a[ap-1]=="b":
            turn=1
        else:
            turn=2
    if turn==1:
        bp+=1
        if bp==len(b)+1:
            print("B")
            sys.exit()
        if b[bp-1]=="a":
            turn=0
        elif b[bp-1]=="b":
            turn=1
        else:
            turn=2
    if turn==2:
        cp+=1
        if cp==len(c)+1:
            print("C")
            sys.exit()
        if c[cp-1]=="a":
            turn=0
        elif c[cp-1]=="b":
            turn=1
        else:
            turn=2

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    while(cin>>h>>w,h!=0||w!=0){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(i==0||j==0||i==h-1||j==w-1)cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3032
from sys import stdin

N, A, B = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0
for i in range(N + 1):
    num = i
    num_sum = 0

    while True:
        num_sum += num % 10
        num //= 10
        if num <= 0:
            break

    if A <= num_sum and num_sum <= B:
        ans += i

print(ans)


Measured memory_bytes: 2940
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n;
    scn(n);

    vi a(n+1), ball(n+1, 0);

    rep(i, 1, n+1)
    scn(a[i]);

    vi res;

    for(int i=n; i>=1; i--) {
        int here = 0;
        for(int j=i; j<=n; j+=i)
            here += ball[j];
        if((here&1) != (a[i]&1))
            res.pb(i), ball[i] = 1;
    }

    prin(res.size());

    for(auto i : res)
        pri(i);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5380
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    vector<char> s(4);
    rep(i, 4) cin >> s[i];
  	int a = s[0] - '0';
  	int b = s[1] - '0';
  	int c = s[2] - '0';
  	int d = s[3] - '0';
    if(a + b + c + d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a + b + c - d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a + b - c + d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a + b - c - d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a - b + c + d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a - b + c - d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a - b - c + d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a - b - c - d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

long long addition(string& numbers, int positionOfPlus);

int main() {
    string numbers;
    cin >> numbers;
    
    long long answer = 0;
    for (int bit = 0; bit < (1 << (numbers.size() - 1)); ++bit) {
        answer += addition(numbers, bit);
    }
    cout << answer << endl;       
}

long long addition(string& numbers, int positionOfPlus) {
    long long sum = 0;
    long long term = 0;
    for (size_t i = 0; i < numbers.size(); ++i) {
        term *= 10;
        term += numbers.at(i) - '0';
        if (positionOfPlus & (1 << i) || i == numbers.size() - 1) {
            sum += term;
            term = 0;
        }
    }
    return sum;
}

Measured memory_bytes: 3628
#include<iostream>
int a,b; 
char o;
main(){
	while(std::cin>>a>>o>>b,o!='?'){
		if(o=='+')a+=b;
		if(o=='-')a-=b;
		if(o=='*')a*=b;
		if(o=='/')a/=b;
		std::cout<<a<<'\n';
	}
}




Measured memory_bytes: 3076
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

void solve()
{
	string S, T;
	cin >> S >> T;
	int s = S.length();
	int t = T.length();
	int dp[s + 1][t + 1];
	for (int i = 0; i <= s; ++i)dp[i][0] = 0;
	for (int i = 0; i <= t; ++i)dp[0][i] = 0;
	for (int i = 1; i <= s; ++i)
	{
		for (int j = 1; j <= t; ++j)
		{
			if (S[i - 1] == T[j - 1])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	int i = s, j = t;
	stack<char> st;
	while (st.size() != dp[s][t])
	{
		if (S[i - 1] == T[j - 1])
		{
			st.push(S[i - 1]);
			i--, j--;
		}
		else
		{
			if (dp[i - 1][j] > dp[i][j - 1])
				i--;
			else
				j--;
		}
	}
	if (st.empty())
		cout << "" << endl;
	while (!st.empty())
	{
		cout << st.top();
		st.pop();
	}
	cout << endl;
}

int main()
{
	fast
	ll t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

Measured memory_bytes: 35456
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N, M, r = map( int, input().split())
    d = dict()
    E = [[] for _ in range(N)]
    for _ in range(M):
        a, b, c = map( int, input().split())
        d[(a,b)] = c
        E[a].append(b)
    INF = 10**14*2
    V = [INF]*N
    V[r] = 0
    for _ in range(N-1):
        for e in d:
            s, t = e
            if V[s] + d[e] < V[t]:
                V[t] = V[s] + d[e]
    q = deque([r])
    W = [False]*N
    while q:
        v = q.pop()
        for w in E[v]:
            if W[w] == False:
                W[w] = True
                q.append(w)
    for e in d:
        s, t = e
        if V[s] + d[e] < V[t] and (W[s] == True or W[t] == True):
            print("NEGATIVE CYCLE")
            return
    for i in range(N):
        if V[i] >= 10**14:
            print("INF")
            continue
        print(V[i])
    # #if you want to know whether its path has negative cycle, we need followings.
    # E = [ V[i] for i in range(N)]
    # for _ in range(N-1):#probably OK, maybe N
    #     for e in d:
    #         s, t = e
    #         if E[s] + d[e] < E[t]:
    #             E[t] = E[s] + d[e]
    # #if you want to know whether its path has negative cycle, we need followings.
    # for i in range(N):
    #     if V[i] == E[i]:
    #         print(V[i])
    #     else:
    #         print("NEGATIVE CYCLE")
        
if __name__ == '__main__':
    main()



Measured memory_bytes: 6580
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);

		Map<String,Integer> map = new TreeMap<>();

		int n = scan.nextInt();

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

			int query = scan.nextInt();
			String key = scan.next();

			switch(query) {

			case 0:
				int value = scan.nextInt();
				map.put(key, value);
				break;

			case 1:
				if(map.containsKey(key)) {
					System.out.println(map.get(key));
				}else
				System.out.println("0");
				break;
				
			case 2:
				map.remove(key);
			}
		}
	}
}



Measured memory_bytes: 195580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n;
    cin>>n;
    int m=1;
    for(int i=2;;i++){
        if(i<=n)m=m*i;
        else break;
    }
    vector<int> p(n),p2(n);
    vector<int> q(n),q2(n);
    rep(i,n){
        cin>>p[i];
        p2[i]=p[i];
    }
    rep(i,n){
        cin>>q[i];
        q2[i]=q[i];
    }
    int a=1;
    int b=1;
    sort(p.begin(),p.end());
    sort(q.begin(),q.end());
    int aco=n;
    int bco=n;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(p[j]!=p2[i]&&p[j]!=-1){
                if(aco==8){
                    a+=5040;
                }else if(aco==7){
                    a+=720;
                }else if(aco==6){
                    a+=120;
                }else if(aco==5){
                    a+=24;
                }else if(aco==4){
                    a+=6;
                }else if(aco==3){
                    a+=2;
                }else if(aco==2){
                    a+=1;
                }
            }
          if(p[j]==p2[i]){
                p[j]=-1;
                aco--;
                break;
          }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(q[j]!=q2[i]&&q[j]!=-1){
                if(bco==8){
                    b+=5040;
                }else if(bco==7){
                    b+=720;
                }else if(bco==6){
                    b+=120;
                }else if(bco==5){
                    b+=24;
                }else if(bco==4){
                    b+=6;
                }else if(bco==3){
                    b+=2;
                }else if(bco==2){
                    b+=1;
                }
            }
          if(q[j]==q2[i]){
                q[j]=-1;
                bco--;
                break;
          }
        }
    }
    cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n,k;
    cin>>n>>k;

    vl v(n);
    forn(i,0,n)
    {
        cin>>v[i];
    }
        
    sort(all(v));
    
    ll sum = 0;

    forn(i,0,k)
    {
        sum += v[i];
    }    
        


    cout<<sum;









    return 0;
}   

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int z,x;
  cin>>z;
  vector<int> y(z);
  for(x=0;x<z;x++) cin>>y.at(x);
  sort(y.begin(),y.end());
  cout<<y.at(z-1)-y.at(0)<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n, z, w;
    cin >> n >> z >> w;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    if (n == 1) {
        cout << abs(w - v[0]) << endl;
        return 0;
    }
    cout << max(abs(w - v[n - 1]), abs(v[n - 1] - v[n - 2])) << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;
const int INF = 1000000000;
const int MAX = 300000;

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

vector<vector<P>> G;
int mxi, mx;

void dfs(int chi, int par=-1, int d=0) {
    for (auto p : G[chi]) {
        int nv = p.first;
        int w = p.second;
        if (nv == par) {
            continue;
        }

        if (mx < d + w) {
            mx = d + w;
            mxi = nv;
        }
        dfs(nv, chi, d + w);
    }
}

int main(void) {
    int N;
    cin >> N;
    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        G[s].push_back(P(t, w));
        G[t].push_back(P(s, w));
    }
    mxi = 0;
    mx = 0;
    dfs(mxi);
    dfs(mxi);
    cout << mx << endl;
}


Measured memory_bytes: 14380
#include <bits/stdc++.h>
#define fi first
#define se second
#define maxn 100003
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;

int n,ans;
int cnt[maxn];

int main() {
	scanf("%d",&n);
	for( int i = 1 ; i < n ; i++ )
		for( int j = i ; j < n ; j += i )
			ans++;
	printf("%d\n",ans);
	return 0;
}

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


int main() {
	int A, B, K;
	cin >> A >> B >> K;
	int counter = 0;
	int ans;
	for(int i = min(A, B); i > 0; i--){
		if(A % i == 0 && B % i == 0){
			counter++;
		}
		if(counter == K){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 1; i < n; i++)

int main()
{
    long double n, k;
    int sum, count;
    long double ans = 0U;

    cin >> n >> k;
    // 1/n * (1/2)^(k/n+1)
    rep(i, n + 1)
    {
        sum = i;
        count = 0;
        while (sum < k)
        {
            sum = sum * 2;
            count++;
        }
        ans = ans + (1 / n) * pow(1.0 / 2.0, count);
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=10101;

int main()
{
    ll n;
    cin>>n;
    map<ll,ll>a;
    rep(i,n)
    {
        ll t;
        cin>>t;
        a[t]++;
    }
    ll ans=0;

    for(auto itr=a.begin();itr!=a.end();itr++)
    {
        if(itr->first<itr->second)
        {
            ans+=itr->second-itr->first;
        }
        else if(itr->first>itr->second)
        {
            ans+=itr->second;
        }
        
    }
    cout<<ans;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  bool flg = 1;
  int r(0);
  vector<string> s(3);
  for(int i=0;i<3;++i){
    cin>>s[i];
    reverse(s[i].begin(), s[i].end());
  }
  while(flg){
    char c = s[r][s[r].length()-1];
    if(s[r].length() == 1 && s[r] == "w"){
      flg = 0;
      c = 'A'+r;
      cout<<c<<endl;
    }else if(s[r].length() == 1){
      s[r] = "w";
      r = c-'a';
    }else{
      s[r].pop_back();
      r = c-'a';
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll  = long long;
using v   = vector<int>;
using vv  = vector<v>;
using P   = pair<int,int>;
using vp  = vector<P>;
using vvp = vector<vp>;

int main(){
    int n,m,c;
    cin>>n>>m>>c;
  
  v b(m);
  rep(i,m)cin>>b[i];
  vv a(n, v (m));
  rep(i,n)rep(j,m)cin>>a[i][j];
  
  int ans = 0;
  
  rep(i,n){
    int point = c;
    rep(j,m)point += a[i][j]*b[j];
    if(point>0)ans++;
  }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = []
for i in range(K):
    t = input()
    l = list(map(int,input().split()))
    A.append(l)

ans = [0]*N
for i in A:
    for j in i:
        ans[j-1]+=1

print(ans.count(0))

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int nn = 2e5 + 5;
vector<pair<int, int> > adjlist[nn];
bool vis[nn];

void dfs(int nod) {
 vis[nod] = 1;
 int l1 = adjlist[nod].size();
 for (int i = 0; i < l1; i++) {
  int ttg = adjlist[nod][i].first;
  if (!vis[ttg]) dfs(ttg);
 }
}

int main() {
 int n, u, v, m, w, ans = 0;
 cin >> n >> m;
 for (int i = 0; i < m; i++) {
  cin >> u >> v >> w;
  adjlist[u].push_back(make_pair(v, w));
  adjlist[v].push_back(make_pair(u, w));
 }
 for (int i = 1; i <= n; i++) if (!vis[i]) ans++, dfs(i);
 printf("%d\n", ans);
}

Measured memory_bytes: 11264
def Replacing():
    import sys
    input = sys.stdin.readline

    n = int(input())
    A = list(map(int,input().split()))
    q = int(input())
    
    total = sum(A) # これを基に各queryに対応(加算、減算)する
    
    l = [0 for i in range(10**5+1)] # 配列のインデックスを各valueとみなす
    for _ in A: # 各インデックスに各keyを加算
        l[_] += 1
    
    for i in range(q):
        b, c = map(int,input().split())
        total += c * l[b] # totalの調整のみ
        total -= b * l[b] # 同上
        print(total)
        l[c] += l[b] # ここでリストの更新
        l[b] = 0 # 同上

Replacing()

Measured memory_bytes: 90960
// code written by kshitij_coder
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds; 
using namespace std;
 
#define ll int64_t
#define pii pair<int,int>
#define pll pair<ll,ll>
#define psi pair<string,ll> 
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pb push_back
#define eb emplace_back
#define lim 100000
#define f(k) k.first
#define s(k) k.second
#define bcnt __builtin_popcount
#define endl "\n"
#define PI 3.1415926535

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const{ 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 

ll power(ll a,ll b){ ll ans = 1; ll k = a;while(b > 0){ if(b & 1){ ans *= k; ans %= MOD; } k = (k*k)%MOD; b = b >> 1;} return ans;}

// ll ncr(ll n,ll r,ll*arr){
//     if(r==0) return 1;
//     ll res = 1;
//     return (arr[n]*(power(arr[n-r],MOD-2))%MOD*(power(arr[r],MOD-2))%MOD)%MOD;
// }

ll gcd(ll a,ll b){ if(a == 0) return b; if(b == 0) return a; return gcd(b,a%b); }
ll add_mod(ll a,ll b,ll m){return ((a%m) + (b%m))%m;}
ll sub_mod(ll a,ll b,ll m){return ((a%m) - (b%m) + m)%m;}
ll mul_mod(ll a,ll b,ll m){return ((a%m)*(b%m))%m;}
void print(double val,int k){ cout<<fixed<<setprecision(k)<<val<<endl;}
ll toint(string s) {stringstream ss; ss << s; ll x; ss >> x; return x;}

void solve(){
    string a, b;
    cin >> a >> b;

    int n = a.size();
    int m = b.size();

    int **arr = new int*[n+1];
    for(int i = 0;i <= n;i++) arr[i] = new int[m+1];
    for(int i = 0;i <= n;i++) arr[i][0] = 0;
    for(int i = 0;i <= m;i++) arr[0][i] = 0;

    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            if(a[i-1] == b[j-1]) arr[i][j] = 1 + arr[i-1][j-1];
            else arr[i][j] = max(arr[i-1][j], arr[i][j-1]);
        }
    }

    string ans = "";
    int i = n, j = m;
    while(i >= 1 and j >= 1){
        if(a[i-1] == b[j-1]){
            ans = ans + a[i-1];
            i--;
            j--;
        }
        else{
            if(arr[i-1][j] > arr[i][j-1]) i--;
            else j--;
        }
    }

    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r = 1;
    // cin >> r;
    for(int i = 1;i <= r;i++) solve();
    return 0;
}

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


int main () {
	
  int k,a,b;
  cin >> k;
  cin >> a;
  cin >> b;
  bool flag= false;
  
  for(int i=a; i<=b;i++)
  {
	  if(i%k==0)
	  {

		  flag = true;
		  break;
	  }

  }
  
  if(flag)
  {
		cout << "OK";
  }
  else
  {
		cout << "NG";
  }
	
	return 0;
}


Measured memory_bytes: 3020
n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
total_list = []
for x in range(n):
    total = sum(a1[0:x+1]) + sum(a2[x:n])
    total_list.append(total)
print(max(total_list))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
int a[3009];
vector<int> G[3009];

int dfs(int v, int p) {
    for(auto &&u : G[v])
        if(u != p)
            if(dfs(u, v) < a[v]) return 1 << 30;
    return a[v];
}

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

    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n - 1) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    vector<int> ans;
    rep(i, n) if(dfs(i, -1) == 1 << 30) ans.push_back(i + 1);

    rep(i, ans.size()) cout << (i ? " " : "") << ans[i];
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3996
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		boolean allSame = true;
		int startB = 0;
		int endA = 0;

		int count = 0;
		
		for (int i=0;i<n;i++) {
			String str = sc.next();
			if (str.charAt(0)=='B') {
				startB++;
			}
			if (str.charAt(str.length()-1)=='A') {
				endA++;
			}
			if ((str.charAt(0)=='B')^(str.charAt(str.length()-1)=='A')) {
				allSame=false;
			}
			for (int j=0;j<str.length()-1;j++) {
				if (str.charAt(j)=='A' && str.charAt(j+1)=='B') {
					count++;
				}
			}
		}
		if (allSame && startB>0) {
			count--;
		}
		System.out.println(count+Math.min(startB,endA));



	}




}


Measured memory_bytes: 31104
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;
int a[N];
int main(){
    int n, ok =1;
    cin >> n;
    for(int i=1;i<=n;++i){
        cin >> a[i];
        if(a[i]%2==0){
            if(a[i]%3 !=0 && a[i]%5!=0){
                ok = 0;
            }
        }
    }
    if(ok){
        cout << "APPROVED\n";
    }else{
        cout <<"DENIED\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int k;
	std::cin >> k;
	while(k--){
		std::cout << "ACL";
	}
	std::cout << std::endl;
	return 0;
}


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

int main(void) {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long long> S(N + 1, 0);
  map<long long, long long> cnt;
  cnt[0]++;
  for (int i = 0; i < N; i++) {
    S[i + 1] = S[i] + A[i];
    cnt[S[i + 1]]++;
  }

  long long ans = 0;
  for (auto c : cnt) {
    ans += c.second * (c.second - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}

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


int main() {
    int N,X;
    int sum=0;
    cin >>N>>X;
    int count =N;
    vector<int>data(N);
    rep(i,N){
        cin>>data[i];
        sum+=data[i];
    }
    sort(data.begin(),data.end());
    int nokori = X-sum-data[0];
    while (nokori>=0){
        count++;
        nokori -= data[0];
    }
    cout <<count <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,j,k) for(int i=j;(i)<(k);(i)++)
using namespace std;
#define mod 1000000007
#define mmax 1000000
typedef long long ll;
ll f[mmax], rf[mmax];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    rep(i, 1, mmax) f[i] = (f[i - 1] * i) % mod;
    rep(i, 0, mmax) rf[i] = inv(f[i]);
}
//------------------------------------------------------------------
ll C(int n, int k) {
    init();
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!
    
    ll bc = (b * c) % mod;
    
    return (a * bc) % mod;
}
int main(void){
    int x,y;
    cin >> x >> y;
    if((x+y)%3 != 0){
        printf("0\n");
    }else{
        int layer = (x+y)/3;
        int left = x-layer;
        if (left < 0 || layer - left < 0) {
            cout << 0;
            return 0;
        }
        //printf("%d %d\n",layer,left);
        printf("%lld\n",C(layer,left));
        //printf("%lld\n",C(a+b,min(a,b)));
        
    }
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
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;
}

int main(void)
{
    ll n;
    cin >> n;
    ll k;
    cin >> k;

    vector<ll> x(n);
    REP(i, n)
    {
        cin >> x[i];
    }

    ll tmin = LLINF;
    REP(i,n - k + 1)
    {
        chmin(tmin, min(abs(x[i]) + abs(x[i] - x[i + k - 1]),
                        abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i])));
    }
    cout << tmin << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  pr((m*1900+(n-m)*100)*(1<<m));
}

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


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

int main(){
  int a,b;
  cin >> a >> b;
  int c=1,n=0;
  while(true){
	if(c>=b){
      cout << n << endl;
      return 0;
    }
    c=c-1+a;
    n++;
  }
}

Measured memory_bytes: 764
#include <stdio.h>
int main()
{
int x,t;
scanf("%d",&x);
for(int i=2;i<=x;i++)
{
	if(i%3==0)printf(" %d",i);
	else {
		t=i;
		while(1){
		if(t%10==3){printf(" %d",i);break;}
		t=t/10;
		if(t==0)break;
		}
	}


	

}
printf("\n");
return 0;
}

Measured memory_bytes: 1028
import java.io.File
import java.io.FileInputStream
import java.io.InputStreamReader

fun main() {
    val n = readInt()

    println(List(n + 1) { if (it % 3 == 0 || it % 5 == 0) 0L else it.toLong() }.sum())
}

// Input Reader
private fun readLn() = readLine()!!
// Read from file
//private val inputReader = InputStreamReader(FileInputStream(File("input.txt")))
//private val lines = inputReader.readLines()
//private var currLine = -1
//private fun readLn(): String {
//    currLine++
//    return lines[currLine]
//}

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 65556
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
const int maxn=9e4+10;
using namespace std;
typedef long long ll;
struct node
{
	int x,y;
}a[maxn];
int h,w,d,maxv,q;
int step[maxn];
int main()
{
	scanf("%d%d%d",&h,&w,&d);
	for(int i=0;i<h;++i)
	{
		for(int j=0;j<w;++j)
		{
			int v;
			scanf("%d",&v);
			a[v].x=i,a[v].y=j;
			maxv=max(maxv,v);
		}
	}
	for(int i=1;i<=d;++i)
	{
		step[i]=0;
		for(int j=i+d;j<=maxv;j+=d)
		{
			step[j]=step[j-d]+abs(a[j].x-a[j-d].x)+abs(a[j].y-a[j-d].y);
		    //printf("%d:%d\n",j,step[j]);
		}
	}
	scanf("%d",&q);
	while(q--)
	{
		int l,r,pos;
		scanf("%d%d",&l,&r);
		printf("%d\n",step[r]-step[l]);
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n;
    double x, ans = 0;
    string u;

    cin >> n;

    for (int i=0; i<n; i++) {
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        }
        else {
            ans += x * 380000;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
k,a,b = gets.chomp.split.map(&:to_i)
ans = 0
if a + 3 < b && (k >= a + 1)
  ans += b
  k = k - (a + 1)
  ans += (b-a)*(k/2)
  ans += k%2
else
  ans = k + 1
end

puts ans


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

#define ll long long
using namespace std;
const int N = 3e5 + 5;

int32_t main() {
    ll n, m;
    cin >> n>> m;
    ll ans = (n - 1) * n / 2;
    ans += (m - 1) * m / 2;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/*
 * 2565.cc: Broken Audio Signal
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;
const int MAX_A = 1000000000;

const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

bool xs[MAX_N];
int as[MAX_N];

/* subroutines */

/* main */

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      if (s == "x") xs[i] = true, as[i] = 0;
      else xs[i] = false, as[i] = atoi(s.c_str());
      //printf("%d: %d(%d)\n", i, as[i], xs[i]);
    }

    int mina = -INF, maxa = INF;
    bool ok = true;

    for (int i = 0; i < n; i++) {
      if (xs[i]) {
	if (! (i & 1)) {
	  int ai = INF;
	  if (i > 0) {
	    if (xs[i - 1]) { ok = false; break; }
	    if (ai > as[i - 1]) ai = as[i - 1];
	  }
	  if (i < n - 1) {
	    if (xs[i + 1]) { ok = false; break; }
	    if (ai > as[i + 1]) ai = as[i + 1];
	  }
	  ai--;
	  if (maxa > ai) maxa = ai;
	  //printf("i=%d, ai=%d, maxa=%d\n", i, ai, maxa);
	}
	else {
	  int ai = -INF;
	  if (i > 0) {
	    if (xs[i - 1]) { ok = false; break; }
	    if (ai < as[i - 1]) ai = as[i - 1];
	  }
	  if (i < n - 1) {
	    if (xs[i + 1]) { ok = false; break; }
	    if (ai < as[i + 1]) ai = as[i + 1];
	  }
	  ai++;
	  if (mina < ai) mina = ai;
	  //printf("i=%d, ai=%d, mina=%d\n", i, ai, mina);
	}
      }
      else {
	if (! (i & 1)) {
	  if ((i > 0 && ! xs[i - 1] && as[i - 1] <= as[i]) ||
	      (i < n - 1 && ! xs[i + 1] && as[i + 1] <= as[i])) {
	    ok = false;
	    break;
	  }
	}
	else {
	  if ((i > 0 && ! xs[i - 1] && as[i - 1] >= as[i]) ||
	      (i < n - 1 && ! xs[i + 1] && as[i + 1] >= as[i])) {
	    ok = false;
	    break;
	  }
	}
      }
    }
    //printf("mina=%d, maxa=%d, ok=%d\n", mina, maxa, ok);

    if (! ok || mina > maxa) puts("none");
    else if (mina < maxa) puts("ambiguous");
    else printf("%d\n", mina);
  }
  
  return 0;
}

Measured memory_bytes: 1228
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;

class Program
{
	static void Main(string[] args)
	{
		string n = Console.ReadLine();
		if (n.Contains("7"))
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 25868
#include <iostream>
#define ll long long
#define MAX(a,b) ((a>b)?a:b)
using namespace std;

const int nmax = 1e5 + 5;

ll v[nmax],dp[nmax][3];
const ll inf = (ll)1e18;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> v[i];
	dp[1][0] = v[1];
	dp[1][1] = -inf;
	dp[2][0] = v[1] + v[2];
	dp[2][1] = -dp[2][0];
	for (int i = 3; i <= n; i++) {
		dp[i][1] = MAX((dp[i - 1][0] - 2 * v[i - 1]), (dp[i - 1][1] + 2 * v[i - 1])) - v[i];
		dp[i][0] = MAX(dp[i - 1][0], dp[i - 1][1]) + v[i];
	}
	cout << MAX(dp[n][0], dp[n][1]);
	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999


bool isLabel(string s){
    if(s[s.size()-1]==':')return true;
    return false;
}

string comb(string s){
    return s.substr(5,s.size()-6);
}

int main(){
    int n;
    cin>>n;
    vector<string> data(n);
    cin.ignore();
    rep(i,n)getline(cin,data[i]);
    
    
    map<string,int> mp;
    rep(i,n){
        string tmp = data[i];
        if(isLabel(tmp))mp[tmp.substr(0,tmp.size()-1)]=i;
    }
    
    int d[110][110];
    rep(i,110)rep(j,110)d[i][j]=INF;
    rep(i,n){
        if(isLabel(data[i])){
            d[i][i+1]=0;
        }
        else{
            d[i][i+1]=1;
            string to = comb(data[i]);
            d[i][mp[to]]=0;
        }
    }
    
    
    rep(k,n+1){
        rep(i,n+1){
            rep(j,n+1){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    cout<<d[0][n]<<endl;

}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){

	ios::sync_with_stdio(false);
	ios_base::sync_with_stdio(false);

	ll n,x;
	cin>>n>>x;

	std::vector<ll> v(n);

	for(ll i=0;i<n;i++)
	{
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	ll ans = 0;
	for(ll i=0;i<n;i++)
	{
		if(x>=v[i] && i!=n-1)
		{	
			ans++;
			x -= v[i];
		}
		if(i==n-1)
		{
			if(x==v[i])
				ans++;
		}
	}

	cout<<ans;
	return 0;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var O, E string

	fmt.Scan(&O)
	fmt.Scan(&E)

	o := []rune(O)
	e := []rune(E)

	ans := make([]rune, len(o)+len(e))

	for i, r := range o {
		ans[i*2] = r
	}

	for i, r := range e {
		ans[i*2+1] = r
	}

	fmt.Print(string(ans))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int> > vv;
///-------------------------

vector<bool> ban(10,false);

bool check(int x){
	while (x>0){
		int id = x%10;
		if (ban[id]) return false;
		x/=10;
	}
	return true;
}

int main()
{
    Phuong_; /// <3333
    int n,k;
    cin >> n >> k;
    ban.resize(k);
    for(int i=0; i<k; ++i){
    	int u;
    	cin >> u;
    	ban[u] = true;
    }
	int ans = n;
	while (check(ans) == false){
		ans++;
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int H, W;
	cin >> H >> W;
	vec ws(W, 0);
	vector <string> maze(H);
	rep(H, i) {cin >> maze[i];}

	rep(W, j)
	{
		int f = 1;
		rep(H, i)
		{
			f &= maze[i][j] == '.';
		}
		ws[j] = f;
	}

	rep(H, i)
	{
		int f = 1;
		rep(W, j)
		{
			f &= maze[i][j] == '.';
		}
		if (f)
		{
			continue;
		}
		rep(W, j)
		{
			if (ws[j])
			{
				continue;
			}
			cout << maze[i][j];
		}
		putln("");
	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
// Ryo Kamoi
// #define DEBUG

#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int INF = 1000000000;

int n;
int p[101];
int res_[101];
int rt_[101];
pii dp[500*100+1];
pii prevdp[500*100+1];
int main(){
  while(1) {
    cin >> n;
    if (n==0) break;

    p[0] = INF; // not used
    REP(i, n) {
      cin >> p[i+1];
    }

    REP(k, 500*n+1) {
      prevdp[k] = pii(0, INF);
      dp[k] = pii(0, INF);
    }
    prevdp[0] = pii(0, 0);

    for(int i=1; i<=n; i++) { 
      REP(k, 500*n+1) {
        int res = p[i] % 1000;
        int rt = 1000 - res;

        if (rt == 1000) {
          res = 1000;
          rt = 0;
        }

        dp[k] = prevdp[k];
        if (rt >= 500) {
          if (k>=(rt-500)) {
            pii prev = prevdp[k-(rt-500)];
            if (prev.second >= INF) continue;
            if (dp[k].first == prev.first+1) {
              dp[k] = pii(prev.first+1, min(dp[k].second, prev.second+p[i]));
            } else if (dp[k].first < prev.first+1) {
              dp[k] = pii(prev.first+1, prev.second+p[i]);
            }
          }
        } else {
          if (k<=500*n-(res-500)) {
            pii prev = prevdp[k+(res-500)];
            if (prev.second < INF) {
              if (dp[k].first < prev.first + 1) {
                dp[k].first = prev.first+1;
                dp[k].second = prev.second + p[i];
              } else if (dp[k].first == prev.first + 1) {
                dp[k].second = min(dp[k].second, prev.second+p[i]);
              }
            }
          }
          if (k>=rt) {
            pii prev = prevdp[k-rt];
            if (prev.second < INF) {
              if (dp[k].first == prev.first) {
                dp[k].second = min(dp[k].second, prev.second + p[i]);
              } else if (dp[k].first < prev.first) {
                dp[k].first = prev.first;
                dp[k].second = prev.second + p[i];
              }
            }
          }
        }
      }

      REP(k, 500*n+1) {
        prevdp[k] = dp[k];
      }
    }

    int maxnum = 0;
    int price;
    REP(k, 500*n+1) {
      if (dp[k].second >= INF) {
        continue;
      }

      if (dp[k].first > maxnum) {
        maxnum = dp[k].first;
        price = dp[k].second;
      } else if (dp[k].first == maxnum) {
        price = min(price, dp[k].second);
      }
    }

    cout << maxnum << " " << price << endl;
  }
}



Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
#define all(x) x.begin(), x.end()
using namespace std;

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

    int tc = 1;
    //cin >>  tc;
    while(tc--){
            ll A;
    cin >> A;
        map<int,char> mp;
    char ch = 'a';
    for(int i=1;i<=26;i++,ch++){
        mp[i] = ch;
    }
    string ans = "";
    while(A>0){
        int rem = (A-1)%26;
        ans += mp[rem+1];
        A= (A-1)/26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
    }
}



Measured memory_bytes: 3656
d, g = map(int, input().split())
pt_ls = [list(map(int, input().split())) for i in range(d)]

INF = 1001001001
ans = INF
for bit in range(2**d):
    total_comp = 0
    q_total = 0
    for i in range(d):
        if (1 << i) & bit:
            total_comp += pt_ls[i][0] * 100 * (i+1) + pt_ls[i][1]
            q_total += pt_ls[i][0]

    if total_comp >= g:
        ans = min(ans, q_total)
    else:
        for i in reversed(range(d)):
            if not (1<<i) & bit:
                a = g - total_comp
                b = 100 * (i+1)
                need_q = (a + b - 1) // b
                if need_q < pt_ls[i][0]:
                    q_total += need_q
                    ans = min(ans, q_total)
                    break

print(ans)

Measured memory_bytes: 41200
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
	int W, a, b;
	cin >> W >> a >> b;
	int l1 = a;
	int r1 = a + W;
	int l2 = b;
	int r2 = b + W;
	int ans = max(l1, l2) - min(r1, r2);
	if (ans < 0)
	{
		ans = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256