akhauriyash/Code-Regression huggingface dataset:
S = input()

S_a = int(S[:2])
S_b = int(S[2:])

if (1 <= S_a and 12 >= S_a) and (1 <= S_b and 12 >= S_b):
    print("AMBIGUOUS")
elif 1 <= S_a and 12 >= S_a:
    print("MMYY")
elif 1 <= S_b and 12 >= S_b:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
while True:
	try:
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		hit = blow = 0
		for i in range(4):
			for j in range(4):
				if i == j and a[i] == b[j]: hit += 1
				if i != j and a[i] == b[j]: blow += 1
		print(hit, blow)
	except EOFError:
		break

Measured memory_bytes: 7588
import java.util.*;

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

    String w =sc.next();

    String alphabets = "abcdefghijklmnopqrstuvwxyz";
    int[] count = new int[26];

    for(int i = 0 ; i < w.length(); i ++){
      count[ alphabets.indexOf( w.charAt(i) ) ] ++ ;
    }

    boolean isBeautiful = true;
    for(int j = 0 ;j < 26 ; j++){
      if( count[j] % 2 != 0 ){
        isBeautiful = false;
        break;
      }
    }
    System.out.println( isBeautiful ? "Yes" : "No" );
  }
}


Measured memory_bytes: 23636
#include<cstdio>
#define N 430100
int a[N],b[N],c[N];
inline int read(){
	int n=0;char a;bool z=false;
	while(a=getchar())
	{
		if (a>'9'||a<'0')
			if (z) break;
			else continue;
		if (!z) z=true;
		n=(n<<1)+(n<<3)+(a^48);
	}
	return n;
}
int main()
{
	int n=read(),m=read(),ans=0,p,x,pr;
	for (int i=1;i<=n;++i) c[i]=read(),++a[c[i]];
	for (int i=1;i<=n;++i)
		for (int j=1;j<=a[i];++j) 
			++b[n+i+1-j];
	for (int j=n+1;j<=n<<1;++j) ans+=!b[j];
//	printf("ans=%d\n",ans);
	while(m--)
	{
		p=read();x=read();
		pr=c[p];--b[n+pr-a[pr]+1];
		if (pr-a[pr]+1>0&&!b[n+pr-a[pr]+1]) ++ans;
		--a[pr];c[p]=x;++a[x];
		if (x-a[x]+1>0&&!b[n+x-a[x]+1]) --ans;
		++b[n+x-a[x]+1];
		printf("%d\n",ans);
	}
	return 0;
}

//by qlwpc

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s;
    cin>>s;
    //隙間にプラスを入れるか入れないかの二択
    //全パターンやっても2^9
    //bit
    int n=s.size();
    n--;
    //nは+が入れる数
    ll ans=0;
    for(int i=0;i<(1<<n);i++){
        //+がくるまで数にする。数にしてから演算子をみる
        ll l=0;
        for(int j=0;j<n+1;j++){
            l*=10;
            l+=(s[j]-'0');
            if((1<<j)&i){
                ans+=l;
                l=0;
            }
        }
        ans+=l;
        l=0;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = s[k - 1] - 'A' + 'a';
    cout << s << endl;
    return 0;
}


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

int main(void) {
  int a, b, c = 65535;
  string n, x, y;
  cin >> n;
  a = n.size();
  for (int i = 1; i < a; i++) {
    b = a - i;
    if ((b % 2) == 0) {
      x = n.substr(0, (b / 2));
      y = n.substr((b / 2), (b / 2));
      if (x.compare(y) == 0) {
        if (i < c)
          c = i;
      }
    }
  }
  cout << a - c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
static const int N=1001;
int lcs(string& X,string& Y){
  int c[N][N] = {};
  int m=X.size();
  int n=Y.size();

  int max1=0;
  X=' '+X;
  Y=' '+Y;

  //for(int i=1;i<=m;i++){
  //  c[i][0]=0;
  //}
  //for(int j=1;j<=n;j++){
  //  c[0][j]=0;
  //}

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }
      else {
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      max1=max(max1,c[i][j]);
    }
  }
  return max1;
}

int main(){
  string s1,s2;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cout<<lcs(s1,s2)<<endl;
  }
  return 0;
}



Measured memory_bytes: 7100
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String a=sc.next();
String b=sc.next();
for(int i=0;i<100-a.length();i++){
a="0"+a;
}
for(int i=0;i<100-b.length();i++){
b="0"+b;
}
if(a.compareTo(b)>0){
    out.println("GREATER");
}else if(a.compareTo(b)<0){
    out.println("LESS");
}else{
    out.println("EQUAL");
}
}
}

Measured memory_bytes: 23380
def make_divisors(n):
  divisors=[]
  for i in range(1, int(n**0.5)+1):
    if n%i==0:
      divisors.append(i)
      if i!=n//i:
        divisors.append(n//i)
  return divisors

def make_cd(x, y):
  div1=make_divisors(x)
  div2=make_divisors(y)
  cd=[]
  for i in div1:
    for j in div2:
      if i==j:
        cd.append(i)
        break
  cd.sort()
  return cd

A, B=map(int, input().split())
if A<B:
  A,B=B,A
cd=make_cd(A, B)
ok=[True for _ in range(len(cd))]
for i in range(1, len(cd)):
  if not ok[i]:
    continue
  for j in range(i+1, len(cd)):
    if cd[j]%cd[i]==0:
      ok[j]=False
print(sum([1 if ok[i] else 0 for i in range(len(cd))]))

Measured memory_bytes: 41276
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define ll long long

using namespace std;
int mod = 1000000007;

int N, A, B;
int main() {
  cin >> N >> A >> B;
  cout << min(B, A*N) << endl;
}

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


using namespace std;

const int INF = 1000000001;
const int MAX = 500000;
int cnt,N,n1,n2;
int S[MAX] = {0}, L[1 + MAX/2] = {0}, R[1 + MAX/2] = {0};


void merge(int* A,int left,int mid,int right)
{
	int i,j;
	n1 = mid - left;
	n2 = right - mid;

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

	L[n1] = INF;
	R[n2] = INF;

	i = 0;
	j = 0;

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

		cnt++;
	}
}


void mergesort(int* A,int left,int right)
{
	int mid;

	if(left + 1 < right)
	{
		mid = (left + right) / 2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main()
{
	cnt = 0;

	scanf("%d", &N);

	for(int i = 0; i < N; i++)
	{
		scanf("%d", &S[i]);
	}

	mergesort(S,0,N);

	for(int i = 0; i < N; i++)
	{
		if (i == N-1)
		{
			printf("%d\n", S[i]);
		}else
		{
			printf("%d ", S[i]);
		}
	}

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

	return 0;
}
	

Measured memory_bytes: 7056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    string a;
    cin>>a;
    ll len=a.length();
    vector<ll> cnt(26,0);
    rep(i,len) cnt[a[i]-'a']++;
    ll ans=len*(len-1)/2;
    rep(i,26){
        if(cnt[i]>=2){
            ans-=cnt[i]*(cnt[i]-1)/2;
        }
    }
    cout<<ans+1<<endl;
}

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

int main(){
  int n;

  cin>>n;
  
  for(int i = 0; i < n; i++){
    int a, b, c;
    bool flag;

    cin>>a>>b>>c;

    flag = a*a ==  b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b;

    cout<<(flag ? "YES" : "NO")<<endl;
  }
}



Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include <string>
using namespace std;
long long x[100005];
int flag[1000005];
int main()
{
    long long A,B;
    int t;
    int i,j;
    j=0;
    for(i=2; i<=1000000; i++)
    {
        if(flag[i]==0)
        {
            x[j++]=i;
            for(int k=2*i; k<=1000000; k=k+i)
                flag[k]=1;
        }
    }
    scanf("%lld%lld",&A,&B);
    long long X,Y;
    t=0;
    for(i=0; i<j; i++)
    {
        if(A%x[i]==0&&B%x[i]==0)
            t++;

        while(A%x[i]==0)
        {
             A=A/x[i];
        }

        while(B%x[i]==0)
            B=B/x[i];
    }
    if(A==B&&A!=1)
    {
        t++;
    }
    printf("%d",t+1);
    return 0;

}


Measured memory_bytes: 4736
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = ReadLine();
            var count = 0;

            for (int i = 0; i < n; i++)
            {
                if (a[i] % 2 != 0)
                {
                    count++;
                }
            }

            if (count % 2 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 21216
from collections import Counter

n = int(input())
s = input()
try:
  x, y, z = Counter(s).values()
  print(x * y * z - sum(s[i] != s[(i + j) // 2] != s[j] != s[i]
                        for i in range(n) for j in range(i + 2, n, 2)))
except ValueError:
  print(0)


Measured memory_bytes: 9480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split('/');
            DateTime date = new DateTime(int.Parse(strs[0]), int.Parse(strs[1]), int.Parse(strs[2]));
            DateTime date0 = new DateTime(2019, 4, 30);

            bool heiseiFlag = date <= date0;


            Console.WriteLine(heiseiFlag? "Heisei" : "TBD");
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
    ll n,a,b;
    cin>>n;
    vector<ll>s(n);
    ll ans=0;
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        ans-=b;
        s[i]=a+b;
    }
    sort(s.begin(),s.end(),greater<ll>());
    for(ll i=0;i<n;i+=2)ans+=s[i];
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  map<int,int>m;
  
  int S[100000],T[100000],n,q,key,low=0,upper=0,mid,flag;
  int i=0,cnt = 0;


  cin >>n;
  for(int i=0; i< n; i++){
    cin >>S[i];
  }
  cin >>q;
  for(int i=0; i< q; i++){
    cin >>T[i];
  }


  for(int i =0;i<q;i++){
          key = T[i];
	  for(int j = 0;j<n;j++){
	    if(key == S[j])m.insert(std::make_pair(key,0));

    }



    

  }

  cout <<m.size()<<endl;
  

  return 0;
}



Measured memory_bytes: 3124
use std::io;

fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n)
        .expect("Failed to read line");
    let n: i32 = n.trim().parse()
        .expect("Failed to parse");
    if n % 2 == 0 {
        println!("{}", 0.5);
    } else {
        println!("{}", (n+1) as f32 / (2*n) as f32);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
bool x=0,y=0;
char a;
int main()
{
	while(a!='\n')
	{
		a=getchar();
		if(a=='C') x=1;
		if(a=='F'&&x) y=1;
	}
	if(x&&y) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
# coding:utf-8
from itertools import accumulate
def main():
    n,q = map(int, input().split())
    s = input()
    l = [list(map(int,input().split())) for _ in range(q)]

    ans = [0] * n
    for i in range(1,n):
        if s[i-1] == 'A' and s[i] == 'C':
            ans[i] = ans[i-1] + 1
        else:
            ans[i] = ans[i-1]
    
    for j in l:
        print(ans[j[1]-1] - ans[j[0]-1])

if __name__ == '__main__' :
    main()

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

typedef long long ll;
const ll maxn = 999999999999;

int main()
{
    int n; cin >> n;
    int a[n+5];
    ll dp[n+5];
    for(int i = 0;i < n;i++){cin >> a[i]; dp[i] = maxn;}
    dp[0] = 0;
    for(int i = 1;i < n;i++){
        int l = i-1, k = i-2;
        if(abs(a[i]-a[l])+dp[l] < dp[i])dp[i] = abs(a[i]-a[l])+dp[l];
        if(k >= 0 && abs(a[i]-a[k])+dp[k] < dp[i])dp[i] = abs(a[i]-a[k])+dp[k];
    }

    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    REP(i, h) REP(j, w){
        if(s[i][j] == '#'){
            int dx[] = {1, -1, 0, 0};
            int dy[] = {0, 0, 1, -1};

            bool flag = true;
            REP(k, 4){
                int x = i + dx[k];
                int y = j + dy[k];

                if(x < 0 || x >= h) continue;
                if(y < 0 || y >= w) continue;

                if(s[x][y] == '#') flag = false;
            }

            if(flag){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}
*/


int main() {
	int n,a,cnt=0;
	bool f[M]={};
	cin>>n;
	rep(i,0,n){
		cin>>a;
		if(!f[a])f[a]=true,cnt++;
	}
	if(cnt%2==1)print(cnt);
	else print(cnt-1);

}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n * (n - 1) / 2 - n / 2 << "\n";
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (i + j == n + 1)
                    continue;
                cout << i << " " << j << "\n";
            }
        }
    } else {
        cout << n * (n - 1) / 2 - (n - 1) / 2 << "\n";
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                if (i + j == n)
                    continue;
                cout << i << " " << j << "\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

int main(){
  int n,x,y;
  cin >> n >> x >> y;
  vector<int> a(n+1,0);
  rep(i,n){
    for(int j=i+1; j<=n; j++){
      int length = min((j-i),abs(x-i)+1+abs(y-j));
      a[length]++;
    }
  }
  rep(i,n-1){
    cout << a[i] << endl;
    cout << endl;
  }
  return 0;
}


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

typedef long int32;
typedef unsigned long uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> pii;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vi> graph;

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rFOR(i,a,b) for(int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x,n) FOR(i,0,n) cout << x[i] << " "; cout << endl

#define PI 3.14159265359

// Custom global variable



// ----------------------

auto main() -> int
{
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
  #endif
  // Fast I/O
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  // Code starts here ----

  int a,b,c;
  cin >> a >> b >> c;
  cout << max(a*b, max(a+b, a-b));


  // ---------------------
  #ifdef DEBUG
    cerr << endl << "Time:" << double(clock())/CLOCKS_PER_SEC << " secs" << endl;
  #endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<int> dp(n + 1, 1e9);
	dp[0] = 0;
	rep(i,n - 1){
		for(int j = 1; j <= k; j++){
			if(i + j < n) dp[i + j] = min(dp[i + j], dp[i] + abs(a.at(i + j) - a.at(i)));
		}
	}
	cout << dp[n - 1] << endl;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long

#define sc(n) scanf("%lld",&n)
#define scc(n1,n2) scanf("%lld %lld",&n1,&n2)
#define sccc(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define debug(x) cerr<<#x<<": "<<x<<endl;



signed main() {

    int n, k; scc(n, k);
    int a[n];
    for(int i=0; i<n; i++) sc(a[i]);
    sort(a, a+n);
    int s=0;
    for(int i=0;i<k; i++) s+=a[i];
    cout<<s;
}


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

int main() {
  int h, w;
  while (cin >> h >> w, h | w) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cout << ((i + j) % 2 ? "." : "#");
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    cout <<t<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
array = input().split()
stack = []
for e in array:
    if e in '+-*':
        ope2 = stack.pop()
        ope1 = stack.pop()
        if e == '+':
            stack.append(ope1 + ope2)
        if e == '-':
            stack.append(ope1 - ope2)
        if e == '*':
            stack.append(ope1 * ope2)
    else:
        stack.append(int(e))
print(stack[0])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,P;
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
   cin>>N>>P;
   auto v=prime_factorize(P);
   int ans=1;
   for(auto e:v){
       //cout<<e.fi<<" "<<e.se<<endl;
       if(e.se>=N){
           int tmp=1;
           rep(i,0,e.se/N){
               tmp*=e.fi;
           }
           ans*=tmp;
       }
   }
   cout<<ans<<endl;
   
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    int ans = z;
    int cnt = 0;
    while (true) {
        ans += (y + z);
        if (ans <= x)
            ++cnt;
        else
            break;
    }
    cout << cnt << endl;

    return 0;
}


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

#define   MOD  (1000000007)

long powmod(long x,long y){
  if(y == 0){
    return 1;
  }else if(y == 1){
    return x % MOD;
  }else if(y % 2 == 0){
    long a = powmod(x, int(y/2));
    return (a * a) % MOD;
  }else{
    long a = powmod(x, int(y/2));
    return ((a * a) % MOD * x) % MOD;
  }
}
long comb(long n,long r){
  long fact, div;
  if(r == 0) return 1;
  if(r > n - r) r = n - r;

  fact =1; div = 1;
  for(int i = 0; i < r; ++i){
    fact *= n - i;
    fact %= MOD;
    div *= i + 1;
    div %= MOD;
  }
  return fact * powmod(div, MOD - 2) % MOD;
}

typedef struct PCnt{
  int p;
  int c;
} PCnt;

int main(){
  int N, M, a;
  long ans;
  vector<PCnt> vpc;
  PCnt pc = {0, 1};

  cin >> N >> M;
  a = M;
  for(int i = 2; i * i <= M; ++i){
    while(a % i == 0){
      if(vpc.size() == 0 || vpc.back().p != i){
        pc.p = i;
        vpc.push_back(pc);
      }else{
        ++(vpc.back().c);
      }
      a /= i;
    }
  }
  if(a > 1){
      if(vpc.size() == 0 || vpc.back().p != a){
        pc.p = a;
        vpc.push_back(pc);
      }else{
        ++(vpc.back().c);
      }
  }

  ans = 1;
  for(int i = 0; i < vpc.size(); ++i){
    ans *= comb(vpc[i].c + N - 1, vpc[i].c) % MOD;
    ans %= MOD;
  }
  cout << ans;
}

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

int main(){
  int N, index, sum=0;
  cin >> N;
  if (N==1){
    cout << 0 << endl;
    return 0;
  }
  vector<string> str(N);
  vector<int> time(N);
  string X;
  for (int i=0; i<N; i++){
    cin >> str.at(i);
    cin >> time.at(i);
  }
  cin >> X;
  for (int i=0; i<N; i++){
    if (str.at(i)==X){
      index=i;
    }
  }
  for (int i=index+1; i<N; i++){
    sum+=time.at(i);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Solve{
    int n;
    long l;
    int q;
    long[] x;
    int[] a;
    int[] b;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int logx = 1;
        {   
            long i = 1;
            while(i <= x[n-1]){
                i*=2;
                logx++;
            }
        }
        int[,] dp = new int[n,logx];
        for(int i=0;i<n;i++){
            int f = 0;
            int ll = n-1;
            while(f != ll){
                int c = (f+ll+1)/2;
                if(x[c] - x[i] <= l){
                    f = c;
                }
                else{
                    ll = c-1;
                }
            }
            dp[i,0] = f;
        }
        for(int i=1;i<logx;i++){
            for(int j=0;j<n;j++){
                dp[j,i] = dp[dp[j,i-1],i-1];
            }
        }
        for(int i = 0;i<q;i++){
            int sum=1;
            int d = 0;
            int s,t;
            if(a[i]<b[i]){
                s = a[i];
                t = b[i];
            }
            else{
                s = b[i];
                t = a[i];
            }
            while(dp[s,d] < t){
                d++;
            }
            if(d == 0){
                Console.WriteLine(1);
                continue;
            }
            int r = dp[s,d-1];
            for(int ii=0;ii<d-1;ii++){
                sum*=2;
                if(dp[r,d-ii-2] < t){
                    sum++;
                    r = dp[r,d-ii-2];
                }
            }
            if(r<t){
                sum++;
            }
            Console.WriteLine(sum);
        }
    }
    void getinput(){
        n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        x = new long[n];
        for(int i=0;i<n;i++){
            x[i] = Int64.Parse(str[i]);
        }
        l = Int64.Parse(Console.ReadLine());
        q = int.Parse(Console.ReadLine());
        a = new int[q];
        b = new int[q];
        for(int i=0;i<q;i++){
            str = Console.ReadLine().Split(' ');
            a[i] = int.Parse(str[0])-1;
            b[i] = int.Parse(str[1])-1;
        }
    }    
}

Measured memory_bytes: 29608
#include <cmath>
#include <iostream>
#include <vector>
typedef std::vector <int> vi;
vi PRIMES;
vi prime(int n){
    vi s,p;
    int i,j,x,h;
    for (i=1;i<=n;i+=2) s.push_back(i);
	h=s.size();
    s[0]=0;
    for (i=1;i<=(int)pow(n,0.5);i++)
        if (x=s[i]) for (j=i+x;j<h;j+=x) s[j]=0;
	s[0]=2;
	for (i=0;i<h;i++) if(s[i]!=0) p.push_back(s[i]);
	return p;
}
int main(void){
	int n,s,i;
	PRIMES=prime(105000);
	while (true){
		std::cin>>n; if (n==0) break;
		s=0;
		for (i=0;i<n;i++) s+=PRIMES[i];
		std::cout<<s<<"\n";
	}
} 

Measured memory_bytes: 1384
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int N, A,B;
	long int ans = 0;
	cin >> N>>A >> B;
	for (int i = 1;i <= N;i++) {
		int d = i % 10 + (i / 10) % 10 + (i / 100) % 10 + (i / 1000) % 10 + (i / 10000) % 10;
		if (d >= A && d <= B)
			ans+=i;
	}
	cout << ans << endl;
		
	return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll H, W; cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0)
	{
		std::cout << 0 << std::endl;
		return 0;
	}

	ll res{INF};
	
	for (ll h1 = 1; h1 < H; ++h1)
	{
		ll A = W * h1;
		ll h2 = H-h1;
		ll w1 = W/2;
		ll w2 = W - w1;
		ll B = h2 * w1;
		ll C = h2 * w2;
		
		res = min(res, max({A, B, C}) - min({A, B, C}));

		ll h3 = h2 / 2;
		ll h4 = h2 - h3;
		B = h3 * W;
		C = h4 * W;

		res = min(res, max({A, B, C}) - min({A, B, C}));
	}

	swap(H, W);
	for (ll h1 = 1; h1 < H; ++h1)
	{
		ll A = W * h1;
		ll h2 = H-h1;
		ll w1 = W/2;
		ll w2 = W - w1;
		ll B = h2 * w1;
		ll C = h2 * w2;
		
		res = min(res, max({A, B, C}) - min({A, B, C}));

		ll h3 = h2 / 2;
		ll h4 = h2 - h3;
		B = h3 * W;
		C = h4 * W;

		res = min(res, max({A, B, C}) - min({A, B, C}));
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        //int Nall = pow(fac(N));
        //int[][] matrixArray = new int[4][Nall];
        int alpha=0;
        int sum =0;

        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                for(int k=1;k<=N;k++){
                    //System.out.println(k);
                    alpha=gcd(i,j);
                    sum += gcd(alpha,k);
                }
            }
        }
        System.out.println(sum);
    }
    public static int fac(int N){
        if(N == 1){
            return 1;
        }else{
            return fac(N -1)*N;
        }
    }
    public static int pow(int N){
        return N*N*N;
    }
    public static int gcd(int a,int b){
        int c = a%b;
        if(c == 0){
            return b;
        }else{
            return gcd(b,c);
        }
    }
}

Measured memory_bytes: 35804
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<int> v(n);
    int cnt_even = 0;
    int cnt_odd = 0;
    int cnt_4_multi = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 0) {
            if (x % 4 == 0)
                cnt_4_multi++;
            else
                cnt_even++;
        }
        else
            cnt_odd++;
    }
    if ((cnt_odd <= cnt_4_multi + 1 && cnt_even % 2 == 0) || (cnt_odd <= cnt_4_multi))
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
}

Measured memory_bytes: 1024
#include <stdio.h>
using namespace std;
int a[100001],b[100001]; 
int main()
{
	int n; 
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		if(i==n) printf("%d",b[i]);
		else printf("%d ",b[i]);
	}
	return 0;
}

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

const int Mod=1e9+7;

int N,M,K,E,Index,Top,Cnt,Ans=1;
int Inv[55],Pow[55],C[205][205];
int Tot,Head[55],Nxt[205],From[205],To[205];
int DFN[55],Low[55],ID[55],St[205];
bool Tag[55];

vector<int> P;

void Add_Edge(int u,int v){
	Nxt[++Tot]=Head[u];
	From[Tot]=u,To[Tot]=v;
	Head[u]=Tot;
}

int Polya(int n){
	int i,ans=0;
	for(i=0;i<n;i++)
		ans=(ans+Pow[__gcd(i,n)])%Mod;
	return 1ll*ans*Inv[n]%Mod;
}

void Tarjan(int u,int fa){
	int i,j,k,v,t;
	DFN[u]=Low[u]=++Index;
	for(i=Head[u];i;i=Nxt[i])
		if(!DFN[v=To[i]]){
			St[++Top]=i;
			Tarjan(v,u);
			Low[u]=min(Low[u],Low[v]);
			if(Low[v]>=DFN[u]){
				Cnt++;
				P.clear();
				do{
					t=St[Top--];
					if(ID[From[t]]^Cnt){
						ID[From[t]]=Cnt;
						P.push_back(From[t]);
					}
					if(ID[To[t]]^Cnt){
						ID[To[t]]=Cnt;
						P.push_back(To[t]);
					}
				}while(i^t);
				for(j=0;j<P.size();j++)
					Tag[P[j]]=true;
				E=0;
				for(j=0;j<P.size();j++)
					for(k=Head[P[j]];k;k=Nxt[k])
						E+=Tag[To[k]];
				E>>=1;
				if(E<P.size())
					Ans=1ll*Ans*K%Mod;
				if(E==P.size())
					Ans=1ll*Ans*Polya(P.size())%Mod;
				if(E>P.size())
					Ans=1ll*Ans*C[E+K-1][K-1]%Mod;
				for(j=0;j<P.size();j++)
					Tag[P[j]]=false;
			}
		}
		else if(v^fa&&DFN[v]<DFN[u]){
			St[++Top]=i;
			Low[u]=min(Low[u],DFN[v]);
		}
}

int main(){
	int i,j,u,v;
	scanf("%d%d%d",&N,&M,&K);
	for(i=1;i<=M;i++){
		scanf("%d%d",&u,&v);
		Add_Edge(u,v);
		Add_Edge(v,u);
	}
	Inv[1]=Pow[0]=1,Pow[1]=K;
	for(i=2;i<=N;i++){
		Inv[i]=1ll*(Mod-Mod/i)*Inv[Mod%i]%Mod;
		Pow[i]=1ll*Pow[i-1]*K%Mod;
	}
	for(i=0;i<=200;i++){
		C[i][0]=1;
		for(j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
	}
	for(i=1;i<=N;i++)
		if(!DFN[i])
			Tarjan(i,0);
	printf("%d\n",Ans);
	return 0;
}

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

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

inline bool in(const int x, const int y, const int w, const int h)
{
  if (0 <= x && x < w && 0 <= y && y < h)
    return true;
  return false;
}

int main()
{
  int d;
  cin >> d;
  while (d--) {
    int n;
    cin >> n;
    vector<string> p(n, string(n, '#'));

    bool update = true;
    int x = 1, y = n-1, dir = 3, cnt = 0;
    while (update) {
      update = false;
      for (int i = 0; i < 4 && !update; ++i) {
	int xx = x + dx[dir], yy = y + dy[dir];
	if (in(xx, yy, n, n) && p[yy][xx] == '#' &&
	    in(xx+dx[dir], yy+dy[dir], n, n) && p[yy+dy[dir]][xx+dx[dir]] == '#') {
	  p[y][x] = ' ';
	  x += dx[dir];
	  y += dy[dir];
	  update = true;
	} else {
	  dir = (dir+1) % 4;
	}
      }
    }

    p[y][x] = ' ';
    for (int i = 0; i < n; ++i)
      cout << p[i] << endl;

    if (d != 0)
      cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 100000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}



int main()
{
    ll x;
    cin>>x;


    for(ll i=0;i<=1000;i++)
    {
        for(ll j=-1000;j<=1000;j++)
        {
            ll temp= POW(i,5LL)-POW(j,5LL);
            if(temp==x)
            {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }


}



















Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll t1,t2,a[210001];
int i,j,k,n,ans;
bool check(ll x){
	int i,j;
	ll k=0;
	for (i=n;i&&t2*x<a[i];i--){
		k+=(a[i]-t2*x)/(t1-t2);
		if ((a[i]-t2*x)%(t1-t2)) k++;
	}
	return k<=x;
}
int solve(){
	int l=1,r=a[n],m;
	while (l<r-1){
		m=(l+r)>>1;
		if (check(m)) r=m;else l=m+1;
	}
	return (check(l))?l:r;
}
int main(){
	scanf("%d%lld%lld",&n,&t1,&t2);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	ans=solve();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main () {
    int N, ma=0, mi=1000000001;
    cin >> N;
    for (int i=0;i<N;i++){
        int x;
        cin >> x;
        mi=min(x,mi);
        ma=max(x,ma);
    }
    cout << ma-mi;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;




int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, x;
    cin >> n >> x;
    ll a[n];
    for (int i = 0; i< n; i++) cin >> a[i];

    int ans = 1;
    ll p = 0;

    for (int i = 2; i <= n + 1; i++) {
        p += a[i- 2];
        ans += (p <= x);
    }

    cout << ans;



}



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

using namespace std;

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

  long long n;
  cin >> n;
  long long res = 1e12;
  for (long long i = 1; i*i <= n; ++i) {
    if (n % i == 0) {
      if (i + n/i < res) 
        res = i + n/i - 2;
    } 
  }
  cout << res << endl;


  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int x[200000];
signed main(){
	int a,ans=0;
	cin>>a;
	f(i,a)cin>>x[i];
	sort(x,x+a);
	if(a==1){
		cout<<x[0]*2%mod<<endl;
		return 0;
	}
	f(i,a){
		ans+=x[i]*mypow(2,a-2,mod)%mod*(a-i+1);
		ans%=mod;
	}
	cout<<ans*mypow(2,a,mod)%mod<<endl;
}


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

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

ll n,a,b;

int main() {
	cin>>n>>a>>b;
	if((a&1)==(b&1)) cout<<(b-a)/2;
	else if(b==a+1) cout<<min(b-1,n-a);
	else {
		ll ans=a+(b-a-1)/2;
		a=n-a+1;b=n-b+1;swap(a,b);ans=min(ans,a+(b-a-1)/2);
		cout<<ans;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	while (true)
	{
		string s;
		char to;
		cin >> s >> to;
		if (to == 'X')
			break;

		vector<string> words;
		s += '_';
		while (!s.empty())
		{
			s[0] = tolower(s[0]);
			for (int i = 0; i < s.size(); ++i)
			{
				if (s[i] == '_' || isupper(s[i]))
				{
					words.push_back(s.substr(0, i));
					words.back()[0] = words.back()[0];
					s.erase(0, i + (s[i] == '_' ? 1 : 0));
					break;
				}
			}
		}

		string res;
		if (to == 'U' || to == 'L')
		{
			if (to == 'U')
				words[0][0] = toupper(words[0][0]);
			res += words[0];
			for (int i = 1; i < words.size(); ++i)
			{
				words[i][0] = toupper(words[i][0]);
				res += words[i];
			}
		}
		else
			for (int i = 0; i < words.size(); ++i)
				res += words[i] + (i + 1 != words.size() ? "_" : "");
		cout << res << endl;
	}
}

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

// A[i]: S[0,i-1] longest match(pre and suf)
template <class T>
struct KMP {
  vector<int> A;
  int n;
  T s;
  KMP() {}
  KMP(T _s) {
    s = _s;
    n = s.size();
    A.assign(n + 1, -1);
    for(int i = 0, j = -1; i < n; ++i) {
      while(j >= 0 && s[i] != s[j]) j = A[j];
      ++j;
      /*
      if(i + 1 < n && s[i + 1] == s[j])
        A[i + 1] = A[j];
      else
        //*/
      A[i + 1] = j;
    }
  }
  inline const int &operator[](int k) const {
    return (A[k]);
  }
  vector<long long> calccycle() {
    vector<long long> res(n, 0);
    for(int i = 0; i < n; ++i) res[i] = i + 1 - A[i + 1];
    return res;
  }

  vector<int> search(const T &t) {
    vector<int> res;
    int tsize = t.size();
    for(int i = 0, j = 0; i + j < tsize;) {
      if(s[j] == t[i + j]) {
        if(++j != n) continue;
        res.push_back(i);
      }
      i += j - A[j];
      j = max(A[j], 0);
    }
    return res;
  }
};

int n;
vector<int> a, b, c, d, e;

void solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> b[i];
  solve();
  return 0;
}

void solve() {
  for(int i = 0; i < n - 1; ++i)
    c.push_back(b[i] ^ b[i + 1]);
  for(int i = 0; i < 2 * n; ++i)
    d.push_back(a[i % n] ^ a[(i + 1) % n]);
  KMP<vector<int>> kmp(c);
  e = kmp.search(d);
  for(int i = 0; i < e.size(); ++i)
    if(e[i] < n)
      cout << e[i] << " " << (a[e[i]] ^ b[0]) << endl;
}

Measured memory_bytes: 10992
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b, x;
  cin >> a >> b >> x;
  if (a + b >= x) {
    if (a > x) {
      cout << "NO" << endl;
    }
    else{
      cout << "YES" << endl;
    }
  }
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <string.h>
#include <math.h>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <iostream>
#include <fstream>
#include <map>
#include <algorithm>
//#include "windows.h"
//#include "../../gmp_int.h"
//#include "../../common.h"
#define MAX(a, b)		((a)>(b)?(a):(b))
#define MAX3(a, b, c)	(MAX((a),MAX((b),(c))))
#define FOR(a,b,c)		for (s32(a)=(b);(a)<(s32)(c);(a)++)
#define BL				{char bl[10];cin.getline(bl, 10);}
#define GL(c)			cin.getline(c, sizeof(c))
typedef char					s8;
typedef unsigned char			u8;
typedef short					s16;
typedef unsigned short			u16;
typedef int						s32;
typedef unsigned int			u32;
typedef long long int			s64;
typedef unsigned long long int	u64;
using namespace std;

//ifstream test_input;
//#define cin test_input


int main(int argc, char* argv[])
{
	cout.precision(15);

	s64 N, K, D[11];
	bool ok[11];
	cin >> N >> K;
	FOR(i, 0, 10) ok[i] = true;
	FOR(i, 0, K) {
		cin >> D[i];
		ok[D[i]] = false;
	}
	for (s64 x = N;; x++) {
		s64 y = x;
		bool ng = false;
		while (y > 0) {
			if (!ok[y % 10]) {
				ng = true;
				break;
			}
			y /= 10;
		}
		if (!ng) {
			cout << x << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	vector<string> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	sort(v.begin(),v.end());
	for(auto it=v.begin();it != v.end();it++)cout<<*it;
	return 0;
	}


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

const int inf = 1e9;
pair<int, int> np[2] = {{inf, inf}, {0, 0}};

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

pair<int, int> P(pair<int, int> a, pair<int, int> b, bool bo) {
	a = pppp(a, b.first, bo);
	a = pppp(a, b.second, bo);
	return a;
}

struct WEEE {
	// a < b | a.first < a.second | b.first > b.second
	WEEE *l, *r;
	pair<int, int> a, b;

	WEEE() {
		l = r = NULL;
		a = np[0];
		b = np[1];
	}

	void pp() {
		if(l == NULL) l = new WEEE();
		if(r == NULL) r = new WEEE();
		a = P(l->a, r->a, 0);
		b = P(l->b, r->b, 1);
	}
} *rt;

const int N = 100005;
int n, p[N];
pair<int, int> a[N];

int M(int l, int r) {
	return (l + r) / 2;
}

int si, vl;
void rnk(int l, int r, WEEE *&t) {
	if(t == NULL) t = new WEEE();
	if(l == r) {
		t->a.first = t->b.first = vl;
		return;
	}
	if(M(l, r) >= si) rnk(l, M(l, r), t->l);
	else rnk(M(l, r) + 1, r, t->r);
	t->pp();
}

void gnk(int Si, int Vl) {
	si = Si, vl = Vl;
	rnk(1, n, rt);
}

bool bo;
int sl, sr;
pair<int, int> rgm(int l, int r, WEEE *&t) {
	if(t == NULL || l > sr || r < sl) return np[bo];
	if(sl <= l && r <= sr) return (bo ? t->b : t->a);
	return P(rgm(l, M(l, r), t->l), rgm(M(l, r) + 1, r, t->r), bo);
}

pair<int, int> sgm(int l, int r, bool Bo) {
	sl = l, sr = r, bo = Bo;
	return rgm(1, n, rt);
}

void pr(pair<int, int> a) {
	cout << a.first << " " << a.second << endl;
}

long long R(pair<long long, long long> x, pair<long long, long long> y, long long a, long long i) {
	long long ll = y.first - y.second,
			  lr = i - y.first,
			  rl = x.first - i,
			  rr = x.second - x.first;
	return a * (ll * rl + lr * rr);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	np[0] = {n + 1, n + 1};
	for(int i = 1; i <= n; ++i) {
		cin >> p[i];
		a[i] = {p[i], i};
	}
	sort(a + 1, a + n + 1, [](pair<int, int> a, pair<int, int> b) { return a > b; } );
	long long fp = 0;
	for(int i = 1; i <= n; ++i) {
		gnk(a[i].second, a[i].second);
		pair<int, int> x = sgm(a[i].second + 1, n, 0),
					   y = sgm(1, a[i].second - 1, 1);
		fp += R(x, y, a[i].first, a[i].second);
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 10752
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int h=in(),w=in(),k=in();
    vector<vec> c(h,vec(w));
    rep(i,h){
        string s=stin();
        rep(j,w){
            if(s[j]=='#')c[i][j]=1;
            else c[i][j]=0;
        }
    }
    ll ans=0;
    rep(i,1<<h){
        rep(j,1<<w){
            int cnt=0;
            rep(x,h)rep(y,w){
                if((i&(1<<x))&&(j&(1<<y)))if(c[x][y]==1)cnt++;
            }
            if(cnt==k){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3584
s = gets.chomp.chars.map{|c| c.ord - 'a'.ord}
t = gets.chomp.chars.map{|c| c.ord - 'a'.ord}
matrix = Array.new(26){ Array.new(26, false) }

(0...s.size).each do |i|
  matrix[s[i]][t[i]] = true
end

if matrix.all?{|row| row.count(true) <= 1} && matrix.transpose.all?{|row| row.count(true) <= 1}
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 31740