akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	int a[5];
	while (~scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
		sort(a, a + 5);
		if ((a[0] == a[1] && a[0] == a[2] && a[0] == a[3]) || (a[1] == a[2] && a[1] == a[3] && a[1] == a[4]))puts("four card");
		else if ((a[0] == a[1] && a[0] == a[2] && a[3] == a[4]) || (a[0] == a[1] && a[2] == a[3] && a[2] == a[4]))puts("full house");
		else if ((a[1] == a[0] + 1 && a[2] == a[1] + 1 && a[3] == a[2] + 1 && a[4] == a[3] + 1) || (a[0] == 1 && a[1] == 10 && a[2] == 11 && a[3] == 12 && a[4] == 13))puts("straight");
		else if ((a[0] == a[1] && a[0] == a[2]) || (a[1] == a[2] && a[1] == a[3]) || (a[2] == a[3] && a[2] == a[4]))puts("three card");
		else if ((a[0] == a[1] && a[2] == a[3]) || (a[0] == a[1] && a[3] == a[4]) || (a[1] == a[2] && a[3] == a[4]))puts("two pair");
		else if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3] || a[3] == a[4])puts("one pair");
		else puts("null");
	}
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
int main() {
  int num,h,m,s;
  scanf("%d",&num);
  h = num / 3600;
  m = (num % 3600) / 60;
  s = num % 60;
  printf("%d:%d:%d\n",h,m,s);
  return 0;
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int n;
VVI vertex;
VI c, d;
int c_i;
void dfs(int i) {
    if (c_i >= n or d[i] > -1) return;
    d[i] = c[c_i];
    c_i++;
    for (auto adj : vertex[i]) dfs(adj);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vertex.resize(n);
    REP(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        vertex[a].push_back(b);
        vertex[b].push_back(a);
    }
    c.resize(n);
    REP(i, n) cin >> c[i];
    sort(ALL(c), greater<int>());

    ll m = 0;
    FOR(i, 1, n - 1) m += c[i];
    cout << m << ln;

    d.resize(n, -1);
    dfs(0);
    REP(i, n) {
        if (i != n - 1)
            cout << d[i] << " ";
        else
            cout << d[i] << ln;
    }
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine().Split(' ')[0]);

            var As = new List<int>();
            for(int i=0;i<N;i++)
            {
                var tmp = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToList();
                tmp.RemoveAt(0);
                As.AddRange(tmp);
            }

            Console.WriteLine(As.GroupBy(s => s).Where(k => k.Count() == N).Count());
        }
    }

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

int main() {
  string s;
  cin >> s;
  string X = "";
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0'){
      X +='0';
    }
    else if(s.at(i)=='1'){
      X +='1';
    }
    else{
      if(X.size()!=0){
      X.pop_back();
      }
    }
  }
      cout << X << endl; 
}

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

#include <iostream>
#include <queue>
using namespace std;

int H,W;
int M[1002][1002]={};
int dp[1002][1002]={};
int dp2[1002][1002]={};
typedef pair<int,int> P;
const int INF=1000000000;

int main() {
	cin>>H>>W;
	fill(M[0],M[1002],INF);

	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			cin>>M[i][j];
		}
	}
//	for(int i=0;i<H+2;i++){
//		M[i][0]=INF;
//		M[i][W+1]=INF;
//	}
//	for(int i=0;i<W+2;i++){
//		M[0][i]=INF;
//		M[H+1][i]=INF;
//	}
	queue<P> que;
	int x1,y1;
	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			if((M[i][j]<M[i-1][j]&&M[i][j]<M[i+1][j])&&(M[i][j]<M[i][j-1]&&M[i][j]<M[i][j+1])){
				//init
				fill(dp[0],dp[1002],0);
				que.push(P(i,j));
				while(!que.empty()){
					P p1=que.front();que.pop();
					x1=p1.first;
					y1=p1.second;
					if(dp[x1][y1]>0||dp2[x1][y1]>1)continue;
					dp[x1][y1]=1;
					dp2[x1][y1]+=1;
					if(M[x1-1][y1]>M[x1][y1]&&x1>1)que.push(P(x1-1,y1));
					if(M[x1+1][y1]>M[x1][y1]&&x1<H)que.push(P(x1+1,y1));
					if(M[x1][y1-1]>M[x1][y1]&&y1>1)que.push(P(x1,y1-1));
					if(M[x1][y1+1]>M[x1][y1]&&y1<W)que.push(P(x1,y1+1));
				}
			}
		}
	}
	int R=0;
	for(int i=1;i<H+1;i++){
		for(int j=1;j<W+1;j++){
			if(dp2[i][j]>1)R++;
		}
	}
	cout<<R<<endl;
	return 0;
}

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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
  if(a.second != b.second){
    return a.second < b.second;
  }else{
    return a.first < b.first;
  }
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vec;
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    vec.push_back(make_pair(a-1, b-1));
  }
  sort(vec.begin(), vec.end(), compare_by_b);
  int count = 0;
  int mostEast = 0;
  for(int i=0; i<m; i++){
    if(vec[i].first >= mostEast){
      mostEast = vec[i].second;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
  

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T T sq(T x){ return x * x; }
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r.begin()); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v){ return accumulate(v.begin(), v.end()); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

struct Field {
  Field(int w, int h) : w(w), h(h) {}
  bool invalid(int x, int y){ return x < 0 || w <= x || y < 0 || h <= y; }
  const int w, h;
};

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int n;
  while (n = in()){
    vector<pair<double, int> > hs;
    for (int i = 0; i < n; i++){
      int id, cm, kg;
      id = in();
      cm = in();
      kg = in();
      double bmi = kg / sq(cm / 100.0);
      hs.push_back(make_pair(abs(22 - bmi), id));
    }
    sort(hs);
    printf("%d\n", hs[0].second);
  }
  return (0);
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(s * t >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int n;
    scanf("%d", &n);
    if (n < 1200) {
        printf("ABC\n");
    } else if (n < 2800) {
        printf("ARC\n");
    } else {
        printf("AGC\n");
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
pys = [list(map(int, input().split())) for _ in range(m)]
map_ = {}
for i, (p, y) in enumerate(pys):
    map_.setdefault(p, [])
    map_[p].append(i)

for val in map_.values():
    val.sort(key=lambda i: pys[i][1])

ans = [None] * m
for key, val in map_.items():
    for num, i in enumerate(val):
        ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)
for a in ans:
    print(a)


Measured memory_bytes: 51472
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 1;
    for (int i = 0; i < N - 1; i++) {
        if (S[i] == S[ i + 1 ]) {
            continue;
        }
        cnt ++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n,a[3][3],b[10];
bool appear[3][3];
int main()
{
   for (int i=0; i<3; i++)
   {
      for (int j=0; j<3; j++) 
	     cin>>a[i][j];
   }
   cin>>n;
   for (int i=0; i<n; i++) 
      cin>>b[i];
   for (int i=0; i<n; i++)
   { 
      for (int j=0; j<n; j++)
	  {
	     appear[i][j]=false;
		 for (int k=0; k<n; k++)
		 {
		    if (a[i][j]==b[k])
			  appear[i][j]=true;
		 }
	  }
   }
   string ans="No";
   for(int i=0; i<3; i++)
   {
      if(appear[i][0] && appear[i][1] && appear[i][2])
	     ans="Yes";
   }
   for(int i=0; i<3; i++)
   {
      if(appear[0][i] && appear[1][i] && appear[2][i]) 
	     ans="Yes";
   }
   if(appear[0][0] && appear[1][1] && appear[2][2]) 
      ans="Yes";
   if(appear[0][2] && appear[1][1] && appear[2][0]) 
      ans="Yes";
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
import fractions
A,B = map(int,input().split())
if A == 1 or B == 1:
    print(1)
else:
    def factorization(n): #2以上の整数n => [[素因数, 指数], ...]の2次元リストを返す
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])
        if temp!=1:
            arr.append([temp, 1])
        if arr==[]:
            arr.append([n, 1])
        return arr
    c = fractions.gcd(A,B)
    arr = factorization(c)
    print(len(arr)+1)

Measured memory_bytes: 68204
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int a = A * 10 + B + C;
    int b = A + B * 10 + C;
    int c = A + B + C * 10;
    cout << max({ a,b,c }) << endl;

}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func max(x,y int) int {
  if x > y {
    return x
  }
  return y
}

func main(){
  var a,b,c,d int
  fmt.Scan(&a, &b, &c, &d)

  fmt.Println(max(a*b, c*d))
  
}

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

#define int long long

using namespace std;

const int N = 2e5 + 5;

int n;
pair <int, int> a[N];

bool cmp (pair <int, int> &p1, pair <int, int> &p2) {
    return p1.first < p2.first;
}

bool cmp2 (pair <int, int> &p1, pair <int, int> &p2) {
    return p1.second < p2.second;
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int x;
    cin >> x;
    cout << 1 - x;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;

ll N;
vector<ll> P;

void input() {
    cin >> N;
    P.resize(N);
    for (auto& p : P)
        cin >> p;
}

void solve() {
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if (P[i] == i + 1) {
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}


int main() {
    input();
    solve();
    
    return 0;
}



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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << " : " << x << endl;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin>>n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    int ans = (1 << 20);
    rep(bits, 1 << n) {

        vector<pii> v;
        int nflip = 0;
        rep(i, n) {
            if ((bits >> i) & 1) {
                v.emplace_back(b[i], i);
                nflip++;
            } else {
                v.emplace_back(a[i], i);
            }
        }
        if (nflip % 2) continue;

        auto vv = v;
        sort(all(v));

        vector<int> used(n, -1);
        vector<int> rev(n);
        rep(i, n) {
            rep(j, n) {
                if (vv[j].first != v[i].first) continue;
                if ((bits >> j) & 1) {
                    if (abs(j - i) % 2 == 0) continue;
                } else {
                    if (abs(j - i) % 2 != 0) continue;
                }
                if (used[j] < 0) {
                    used[j] = i;
                    rev[i] = j;
                    break;
                }
            }
        }

        bool ok = true;
        int tmp = 0;
        rep(i, n) {
            if (used[i] < 0) {
                ok = false;
                break;
            }
            int idx = 0;
            rep(j, n) if (rev[j] == i) idx = j;
            while(idx > i) {
                swap(rev[idx], rev[idx-1]);
                idx--;
                tmp++;
            }
            // cout << "t " << i << " " << rev[i] << endl;
            // tmp += max(0, rev[i] - i);
            // for (int j = rev[i]; j > i; j--) {
            //     rev[j] = rev[j - 1];
            // }
            // tmp += abs(used[i] - i);
        }

        if(ok) ans = min(ans, tmp);
    }

    if (ans == (1 << 20)) ans = -1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool f(string a,string b)
{
	for(int i=0;i<a.size();i++)if(a[i]=='?')a[i]='a';
	return a<=b;
}
bool ff(string a,string b)
{
	for(int i=0;i<a.size();i++)if(a[i]=='?')a[i]='z';
	return b<=a;
}
main()
{
	int n;cin>>n;int countl=0,countf=0;
	string a[10000],t;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>t;
	for(int i=0;i<n;i++)
	{
		countl+=f(a[i],t);
		countf+=ff(a[i],t);
	}
	for(int i=0;i<=countl-n+countf;i++)
	{
		cout<<(i?" ":"")<<n-countf+i+1;
	}
	cout<<endl;
}


Measured memory_bytes: 896
/* *
 *
 * Author: Hamkor
 *
 * */
 
#include <bits/stdc++.h>

using namespace std;

/* * * *   * * *   	* * * */
typedef long long ll;
const int oo = 1e9;
const ll mod = 100000000;
typedef complex<ll> P;
#define X real()
#define Y imag()
/* * * *   * * *   	* * * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b; cin>>a>>b;
	for (int i=1; i<=3; i++){
		if ((a*b*i)%2){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    for i in range(n):
        if (i+1) % 2 == 1 and A[i] % 2 == 1:
            cnt += 1

    print(cnt)


resolve()

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

using namespace std;

int main() {
  char a1, a2, a3;
  char b1, b2, b3;
  cin >> a1 >> a2 >> a3;
  cin >> b1 >> b2 >> b3;
  int ans = int(a1 == b1) + int(a2 == b2) + int(a3 == b3);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(H * W - (h * W + w * H) + h * w);
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1005;
const char s3[4][4]=
{
"aa.",
"..a",
"..a"
};
const char s4[5][5]=
{
"aabc",
"ddbc",
"efgg",
"efhh"
};
const char s5[6][6]=
{
"a.bbc",
"add.c",
"eeffg",
"hi..g",
"hi.jj"
};
const char s6[7][7]=
{
"aabbc.",
"d...ce",
"d.f..e",
"..fghh",
"ii.g.k",
".llnnk"
};
const char s7[8][8]=
{
"aabbc..",
".d..cee",
"fd...gg",
"f.h...i",
"..hjj.i",
"kklm...",
"..lmnn."
};
int n,m;
char col[N][N];
int main()
{
	scanf("%d",&n);
	if(n<=2)
	{
		printf("-1");
		return 0;
	}
	if(n==3)
	{
		for(int x=0;x<3;x++)
		{
			for(int y=0;y<3;y++)
				printf("%c",s3[x][y]);
			printf("\n");
		}
		return 0;
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			col[i][j]='.';
	if(n%4==0)
	{
		for(int i=1;i<=n;i+=4)
			for(int x=0;x<4;x++)
				for(int y=0;y<4;y++)
					col[i+x][i+y]=s4[x][y];
	}
	else if(n%4==1)
	{
		m=n-5;
		int i;
		for(i=1;i<=m;i+=4)
			for(int x=0;x<4;x++)
				for(int y=0;y<4;y++)
					col[i+x][i+y]=s4[x][y];
		for(int x=0;x<5;x++)
			for(int y=0;y<5;y++)
				col[i+x][i+y]=s5[x][y];
	}
	else if(n%4==2)
	{
		m=n-6;
		int i;
		for(i=1;i<=m;i+=4)
			for(int x=0;x<4;x++)
				for(int y=0;y<4;y++)
					col[i+x][i+y]=s4[x][y];
		for(int x=0;x<6;x++)
			for(int y=0;y<6;y++)
				col[i+x][i+y]=s6[x][y];
	}
	else if(n%4==3)
	{
		m=n-7;
		int i;
		for(i=1;i<=m;i+=4)
			for(int x=0;x<4;x++)
				for(int y=0;y<4;y++)
					col[i+x][i+y]=s4[x][y];
		for(int x=0;x<7;x++)
			for(int y=0;y<7;y++)
				col[i+x][i+y]=s7[x][y];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			printf("%c",col[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 4616
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long i=0; i<n; ++i) { cout<<a[i]; if(i!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> vl;
typedef vector<vector<long long> > vll;
typedef vector<P> vp;
typedef vector<vector<P> > vpp;
class union_find {
public:
	union_find(int n)
	: par_(n, -1)
	{}
	void init(int n) {
		par_.assign(n, -1);
	}

	int root(int x) {
		return par_[x] < 0 ? x : par_[x] = root(par_[x]);
	}

	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if(x == y) {
			return false;
		} else {
			if(par_[x] < par_[y]) {
				par_[x] += par_[y];
				par_[y] = x;
			} else {
				par_[y] += par_[x];
				par_[x] = y;
			}
			return true;
		}
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	int size(int x) {
		return -par_[root(x)];
	}

private:
	std::vector<int> par_;
};
int main() {
	ios::sync_with_stdio(false);
	int n,q;
	cin>>n>>q;
	union_find uf(n);
	REP(i,q) {
		int c,x,y;
		cin>>c>>x>>y;
		switch(c) {
			case 0: {
				uf.unite(x,y);
				break;
			}
			case 1: {
				cout<<(int)uf.same(x,y)<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n,k;    cin >> n >> k;
    vector<int>sunuke(n);
    rep(i, k){
        int d;  cin >> d;
        rep(j, d){
            int a;  cin >> a;
            --a;
            sunuke[a]++;
        }
    }
    int ans = 0;
    rep(i, n){
        if(sunuke[i] == 0)  ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;

int main(){
	ll n,m;
	ll sum = 0;
	scanf("%lld %lld",&n,&m);
	while(m--){
		ll x;
		scanf("%lld",&x);
		sum += x;
	}
	if(n - sum < 0) printf("-1\n");
	else printf("%lld\n",n-sum);
	return 0;
} 

Measured memory_bytes: 3828
a,b,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans = 123456789012345

for i in range(m):
    x,y,c=map(int,input().split())
    ans = min(ans, a[x-1]+b[y-1]-c)
a.sort()
b.sort()
ans = min(ans,a[0]+b[0])
print(ans)

Measured memory_bytes: 66284
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ldb;
typedef complex<double> base;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const bool debug=false;
const ll mod=200003;

ll n, ans, C_1=46, C_2=22;
ll cnt[111][111];
string s;

int main(void)
{
	fio; ll i, j, k, l; cin>>n;
	for(i=1 ; i<=n ; i++)
	{
		cin>>s; bool ex=false; ll t=0, n2=0, n5=0;
		for(j=0 ; j<s.length() ; j++)
		{
			if(s[j]=='.') { ex=true; continue; }
			if(ex) { n2--; n5--; }
			t=10LL*t+(s[j]-'0');
		}
		while(t%2==0) t/=2, n2++;
		while(t%5==0) t/=5, n5++;
		if(n2>=0 && n5>=0) ans--;
		cnt[n2+10][n5+10]++;
	}
	for(i=1 ; i<=60 ; i++)
	{
		for(j=1 ; j<=40 ; j++)
		{
			for(k=1 ; k<=60 ; k++)
			{
				for(l=1 ; l<=40 ; l++)
				{
					if(i+k>=20 && j+l>=20)
					{
						ans+=cnt[i][j]*cnt[k][l];
					}
				}
			}
		}
	}
	cout<<ans/2; return 0;
}

Measured memory_bytes: 3648
import sys
n = int(input())
a = list(map(int,input().split()))

dp = [sys.maxsize]*n
dp[0]=0

#print(dp)
for i in range(n):
  for j in range(i+1,i+2+1):
    if j<n:
      dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]))
  #print(dp)
      
print(dp[n-1])

Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
ll mod = 1e9 + 7;

using namespace std;



int main()
{
	int A,B;

	cin >>A>>B;
	int ans = A + B;
	if (ans >= 24)
	{
		ans = ans - 24;
	}
	cout << ans << endl;


	return 0;
}


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

int main()
{
  int r,c;
  cin >> r >> c;
  vector<vector<int> > v(r+1,vector<int>(c+1,0));
  for(int i=0; i<r; i++){
    for(int j=0; j<c; j++){
      int n;
      cin >> n;
      v[i][j] = n;
      v[i][c] += n;
      v[r][j] += n;
      v[r][c] += n;
    }
  }
  for(int i=0; i<=r; i++){
    for(int j=0; j<=c; j++){
      if(j != 0) cout << " ";
      cout << v[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int s = a>b?a:b;
	s = s>c?s:c;
	int d = s;
	for (int i = 0; i < k; i++)
		s *= 2;
	s += a+b+c-d;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/dp/tasks/dp_g

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int M_MAX = 1e5;

int N, M;
int x[M_MAX];
int y[M_MAX];

//------------------------------------------------------------------------------
const int V_MAX = 1e5;

int V;
vector<int> rG[V_MAX];
int outdeg[V_MAX];

void add_edge(int from, int to) {
  rG[to].push_back(from);
  outdeg[from]++;
}

int ans = 0;
int dp[V_MAX];
void execDP() {
  queue<int> que;
  REP(v, V) if (outdeg[v] == 0) que.push(v);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    REP(i, rG[v].size()) {
      int u = rG[v][i];
      dp[u] = max(dp[u], dp[v] + 1);
      ans = max(ans, dp[u]);
      if (--outdeg[u] == 0) que.push(u);
    }
  }
}

//------------------------------------------------------------------------------
void solve() {
  V = N;
  REP(i, M) add_edge(x[i] - 1, y[i] - 1);
  execDP();
  // DUMP(dp, V);
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) scanf("%d%d", x + i, y + i);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 7296
def hantei(s, h):
    try:
        slen = len(s)
        hlen = len(h)
        res = s.index(h, slen - hlen, slen + 1)
        return res
    except ValueError as e:
        return -1


def resolve():
    s = input()
    a = 'dream'
    b = 'dreamer'
    c = 'erase'
    d = 'eraser'
    while True:
        # 後ろから文字列検索
        # 合ったらその文字を削除
        D = hantei(s, d)
        if D > -1:
            s = s[:-len(d)]
            continue
        B = hantei(s, b)
        if B > -1:
            s = s[:-len(b)]
            continue
        C = hantei(s, c)
        if C > -1:
            s = s[:-len(c)]
            continue
        A = hantei(s, a)
        if A > -1:
            s = s[:-len(a)]
            continue
        if len(s) == 0:
            print('YES')
        else:
            print('NO')
        break
        
resolve()

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
//Disjoint Sparse Table
#include<vector>
#include<functional>
template<typename T>
struct DST{
	function<T(T,T)>calcfn;
	int n;
	vector<vector<T> >dat;
	DST(const vector<T>&v={},
		function<T(T,T)>calcfn_=[](T a,T b){return a<b?a:b;}
	):n(v.size()),calcfn(calcfn_)
	{
		dat.push_back(v);
		for(int i=2;i<n;i<<=1)
		{
			dat.push_back(vector<T>(n));
			for(int j=i;j<n;j+=i<<1)
			{
				dat.back()[j-1]=dat[0][j-1];
				for(int k=2;k<=i;k++)
				{
					dat.back()[j-k]=calcfn(dat[0][j-k],dat.back()[j-k+1]);
				}
				dat.back()[j]=dat[0][j];
				for(int k=2;k<=i&&j+k<=n;k++)
				{
					dat.back()[j+k-1]=calcfn(dat[0][j+k-1],dat.back()[j+k-2]);
				}
			}
		}
	}
	T query(int l,int r)//[l,r)
	{
		if(l<0)l=0;
		if(r>n)r=n;
		r--;
		if(l==r)return dat[0][l];
		int k=31-__builtin_clz(l^r);
		return calcfn(dat[k][l],dat[k][r]);
	}
};
int N,K;
bool flag[2<<17];
main()
{
	cin>>N>>K;
	vector<int>P(N);
	for(int i=0;i<N;i++)
	{
		cin>>P[i];
	}
	DST<int>X(P,[](int a,int b){return a<b?b:a;});
	DST<int>Y(P,[](int a,int b){return a>b?b:a;});
	int ans=0;
	int p=0;
	int ret=0;
	for(int i=0;i<N;i++)
	{
		if(i>0&&P[i-1]>P[i])p=i;
		if(i-p+1>=K)
		{
			flag[i]=true;
			ret=1;
		}
		if(i>=K-1&&!flag[i])
		{
			if(i==K-1||flag[i-1]||!flag[i-1]&&(P[i-K]!=Y.query(i-K,i)||P[i]!=X.query(i-K+1,i+1)))
			{
				ans++;
			}
		}
	}
	cout<<ans+ret<<endl;
}


Measured memory_bytes: 29440
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

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

    Int ans = 0, m = 0;
    vector<Int> b(n);
    for (Int i = 0; i < n; i++) {
        if (a[i] < 0) {
            m++;
        }

        b[i] = abs(a[i]);
    }

    for (Int i = 0; i < n; i++) {
        ans += b[i];
    }
    if (m % 2 != 0) {
        ans -= *min_element(b.begin(), b.end()) * 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
n,m = map(int, input().split())
diff = abs(abs(n) - abs(m))
res = diff

if abs(n) <= abs(m):
  if n < 0:
    res += 1
  if m < 0:
    res += 1
  print(res)

else:
  if n > 0:
    res += 1
  if m > 0:
    res += 1
  print(res)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a = 0;
  vector<long long> vec(N);
  long long ans = 1;
  for(int i = 0; i<N; i++){
    cin >> vec[i];
    if (vec[i] == 0){
      a = 1;
    }
  }
  if(a == 1){
    cout << 0 << endl;
    return 0;
  }
  
  for(int i = 0; i<N; i++){
    if( vec[i] <= 1000000000000000000/ ans){
      ans *= vec[i];
    } else{
      a = 2;;
      break;
    }
  }
  if(a == 0){
    cout << ans << endl;
  }else if(a == 2){
    cout << -1 << endl;
  }
}

Measured memory_bytes: 4032
package main

import "fmt"

type point struct {
	x int
	y int
	h int
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxph(ps []point) int {
	ans := ps[0].h
	for _, p := range ps {
		if p.h > ans {
			ans = p.h
		}
	}
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)
	ps := make([]point, n)
	for i := range ps {
		fmt.Scan(&ps[i].x, &ps[i].y, &ps[i].h)
	}

	for ch := maxph(ps); ; ch++ {
		for cx := 0; cx <= 100; cx++ {
		L:
			for cy := 0; cy <= 100; cy++ {
				for _, p := range ps {
					if p.h != max(ch-abs(p.x-cx)-abs(p.y-cy), 0) {
						continue L
					}
				}
				fmt.Println(cx, cy, ch)
				return
			}
		}
	}
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if (a>b)
		cout<<"a > b"<<"\n";
	else if(a==b)
		cout<<"a == b"<<"\n";
	else
		cout<<"a < b"<<"\n";
		
		
	return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <math.h>

int main()
{
    int D, N;
    scanf("%d%d", &D, &N);
    
    if( N == 100 )
        printf("%d\n", (int)pow(100, D) * 101);
    else
        printf("%d\n", (int)pow(100, D) * N);

    return 0;
}


Measured memory_bytes: 128
A = list(input())
B = list(input())
C = list(input())

next = "a"
while True:
    if next == "a":
        if len(A) == 0:
            print("A")
            break
        n = A.pop(0)
        next = n
    elif next == "b":
        if len(B) == 0:
            print("B")
            break
        n = B.pop(0)
        next = n
    else:
        if len(C) == 0:
            print("C")
            break
        n = C.pop(0)
        next = n


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int q1 = sc.nextInt();
			if (q1 == 0) return;
			int b = sc.nextInt();
			int c1 = sc.nextInt();
			int c2 = sc.nextInt();
			int q2 = sc.nextInt();

			int aizCnt = 0;
			int norCnt = 0;

			aizCnt = Math.min(b / c1, q2);
			b -= aizCnt * c1;
			norCnt += b / c2;
			b -= norCnt * c2;
			while (aizCnt + norCnt < q1 && 1 < aizCnt--) {
				b += c1;
				norCnt += b / c2;
				b -= (b / c2) * c2;
			}
			System.out.println((aizCnt == 0 || aizCnt + norCnt < q1) ? "NA" : (aizCnt + " " + norCnt));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

struct dsu {
public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m);
    for (ll i = 0;i < m;++i) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
    }
    vector<ll> ans;
    dsu uf(n);
    ll now = n * (n - 1) / 2;
    ans.push_back(now);
    for (ll i = m - 1;i > 0;--i) {
        if (!uf.same(a[i], b[i])) {
            now -= uf.size(a[i]) * uf.size(b[i]);
            uf.merge(a[i], b[i]);
        }
        ans.push_back(now);
    }
    for (auto it = ans.rbegin();it != ans.rend();++it) {
        cout << *it << endl;
    }
}

Measured memory_bytes: 6276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;


int main(){
    string s;
    cin>>s;
    rep(i,s.size()) cout<<"x";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c,x,y;
	long int val=0;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if(a+b<c*2){
		while(x*y){
			x--,y--;
			val+=a+b;
		}
		if(x+y==0){;}
		else if((a*x+b*y)<(c*2)*(x>y?x:y)){
			val+=a*x+b*y;
		}
		else{
			val+=(c*2)*(x>y?x:y);
		}
	}
	else{
		while(x*y){
			x--,y--;
			val+=c*2;
		}
		if(x+y==0){;}
		else if((a*x+b*y)<(c*2)*(x>y?x:y)){
			val+=a*x+b*y;
		}
		else{
			val+=(c*2)*(x>y?x:y);
		}
	}
	printf("%ld",val);
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector< vector<int> > kto(n), jaki(n);
    for (int i = 0; i < n; ++i)
    {
        int m;
        cin >> m;
        for (int j = 0; j < m; ++j)
        {
            int x, y;
            cin >> x >> y;
            --x;
            kto[i].push_back(x);
            jaki[i].push_back(y);
        }
    }
    int odp = 0;
    for (int mask = 0; mask < (1 << n); ++mask)
    {
        bool ok = true;
        for (int i = 0; i < n; ++i)
        {
            if ((mask & (1 << i)) > 0)
            {
                for (int j = 0; j < kto[i].size(); ++j)
                {
                    if ((jaki[i][j] == 1 && (mask & (1 << kto[i][j])) == 0) ||
                        (jaki[i][j] == 0 && (mask & (1 << kto[i][j])) > 0))
                            ok = false;
                }
            }
        }
        if (ok)
            odp = max(odp, __builtin_popcount(mask));
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(ll i=1;i<n;i++)
#define all(V) V.begin(),V.end()
#define ll long long
#define ld long double
#define MOD 998244353
#define mod MOD
#define sec setprecision
constexpr double eps = 1e-9;
constexpr double PI = 3.141592653589793238462643383279;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a) % mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}
int main() {
	solve();
}

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

int n,m,a,b,c,t;
int x[50];
int mat[50][50],ans[50][50];

void A(int mx[50][50],int my[50][50],int check){
	int z[50][50];
	memset(z,0,sizeof(z));
	rep(i,n)rep(j,n)rep(k,n){
		z[i][j]+=mx[i][k]*my[k][j];
		z[i][j]%=m;
	}
	if(check)rep(i,n)rep(j,n)ans[i][j]=z[i][j];
	else rep(i,n)rep(j,n)mat[i][j]=z[i][j];
}

int main(){
	while(cin>>n>>m>>a>>b>>c>>t,n||m||a||b||c||t){
		rep(i,n)cin>>x[i];
		memset(ans,0,sizeof(ans));
		memset(mat,0,sizeof(mat));
		rep(i,n)ans[i][i]=1;
		if(n==1){
			mat[0][0]=b;
		} else{
			mat[0][0]=b;mat[0][1]=c;
			for(int i=1;i<n-1;i++){
				mat[i][i-1]=a;mat[i][i]=b;mat[i][i+1]=c;
			}
			mat[n-1][n-2]=a;mat[n-1][n-1]=b;
		}
		while(t){
			if(t%2) A(ans,mat,1);
			A(mat,mat,0);
			t/=2;
		}
		rep(i,n){
			int out=0;
			rep(j,n)out+=ans[i][j]*x[j];
			if(i)cout<<" ";
			cout<<out%m;
		}
		cout<<endl;
	}
}

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

int main() {
  while (1) {
    int h, w;
    cin >> h >> w;

    if (h == 0 && w == 0) { break; }

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

const int MOD = 1000000007;
vector<long long> COM;

// val を m で割った余り (>= 0) を返す
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

// a^b mod p を返す
long long modpow(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long res = modpow(a, b / 2, p);
  if (b % 2 == 0) res = (res * res) % p;
  else res = (((res * res) % p) * a) % p;
  return res;
}

// mod p における a の逆元 a^{p-2} mod p を返す
long long inverse(long long a, long long p) {
  return modpow(a, p-2, p);
}

// nCr を計算
// COM[r] := nCr mod p の値
void Combination(long long n, long long r, long long p) {
  COM.resize(r+1);
  long long t = 1;
  COM.at(0) = t;
  for (int i = 1; i <= r; i++) {
    t = mod(t * (n-i+1), p);
    t = mod(t * inverse(i, p), p);
    COM.at(i) = t;
  }
}

int main() {
  int n, a, b; cin >> n >> a >> b;
  Combination(n, 200000, MOD);
  long long ans = modpow(2, n, MOD);
  cout << mod(ans - 1 - COM.at(a) - COM.at(b), MOD) << endl;
}

Measured memory_bytes: 1792
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

res = 0

n.times do |i|
  ate = a[i]
  res += b[ate - 1]
  res += c[a[i-1] - 1] if i > 0 and a[i-1] == ate - 1
end

puts res

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll inf = (1LL << 50);

vector<int> to[200200];
map<int, map<int, int>> memo;  // key = from, to
map<int, map<int, bool>> used; // key = from, to

int mod;
int dfs(int u, int p = -1) {
    if (used[p][u]) return memo[p][u];

    used[p][u] = true;
    int ret = 1;
    for (auto v : to[u]) {
        if (v != p) ret = (ret * (dfs(v, u) + 1)) % mod;
    }
    return memo[p][u] = ret;
}

int dfs2(int u, int p = -1) {
    if (used[p][u]) return memo[p][u];

    used[p][u] = true;
    int ret = 1;
    vector<int> l = {1}, r = {1};
    rep(i, to[u].size()) {
        int lv = to[u][i];
        int rv = to[u][to[u].size() - i - 1];
        l.push_back(l.back() * (dfs2(lv, u) + 1) % mod);
        r.push_back(r.back() * (dfs2(rv, u) + 1) % mod);
        if (lv != p) ret = (ret * (dfs2(lv, u) + 1)) % mod;
    }
    reverse(all(r));

    rep(i, to[u].size()) {
        int v = to[u][i];
        used[v][u] = true;
        memo[v][u] = (l[i] * r[i + 1]) % mod;
    }
    // if (p != -1 and memo[p][u] != ret) {
    //     cout << "ERROR :" << p << " " << u << " " << memo[p][u] << " " << ret << endl;
    // }
    return memo[p][u] = ret;
}

void solve(long long N, long long M, std::vector<long long> x, std::vector<long long> y) {
    mod = M;
    rep(i, N - 1) {
        to[x[i]].push_back(y[i]);
        to[y[i]].push_back(x[i]);
    }

    dfs(0);
    rep(i, N) {
        cout << dfs2(i) << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> x(N - 1);
    std::vector<long long> y(N - 1);
    for (int i = 0; i < N - 1; i++) {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
        x[i]--;
        y[i]--;
    }
    solve(N, M, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 78720
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  int A;
  int Ans = X;
  for(int i = 0; i < N; i++){
    cin >> A;
    Ans += (D-1)/A+1;
  }

  printf("%d\n",Ans);
  return 0;

}



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

int N, A, B, C, l[10];

int main(void) {

	cin >> N >> A >> B >> C;

	long long int ans = 999999999999;

	for (int i = 1; i <= N; i++) {
		cin >> l[i];
	}
	vector<int> a, b, c;
	for (int i = 1; i <= pow(4, N); i++) {
		int tmp = i;
		int count = 1;
		a.clear(); b.clear(); c.clear();
		while (tmp > 0) {
			if ((tmp % 4) == 1) { a.push_back(count); }
			else if ((tmp % 4) == 2) { b.push_back(count); }
			else if((tmp%4)==3){ c.push_back(count); }
			count++;
			tmp /= 4;
		}

		if ((a.size() == 0) || (b.size() == 0) || (c.size() == 0)) { continue; }

		long long int tmp_A = 0, tmp_B = 0, tmp_C = 0;
		for (int k = 0; k < (int)a.size(); k++) { tmp_A += l[a[k]]; }
		for (int k = 0; k < (int)b.size(); k++) { tmp_B += l[b[k]]; }
		for (int k = 0; k < (int)c.size(); k++) { tmp_C += l[c[k]]; }

		long long int MP = 0;
		MP += (a.size() - 1) * 10 + (b.size() - 1) * 10 + (c.size() - 1) * 10;

		/*cout << "a "; for (int k = 0; k < (int)a.size(); k++) { cout << a[k] << " "; } cout << endl;
		cout << "b "; for (int k = 0; k < (int)b.size(); k++) { cout << b[k] << " "; } cout << endl;
		cout << "c "; for (int k = 0; k < (int)c.size(); k++) { cout << c[k] << " "; } cout << endl;
		//cout << "tmp_A= " << tmp_A << " tmp_B= " << tmp_B << "tmp_C= " << tmp_C << endl;
		*/
		MP += abs(A - tmp_A);
		MP += abs(B - tmp_B);
		MP += abs(C - tmp_C);

		ans = min(ans, MP);

	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int, input().split()))
    for col in range(W):
        table[row][col] = work[col]

for row in range(H):
    for col in range(W):
        table[row][W] += table[row][col]

for col in range(W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]

for row in range(H+1):
    print('%d'%(table[row][0]), end="")
    for col in range(1, W+1):
        print(' %d'%(table[row][col]), end="")
    print()


Measured memory_bytes: 6204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for(i=0; i<(n); i++)
#define forn1 for(i=1; i<=n; i++)


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>a>>b>>n;
    if(n>=b)
    {
        cout<<(a*(b-1))/b<<endl;
    }
    else
    {
        cout<<(((a*n)/b)-a*(n/b))<<endl;
    }


}


Measured memory_bytes: 3652