akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    double m;
    cin >> n >> m;
    int a[n];
    rep(i,n) cin >> a[i];
    int count = 0;
    double sum =0;
    rep(i,n){
        sum+=a[i];
    }

    for(int i=0;i<n;i++){
        double x = sum/(4*m);
        if(a[i]>=x){
            count++;
        }
    }

    if(count>=m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
from collections import deque

n = int( raw_input( ) )
que = deque( )
for i in range( n ):
	op = raw_input( ).split( " " )
	if "insert" == op[0]:
		que.appendleft( op[1] )
	elif "delete" == op[0]:
		if op[1] in que:
			que.remove( op[1] )
	elif "deleteFirst" == op[0] :
		que.popleft( )
	elif "deleteLast" == op[0]:
		que.pop( )

print( " ".join( que ) )

Measured memory_bytes: 124752
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
//#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(s, v, it) for (s::iterator it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(s) freopen(s".in", "r", stdin), freopen(s."out", "w", stdout)
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 200010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }


ll dp[N][5], A[N] ;
ll ans = linf ;
int L ;

int main() {
	scanf("%d", &L) ;
    rep(i, 0, L - 1) cin >> A[i] ;
    rep(i, 0, L - 1) {
        dp[i + 1][0] = dp[i][0] + A[i] ;
        dp[i + 1][1] = min(dp[i][0], dp[i][1]) + (A[i] == 0 ? 2 : A[i] % 2) ;
        dp[i + 1][2] = min(min(dp[i][0], dp[i][1]), dp[i][2]) + (A[i] + 1) % 2 ;
        dp[i + 1][3] = min(min(min(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]) + (A[i] == 0 ? 2 : A[i] % 2) ;
        dp[i + 1][4] = min(min(min(min(dp[i][0], dp[i][1]), dp[i][2]), dp[i][3]), dp[i][4]) + A[i] ;
    }
    rep(i, 0, 4) ans = min(ans, dp[L][i]) ;
    printf("%lld\n", ans) ;
    return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/



Measured memory_bytes: 9600
from sys import stdin
h, w = [int(_) for _ in stdin.readline().rstrip().split()]
data = [list(stdin.readline().rstrip()) for _ in range(h)]

for i in range(h):
    for j in range(w):
        if data[i][j] == '.':
            count = 0
            for ii in range(i-1, i+2):
                for jj in range(j-1, j+2):
                    if 0 <= ii < h and 0 <= jj < w:
                        if data[ii][jj] == '#':
                           count += 1
        else:
            count = '#'
        print(count, end='')
    print()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	ll ans = 0;
	if(n <= 3){
		ans += (4-n)*100000;
	}
	if(m <= 3){
		ans += (4-m)*100000;
	}
	if(n == 1 && m == 1){
		ans += 400000;
	}
	print(ans)
	return 0;
}

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


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a*b,c);
    
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=100;
ll dp[N][N];
ll find(ll x){
    while(x){
        if(x/10==0){
            return x;
        }
        x/=10;
    }
}
int main()
{
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        ll h=i;
        ll a1=h%10;
        ll a2=find(h);
        dp[a2][a1]++;
    }
    ll ans=0;
    for(ll i=1;i<=9;i++){
        for(ll j=1;j<=9;j++){
            ans+=dp[i][j]*dp[j][i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	int a[120];

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

	int ans=100*100*100*100;

	for(int i=-100;i<=100;i++){
		int sum=0;
		for(int j=0;j<n;j++)
			sum+=(a[j]-i)*(a[j]-i);
		ans=min(sum,ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>

#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

vector<int> a;

void input() {
  cin >> n;

  a.resize(n);
  for (auto&& i : a) {
    cin >> i;
  }
}

void solve() {
  int ans = 0;

  for (auto&& i : a) {
    ans += __builtin_ctz(i);
  }

  cout << ans;
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
    //  static int dx[]={1,-1,0,0};
    //  static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  // int n=sc.nextInt(), k=sc.nextInt();  
  // int s=sc.nextInt(), t=sc.nextInt(); 
    int n = sc.nextInt();
    int W = sc.nextInt();
    long dp[][][] = new long[2][103][310];
    long v[] = new long[n];
    long w[] = new long[n], a=0;

    for( int i=0; i<n; i++ ) {
       w[i] = sc.nextInt();
       v[i] = sc.nextInt();
    }
    // dp[0][1][0] = v[0];

    for( int i=0; i<n; i++ ){
        int cur = i%2, pr = (i+1)%2;
        int wx = (int)(w[i] - w[0]); 
        for( int t=1; t <= i + 1; t++ ){
            for( int j=0; j<305; j++ ){
                dp[cur][t][j + wx] = max(dp[cur][t][j + wx], dp[pr][t-1][j] + v[i]);
            }
        }
        for( int t=1; t <= i + 1; t++ ){
            for( int j=0; j<=305; j++ ){
                if( w[0] * t + j > W )break;
                dp[cur][t][j] = max(dp[cur][t][j], dp[pr][t][j]);
                a=max(a, dp[cur][t][j]);
            }
        }
    }

    out.println(a);
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}







class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 22476
N, K = list(map(int, input().split()))
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))

max_score = -1 * float('inf')

for start_pos in range(N):
    step_score = []
    pos = start_pos
    loop_num = 0
    loop_sum = 0
    step = 0
    while (step < K):
        pos = P[pos]
        loop_sum += C[pos]
        step_score.append(loop_sum)
        step += 1
        if pos == start_pos:
            break
    loop_num = step
    step_max_score = max(step_score)
    if loop_num < K:
        if K // loop_num > 0:
            if K % loop_num != 0:
                step_max_score = max(
                    step_max_score,
                    max(step_score[:(K % loop_num)]) + loop_sum * (K // loop_num)
                )
            else:
                step_max_score = max(
                    step_max_score,
                    loop_sum * (K // loop_num)
                )
        if K // loop_num > 1:
            step_max_score = max(
                step_max_score,
                max(step_score) + loop_sum * (K // loop_num - 1)
            )
    max_score = max(step_max_score, max_score)
    #print(start_pos, step_max_score, max(step_score), loop_sum, loop_num)

print(max_score)

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

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

int main () {
    int k;
    while (scanf("%d", &k) == 1) {
        long long s = 0;
        for (int a = 1; a <= k; a++)
        for (int b = 1; b <= k; b++)
        for (int c = 1; c <= k; c++)
            s += gcd(a, gcd(b, c));
        cout << s << "\n";
    }
}



Measured memory_bytes: 3768
n = int(input())
abc = [list(map(int , input().split())) for _ in range(n)]
dp = [[0,0,0] for _ in range(n)]
dp[0] = abc[0]
for i in range(1, n):
    for j in range(3):
        maxprev = max(dp[i-1][(j + 1)%3], dp[i-1][(j + 2)%3])
        dp[i][j] = abc[i][j] + maxprev
#print(abc)
#print(dp)
print(max(dp[n-1]))

Measured memory_bytes: 76248
#include<stdio.h>
int main()
{
    long long int a,b,c=0,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;


        scanf("%lld",&n);

    printf("%lld\n",n+n*n+n*n*n);

}


Measured memory_bytes: 1696
N=int(input())
K=int(input())

M = len(str(N)) # 桁数

def solve_1(n,m):
    ans = 0
    ans += 9*(m-1)
    x = n//(10**(m-1))
    ans += x
    return ans

def solve_2(n,m):
    ans=0
    if m<2:
        return ans
    elif m>2:
        ans+= (9**2)*int((m-2)*(m-1)/2) 

    x = n//(10**(m-1))
    ans+= (x-1)*(m-1)*9

    y=int(str(n)[1:])
    ans+=solve_1(y,len(str(y)))
    # ans+= int(str(n)[1])+9*(m-2)
    return ans

def solve_3(n,m):
    ans=0
    if m<3:
        return ans
    elif m>3:
        ans+=int((9**3)*(1/6)*(m-1)*(m-2)*(m-3))
    
    x = n//(10**(m-1))
    ans+=int((x-1)*(m-1)*(m-2)/2*81)
    
    y= int(str(n)[1:])

    ans+=solve_2(y,len(str(y)))
    return ans

if K==1:
    ans = solve_1(N,M)
if K==2:
    ans = solve_2(N,M)
if K==3:
    ans = solve_3(N,M)

print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> ds(n);
  for (auto &d : ds) {
    cin >> d;
  }
  
  sort(ds.begin(), ds.end());
  
  cout << ds[n / 2] - ds[(n - 1) / 2] << endl;
  
  return 0;
}

Measured memory_bytes: 640
n = int(input())
s = input()

counter = 0
for i in range(10):
    str_i = str(i)
    i_dig = s.find(str_i)
    if i_dig == -1:
        continue

    for j in range(10):
        str_j = str(j)
        j_dig = s.find(str_j, i_dig+1)
        if j_dig == -1:
            continue
        
        for k in range(10):
            str_k = str(k)
            k_dig = s.find(str_k, j_dig+1)
            if k_dig != -1:
                counter += 1

print(counter)

Measured memory_bytes: 9152
H, N = gets.chomp.split(" ").map(&:to_i)

dp = Array.new(20001, 0xffffffff)
dp[0] = 0
N.times do |i|
  a, b = gets.chomp.split(" ").map(&:to_i)
  (0...H).each do |j|
    hp, mp = j + a, dp[j] + b
    dp[hp] = mp if mp < dp[hp]
  end
end
puts dp.drop(H).min


Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
#define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {
	
	int n;
	cin >> n;
	int sm = 0;
	for (int i=1; i<=n; i++) {
		if (i % 3 == 0) continue;
		if (i % 5 == 0) continue;
		sm += i;
	}
	cout << sm << endl;
	
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;

const int N = 300000 + 5;

int wl[N], er[N];

int main(){
    string str;
    int n;
    cin >> n >> str;

    for(int i = 0; i < n; i++){ // starting from left to right
        wl[i] = i > 0? wl[i-1]:0;
        if(str[i] == 'W') wl[i]++;
    }

    for(int i = n - 1; i >= 0; i--){ // starting from right to left
        er[i] = i < n - 1? er[i + 1]:0;
        if(str[i] == 'E')er[i]++;
    }
    int ans = INT_MAX;
    for(int i = 0; i < n; i++){

        int l = (i != 0)? wl[i-1]:0;
        int r = (i!=n-1)? er[i+1]:0;
        ans = min(ans, l + r);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include<stdio.h>
int main()
{
  int n,i,k,j,st,ex=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int flag=1;
  while(flag==1){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	st=a[j-1];
	a[j-1]=a[j];
	a[j]=st;
	flag=1;
	ex++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
   printf("%d\n",ex);
  return 0;
}


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


using namespace std;


int main(){
    string order;
    int ramen_price = 700;
    int topping_price = 100;
    int counter =0;

    cin >> order;

    if(order[0] == 'o') counter++;
    if(order[1] == 'o') counter++;
    if(order[2] == 'o') counter++;

    cout<<ramen_price+topping_price*counter<<endl;
}

Measured memory_bytes: 256
n,k = [int(s) for s in input().split()]
freq = [0]*(n+1)
for i in range(k):
    d = int(input())
    arr = [int(s) for s in input().split()]
    for j in arr:
        freq[j]+=1
c = 0
for i in range(1,n+1):
    if  freq[i] == 0:
        c+=1
print(c)



Measured memory_bytes: 67676
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,2) rep(j,2) {
        vi ans(n,0);
        ans[0] = i;
        ans[1] = j;
        rep2(k,2,n) {
            if(ans[k-1] xor (s[k-1] == 'x')) {
                ans[k] = ans[k-2];
            } else {
                ans[k] = 1-ans[k-2];
            }
        }
        bool ok = true;
        if(ans[0]) {
            if(s[0] == 'o' xor ans[n-1] == ans[1]) ok = false;
        } else {
            if(s[0] == 'x' xor ans[n-1] == ans[1]) ok = false;
        }
        if(ans[n-1]) {
            if(s[n-1] == 'o' xor ans[n-2] == ans[0]) ok = false;
        } else {
            if(s[n-1] == 'x' xor ans[n-2] == ans[0]) ok = false;
        }
        if(ok) {
            rep(k,n) cout << (ans[k] ? 'S' : 'W');
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n, k;
    cin >> n >> k;
    ll ans = k;
    rep(i, n - 1){
        ans *= k - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

const long long MOD = 1000000007;

void solve(long long N, std::string S){
  long long depth = 1;
  long long ans = 1;
  if (S[0] == 'W') {
    std::cout << 0 << std::endl;
    return;
  }
  long long dire = 1;
  for (int i = 1; i < N*2; i++) {
    if (S[i-1] == S[i]) {
      dire *= -1;
    } else {
      depth += dire;
    }
    if (dire < 0) {
      ans *= depth;
      ans %= MOD;
    }
    if (depth < 1) {
      std::cout << 0 << std::endl;
      return;
    }
  }
  if (depth != 1) {
    std::cout << 0 << std::endl;
    return;
  }
  for (int i = 0; i < N; i++) {
      ans *= i+1;
      ans %= MOD;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> button(N);
  int i,j;
  for (i=0; i<N; i++){
    cin >> button.at(i);}
  int gofor = button.at(0);
  for (j=0; j<N; j++){
    if (button.at(0)==2){
      cout << 1 << endl;
    break;}
    else if( button.at(gofor-1) ==2){
      cout << j+2 << endl;
    break;}
    else if(j == N-1){
      cout << -1 << endl;}
    else gofor = button.at(gofor-1);
  }
}

Measured memory_bytes: 640
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    vector<int> v(n);
    // 値に対して個数を持つ。ペアとして使用する際に個数を数える。
    multiset<int> m;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m.insert(a);
    }

    // 大きい値から順に処理する
    while (!m.empty()) {
        int x = *(m.rbegin());
        // m.erase(x)にしてしまうと値xがすべて消えてしまう
        m.erase(m.find(x));
        // xより大きい２のべき乗を作成
        uint32_t p = (1u << (32 - __builtin_clz(x)));
        // while (p <= x)
        //     p *= 2;
        int y = p - x; // ペアとなるyは1通り
        auto itr = m.find(y);
        if (itr != m.end()) {
            m.erase(itr);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10368
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
#include<iostream>
#include<bits/stdc++.h>
#include<cstdio>
#include<string.h>
#include<map>
#include<cmath>
#include<stack>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const double Rad_to_deg=45.0/atan(1.0);
inline ll floor(const ll&a,const ll&b){return a/b;}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const ll INF=4223372036854775807,max_n=100005,mod=998244353;
inline int cal(int x){int res=0;while(x){x/=10;res++;}return res;}
inline ll ceil(const ll&a,const ll&b){if(a%b==0)return a/b;return a/b+1;};
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int mul(int a,int b){return (ll)a*b%mod;}
int a[max_n];
int x;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<' ';
	}
}

Measured memory_bytes: 3952
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const double PI=acos(-1);
int n,L;
int T[3010];
int main()
{
	scanf("%d %d",&n,&L);
	for(int i=1;i<=n;i++)
		scanf("%d",&T[i]);
	double ansx=0,ansy=0;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
		{
			double x=cos(PI*(T[i]+T[j])/L),y=sin(PI*(T[i]+T[j])/L);
			int num=j-i-1;num=n-2-num;
			double p=(double)6*num/n/(n-1)/(n-2);
			ansx+=p*x;ansy+=p*y;
			x=-x;y=-y;num=n-2-num;
			p=(double)6*num/n/(n-1)/(n-2);
			ansx+=p*x;ansy+=p*y;
		}
	printf("%.10lf %.10lf\n",ansx,ansy);
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Pair {
	int a[];

}

class TaskB {

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		int N = in.nextInt();
		int dp[] = new int[3];
		for (int day = 0; day < N; day++) {
			int new_dp[] = new int[3];
			int arr[] = new int[3];
			for (int i = 0; i < 3; i++) {
				arr[i] = in.nextInt();
			}
			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					if (i != j) {
						new_dp[j] = Math.max(new_dp[j], dp[i] + arr[j]);
					}
				}
			}
			dp = new_dp;
		}
		pw.println(Math.max(dp[0], Math.max(dp[1], dp[2])));
	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main()
{
    int i,j;
	string s;
	cin>>s;
  	if(s.length()==1){cout<<"Yes"; return 0;}
	j=1;
	for(i=0;i<(s.length()-1)/2;i++){
		if(s[i]!=s[(s.length()-1)/2-i-1]){
		j=0; break;
		}
	}
	if(j){
	for(i=(s.length()+3)/2-1;i<s.length();i++){
		if(s[i]!=s[s.length()-i-1]){
		j=0; break;
		}
	}
	}
	if(j){cout<<"Yes";}
	else{cout<<"No";}
   return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 1

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

L, R, d = s
cnt = 0
for i in range(L, R + 1):
    if i % d == 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 27160
N = int(input())
A = list(map(int, input().split()))
S = [0]

for i in range(N):
    S.append(S[-1] + A[i])

res = 10**18

for i in range(2, N - 1):
    hi = i
    lo = 0
    while hi - lo > 1:
        mid = (hi + lo) // 2
        if S[mid] - S[0] >= S[i] - S[mid]:
            hi = mid
        else:
            lo = mid
    p = S[hi] - S[0]
    q = S[i] - S[hi]
    if p - q > abs((p - A[hi - 1]) - (q + A[hi - 1])):
        p -= A[hi - 1]
        q += A[hi - 1]

    hi = N
    lo = i
    while hi - lo > 1:
        mid = (hi + lo) // 2
        if S[mid] - S[i] >= S[N] - S[mid]:
            hi = mid
        else:
            lo = mid
    s = S[hi] - S[i]
    t = S[N] - S[hi]
    if s - t > abs((s - A[hi - 1]) - (t + A[hi - 1])):
        s -= A[hi - 1]
        t += A[hi - 1]

    res = min(res, max(p, q, s, t) - min(p, q, s, t))

print(res)

Measured memory_bytes: 107296
//itp1_topic4_b
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  cout << fixed << setprecision(12);

  double r;
  cin>>r;

  double PI = acos(-1);
  double area = r * r * PI;
  double cir = (r + r) * PI;
  cout<<area<<" "<<cir<<endl;
 
  return 0;
}


Measured memory_bytes: 3260
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N = int(input())
A = [int(input()) for _ in range(N)]

B = sorted(A)
B.reverse()
m1 = B[0]
m2 = B[1]

for a in A:
    if m1 == a:
        print(m2)
    else:
        print(m1)





Measured memory_bytes: 14864
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 1e5+20;

int a[N],b[N];

int main(){
	
	fastio;
	int A,B,M,x,y,c;
	cin >> A >> B >> M;
	int ref = 1e9, mic = 1e9, dis = 0;
	REP(i,0,A){
		cin >> a[i];
		ref = min(ref,a[i]);
	}
	REP(i,0,B){
		cin >> b[i];
		mic = min(mic,b[i]);
	}
	int ans = ref + mic;
	for(int i = 0; i < M; ++i){
		cin >> x >> y >> c;
		ans = min(ans,a[x-1]+b[y-1]-c);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = []
for i in range(N):
    t = input()
    if t[0] == "M" or t[0] == "A" or t[0] == "R" or t[0] == "C" or t[0] == "H":
        S.append(t[0])
l = len(S)
S_set = set(S)
count_list = []
for i in S_set:
    count_list.append(S.count(i))
if len(S_set) == 3:
    ans = count_list[0] * count_list[1] * count_list[2]
elif len(S_set) == 4:
    ans = count_list[0] * count_list[1] * count_list[2] + count_list[0] * count_list[1] * count_list[3] + count_list[0] * count_list[2] * count_list[3] + count_list[1] * count_list[2] * count_list[3]
elif len(S_set) == 5:
    tmp0 = count_list[0] * count_list[1] * count_list[2] + count_list[0] * count_list[1] * count_list[3] + count_list[0] * count_list[1] * count_list[4]
    tmp1 = count_list[0] * count_list[2] * count_list[3] + count_list[0] * count_list[2] * count_list[4] + count_list[0] * count_list[3] * count_list[4]
    tmp2 = count_list[1] * count_list[2] * count_list[3] + count_list[1] * count_list[2] * count_list[4] + count_list[1] * count_list[3] * count_list[4]
    tmp3 = count_list[2] * count_list[3] * count_list[4]
    ans = tmp0 + tmp1 + tmp2 + tmp3
else:
    ans = 0
print(ans)

Measured memory_bytes: 4032
using System;
using System.Linq;

class abc121_B
{
    static void Main(string[] args)
    {
        var line1 = readInts();
        var QN = line1[0];
        var QM = line1[1];
        var QC = line1[2];
        
        var QBs = readInts();
        var QAss = Enumerable.Range(0, QN).Select(x => readInts()).ToArray();

        var count = QAss.Select(QAs => QAs.Zip(QBs, (QA, QB) => QA*QB ).Sum()).Count(sum => sum + QC > 0);

        Console.WriteLine(count);
    }

    
    static int readInt() { return int.Parse(Console.ReadLine()); }

    static int[] readInts() { return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); }

    static long readLong() { return long.Parse(Console.ReadLine()); }

    static long[] readLongs() { return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray(); }

}

Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
const double PI = acos(-1);
#define INF 1e9 
#define MOD 1000000007 

int N, M, X;
int C[12], A[12][12], rikaido[12];
int ans = INF;

void dfs(int cur, int money) {
    if (cur == N) {
        rep(i, M) {
            if (rikaido[i] < X) return;
        }
        ans = min(ans, money);
        return;
    }

    // 買うケース
    rep(i, M) {
        rikaido[i] += A[cur][i];
    }
    dfs(cur + 1, money + C[cur]);
    // 買わないケース
    rep(i, M) {
        rikaido[i] -= A[cur][i];
    }
    dfs(cur + 1, money);
}


int main(void) {
    cin >> N >> M >> X;

    rep(i, N) {
        cin >> C[i];
        rep(j, M) {
            cin >> A[i][j];
        }
    }

    dfs(0, 0);

    if (ans == INF) {
        cout << "-1" << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-


def main():
    from math import sqrt

    n, m = map(int, input().split())
    ans = 1

    for k in range(1, int(sqrt(m)) + 1):
        p, q = divmod(m, k)

        if q == 0 and p * n <= m:
            ans = max(ans, p)

        if q == 0 and m // p * n <= m:
            ans = max(ans, m // p)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, sum = 0, s1 = 0, s2 = 0, min = 1000;
    cin >> n;
    vector<int>as(n);
    for (int i = 0; i < n; i++){
        cin >> as[i];
    }
    for (int i = 0; i < n; i++){
        sum = sum + as[i];
    }
    for(int i = 0; i < n; i++){
        s1 = s1 + as[i];
        s2 = sum - s1;
        if (min > abs(s2 - s1)){
            min = abs(s2 - s1);
        }
    }
    cout << min << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A (N);
  
  for (int i = 0; i<N; i++) {
    cin >> A.at(i);
  }  
  sort(A.begin(), A.end());
  
  
  int i = 0;
  while (A.at(0)%2 == 0) {
    A.at(0) = A.at(0)/2 + A.at(0)%2;
    i++;
  }  
    
  for (int j = 1; j<N; j++){ 
    //a.at(j)について
    if (A.at(j)%2 == 0) {
      for (int k = 0; k<i; k++) {
        A.at(j) = A.at(j)/2 + A.at(j)%2;
        if (A.at(j)%2 == 1) {
          i = k+1;
          break;
        }
      }
    }
    else {
      i = 0;
      break;
    }
  }
    
  cout << i << endl;
  
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
const int mod = 1000000007;

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);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];

int main(){
  string s;
  cin>>s;
  int l=s.length();
  for(int i=0;i<l;i++){
    s[i]='x';
  }
  cout<<s;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
list1=list(map(int,input().split()))
list2=list(map(int,input().split()))
list3=list(map(int,input().split()))
ans=sum(list2)
for i in range(len(list1)-1):
    if list1[i]+1==list1[i+1]:
        ans+=list3[list1[i]-1]
print(ans)

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N, ai;
int Alice, Bob;
priority_queue<int> cards;

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

	cin >> N;

	for(int i = 0; i < N; i++){
		cin >> ai;
		cards.push(ai);
	}

	while(!cards.empty()){
		Alice += cards.top();
		cards.pop();

		if(!cards.empty()){
			Bob += cards.top();
			cards.pop();
		}
	}
	
	cout << Alice - Bob << "\n";


	return 0;		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;


int main() {
	int a, b;

	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  char s[12];
  scanf("%s",s);
  if(s[a]!='-'){printf("No");return 0;}
  for(int i=0;i<a+b;i++){
    if(i!=a&&s[i]=='-') {printf("No");return 0;}
  }
  printf("Yes");
  return 0;
}

Measured memory_bytes: 128
N = int(input())
D, X = list(map(int,input().split()))
A = [int(input()) for _ in range(N)]
sum = N+X
for a in A:
    n = 1
    while True:
        if n*a+1 > D:
            break
        else:
            n +=1
            sum += 1
print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int sum = 1;

  for (int i = 0; i < N; i++) {
    if (sum<K)
      sum *= 2;
    else
      sum += K;
  }

  cout << sum << endl;
}  

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

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	
	vi nums;
	for (int i = 0; i < n; ++i) {
		int k;
		cin >> k;
		nums.pb(k);
	}
	
	sort(nums.begin(), nums.end());
	
	//n is always even
	//diff between the center and last number
	cout << nums.at(nums.size()/2) - nums.at(nums.size()/2 - 1) << endl;
	
  return 0;
}

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

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    string s,t,ans="";
    cin >> s >> t;
    rep(i,s.size()+t.size()){
        if(i % 2 == 0) ans += s[i/2];
        else ans += t[i/2];
    }
    cout << ans << endl;
    return 0;
}  


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

using namespace std;

int main(void) {
	int n, m;
	cin >> n >> m;

	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];
		}
	}

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

	vector<int> c(n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			c[i] += A[i][j]*b[j];
		}
		cout << c[i] << endl;
	}
	return 0;
}


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

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


Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string S,ans="Yes";
  cin>>S;
  int A[4];
  rep(i,4)A[i]=0;
  rep(i,S.size()){
    if(S[i]=='N')A[0]+=1;
    if(S[i]=='E')A[1]+=1;
    if(S[i]=='S')A[2]+=1;
    if(S[i]=='W')A[3]+=1;
  }
  if(A[0]>=1&&A[2]==0)ans="No";
  if(A[2]>=1&&A[0]==0)ans="No";
  if(A[1]>=1&&A[3]==0)ans="No";
  if(A[3]>=1&&A[1]==0)ans="No";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int a,b,c,d;
 scanf("%d",&a);
b=a/100;
c=(a-b*100)/10;
d=(a-b*100-c*10);
if(b==d){
  printf("Yes");

}else{
  printf("No");
}

  return 0;
}

Measured memory_bytes: 128
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $cnt = [];
  for($i=0; $i<$n; $i++){
      $cnt[$a[$i]]++;
  }
  $ans = 0;
  foreach($cnt as $key => $num){
      if($key > $num){
          $ans += $num; 
      }else if($key < $num){
          $ans += ($num - $key);
      }
  }
  echo $ans;

Measured memory_bytes: 19188
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vint num(n) ;
  int ans = 0 ;
  REP(i,n){
    cin >> num[i] ;
    if(i+1==num[i]){
      ans++ ;
    }
  }
  for(int i=0;i<n-1;i++){
    if(i+1==num[i] && i+2==num[i+1]){
      ans-- ;
      num[i+1] = num[i] ;
    }
  }
  
  cout << ans <<endl ;
  
  
  
  return 0 ;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi; typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;  typedef pair<ll, pi> plp;
typedef pair<int, pi> pip; typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

int A, B, C;

int main() {
	cin >> A >> B >> C;
	multiset<string> S;
	for(int i=0; i<A; i++) S.insert("a");
	for(int i=0; i<B; i++) S.insert("b");
	for(int i=0; i<C; i++) S.insert("c");

	for(int k=0; k<A+B+C-1; k++) {
		string l = *S.begin();
		auto it = S.end(); it--;
		string r = *it;
		S.erase(S.begin());
		S.erase(it);
		S.insert(l+r);
	}
	cout << *S.begin() << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n=in.nextLong();
		long min=Long.MAX_VALUE;
		for(long i=2;i<=Math.sqrt(n);i++)
		{
			
			if(n%i==0)
			{
				min=Math.min(min,(i-1)+((n/i)-1));
			}
		}
		if(min==Long.MAX_VALUE)
		{
				System.out.println(n-1);
			return;
		}
		System.out.println(min);
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<string> A(N);
  
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> B(M);
  for (int i = 0; i < M; i++)
    cin >> B.at(i);
  
  vector<string> UniqueStr;
  vector<int> UniqueCnt;
  for (int i = 0; i < N; i++){
    int exist = 0;
    for (int j = 0; j < UniqueStr.size(); j++){
      if (A.at(i) == UniqueStr.at(j)) {
        exist = 1;
        UniqueCnt.at(j)++;
      }
    }
    if (exist == 0){
      UniqueStr.push_back(A.at(i));
      UniqueCnt.push_back(1);
    }
  }
 
  for (int i = 0; i < M; i++){
    int exist = 0;
    for (int j = 0; j < UniqueStr.size(); j++){
      if (B.at(i) == UniqueStr.at(j)) {
        exist = 1;
        UniqueCnt.at(j)--;
      }
    }
    if (exist == 0){
      UniqueStr.push_back(B.at(i));
      UniqueCnt.push_back(1);
    }
  }
  
  int max = 0;
  for (int j = 0; j < UniqueStr.size(); j++){
    if (max < UniqueCnt.at(j))
      max = UniqueCnt.at(j);
  }
  
  cout << max << endl;
}


Measured memory_bytes: 256
characters = input()
N = len(characters)

total = 0
for i in range(2 ** (N - 1)):
    operation = ""
    for j in range(N - 1):
        operation += characters[j]
        if ((i >> j) & 1):
            operation += "+"
    operation += characters[N - 1]
    ans = eval(operation)
    total += ans
print(total)


Measured memory_bytes: 3060
def main():
    H, W = map(int, input().split())
    s = [list(input()) for _ in range(H)]
    if s[0][0] == '#':
        if s[1][0] != '#' and \
                s[0][1] != '#':
            print('No')
            exit()
    if s[H - 1][0] == '#':
        if s[H - 2][0] != '#' and \
                s[H - 1][1] != '#':
            print('No')
            exit()
    if s[0][W - 1] == '#':
        if s[0][W - 2] != '#' and \
                s[1][W - 1] != '#':
            print('No')
            exit()
    if s[H - 1][W - 1] == '#':
        if s[H - 2][W - 1] != '#' and \
                s[H - 1][W - 2] != '#':
            print('No')
            exit()

    for h in range(H):
        if s[h][0] == '#':
            if s[h - 1][0] != '#' and \
                s[h][1] != '#' and \
                    s[h + 1][0] != '#':
                print('No')
                exit()
        if s[h][W - 1] == '#':
            if s[h - 1][W - 1] != '#' and \
                s[h][W - 2] != '#' and \
                    s[h + 1][W - 1] != '#':
                print('No')
                exit()

    for w in range(W):
        if s[0][w] == '#':
            if s[0][w - 1] != '#' and \
                s[1][w] != '#' and \
                    s[0][w + 1] != '#':
                print('No')
                exit()
        if s[H - 1][w] == '#':
            if s[H - 1][w - 1] != '#' and \
                s[H - 2][w] != '#' and \
                    s[H - 1][w + 1] != '#':
                print('No')
                exit()

    for h in range(1, H - 1):
        for w in range(1, W - 1):
            if s[h][w] == '#':
                if s[h - 1][w] != '#' and \
                    s[h + 1][w] != '#' and \
                    s[h][w - 1] != '#' and \
                        s[h][w + 1] != '#':
                    print('No')
                    exit()
    print('Yes')


main()


Measured memory_bytes: 3192