akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    string s; cin >> s;

    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
        cout << "Bad" << endl;
    else
        cout << "Good" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b, r;
	cin >> a >> b;
	if( a < b )
		swap(a , b);

	while( r = a % b ){
		a = b;
		b = r;
	}
	cout << b << "\n";

	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<queue>
#include<set>
#include<cstdio>
#include<climits>
#include<cstring>

using namespace std;

int main(){

	int H,W;
	cin >> H >> W;

    char s[52][52];



    for(int i = 1;i <= H;i++){
    	for(int j = 1;j <= W;j++){
    	   	cin >> s[i][j];
    	}
    }

    for(int i = 1;i <= H;i++){
    	for(int j = 1;j <= W;j++){
    		if(s[i][j] == '#'){
    		   if(s[i-1][j] !='#' && s[i][j-1] != '#' && s[i+1][j] != '#' && s[i][j+1] !='#'){
    			   cout << "No" << endl;
    			   return 0;
    		   }
    		}
    	}
    }

    cout << "Yes" << endl;

    return 0;

}


Measured memory_bytes: 256
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int

()
|> readIntArray
|> fun [| n; _ |] ->
    [| 1 .. n |]
    |> Array.collect (fun _ -> readIntArray () |> Array.tail)
    |> Array.groupBy id
    |> Array.map (fun (_, arr) -> arr |> Array.length)
    |> Array.filter ((=) n)
    |> Array.length
    |> printfn "%d"


Measured memory_bytes: 30356
let k, s = Scanf.scanf "%d %d" (fun k s -> k, s)
let ans = ref 0

let () =
  for x = 0 to k do 
    for y = 0 to k do 
      if (s - x - y >= 0 && s - x - y <= k) then incr ans
    done ;
  done ;
  Printf.printf "%d\n" !ans

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

int main()
{
	int n;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	sort(a, a + n);
	cout << a[n / 2] - a[n / 2-1];
	delete[]a;
	return 0;
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<double> a(N);
  vector<double> S(N+1, 0.);
  for(int i = 0; i < N; i++) {
    double b; cin >> b;
    a[i] = (b+1) / 2;
    S[i+1] = S[i] + a[i];
  }
  double ans = 0.;
  for(int i = 0; i < N-K+1; i++) {
    ans = max(ans, S[i+K] - S[i]);
  }
  cout << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

const int MOD = 1000000007;

int DP[2][13];

int main() {
    string S;
    cin >> S;
    
    int n = S.length();
    
    S = "?" + S;
    
    if(S[1] == '?') {
        for(int r = 0; r <= 9; r++) {
            DP[1][r] = 1;
        }
    } else {
        DP[1][S[1] - '0'] = 1;
    }
    
    for(int i = 2; i <= n; i++) {
        for(int r = 0; r < 13; r++) {
            DP[i % 2][r] = 0;
        }
        
        for(int r = 0; r < 13; r++) {
            if(S[i] != '?') {
                int x = (10 * r + S[i] - '0') % 13;
                DP[i % 2][x] += DP[(i + 1) % 2][r]; 
                DP[i % 2][x] %= MOD;
                continue;
            }
            
            for(int c = 0; c <= 9; c++) {
                int x = (10 * r + c) % 13;
                DP[i % 2][x] += DP[(i + 1) % 2][r];
                DP[i % 2][x] %= MOD;
            }
        }
    }
    
    
    cout << DP[n % 2][5];
    
    return 0;
}

Measured memory_bytes: 3816
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef pair<int, int> P;
int k, a[100000], dist[100000];
vector<int> v[100000];
vector<P> w;
bool b[100000];
void cal(int x, int y){
    dist[x] = y;
    b[x] = false;
    w.push_back(P(y, x));
    for(int i=0;i<v[x].size();i++){
        cal(v[x][i], y+1);
    }
}
int hin(int x, int y){
    if(b[x])return 0;
    b[x] = true;
    if(x == 0 || (a[x] == 0 && y == k-1))return 0;
    if(y == k-1)return 1;
    return hin(a[x], y+1);
}
int main() {
    int n, ans = 0;
    cin >> n >> k >> a[0];
    if(--a[0] != 0)ans++;
    for(int i=1;i<n;i++){
        cin >> a[i];
        v[--a[i]].push_back(i);
    }
    cal(0, 0);
    sort(w.begin(), w.end(), greater<P>());
    for(int i=0;i<w.size();i++){
        int p = w[i].second;
        if(!b[p]){
            ans += hin(p, 0);
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13812
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int a[200020];
int f[200020]={0};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;lli ans=0ll;
    cin>>n;
    set<int> s;
    for(int i=0;i<n;++i)
       {
            cin>>a[i];
            s.insert(a[i]);
            f[a[i]]++;
       }
    for(auto i: s)
    {
        ans+=(1ll*f[i]*(f[i]-1))/2;
    }
    for(int i=0;i<n;++i)
    {
        cout<<ans-(lli)f[a[i]]+1ll<<endl;
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

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

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

	int a[n];

	loop(i,n)
	{
		cin>>a[i];
	}
    
    sort(a,a+n);
	reverse(a,a+n);

	ll sum = 0;

	loop(i,k)
	{
		sum += a[i];
	}

	cout<<sum<<endl;


}


Measured memory_bytes: 3628
N, M = map(int,input().split())

S = [0]*M

for i in range(N):
    B = list(map(int, input().split()))
    K = B[0]
    for j in range(K):
        S[B[j+1]-1] += 1

count = 0
for i in range(M):
    if S[i] == N:
        count += 1

print(count)

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<bitset<20>> vbi;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
  return a * b / gcd(a, b);
}

void Main()
{
  rep(i, 3)
  {
    str s; cin >> s;
    cout << s[i];
  }
  fin("");
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
x,y = (int(i) for i in input().split())

case = [(x*1,y*1,0),(x*(-1),y*1,1),(x*1,y*(-1),1),(x*(-1),y*(-1),2)]
ans = float('inf')

for c in case:
    x,y = c[0],c[1]
    if y>=x: ans = min(ans,y-x+c[2])
print(ans)


Measured memory_bytes: 3064
S = input()
Q = int(input())
Query = [list(map(str,input().split())) for i in range(Q)]
front = ""
back = ""
hanten_flag = 0
cnt = 0
for i in range(Q):
    if(Query[i][0] == "1"):
        hanten_flag ^= 1
    else:
        if(Query[i][1] == "1" and hanten_flag == 0):
            front = Query[i][2] + front
        elif(Query[i][1] == "1" and hanten_flag == 1):
            back = back + Query[i][2]
        elif(Query[i][1] == "2" and hanten_flag == 0):
            back = back + Query[i][2]
        else:
            front = Query[i][2] + front
SS = front + S + back
if(hanten_flag == 1):
    SS = SS[::-1]
print(SS)


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

int main() {
	
	int h1,s1,h2,s2;
	cin>>h1>>s1>>h2>>s2;
	int n1,n2;
	if(h1%s2!=0)
	n1=(h1/s2)+1;
	else
	n1=(h1/s2);
	
	if(h2%s1!=0)
	n2=(h2/s1)+1;
	else
	n2=(h2/s1);
	
	if(n1>=n2)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3548
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;


int main(){
 string N;
  cin>>N;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(N=="ABC")cout << "ARC" << endl;
  else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='C') {
			for(int j=i;j<=s.length();j++){
				if(s[j]=='F'){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;//养成好习惯 
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<63) - 600;
const ll mod=1e9+7 ;
const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
  int H, W; cin >> H >> W; string S[H];
  rep(i, H){
    cin >> S[i];
  }
  int dist[H][W];
  queue<pair<int, int>> Q;
  int mochi[5] = {0, 1, 0, -1, 0}; int ans = 0;
  rep(i, H)rep(j, W){
    if(S[i][j]=='#') continue;
    rep(i, H)rep(j, W){
      dist[i][j]=inf;
    }
    Q.push({i, j}); dist[i][j]=0;
    while(!(Q.empty())){
      int ii = Q.front().first, jj = Q.front().second; Q.pop();
      rep(k, 4){
        if(ii+mochi[k]>=H || jj+mochi[k+1]>=W || ii+mochi[k]<0 || jj+mochi[k+1]<0) continue;
        if(S[ii+mochi[k]][jj+mochi[k+1]]=='#') continue;
        if(dist[ii+mochi[k]][jj+mochi[k+1]]!=inf) continue;
        dist[ii+mochi[k]][jj+mochi[k+1]]=dist[ii][jj]+1;  Q.push({ii+mochi[k], jj+mochi[k+1]});
        //if(i==0&&j==0) cout << ii << " " << jj << " " << ii+mochi[k] << " " << jj+mochi[k+1] << " " << dist[ii][jj]+1 << endl;
      }
      ans = max(ans, dist[ii][jj]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
int main() {
    cin >> n >> a >> b;
    long long sa = b-a;
    long long ans = 0;
    if(sa % 2 == 0) {
        ans = sa/2;
    }else {
        long long fst = a-1;
        long long last = n-b;
        if(fst < last) {
            ans += fst+1;
            ans += (b-(fst+1)-1)/2;
        }else {
            ans += last+1;
            ans += (n-(a+last+1))/2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){

		Scanner sc=new Scanner(System.in);

		String[] str=(sc.next()).split("");

		sc.close();

		List<String> list=new ArrayList<String>();

		int cnt=0;

		for(int i=0;i<4;i++){
			if(list.contains(str[i])){
				cnt++;
			}else{
				list.add(str[i]);
			}
		}

		if(list.size()>2){
			System.out.println("No");
		}else{
			if(cnt==2){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}


	}
}


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

int main(){
  int N, l, r, sum;
  sum = 0;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string s, t, x="UNRESTORABLE";
int main() {
	int i, j;
	cin>>s>>t;
	for(i=s.size()-t.size(); i>=0; i--) {
		for(j=0; j<t.size(); j++) {
			if(s[i+j]!='?' && s[i+j]!=t[j]) break;
		}
		if(j==t.size()) {
			x = s;
			for(j=0; j<t.size(); j++) x[i+j] = t[j];
			for(j=0; j<s.size(); j++) if(x[j]=='?') x[j] = 'a';
			break;
		}
	}
	cout<<x;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define int long long
//#define ll long long
const int maxm=3e5+5;
struct Node{
    int a[maxm<<2];
    void pp(int k){
        a[k]=max(a[k*2],a[k*2+1]);
    }
    void update(int x,int val,int l,int r,int k){
        if(l==r){
            a[k]=val;return ;
        }
        int mid=(l+r)/2;
        if(x<=mid)update(x,val,l,mid,k*2);
        else update(x,val,mid+1,r,k*2+1);
        pp(k);
    }
    int askma(int st,int ed,int l,int r,int k){
        if(st<=l&&ed>=r)return a[k];
        int mid=(l+r)/2;
        int ans=0;
        if(st<=mid)ans=max(ans,askma(st,ed,l,mid,k*2));
        if(ed>mid)ans=max(ans,askma(st,ed,mid+1,r,k*2+1));
        return ans;
    }
}T;
int a[maxm];
int n,k;
signed main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    const int p=3e5;
    for(int i=1;i<=n;i++){
        int l=max(a[i]-k,0);
        int r=min(p,a[i]+k);
        int t=T.askma(l,r,0,p,1)+1;
        T.update(a[i],t,0,p,1);
    }
    cout<<T.a[1]<<endl;
    return 0;
}
/*
发现a[i]比较小,那么令d[k]表示以k为结尾的最长串.
d[k]=mak{d[k]}+1,其中k和k的绝对值差值<=k.
查询d[k]最大值可以用线段树.
*/


Measured memory_bytes: 8876
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
using namespace std;

int		main(void)
{
	int n;

	cin >> n;
	vector<tuple<string, int, int>> R(n);
	for (int i = 0; i < n; i++)
	{
		cin >> get<0>(R[i]) >> get<1>(R[i]);
		get<2>(R[i]) = i + 1;
	}
	sort(all(R));
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if ((get<0>(R[i]) == get<0>(R[j])) && 
				(get<1>(R[i]) < get<1>(R[j])))
				swap(R[i], R[j]);
		}
	}
	for (int i = 0; i < n; i++)
		printf("%d\n", get<2>(R[i]));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner s = new Scanner(System.in);
    	int n = s.nextInt();
    	int cnt = 0;
    	for (int a = 1; a < n; a++) {
    		for (int b = 1; b < n; b++) {
    			if (a * b > n) {
    				break;
    			}
    			int c = n - a * b;
    			if (c > 0) {
    				cnt++;
    			}
    		}
    	}
    	System.out.println(cnt);
    }
}

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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    string a,b;
    cin>>a>>b;
    cout<<b<<a<<endl;


    return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

int main() {
	int c[] = {1000,2,5,5,4,5,6,3,7,6 };

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

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

	vector<long long> dp(n+1,-1); // n本使った時の作った桁の数
	dp[0] = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < m; j++) {
			if (i - c[a[j]] >= 0) {
				dp[i] = max(dp[i], dp[i - c[a[j]]] + 1); 

			}
		}
	}

	vector<long long> ans(dp[n], 0);

	long long num = n;
	for (int j = 0; j < dp[n]; j++) {
		for (int i = 0; i < m; i++) {
			if (num - c[a[i]] >= 0) {
				if (dp[num - c[a[i]]] == (dp[num] - 1)) {
					ans[j] = a[i];
					num -= c[a[i]];
					break;
				}
			}
		}
	}

	for (int i = 0; i < dp[n]; i++) {
		cout << ans[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int m1, m2, m3, a ,i;
	for(i=1; i<11; i++){
	scanf("%d", &a);
	if(m1<a){
		m3=m2;
		m2=m1;
		m1=a;
	}else if(m2<a){
		m3=m2;
		m2=a;
		}else if(m3<a){
			m3=a;
			}
	}
	printf("%d\n%d\n%d\n", m1,m2,m3);
	return 0;
}	

Measured memory_bytes: 600
c = [list(map(int, input().split())) for _ in range(3)]

a = [0, 0, 0]
b = [0, 0, 0]

def check(c, a, b):
    for i in range(3):
        for j in range(3):
            if a[i] + b[j] != c[i][j]:
                return False
    return True

for i in range(101):
    b[0] = i
    a[0] = c[0][0] - b[0]
    a[1] = c[1][0] - b[0]
    a[2] = c[2][0] - b[0]
    b[1] = c[0][1] - a[0]
    b[2] = c[0][2] - a[0]

    if check(c, a, b):
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll n,m;
vl adj[150000];
ll dp[100005];

ll val(int i)
{
    if(dp[i]!=-1)
        return dp[i];
    if(sz(adj[i])==0)
    {
        return 1;
    }
    ll ma = val(adj[i][0]);
    REP(j,sz(adj[i]))
    {
        ma = max(ma,val(adj[i][j]));
    }
    dp[i] = ma+1;
    return ma+1;
}

int main()
{
    IOS
    cin>>n>>m;
    memset(dp,-1,(n+1)*sizeof(dp[0]));
    REP(i,m)
    {
        ll x,y;
        cin>>x>>y;
        adj[y].pb(x);
    }
    for(int i=1;i<n+1;i++)
    {
        if(dp[i]==-1)
        {
            dp[i] = val(i);
        }
    }
    ll ma=dp[1];
    REP(i,n)
    {
        // cout<<dp[i+1]<<" ";
        ma = max(ma,dp[i+1]);
    }
    // cout<<endl;
    cout<<ma-1<<endl;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    ll ans = (N)*(N+1)*(N+2)/6;
    for (int i = 0; i < N-1; i++) {
        ll a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        ans -= (N-b+1)*a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main(){
    int n, m, t;
    while(cin >> n >> m >> t && n){
        int a[110];
        a[0] = 0;
        rep(i, n) cin >> a[i+1];
        a[n+1] = t;
        int ans = 0;
        rep(i, n+1) ans += max(0, a[i+1] - a[i] - ((i==0 || i==n) ? m : 2*m));
        cout << ans << endl;
    }
}

Measured memory_bytes: 3092
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>
#include <cassert>

#define ll long long

using namespace std;

// kを二進数として出力する(d桁になるようにleading 0をつける)
void show_binary(ll k, int d) {
	vector<int> res;
	while (k) {
		res.push_back(k & 1); k >>= 1;
	}
	reverse(res.begin(), res.end());
	assert(d >= res.size());
	for (int i = 0; i < d - res.size(); ++i) cout << 0;
	for (int b : res) cout << b;
	cout << endl;
}

// bitcount
int bitcount(ll k) {
	int res = 0;
	while (k) {
		if (k & 1) ++res;
		k >>= 1;
	}
	return res;
}

// kビットグレイコードを生成
vector<ll> graycode(int k) {
	vector<ll> res;
	for (ll v = 0LL; v < (1LL << k); ++v)
		res.push_back(v ^ (v >> 1));
	return res;
}

int h, w;
vector<ll> line, colum; // カルノーマップ
// 0からtまでの経路
vector<pair<ll, ll>> route(pair<ll, ll> t) {
	assert((t.first + t.second) % 2);
	ll x = t.second, y = t.first;
	vector<pair<ll, ll>> res;
	if (y % 2) {
		for (ll xx = 0; xx < x; ++xx)
			for (ll yy = (xx % 2) ? colum.size() - 1 : 0; yy >= 0 && yy < colum.size(); yy += (xx % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll yy = 0; yy < y; ++yy)
			for (ll xx = (yy % 2) ? line.size() - 1 : x; xx >= x && xx < line.size(); xx += (yy % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll xx = line.size() - 1; xx >= x; --xx)
			for (ll yy = (xx % 2) ? y : colum.size() - 1; yy < colum.size() && yy >= y; yy += (xx % 2) ? 1 : -1)
				res.emplace_back(yy, xx);
	}
	else {
		for (ll yy = 0; yy < y; ++yy)
			for (ll xx = (yy % 2) ? line.size() - 1 : 0; xx >= 0 && xx < line.size(); xx += (yy % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll xx = 0; xx < x; ++xx)
			for (ll yy = (xx % 2) ? colum.size() - 1 : y; yy >= y && yy < colum.size(); yy += (xx % 2) ? -1 : 1)
				res.emplace_back(yy, xx);
		for (ll yy = colum.size() - 1; yy >= y; --yy)
			for (ll xx = (yy % 2) ? x : line.size() - 1; xx < line.size() && xx >= x; xx += (yy % 2) ? 1 : -1)
				res.emplace_back(yy, xx);
	}
	return res;
}
// cの指す値を取得
ll number(pair<ll, ll> c) {
	return ((colum[c.first] << w) | line[c.second]);
}
void show_map() {
	for (ll i = 0; i < (1LL << h); ++i) {
		for (ll j = 0; j < (1LL << w); ++j) {
			ll p = number({ i,j });
			if (p < 10) cout << 0;
			cout << p << " ";
		}
		cout << endl;
	}
}

signed main() {
	int n; ll a, b;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a == b)	cout << "NO" << endl;
		else cout << "YES" << endl << a << " " << b;
	}
	else if (bitcount(a) % 2 == bitcount(b) % 2) {
		cout << "NO" << endl;
	}
	else {
		// カルノーマップを生成
		h = (n + 1) / 2; w = n / 2;
		line = graycode(w); colum = graycode(h);
		//show_map();
		// a^bの座標を求める
		pair<ll, ll> c = { -1LL,-1LL };
		for (ll i = 0; i < (1LL << h); ++i)
			for (ll j = 0; j < (1LL << w); ++j)
				if (number({ i,j }) == (a ^ b))
					c = { i,j };
		// 0からa^bのルートを求める
		vector<pair<ll, ll>> r = route(c);
		// 答えの出力
		cout << "YES" << endl;
		for (auto p : r)
			cout << (a ^ number(p)) << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3320
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N, X, Y = map(int, read().split())

dist = []
for i in range(1, N):
    x = np.arange(i+1, N + 1)
    # 直接
    d1 = np.abs(x - i)
    # i -> X -> Y -> x
    d2 = np.abs(i - X) + np.abs(Y - x) + 1
    # i -> Y -> X -> x
    d3 = np.abs(i - Y) + np.abs(X - x) + 1
    d = np.minimum(np.minimum(d1, d2), d3)
    dist.append(d)

dist = np.concatenate(dist)
count = np.bincount(dist, minlength=N)
print('\n'.join(count[1:].astype(str)))


Measured memory_bytes: 43896
#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int x;
    cin >> x;
    int b = 1;
    int p = 0;
    int max = 0;
    while(1){
        b++;
        p = 2;
        while(1){
            if(pow(b,p) > max && pow(b, p) <= x){
                max = pow(b, p);
            }
            if(pow(b, p) > x && p == 2){
                goto end;
            }
            if(pow(b,p) > x){
                break;
            }
            p++;
        }
    }
end:
    if(max == 0)
        max = 1;
    cout << max << endl;
}


Measured memory_bytes: 256
N = int(input())
A=list(map(int,input().split()))
ask=0
#N-1~1までループ
for x in range(N-1,0,-1):
    if A[x]-A[x-1]<0:
        A[x-1]=A[x-1]-1
for x in range(1,N):
    if A[x]-A[x-1]<0:
        ask=1
        break
if ask==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14224
#include <iostream>

using namespace std;
int main(void){
    int64_t N,K;
    int64_t x,y;
    
    cin>>N;
    cin>>K;
    
    while(1){
        x=N%K;
        if(x<K){
            break;
        }
    }
    
    y=x-K;
    if(y<0){
        y*=(-1);
    }
    
    if(x>y){
        cout<<y;
    }else{
        cout<<x;
    }
    
    return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int int64_t
#define watch(x) cout << (#x) << " is " << (x) << endl

const int32_t MAX=1e9+7;
typedef vector<int> vi;
typedef vector<int64_t> vll;


int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
	
	int a;
	cin >> a;
	cout << a*(a*(a+1)+1);
    return 0;
}



Measured memory_bytes: 3640
#[allow(unused_imports)]
use proconio::{input, fastout};
#[allow(unused_imports)]
use proconio::marker::{Chars};

#[fastout]
fn main() {
  input!{
    l:usize,r:usize,d:usize
  }
  let mut i = 1;
  let mut res = 0;
  loop {
    if d*i >= l {
      if d*i <= r {
        i += 1;
        res += 1;
      } else {
        println!("{}",res);
        return;
      }
    } else {
      i += 1;
    }
  }
}


Measured memory_bytes: 2092
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;
const long long int MOD=1e9+7;

map<long long, long long> m;

int main(){
  long long int n,k,q;
  cin >> n >> k >> q;
  for(int i=0;i<q;i++){
    long long a;
    cin >> a;a--;
    m[a]++;
  }
  for(int i=0;i<n;i++){
    if(k-(q - m[i])<=0){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}


Measured memory_bytes: 6912
import queue
K = int(input())

q = queue.Queue()

for i in range(1,10):
    q.put(i)

for i in range(K-1):
    x = q.get()

    if x%10 == 0:
        q.put(x*10 + 0)
        q.put(x*10 + 1)
    elif x%10 == 9:
        q.put(x*10 + 8)
        q.put(x*10 + 9)
    else:
        q.put(x*10 + x%10-1)
        q.put(x*10 + x%10)
        q.put(x*10 + x%10+1)
    
print(q.get())


Measured memory_bytes: 12564
#include<cstdio>
typedef long long ll;
const int MAXN = 1e5 + 5;
const ll mod = 1e9 + 7;

char s[MAXN*2];

int main(void)
{
	int n;
	scanf("%d%s",&n,s+1);
	
	if(s[1]=='W' || s[n<<1]=='W')
	{
		printf("0");
		return 0;
	}
	ll ans=1, t=1, last=1;
	for(int i=2; i<=(n*2); ++i)
	{	
		if(s[i]!=s[i-1])
		{
			if(last) ++t;
			else --t;
		}
		else
		{
			if(last) --t;
			else ++t;
			last=!last;
		}
		if(!last)
			ans = ans*(t+1) %mod;
		if(t<0)
		{
			printf("0");
			return 0;
		}
	}
	if(t)
	{
		printf("0");
		return 0;
	}
	
	for(int i=1; i<=n; ++i) ans = ans*i%mod;
	printf("%lld",ans);
	return 0;
}

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

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int a,n;
    string s;
    cin>>n>>a;
    cin>>s;
    s[a-1]+=0x20;
    cout<<s<<endl;
}


Measured memory_bytes: 256
n = int(input())
taro = 0
hanako = 0
for i in range(n):
  t, h = input().split()
  if t > h:
    taro += 3
  elif t< h:
    hanako += 3
  else:
    taro += 1
    hanako += 1
print(taro, hanako)


Measured memory_bytes: 5596
dp = {}
n,a,b,c,d = 0,0,0,0,0

def get(n):
	global dp,a,b,c,d
	if (n in dp.keys()): return dp[n]
	dp[n] = d * n
	if(n >= 2): dp[n] = min(dp[n], get(n // 2) + (n % 2) * d + a)
	dp[n] = min(dp[n], get(n // 2 + 1) + (2 - n % 2) * d + a)
	if(n >= 3): dp[n] = min(dp[n], get(n // 3) + (n % 3) * d + b)
	dp[n] = min(dp[n], get(n // 3 + 1) + (3 - n % 3) * d + b)
	if(n >= 5): dp[n] = min(dp[n], get(n // 5) + (n % 5) * d + c)
	dp[n] = min(dp[n], get(n // 5 + 1) + (5 - n % 5) * d + c)
	# print(f'n {n} {dp[n]}')
	return dp[n]

def solve():
	global dp, n, a, b, c, d
	n,a,b,c,d = [*map(int,input().split())]
	dp = {}

	print(get(n))

cas = int(input())
for ca in range(cas):
    solve()


Measured memory_bytes: 11612
def lcs(x, y)
  c = Array.new(y.length + 1, 0)
  x.each_char do |xi|
    tmp = c.dup
    y.each_char.with_index do |y, ji|
      j = ji + 1
      if xi == y
        c[j] = tmp[j - 1] + 1
      elsif c[j] < c[j - 1]
        c[j] = c[j - 1]
      end
    end
  end
  c[-1] - 1
end
 
 
n = gets.chomp.to_i
 
n.times.each do |i|
  x = gets
  y = gets
  puts lcs(x, y)
end

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

int main() {
    char ch;
    int cnt[26] = {};

    while (cin >> ch) {
        ch = tolower(ch);
        if (isalpha(ch)) cnt[ch - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        printf ("%c : %d\n", i + 'a', cnt[i]);
    }

    return 0;
}


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

int main() {
    long int N, K,array[(int)1e5 + 1] = {0},a,b;
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> a >> b;
        array[a] += b;
    }
    for (int i = 0; i < 1e5 + 1; ++i) {
        K -= array[i];
        if(K <= 0) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
/* ****Enigma27**** */
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pll         pair<ll int,ll int>
#define vll          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define rep(i,a,b)   for(ll i=a;ia<b;i++)
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,k,l,sum=0,flag=0,ans=0,m,a[100005][3]={0};
int main()
{	
	ios
	cin>>n;
	for(i=1;i<=n;i++){
		for(j=0;j<3;j++) cin>>a[i][j];
	}	
	for(i=1;i<=n;i++){
		ll t=a[i][0]-a[i-1][0];
		ll x=abs(a[i][1]-a[i-1][1]);
		ll y=abs(a[i][2]-a[i-1][2]);
		if(x+y>t||((t-(x+y))&1)){
			cout<<"No\n";return 0;
		}

	}
	cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, a[110];
int ans;

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i % 2 && a[i] % 2)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v,pick[200000];
map<string, vector<LL>>ma;
multiset<LL>st[3];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct vecter {
	double x, y, r;
	vecter() {}
	vecter(double x_, double y_) :x(x_), y(y_) {
		r = sqrt(x*x + y * y);
	}
	vecter operator+(vecter v) {
		return vecter(x + v.x, y + v.y);
	}
	vecter operator-(vecter v) {
		return vecter(x - v.x, y - v.y);
	}
	vecter operator/(double k) {
		return vecter(x/k, y/k);
	}
	vecter operator*(double k) {
		return vecter(x*k,y*k);
	}
	double operator*(vecter v) { //内積
		return x * v.x + y * v.y;
	}
	double angle(vecter v) { //なす角(Radians)
		if((r * v.r)>0)
		return acos(*this*v / (r * v.r));
		else return 0;
	}
	vecter unit() {
		return (r == 0 ? vecter() : vecter(x, y) / r);
	}
};
vecter dir(double rad) {
	return vecter(cos(rad),sin(rad));
}
int main() {
	double x, y;
	cin >> x >> y;
	vecter p1(x, y);
	cin >> x >> y;
	vecter p2(x, y);
	cin >> n;
	rep(i, n) {
		cin >> x >> y;
		vecter P(x, y);
		vecter cur=p1+(p2-p1).unit()*(P - p1).r*cos(((vecter)(p2 - p1)).angle((vecter)(P - p1)));
		printf("%.15f %.15f\n", cur.x,cur.y);
	}
	return 0;
}



Measured memory_bytes: 13044
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    string s;
    cin >> s;
    if (s=="ABC") s = "ARC";
    else s = "ABC";
    
    
    
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>

int main() {
	int N;
	int K;
	char str[50];
	scanf("%d", &N);
	scanf("%d", &K);
	for (int i = 0; i <= N; i++) {
		scanf("%c", &str[i]);
	}

	if (N >= 1 && N <= 50 && K >= 1 && K <= N) {
		str[K] = tolower(str[K]);
		for (int i = 0; i <= N; i++) {
			printf("%c", str[i]);
		}
	}

	return 0;
}

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

using namespace std;


int main(){
  string S;
  cin >> S;

  int num1,num2;

  istringstream ss1;
  istringstream ss2;

  ss1 = istringstream(S.substr(0,2));
  ss2 = istringstream(S.substr(2,2));
  
  ss1 >> num1;
  ss2 >> num2;

  /* cout << num1 << num2 << endl; */

  if((num1 > 12) && (num2 > 12)){
    cout << "NA" << endl;
    return 0;
  }
  if((num1 == 0) && (num2 == 0)){
    cout << "NA" << endl;
    return 0;
  }

  if((num1 == 0) && (num2 < 13)){
    cout << "YYMM" << endl;
    return 0;
  }
  if((num1 == 0) && (num2 > 12)){
    cout << "NA" << endl;
    return 0;
  }

  if((num1 < 13) && (num2 == 0)){
    cout << "MMYY" << endl;
    return 0;
  }
  if((num1 >12 ) && (num2 == 0)){
    cout << "NA" << endl;
    return 0;
  }

  if((num1 > 12 ) && (num2 <= 12)){
    cout << "YYMM" << endl;
    return 0;
  }
  if((num1 <= 12 ) && (num2 > 12)){
    cout << "MMYY" << endl;
    return 0;
  }
  cout << "AMBIGUOUS" << endl;

}



Measured memory_bytes: 256
#include<stdio.h>

int ab(int x){
	if(x<0)return -x;
	return x;
}

int main(){
	int N;
	scanf("%d",&N);
	int a[N];
	int sum=0;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int min=99999999,mini;
	for(int i=0;i<N;i++){
		if(ab(a[i]*N-sum)<min){
			min=ab(a[i]*N-sum);
			mini=i;
		}
	}
	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,k,n) for(int i = k; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 2000000001
#define MOD 1000000007
using namespace std;

int h, w, dp[1001][1001];
char a[1001][1001];
int main() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
		}
	}
	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			if (a[i][j] == '.') {
				if (i < h - 1) {
					if (a[i + 1][j] == '.') dp[i + 1][j] = (dp[i][j] % MOD + dp[i + 1][j] % MOD) % MOD;
				}
				if (j < w - 1) {
					if (a[i][j + 1] == '.') dp[i][j + 1] = (dp[i][j] % MOD + dp[i][j + 1] % MOD) % MOD;
				}
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 5120
a, b, c, x, y = map(int, input().split())
cost = int()
tmp = min(x, y)
x -= tmp
y -= tmp
if a+b > c*2:
    cost += tmp*2*c
else:
    cost += tmp*(a+b)

if x == 0:
    cost += min(b, c*2)*y
else:
    cost += min(a, c*2)*x

print(cost)


Measured memory_bytes: 3060
import math
N = input()
ans = 0
def counths(n,i,j):
    s = int(n)
    bot = sum([10**x for x in range(len(n)-2)])
    if int(n[0]) > i:
        top = 10**(len(n)-2)
    elif int(n[0]) < i:
        top = 0
    else:
        a = i * 10 ** (len(n)-1) + j
        if a < s:
            top = (s-a) // 10 + 1
        elif a == s:
            top = 1
        else:
            top = 0
    if i == j:
        if len(n) > 1:
            bot += 1
        else:
            if s >= i:
                bot += 1
    return bot + top
for i in range(1,10):
    for j in range(1,10):
        ans += counths(N,i,j) * counths(N,j,i)
print(ans)

Measured memory_bytes: 3064
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
	int A, B, C, K; cin >> A >> B >> C >> K;
	int sum = 0;
	
	if (K <= A)cout << K << endl;
	else if (K <= A + B)cout << A << endl;
	else cout << A - (K - A - B) << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <string>
#include <iostream>
#include <algorithm>
#define base 257
using namespace std;
string s, t; unsigned long long power[333333], val[333333];
int main() {
	power[0] = 1;
	for (int i = 1; i < 333333; i++) power[i] = power[i - 1] * base;
	cin >> s >> t;
	int s1 = t.size(), s2 = s.size(), s3 = s.size() - t.size() + 1;
	unsigned long long v = 0;
	for (int i = 0; i < s1; i++) v = v * base + s[i]; val[0] = v;
	for (int i = s1; i < s2; i++) v = v * base - power[s1] * s[i - s1] + s[i], val[i - s1 + 1] = v;
	sort(val, val + s3);
	unsigned long long u = 0;
	for (int i = 0; i < s1; i++) u = u * base + t[i];
	int ret = 0;
	for (int i = 0; i < s1; i++) {
		for (char j = 'a'; j <= 'z'; j++) {
			if (j != t[i]) {
				u += power[s1 - i - 1] * (j - t[i]);
				ret += upper_bound(val, val + s3, u) - lower_bound(val, val + s3, u);
				u -= power[s1 - i - 1] * (j - t[i]);
			}
		}
		for (char j = 'A'; j <= 'Z'; j++) {
			if (j != t[i]) {
				u += power[s1 - i - 1] * (j - t[i]);
				ret += upper_bound(val, val + s3, u) - lower_bound(val, val + s3, u);
				u -= power[s1 - i - 1] * (j - t[i]);
			}
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 8396
fun main(args: Array<String>) {
    val K = nextInt()
    val ans = LongArray(100001)
    (0..9).forEach { ans[it] = it.toLong() }
    var n = 10
    var p = 1
    while (n < ans.size && p < K) {
        val x = ans[p++]
//System.err.println(x)
        val r = x % 10
        if (r != 0L) ans[n++] = (10 * x - 1 + r)
        ans[n++] = (10 * x + r)
        if (r != 9L) ans[n++] = (10 * x + 1 + r)
    }
    println(ans[K])
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(delta: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + delta }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(delta: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + delta }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }






Measured memory_bytes: 33920