akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

struct P {int first; int second;}

int main()
{
    while (true) {
        string[] str = readln().chomp().split();
        int h = str[0].to!int();
        int w = str[1].to!int();
        if (h == 0 && w == 0) break;
        string t;
        char[101][101] f;
        for (int i = 0; i < h; i++) {
            t = readln.chomp;
            for (int j = 0; j < w; j++) {
                f[i][j] = t[j].to!char;
            }
        }

        P[char] m; P p;
        p.first = 0; p.second = 1; m['>'] = p;
        p.first = 0; p.second = -1; m['<'] = p;
        p.first = -1; p.second = 0; m['^'] = p;
        p.first = 1; p.second = 0; m['v'] = p;
        p.first = p.second = 0; m['.'] = m['*'] = p;

        int x = 0, y = 0;
        while (true) {
            int nx = x, ny = y;
            if (f[nx][ny] == '*') {
                writeln("LOOP");
                break;
            }
            //writeln(m[f[nx][ny]].first, " ", m[f[nx][ny]].second);
            if (0 <= nx + m[f[nx][ny]].first && nx + m[f[nx][ny]].first < h && 0 <= ny + m[f[nx][ny]].second && ny + m[f[nx][ny]].second < w) {
                nx = nx + m[f[nx][ny]].first;
                ny = ny + m[f[nx][ny]].second;
            }
            f[x][y] = '*';
            if (x == nx && y == ny || f[nx][ny] == '.') {
                writeln(ny, " ", nx);
                break;
            }
            x = nx; y = ny;
        }
    }

    return 0;
}

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

int a[12][12];

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	rep(i, n)
	{
		cin >> c[i];
		rep(j, m)
			cin >> a[i][j];
	}
	//bit全探索 1<<nで、1の後ろにn個0がつく
	//n=3 => 1000 なので(s = 0000; s < 1000 s++)の0〜7まで
	int ans = INT_MAX;
	rep (s, 1<<n)
	{
		int cost = 0;
		vector<int> d(m);
		rep(i, n)
		{
			if (s>>i&1)
			{
				cost += c[i];
				rep(j,m)
					d[j] += a[i][j];
			}
			bool ok = true;
			rep (j, m)
			{
				if (d[j] < x)
					ok = false;
			}
			if (ok == true)
				ans = min(ans, cost);
		}
	}
	if (ans == INT_MAX)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return (0);
}

Measured memory_bytes: 3632
def form(x, e=""):
    print("{:>5}".format(x), end=e)

while True:
    n = int(input())
    if n == 0:
        break
    rows = [list(map(int, input().split())) for _ in range(n)]
    for row in rows:
        for r in row:
            form(r)
        form(sum(row), "\n")
    columns = list(zip(*rows))
    for column in columns:
        form(sum(column))
    form(sum(sum(row) for row in rows), "\n")

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

using namespace std;

struct data{
  int count=0;
  int x;
  bool operator<(data d)const{
    return count < d.count;
  }
  bool operator>(data d)const{
    return count > d.count;
  }
};

int main(void){
  int n;
  cin>>n;
  int num=n/2;
  vector<data> o(100000+1);
  vector<data> e(100000+1);
  for (int i=0;i<n;i++){
    int temp;
    cin>>temp;
    if (i%2){
      e[temp].count++;
      e[temp].x=temp;
    }
    else {
      o[temp].count++;
      o[temp].x=temp;
    }
  }
  sort(e.begin(),e.end(),greater<data>());
  sort(o.begin(),o.end(),greater<data>());
  int ans;
  if (e[0].x!=o[0].x) {
    ans=(num-e[0].count)+(num-o[0].count);
  }
  else {
    int E,O;
    E=(num-e[0].count)+(num-o[1].count);
    O=(num-e[1].count)+(num-o[0].count);
    ans=min(E,O);
  }

  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,i;
    string s;
    cin>>k;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        if(i<k)
        {
            cout<<s[i];
        }
        else
        {
            cout<<"...";
            break;
        }
    }
    
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
int n, m, q, ans;
int A[15], a[55], b[55], c[55], d[55];
void dfs(int t) {
	if (t == n + 1) {
		int s = 0;
		for (int i = 1; i <= q; ++i)
			if (A[b[i]] - A[a[i]] == c[i]) s += d[i];
		if (s > ans) 
			ans = s;
		return;
	}
	for (int i = A[t - 1]; i <= m; ++i) {
		A[t] = i;
		dfs(t + 1);
		A[t] = 0;
	}
}
int main() {
	std::cin >> n >> m >> q;
	A[0] = 1;
	for (int i = 1; i <= q; ++i) std::cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(1);
	std::cout << ans << '\n';
	return 0;
}














Measured memory_bytes: 3588
import java.util.*;

public class Main{
	public static void main(String[] argc){
    	Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String tmp = sc.next();
        long K = Long.parseLong(tmp);

        if(s.length() == 1){
            System.out.println(s);
            return;
        }

        for(int i=0;i<s.length();i++){
            if(s.charAt(i) != '1'){
                if(K < i+1){
                    System.out.println(1);
                    return;
                }else{
                    System.out.println(s.charAt(i));
                    return;
                }
            }
        }

        System.out.println(1);

    }
}

Measured memory_bytes: 21716
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
d1,d2,d3,d4,d5,d6=c2-c1,c3-c2,c5-c4,c6-c5,c8-c7,c9-c8
if d1==d3 and d3==d5 and d2==d4 and d4==d6:print("Yes")
else:print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, k, ndx;
    cin >> n >> k;
    vector<ll> a(n, 0);
    rep1(i, n){
        cin >> a[i];
        if (a[i]==1) ndx = i;
    }
    ll ans = (n-1) / (k-1) + ((n-1)%(k-1)!=0);
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 4048
n,t = gets.split.map(&:to_i)
list = (1..n).map{gets.split.map(&:to_i)}.sort
tm = t-1
dp = [0]*(t)
ans = 0
list.each{|a,b|
  if ans < tmpans=dp[tm]+b
    ans = tmpans
  end
  dp2=[0]*a+dp
  (t-1).downto(a){|ti|
    if dp[ti] < dpb=dp2[ti]+b
      dp[ti] = dpb
    end
  }
}
p ans

Measured memory_bytes: 72736
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main()
{
    int N; cin >> N;
    int num[100010] = {0};
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        num[a]++;
    }
    int ans = 0;
    for (int i = 0; i < 100005; i++)
    {
        ans = max(ans,num[i]+num[i+1]+num[i+2]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 768
package main

import (
	"fmt"
)

func main() {
	var C1, C2, ans string
	fmt.Scan(&C1, &C2)

	if C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0] {
		ans = "YES"
	} else {
		ans = "NO"
	}

	fmt.Println(ans)
}

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

int main() {
  int A;
  int B;
  cin >> A >> B;

  int max = A+B;
  if(A-B > max) max = A-B;
  if(A*B > max) max = A*B;
  
  cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	char p[1000000];
	for(int i=2;i<1000000;i++)p[i]=1;
	for(int i=2;i<1000;i++){
		if(p[i]==0)continue;
		for(int j=i+1;j<1000000;j++){
			if(p[j]==0)continue;
			if(j%i==0)p[j]=0;
		}
	}
	
	int a,d,n;
	while(1){
		cin>>a>>d>>n;
		if(a==0)return 0;
		int m=-1;
		for(int i=0;i<n;i++){
			while(1){
				m++;
				if(p[a+m*d]==1)break;
			}
		}
		cout<<a+m*d<<endl;
	}
}

Measured memory_bytes: 1776
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    A = [lmis(), lmis(), lmis()]
    for _ in range(ii()):
        b = ii()
        for vec in A:
            for i in range(3):
                if vec[i] == b:
                    vec[i] = 0
    import numpy as np
    A = np.array(A)
    for i in range(3):
        if np.sum(A[i]) == 0 or np.sum(A[:, i]) == 0:
            print('Yes')
            return
    if A[0][0] == A[1][1] == A[2][2] == 0:
        print('Yes')
        return
    if A[0][2] == A[1][1] == A[2][0] == 0:
        print('Yes')
        return
    print('No')




main()







Measured memory_bytes: 23128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    if (s[0] == 'A') {
        int cnt = 0;
        for (int i = 2; i < n-1; ++i) {
            if (s[i] == 'C') cnt++;
        }
        if (cnt == 1) {
            int cnt2 = 0;
            rep(i, n) {
                if ('A' <= s[i] && s[i] <= 'Z') cnt2++;
            }
            if (cnt2 == 2) {
                cout << "AC" << endl;
                return 0;
            }
        }
    }
    cout << "WA" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

int binarySearch(int,int);

int A[N];

int main()
{
  int n,m,i,count=0,key;
  
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&m);
  for(i = 0 ; i < m ; i++){
    scanf("%d",&key);

    if(binarySearch(key,n) != -1) count++; 
  }

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

  return 0;
}

    int binarySearch(int key, int n)
  {
    int left = 0, right = n, mid;

    while(left < right){
      mid = (left + right)/2;
      
      if(A[mid] == key) return mid;

      else if(key < A[mid]) right = mid;

      else left = mid + 1;

    }
    return -1;
  }

Measured memory_bytes: 988
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,ans=0; cin>>n;
    vector<int> cnt(1000001,0);
    rep(i,n){
        int a; cin>>a;
        cnt[a]++;
    }
    for(int i=1;i<100000;i++){
        ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0){
            break;
        }
        int G[n];
        int a,b,c,d;
        for(int i=0;i<n+1;i++){
            cin>>G[i];
        }
        for(int i=2;i<n;i++){
            a=G[i-1]-G[i-2];
            b=G[i]-G[i-1];
            c=G[i+1]-G[i];
            d=G[i+2]-G[i+1];
            if(a==b&&c!=d){
                if(a==c){
                    cout<<G[i+2]<<endl;
                    break;
                }
                else{
                    cout<<G[i+1]<<endl;
                    break;
                }
            }
            else if(a!=b&&c==d){
                if(b==c){
                    cout<<G[i-2]<<endl;
                    break;
                }
                else{
                    cout<<G[i-1]<<endl;
                    break;
                }
            }
            else if(a!=c&&a!=d&&b!=c&&b!=d){
                if(a==G[i+2]-G[i]&&b==G[i+2]-G[i]){
                    cout<<G[i+1]<<endl;
                    break;
                }
                else if(c==G[i]-G[i-2]&&d==G[i]-G[i-2]){
                    cout<<G[i-1]<<endl;
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 3108
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    d = LIR(n)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][k]+d[k][j] < d[i][j]:
                    print(-1)
                    return
    ans = 0
    for i in range(n):
        for j in range(i+1,n):
            for k in range(n):
                if k in (i,j):
                    continue
                if d[i][k]+d[k][j] <= d[i][j]:
                    break
            else:                
                ans += d[i][j]
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 45424
import sys

N , A , B = map(int,input().split())

if (B < A):
    res = 0
elif (N == 1) & (A < B):
    res = 0
else:    
    res = (B * (N - 1) + A) - (A * (N - 1) + B) + 1



print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int y[3];
    cin>>y[0]>>y[1]>>y[2];
    sort(y,y+3);
    if (y[0]==y[1])
        cout<<y[2];
    else
        cout<<y[0];
    return 0;
}

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

int main() {
    int cards[4][14] = {};
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        char mark;
        int rank;
        cin >> mark >> rank;
        switch (mark) {
            case 'S': cards[0][rank] = 1; break;
            case 'H': cards[1][rank] = 1; break;
            case 'C': cards[2][rank] = 1; break;
            case 'D': cards[3][rank] = 1; break;
        }
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 1; j < 14; j++) {
            if (cards[i][j] == 0) {
                switch (i) {
                    case 0: cout << "S " << j << endl; break;
                    case 1: cout << "H " << j << endl; break;
                    case 2: cout << "C " << j << endl; break;
                    case 3: cout << "D " << j << endl; break;
                }
            }
        }
    }
    return 0;
}



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

int main(){
    int K[114514]={};
    int L[114514]={};
    int A,B;
    cin >> A >> B;
    REP(i,114514){
        if((i/10000)%10 == i%10 && (i/1000)%10 == (i/10)%10){
            K[i]=1;
        }
    }
    REP(i,114514){
        if(i==0){
            L[0]=K[0];
        }else{
            L[i]=L[i-1]+K[i];
        }
    }
    cout << L[B]-L[A-1] << endl;
    return 0;
}

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

int main() {
	ll A,V,B,W,T,x,y;
	cin >> A >> V >> B >> W >> T;

	x = abs(A-B);
	y = (V-W)*T;
	
	cout << ((x <= y) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    l=[]
    for j in range(max(0,i-k),i):
        l.append(dp[j]+abs(h[i]-h[j]))
    dp[i]=min(l)
    #print(l)
print(dp[-1])


Measured memory_bytes: 52444
// abc131_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;
    vector<int> size;

    UnionFind(int N) : par(N), rank(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {par[i] = i; rank[i] = 0;}
    }

    int find(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = find(x); //xの根をrx
        int ry = find(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        if(rank[rx] < rank[ry]) { // root が rx の木の方が root が ry の木よりも低い
            par[rx] = ry; // root ry に rx の木をつなぐ
        } else {
            par[ry] = rx; // root rx に ry の木をつなぐ
            if(rank[rx] == rank[ry]) ++rank[rx]; // 同じ高さだったならばまとめたことによって高さ +1
        }
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    const int max_xy = 100001;
    vector<int> X(N), Y(N);
    vector<vector<int>> x_list(max_xy), y_list(max_xy);

    REP(i, N){
        cin >> X[i] >> Y[i];
        x_list[X[i]].emplace_back(i);
        y_list[Y[i]].emplace_back(i);
    }

    auto uf = UnionFind(N);

    REP(i, max_xy){
        if (x_list[i].empty()) continue;

        for (auto x: x_list[i]){
            uf.unite(x, x_list[i][0]);
        }
    }

    REP(i, max_xy){
        if (y_list[i].empty()) continue;

        for (auto y: y_list[i]){
            uf.unite(y, y_list[i][0]);
        }
    }

    vector<set<int>> x_num_list(N), y_num_list(N);
    vector<int> point_num(N, 0);

    REP(i, N){
        int conn_idx = uf.find(i);
        x_num_list[conn_idx].insert(X[i]);
        y_num_list[conn_idx].insert(Y[i]);
        point_num[conn_idx]++;
    }

    ll ans = 0;
    REP(i, N){
        ans += x_num_list[i].size() * y_num_list[i].size() - point_num[i];
    }

    print(ans);


    return 0;
}


Measured memory_bytes: 24576
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);
parse_tuple!(A, B, C, D);
parse_tuple!(A, B, C, D, E);

// ===

fn main() {
    let (n, m): (i32, i32) = read();
    let time = (n-m)*100+m*1900;
    println!("{}", time<<m);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

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

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    int a,b;cin>>a>>b;
    if(a<=8 && b<=8)
        cout<<"Yay!";
    else
        cout<<":(";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n,k; cin >> n >> k;
	vi h(n); rep(i,n) cin >> h[i];
	int ans = 0;
	rep(i,n){
		if(h[i]>=k) ans ++;
	}
	out(ans);
}




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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <


// CODE STARTS HERE

void solve(){
	int X;
	cin >> X;

	int rank = 8 - (X - 400) / 200;
	cout << rank << "\n";
}

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

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3652
n,k=map(int,input().split())
s=list(input())
if s[k-1]=="A":
  s[k-1]="a"
elif s[k-1]=="B":
  s[k-1]="b"
elif s[k-1]=="C":
  s[k-1]="c"
s="".join(s)
print(s)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

vector<P> to[100005];
vector<int> d(100005);
void dfs(int v, int p=-1) {
  for (auto u : to[v]) {
    if (u.first == p) continue;
    d[u.first] += d[v]+u.second%2;
    dfs(u.first,v);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1) {
    int u,v,w;
    cin >> u >> v >> w;
    --u; --v;
    to[u].emplace_back(v,w);
    to[v].emplace_back(u,w);
  }
  d[0]=0;
  dfs(0);
  rep(i,n) {
    cout << d[i]%2 << endl;
  }
  return 0;
}


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

int main(){
    int k;
    string s1;
    string s2;
    cin >> k >> s1;
    if(s1.size() > k){
        s2 = s1.substr(0,k);
        cout << s2 << "..." << endl;
    }else{
        cout << s1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

#include <set>
using namespace std;



int main(){
    long long n;
    cin >> n;

    vector<long long> a(n);

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

    sort(a.begin(), a.end());

    vector<bool> dp(a[a.size()-1]+1, true);
    set<long long> unique;
    for(long long i = 0; i < n; i++){
        if(unique.find(a[i]) != unique.end()){
            dp[a[i]] = false;
        }

        for(long long j = 2*a[i]; j <= a[a.size()-1]; j += a[i]){
            dp[j] = false;
            
        }

        unique.insert(a[i]);

    }

    long long count = 0;
    for(long long i = 0; i < n; i++){
        if(dp[a[i]] == true){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 14288
#include<stdio.h>

int main(void){
  int A,B,C,D;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  if((A+B)>(C+D)){
  printf("Left\n");
  }
  if((A+B)==(C+D)){
  printf("Balanced\n");
  }
  if((A+B)<(C+D)){
  printf("Right\n");
  }
 
}

Measured memory_bytes: 128
X= input()

T_count=X.count("T")
S_count=X.count("S")
T_removed=0
i=0
ans=0
while i<len(X):
    if X[i]=="T":
        if T_removed>0:
            T_removed -=1
        else:
            T_count -= 1
            ans+=1
    elif X[i]=="S":
        if T_count:
            T_count-=1
            T_removed+=1
        else:
            ans+=1
    i+=1
print(ans)

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

int main() {
  int n;
  cin >> n;
  int u, k;
  int M[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      M[u - 1][v - 1] = 1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (j < n - 1) cout << M[i][j] << ' ';
      else cout << M[i][j] << endl;
    }
  }
};



Measured memory_bytes: 3088
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    
    for (int i = 0; i < n; i++) {
      String ss = s.substring(i, i + 1);
      String tt = t.substring(i, i + 1);
      System.out.print(ss + tt);
    }
    System.out.print(s.substring(n));
    System.out.print(t.substring(n));
  }
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int ans[100007];
int grupo[100007];
int tam[100007];
bitset<100007> vis;
vector<vi> graph;

void dfs(int i, int idx){
	grupo[i] = idx;
	tam[idx]++;
	vis[i] = 1;
	for(auto& p: graph[i]){
		if(vis[p] == 0){
			dfs(p, idx);
		}
	}
}

/*void dfs2(int i){
	vis[i] = 1;
	for(auto&p : block[i]){
		if(vis[p] == 0){
			if(grupo[p] == grupo[i]){
				ans[p]--; ans[i]--;
			}
			dfs2(p);
		}
	}
}*/

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

	int n, m, k; cin >> n >> m >> k;

	graph.resize(n);

	FOR(i,m){
		int a, b; cin >> a >> b;
		graph[a-1].PB(b-1);
		graph[b-1].PB(a-1);
	}

	vis.reset();
	int cnt = 0;
	FOR(i, n){
		if(vis[i] == 0)
			dfs(i, cnt++);
	}

	FOR(i,k){
		int a, b; cin >> a >> b;
		a--; b--;
		if(grupo[a] == grupo[b]){
			ans[a]--; ans[b]--;
		}
	}

	FOR(i, n){
		int add = tam[grupo[i]] - graph[i].size()-1;
		ans[i] += add;
		cout << ans[i] << " \n"[i==n-1];
	}

	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n) - 1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9)+1;
const LL LLINF = LL(1e18)+1;
long double eps = 1.0E-14;



void solve()
{
  int A,B; cin>>A>>B;
  int ans = 3;
  if (1!=A and 1!=B)
  {
    ans = 1;
  }
  else if (2!=A and 2!=B)
  {
    ans = 2;
  }
  cout << ans << endl;
  
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
d = Counter(list(map(int, input().split())))
m = int(input())
T = list(map(int, input().split()))

ans = "YES"
for t in T:
    if t in d and d[t] > 0:
        d[t] -= 1
    else:
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 50496
import fractions
 
a, b, c, d = (int(x) for x in input().split())
def kansu(x,y,z):
    sta = x
    end = y
    if sta%z != 0:
        sta = sta+(z-(sta%z))
    if end%z != 0:
        end = end-(end%z)
    ans = ((end-sta)//z) +1
    return ans
a1 = kansu(a,b,c)
a2 = kansu(a,b,d)
lcm = c*d//(fractions.gcd(c,d))
a3 = kansu(a,b,lcm)
print(b-a-a1-a2+a3+1)

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, m;
string s;
void solve() {
    cin >> n >> m >> s;

    all(reverse, s);
    int now = 0;
    vector<int> ans;
    while (now != n) {
        bool ok = false;
        repds(i, min(now + m, n) - now) {
            if (s[now + i] == '1') continue;
            ok = true;
            ans.emplace_back(i);
            now = now + i;
            break;
        }

        if (!ok) break;
    }

    if (now == n) {
        repd(i, ans.size()) cout << ans[i] << " ";
        cout << endn;
    }
    else cout << -1 << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1096
a, b, c, d, e, f = map(int, input().split())
water_set = set()
sugar_set = set()

for i in range(31):
    for j in range(31):
        w = 100 * (a * i + b * j)
        if w > f:
            continue
        water_set.add(w)

for i in range(3001):
    for j in range(3001):
        s = c * i + d * j
        if s > f:
            continue
        sugar_set.add(s)

concentration_lim = e / (100 + e)
concentration = -1
ans_w = 0
ans_s = 0
for s in sugar_set:
    for w in water_set:
        total = s + w
        if total == 0:
            continue
        x = s / total
        if total <= f and x <= concentration_lim and x > concentration:
            concentration = x
            ans_w = total
            ans_s = s

print(ans_w, ans_s)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		String[] s = new String[h];//sはw文字
		StringBuilder soto = new StringBuilder();
		soto.append("##");
		for(int i=0;i<h;i++) {
			s[i]=scan.next();
		}
		for(int i=0;i<w;i++) {
			soto.append("#");
		}
		System.out.println(soto);

		for (int i=0;i<h;i++) {
			System.out.print("#");
			System.out.print(s[i]);
			System.out.println("#");
		}
		System.out.println(soto);
	}

}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);

  for (int i=0;i<n;i++) {
    cin >> vec.at(i);
  }

  sort(vec.begin(), vec.end());

  int sum = 1;

  for (int i=0;i<n-1;i++) {
    if(vec.at(i+1) > vec.at(i)) {
      sum += 1;
    }
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

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

  int ret1=0;
  int ret2=0;
  for(int i=0;i<b;i++)
  {
    ret1+=a*pow(10,i);
  }
  for(int j=0;j<a;j++)
  {
    ret2+=b*pow(10,j);
  }

  if(a>b)
  {
    cout<<ret2<<endl;
  }
  else
  {
    cout<<ret1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
from math import *
 
n=int(raw_input())
arr=list(map(int,raw_input().split()))
dict1={}
for i in range(n):
    val=arr[i]
    try:
        dict1[val]+=1
    except:
        KeyError
        dict1[val]=1
#print(dict1)
ans=0
arr.sort(reverse=True)
for i in range(n):
    if(dict1[arr[i]]>0):
        xd=2**(len(bin(arr[i]))-2)
        if(xd-arr[i]!=arr[i]):
            try:
                if(dict1[xd-arr[i]]>0):
                    ans+=1
                    dict1[xd-arr[i]]-=1
                    dict1[arr[i]]-=1
            except:
                KeyError
        else:
            if(dict1[arr[i]]>1):
                ans+=1
                dict1[arr[i]]-=2
print(ans)

Measured memory_bytes: 79324
while True :
    n, m = map(int, input().split())
    if n == 0  and m == 0 :
        break
    car_list = []
    if n != 0 :
        A = list(map(int, input().split()))
        for i in range(n) :
            car_list.append(A[i])
    if m != 0 :
        A = list(map(int, input().split()))
        for i in range(m) :
            car_list.append(A[i])
    car_list.sort()
    car_list.insert(0, 0)
    
    max_car = 0
    for i in range(n+m) :
        if car_list[i+1] - car_list[i] > max_car :
            max_car = car_list[i+1] - car_list[i]
    print(max_car)
    


Measured memory_bytes: 7196
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
int main(){
    string s;
    cin >> s;
    bool flag = true;
    if(s[0]!='A') flag = false;
    int cnt = 1;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C')cnt--;
    }
    if(cnt)flag = false;
    cnt =2;
    rep(i,s.size()){
        if(s[i]<=90)cnt--;
    }
    if(cnt)flag = false;
    if(flag){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }

}

Measured memory_bytes: 256
import sys


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a
    
if __name__ == '__main__':
    ab = sys.stdin.readline()
    a, b = ab.split()
    a, b = int(a), int(b)
    
    sys.stdout.write(str(gcd(a, b)) + '\n')

Measured memory_bytes: 4204
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__)
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
int main(){
    ll a, b;
    cin >> a >> b;
    cout << min(a % b, abs(a%b-b)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int min(int A, int B){
	return A>B ? B : A;
}

int main(){
	int tmp;
  	int ans;
  	int A, B, C, K;
  
  	scanf("%d%d%d%d", &A, &B, &C, &K);
  
  	ans = 0;
    //A
  	tmp = min(A, K);
    K -= tmp;
    ans += tmp;
  	//B
  	tmp = min(B, K);
  	K -= tmp;
  	//C
  	tmp = min(C, K);
  	K -= tmp;
  	ans -= tmp;
  
  	printf("%d\n", ans);
  
  	return 0;
}

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

typedef long long ll;

ll table[45];
bool flg[45];

ll fib(int n){
    if(flg[n])return table[n];
    else{
        flg[n]=true;
        return table[n]=fib(n-1)+fib(n-2);
    }
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    table[0]=table[1]=1;
    flg[0]=flg[1]=true;
    int n;
    cin >> n;
    cout << fib(n) << endl;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <queue>
#include <cstring>

#define mp make_pair
#define pb push_back
#define p push

#define FOR(a, c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) (1e5+5)

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector <vector<int>> vvi;
typedef vector<long long> vl;
typedef vector <pair<int, int>> vpi;
typedef vector <pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <vi> graph;

int main(){
    IOS
    string s,s2;
    cin >>s;
    cin>>s2;
    cout<<s2<<s;


    return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
s = []
for i in range(n):
    s.append(input())

c = []
for i in range(n):
    c.append(collections.Counter(s[i]))
f = []
d = []
e = []
for i in range(n):
    if i == 0:
        for j in c[i]:
            f.append(j)
            d.append([j, c[i][j]])
            e.append(c[i][j])
    else:
        for j in c[i]:
            if j in f:
                if c[i][j] < e[f.index(j)]:
                    e[f.index(j)] = c[i][j]
                    d[f.index(j)][1] = c[i][j]
p = []
for i in range(len(d)):
    for j in range(n):
        if d[i][0] not in s[j]:
            p.append(i)
            break
j = 0
for i in p:
    del d[i - j]
    j += 1
d.sort()
for i in range(len(d)):
    print(d[i][0] * d[i][1], end = '', sep='')

Measured memory_bytes: 3444
import sys,collections as cl,bisect as bs,heapq as hq
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

r,c,k = m()


item = [[0 for j in range(c)] for i in range(r)]



for i in range(k):
    R,C,V = m()
    item[R-1][C-1] = V


dp = [[0 for k in range(4)] for j in range(c)]
dpo = [[0 for k in range(4)] for j in range(c)]
for i in range(r):
    for j in range(c):
        if j == 0:
            if item[i][j] != 0:
                po = 0
                for kk in range(4):
                    po = max(po,dpo[j][kk])
                for k in range(4):
                    if k == 0:
                        dp[j][k] = po
                    elif k == 1:
                        dp[j][k] = po + item[i][j]
                    else:
                        dp[j][k] = 0

            else:
                po = 0
                for kk in range(4):
                    po = max(po,dpo[j][kk])
                for k in range(4):
                    if k == 0:
                        dp[j][k] = po
                    else:
                        dp[j][k] = 0

        else:
            if item[i][j] != 0:
                po = 0
                for kk in range(4):
                    po = max(po,dpo[j][kk])
                for k in range(4):
                    if k == 0:
                        dp[j][k] = max(dp[j-1][k],po)
                    elif k == 1:
                        dp[j][k] = max(dp[j-1][k],dp[j-1][0] + item[i][j],po + item[i][j])
                    else:
                        dp[j][k] = max(dp[j-1][k],dp[j-1][k-1] + item[i][j])

            else:
                po = 0
                for kk in range(4):
                    po = max(po,dpo[j][kk])
                for k in range(4):
                    if k == 0:
                        dp[j][k] = max(dp[j-1][k],po)
                    else:
                        dp[j][k] = dp[j-1][k]
    for j in range(c):
        for k in range(4):
            dpo[j][k] = dp[j][k]
            dp[j][k] = 0


ans = 0

for i in range(4):
    ans = max(ans,dpo[-1][i])
print(ans)


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

int dp[1001][1001][3];

int main(){
    int N,M,K,a,b,c,d;
    char input;
    cin>>M>>N>>K;
    for(int i=1;i<=M;i++){
        for(int j=1;j<=N;j++){
            cin>>input;
            for(int k=0;k<3;k++){
                dp[i][j][k]=dp[i-1][j][k]+dp[i][j-1][k]-dp[i-1][j-1][k];
            }
            if(input=='J') dp[i][j][0]++;
            else if(input=='O') dp[i][j][1]++;
            else dp[i][j][2]++;
        }
    }
    for(int i=0;i<K;i++){
        cin>>a>>b>>c>>d;
        printf("%d",dp[c][d][0]-dp[c][b-1][0]-dp[a-1][d][0]+dp[a-1][b-1][0]);
        for(int j=1;j<3;j++)
            printf(" %d",dp[c][d][j]-dp[c][b-1][j]-dp[a-1][d][j]+dp[a-1][b-1][j]);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 12764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  vector<int>h(1000);
  int sum=0;
  for(int i=1;i<1000;i++)
  {
    sum+=i;
    h.at(i)=sum;
  }
   for(int i=1;i<999;i++)
   {
     if(h.at(i)-a==h.at(i+1)-b)
     {
       cout<<h.at(i)-a<<endl;
     }
   }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int num = sc.nextInt();
          switch(num){
            case 22:
              System.out.println("Christmas Eve Eve Eve");
              break;
            case 23:
              System.out.println("Christmas Eve Eve");
              break;
            case 24:
              System.out.println("Christmas Eve");
              break;
            case 25:
              System.out.println("Christmas");
              break;
          }
          }
    }

Measured memory_bytes: 19924
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    a, b, c, k = map(int, input().split())
    if k <= a:
        print(k)
    elif k <= a + b:
        print(a)
    else:
        print(a - (k - a - b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define N 2005
#define ll long long
const ll mod=1e9+7;
vector<pair<int,int> >v;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int m=(n-1)*(n-2)/2;
    if(k>m){puts("-1");return 0;}
    else
    {
        for(int i=1;i<n;i++)
            v.push_back({i,n});
        int i=1,j=2;
        while(m!=k)
        {
            v.push_back({i,j});
            m--;
            j++;
            if(j==n)i++,j=i+1;
        }
        printf("%d\n",v.size());
        for(auto i:v)
            printf("%d %d\n",i.first,i.second);
    }
    return 0;
}


Measured memory_bytes: 384